spec/trakio/exception_spec.rb in trakio-ruby-0.1.3 vs spec/trakio/exception_spec.rb in trakio-ruby-0.1.4

- old
+ new

@@ -6,18 +6,19 @@ after { Trakio.default_instance = nil } - describe '.track' do + describe '#track' do context "when an error is returned by the API" do it "raises an exception" do stub = stub_request(:post, "https://api.trak.io/v1/track"). with(:body => { token: 'my_api_token', data: { + time: /.+/, distinct_id: 'user@example.com', event: 'my-event' } }).to_return(:body => { status: 'error', @@ -30,21 +31,22 @@ trakio = Trakio.new 'my_api_token' expect { trakio.track distinct_id: 'user@example.com', event: 'my-event' }.to raise_error Trakio::Exceptions::InvalidToken - stub.should have_been_requested + expect(stub).to have_been_requested end end context "when no error is returned by the API" do it "returns the result" do stub = stub_request(:post, "https://api.trak.io/v1/track"). with(:body => { token: 'my_api_token', data: { + time: /.+/, distinct_id: 'user@example.com', event: 'my-event' } }).to_return(:body => { status: 'success', @@ -55,11 +57,12 @@ resp = trakio.track distinct_id: 'user@example.com', event: 'my-event' expect(resp[:status]).to eql 'success' expect(resp[:trak_id]).to eql '1234567890' - stub.should have_been_requested + expect(stub).to have_been_requested end end - end # end .track + end + end