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

  • Commander Chalkboard

    Commander Ch

    20 Ocak 2014
  • LatinNinja99

    LatinNinja99

    28 EKİM 2011
  • SomeOne Pro

    SomeOne Pro

    25 EKİM 2013