2011-12-24 6 views
2
私はRailsの3.1、RSpecの2.6、およびRR 1.0.4を使用しています

は、私はNoMethodErrorを取得します私の "活動" show.hamlのビューをテストしてください。 rrの代わりにmockにRSpecを使用するようにspec_helper.rbファイルを変更すると、テストに合格します。私はコードの構文を変更しようとしましたが、成功しませんでした。RSpecのビューのテスト使用してRRが失敗未定義のメソッドスタブ

私はいくつかのウェブサイトは、RSpecのとRRは「一緒にうまく再生されないことを示す発見し、一人は私のために動作しませんでした。このrpsec-rrソリューションを提供する。

これは

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 
私show.haml_spec.rbです

これは

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 

代替構文への任意の勧告をいただければ幸いAptanaのStudioの

を使用して、私のEclipseのコンパイラから出力されました!

答えて

0

RR 1.0.5(2013年3月28日リリース)では、この問題はもう存在しないはずです。RRはRSpec 2と完全に互換性があります。

関連する問題