spec/acceptance/rest/auth_spec.rb in ably-0.1.0 vs spec/acceptance/rest/auth_spec.rb in ably-0.1.1
- old
+ new
@@ -154,22 +154,22 @@
let!(:auth_url_request_stub) do
stub_request(auth_method, auth_url).to_return(:status => 500)
end
it 'raises ServerError' do
- expect { auth.request_token options }.to raise_error(Ably::ServerError)
+ expect { auth.request_token options }.to raise_error(Ably::Exceptions::ServerError)
end
end
context 'XML' do
let!(:auth_url_request_stub) do
stub_request(auth_method, auth_url).
to_return(:status => 201, :body => '<xml></xml>', :headers => { 'Content-Type' => 'application/xml' })
end
it 'raises InvalidResponseBody' do
- expect { auth.request_token options }.to raise_error(Ably::InvalidResponseBody)
+ expect { auth.request_token options }.to raise_error(Ably::Exceptions::InvalidResponseBody)
end
end
end
end
@@ -292,15 +292,15 @@
context "missing key ID and/or secret" do
let(:client) { Ably::Rest::Client.new(auth_url: 'http://example.com') }
it "should raise an exception if key secret is missing" do
- expect { auth.create_token_request(key_id: 'id') }.to raise_error Ably::TokenRequestError
+ expect { auth.create_token_request(key_id: 'id') }.to raise_error Ably::Exceptions::TokenRequestError
end
it "should raise an exception if key id is missing" do
- expect { auth.create_token_request(key_secret: 'secret') }.to raise_error Ably::TokenRequestError
+ expect { auth.create_token_request(key_secret: 'secret') }.to raise_error Ably::Exceptions::TokenRequestError
end
end
context "with :query_time option" do
let(:time) { Time.now - 30 }
@@ -351,19 +351,19 @@
expect(token_auth_client.channel("foo").publish("event", "data")).to be_truthy
end
it "disallows publishing on unspecified capability channels" do
expect { token_auth_client.channel("bar").publish("event", "data") }.to raise_error do |error|
- expect(error).to be_a(Ably::InvalidRequest)
+ expect(error).to be_a(Ably::Exceptions::InvalidRequest)
expect(error.status).to eql(401)
expect(error.code).to eql(40160)
end
end
it "fails if timestamp is invalid" do
expect { auth.request_token(timestamp: Time.now.to_i - 180) }.to raise_error do |error|
- expect(error).to be_a(Ably::InvalidRequest)
+ expect(error).to be_a(Ably::Exceptions::InvalidRequest)
expect(error.status).to eql(401)
expect(error.code).to eql(40101)
end
end
end
@@ -415,10 +415,10 @@
expect(token).to be_a(Ably::Token)
capability_with_str_key = Ably::Token::DEFAULTS[:capability]
capability = Hash[capability_with_str_key.keys.map(&:to_sym).zip(capability_with_str_key.values)]
expect(token.capability).to eql(capability)
- expect(token.expires_at).to be_within(2).of(Time.now + Ably::Token::DEFAULTS[:ttl])
+ expect(token.expires_at.to_i).to be_within(2).of(Time.now.to_i + Ably::Token::DEFAULTS[:ttl])
expect(token.client_id).to eql(client_id)
end
end
end
end