spec/unit/contextio/account_collection_spec.rb in contextio-1.5.0 vs spec/unit/contextio/account_collection_spec.rb in contextio-1.6.0

- old
+ new

@@ -6,11 +6,11 @@ subject { ContextIO::AccountCollection.new(api) } describe "#create" do before do - api.stub(:request).with(:post, anything, anything).and_return( + allow(api).to receive(:request).with(:post, anything, anything).and_return( 'success' => true, 'id' => '1234', 'resource_url' => 'resource_url' ) end @@ -19,41 +19,41 @@ it "requires an email address" do expect { subject.create(first_name: 'Bruno') }.to raise_error(ArgumentError) end it "posts to the api" do - api.should_receive(:request).with( + expect(api).to receive(:request).with( :post, 'url from api', hash_including(email: 'hello@email.com') ) subject.create(email: 'hello@email.com') end it "doesn't make any more API calls than it needs to" do - api.should_not_receive(:request).with(:get, anything, anything) + expect(api).to_not receive(:request).with(:get, anything, anything) subject.create(email: 'hello@email.com') end it "returns an Account" do expect(subject.create(email: 'hello@email.com')).to be_a(ContextIO::Account) end it "takes an optional first name" do - api.should_receive(:request).with( + expect(api).to receive(:request).with( anything, anything, hash_including(first_name: 'Bruno') ) subject.create(email: 'hello@email.com', first_name: 'Bruno') end it "takes an optional last name" do - api.should_receive(:request).with( + expect(api).to receive(:request).with( anything, anything, hash_including(last_name: 'Morency') ) @@ -63,14 +63,14 @@ context "with email in the where constraints" do subject { ContextIO::AccountCollection.new(api).where(email: 'hello@email.com')} it "allows a missing email address" do - expect { subject.create(first_name: 'Bruno') }.to_not raise_error(ArgumentError) + expect { subject.create(first_name: 'Bruno') }.to_not raise_error end it "uses the email address from the where constraints" do - api.should_receive(:request).with(anything, anything, hash_including(email: 'hello@email.com')) + expect(api).to receive(:request).with(anything, anything, hash_including(email: 'hello@email.com')) subject.create(first_name: 'Bruno') end end end