I'm writing a view spec in RSpec 2.12.2. The error I'm getting is undefined method: allow. I have used something similar in later versions of RSpec. Is allow not present in 2.12.2? Is there another way to stub a method call in this version?
require 'spec_helper'
describe "user_achievements/index.html.haml" do
let(:application) { double }
let(:user) { double }
before do
allow(view).to receive_message_chain(:user, :registered?).and_return(true)
render
end
it "includes a table for user achievements" do
expect(rendered).to have_css(".data-table")
end
end
Allow wasn't introduced until 2.14. You can use obj.stub and stub_chain
# specify a return value
obj.stub(:message) { :value }
obj.stub(:message => :value)
obj.stub(:message).and_return(:value)
subject.stub_chain(:one, :two, :three).and_return(:four)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With