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编译器输出!!