SORU
24 Kasım 2010, ÇARŞAMBA


Rspec, Raylar: nasıl denetleyicileri özel yöntemler test etmek için?

Denetleyicisi var:

class AccountController < ApplicationController
  def index
  end

  private
  def current_account
    @current_account ||= current_user.account
  end
end

Nasıl özel yöntem current_account rspec ile test etmek için?

P. S. ben ve Ruby on Rails Rspec2 3 kullanın

CEVAP
24 Kasım 2010, ÇARŞAMBA


#İnstance_eval kullanın

@controller = AccountController.new
@controller.instance_eval{ current_account }   # invoke the private method
@controller.instance_eval{ @current_account }.should eql ... # check the value of the instance variable

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Creavite

    Creavite

    8 Mart 2009
  • TechnoBuffalo

    TechnoBuffal

    8 HAZİRAN 2007
  • TheRightTire

    TheRightTire

    14 EKİM 2009