我正在使用 RSpec2 v2.13.1,它似乎应该包含rspec-mocks ( https://github.com/rspec/rspec-mocks )。当然它列在我的 Gemfile.lock 中。
但是,当我运行测试时,我得到
Failure/Error: allow(Notifier).to receive(:new_comment) { @decoy }
NoMethodError:
undefined method `allow' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fc302aeca78>
Run Code Online (Sandbox Code Playgroud)
这是我尝试运行的测试:
require 'spec_helper'
describe CommentEvent do
before(:each) do
@event = FactoryGirl.build(:comment_event)
@decoy = double('Resque::Mailer::MessageDecoy', :deliver => true)
# allow(Notifier).to receive(:new_comment) { @decoy }
# allow(Notifier).to receive(:welcome_email) { @decoy }
end
it "should have a comment for its object" do
@event.object.should be_a(Comment)
end
describe "email notifications" do
it "should be sent for a user who chooses to be notified" do …Run Code Online (Sandbox Code Playgroud)