Rails 3.1、RSpec 2.6、および rr 1.0.4 を使用していますが、NoMethodError が発生します。
undefined method `stub' for #<Activity:0x007faa90996190>
「Activities」の show.haml ビューをテストするために、以下の RSpec テストを利用しようとしています。モックに rr の代わりに RSpec を使用するように spec_helper.rb ファイルを変更すると、テストはパスします。コードの構文を変更しようとしましたが、成功しませんでした。
RSpec と rr は「一緒にうまく機能しない」と述べている Web サイトをいくつか見つけました。
これは私の 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
これは、Aptana Studio を使用した Eclipse コンパイラーからの出力です
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
代替構文への推奨事項は大歓迎です!!