2011-12-24 80 views
2

我使用Rails 3.1,RSpec的2.6和rr 1.0.4,我得到一個NoMethodError:RSpec的視圖測試使用RR失敗 - 未定義的方法存根

undefined method `stub' for #<Activity:0x007faa90996190> 

我想利用下面的RSpec的測試測試我的「活動」show.haml視圖。如果我將spec_helper.rb文件更改爲使用RSpec而不是rr,那麼測試通過。我試圖改變代碼的語法,但沒有成功。

我發現幾個網站指出RSpec的和RR不「玩的很好,提供了這個rpsec-rr解決方案,它並沒有爲我工作的一個人。

這是我show.haml_spec.rb

require 'spec_helper' 

describe "activities/show.haml" do 
    before(:each) do 
    @activity = assign(:activity, stub_model(Activity)) 
    end 

    it "renders attributes in .haml" do 
    render 
    end 
end 

這是使用集錦工作室

Failures: 

    1) activities/show.haml renders attributes in .haml 
    Failure/Error: @activity = assign(:activity, stub_model(Activity)) 
    NoMethodError: 
     undefined method `stub' for #<Activity:0x007faa90996190> 
    # ./spec/views/activities/show.haml_spec.rb:5:in `block (2 levels) in <top (required)>' 

Finished in 0.15479 seconds 
1 example, 1 failure 

Failed examples: 
rspec ./spec/views/activities/show.haml_spec.rb:8 # activities/show.haml renders attributes in .haml 

到備用語法的任何建議,將不勝感激從我的Eclipse編譯器輸出!!

回答

0

請注意,截至RR 1.0.5(2013年3月28日發佈),此問題不再存在 - RR與RSpec 2完全兼容。

相關問題