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

  • DavidParody

    DavidParody

    17 EKİM 2009
  • LIVESTRONG.COM

    LIVESTRONG.C

    5 EKİM 2005
  • Ordetta Price

    Ordetta Pric

    12 EYLÜL 2011