RSpec 3 undefined `allow 'method for # <RSpec :: Core :: ExampleGroup ...>
describe '#messages' do
subject do
FactoryGirl.create :foo,
:type => 'test',
:country => 'US'
end
context 'when is not U.S.' do
before{ allow(subject).to receive(:country).and_return('MX') }
describe '#messages' do
subject { super().messages }
it { is_expected.to include 'This foo was not issued in the United States of America.' }
end
end
end
I am trying to assign an attribute to this topic ... I cannot force the spell to work correctly. Do I need a Double here? I am not sure how this works, and I apparently cannot decrypt the documents. Any help is appreciated.
+4
2 answers
, subject , let. , .
, :
describe '#messages' do
let(:subject) do
FactoryGirl.create :foo,
:type => 'test',
:country => 'US'
end
context 'when is not U.S.' do
before{ allow(subject).to receive(:country).and_return('MX') }
describe '#messages' do
subject { super().messages }
it { is_expected.to include 'This foo was not issued in the United States of America.' }
end
end
end
0