Sha256: 230ca30f2bfdaa7a09b1c6c42f7bb33248d91e03f5b53ade4c6f99b8607beb65
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
require 'contextio/account' describe ContextIO::Account do let(:api) { double('api', url_for: 'url from api') } subject { ContextIO::Account.new(api, id: '1234') } describe ".new" do context "with an id passed in" do it "doesn't raise an error" do expect { ContextIO::Account.new(api, id: '1234') }.to_not raise_error end end context "with neither an id nor a resource_url passed in" do it "raises an ArgumentError" do expect { ContextIO::Account.new(api, foo: 'bar') }.to raise_error(ArgumentError) end end end describe "#update" do before do allow(api).to receive(:request).and_return({'success' => true}) end subject { ContextIO::Account.new(api, id: '1234', first_name: 'old first name') } it "posts to the api" do expect(api).to receive(:request).with( :post, 'url from api', first_name: 'new first name' ) subject.update(first_name: 'new first name') end it "updates the object" do subject.update(first_name: 'new first name') expect(subject.first_name).to eq('new first name') end it "doesn't make any more API calls than it needs to" do expect(api).to_not receive(:request).with(:get, anything, anything) subject.update(first_name: 'new first name') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
contextio-2.0.0 | spec/unit/contextio/account_spec.rb |
contextio-1.8.1 | spec/unit/contextio/account_spec.rb |
contextio-1.8.0 | spec/unit/contextio/account_spec.rb |