spec/zeppelin_spec.rb in zeppelin-0.8.1 vs spec/zeppelin_spec.rb in zeppelin-0.8.2
- old
+ new
@@ -26,13 +26,13 @@
it { subject.connection.host.should eq('go.urbanairship.com') }
it { subject.connection.builder.handlers.should include(Faraday::Adapter::NetHttp) }
- it { subject.connection.builder.handlers.should include(Faraday::Request::JSON) }
+ it { subject.connection.builder.handlers.should include(FaradayMiddleware::EncodeJson) }
- it { subject.connection.builder.handlers.should include(Zeppelin::Middleware::JsonParser) }
+ it { subject.connection.builder.handlers.should include(FaradayMiddleware::ParseJson) }
it { subject.connection.builder.handlers.should include(Zeppelin::Middleware::ResponseRaiseError) }
it { subject.connection.headers['Authorization'].should eq('Basic YXBwIGtleTphcHAgbWFzdGVyIHNlY3JldA==') }
end
@@ -74,11 +74,11 @@
let(:response_body) { { 'foo' => 'bar' } }
it 'gets information about a device' do
stub_requests do |stub|
- stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(response_body)] }
+ stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, JSON.dump(response_body)] }
end
subject.device_token(device_token).should eq(response_body)
end
@@ -137,35 +137,35 @@
results_without_next_page.merge('next_page' => 'https://go.urbanairship.com/api/device_tokens/?page=2&limit=5000')
}
it 'requests a page of device tokens' do
stub_requests do |stub|
- stub.get('/api/device_tokens/?page=') { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(results_without_next_page)] }
+ stub.get('/api/device_tokens/?page=') { [200, { 'Content-Type' => 'application/json' }, JSON.dump(results_without_next_page)] }
end
subject.device_tokens.should eq(results_without_next_page)
end
it 'includes the page number of the next page' do
stub_requests do |stub|
- stub.get('/api/device_tokens/?page=') { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(results_with_next_page)] }
+ stub.get('/api/device_tokens/?page=') { [200, { 'Content-Type' => 'application/json' }, JSON.dump(results_with_next_page)] }
end
subject.device_tokens['next_page'].should eq(2)
end
it 'does not include the page number if there are no additional pages' do
stub_requests do |stub|
- stub.get('/api/device_tokens/?page=') { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(results_without_next_page)] }
+ stub.get('/api/device_tokens/?page=') { [200, { 'Content-Type' => 'application/json' }, JSON.dump(results_without_next_page)] }
end
subject.device_tokens.should_not have_key('next_page')
end
it 'requests a specified page of device_tokens' do
stub_requests do |stub|
- stub.get('/api/device_tokens/?page=4') { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(results_without_next_page)] }
+ stub.get('/api/device_tokens/?page=4') { [200, { 'Content-Type' => 'application/json' }, JSON.dump(results_without_next_page)] }
end
subject.device_tokens(4)
end
@@ -193,11 +193,11 @@
subject.register_apid(device_token).should be_true
end
it 'accepts a payload' do
stub_requests do |stub|
- stub.put(uri, MultiJson.encode(payload)) { [200, {}, ''] }
+ stub.put(uri, JSON.dump(payload)) { [200, {}, ''] }
end
subject.register_apid(device_token, payload).should be_true
end
@@ -217,11 +217,11 @@
let(:response_body) { { 'foo' => 'bar' } }
it 'responds with information about a device when request is successful' do
stub_requests do |stub|
- stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(response_body)] }
+ stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, JSON.dump(response_body)] }
end
subject.apid(device_token).should eq(response_body)
end
@@ -276,35 +276,35 @@
results_without_next_page.merge('next_page' => 'https://go.urbanairship.com/api/apids/?start=2&limit=5000')
}
it 'requests a page of APIDs' do
stub_requests do |stub|
- stub.get('/api/apids/?page=') { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(results_without_next_page)] }
+ stub.get('/api/apids/?page=') { [200, { 'Content-Type' => 'application/json' }, JSON.dump(results_without_next_page)] }
end
subject.apids.should eq(results_without_next_page)
end
it 'includes the page number of the next page' do
stub_requests do |stub|
- stub.get('/api/apids/?page=') { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(results_with_next_page)] }
+ stub.get('/api/apids/?page=') { [200, { 'Content-Type' => 'application/json' }, JSON.dump(results_with_next_page)] }
end
subject.apids['next_page'].should eq(2)
end
it 'does not include the page number if there are no additional pages' do
stub_requests do |stub|
- stub.get('/api/apids/?page=') { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(results_without_next_page)] }
+ stub.get('/api/apids/?page=') { [200, { 'Content-Type' => 'application/json' }, JSON.dump(results_without_next_page)] }
end
subject.apids.should_not have_key('next_page')
end
it 'requests a specified page of APIDs' do
stub_requests do |stub|
- stub.get('/api/apids/?page=4') { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(results_without_next_page)] }
+ stub.get('/api/apids/?page=4') { [200, { 'Content-Type' => 'application/json' }, JSON.dump(results_without_next_page)] }
end
subject.apids(4)
end
@@ -324,11 +324,11 @@
let(:payload) { { :device_tokens => [device_token], :aps => { :alert => 'Hello from Urban Airship!' } } }
it 'is true when the request is successful' do
stub_requests do |stub|
- stub.post(uri, MultiJson.encode(payload)) { [200, {}, ''] }
+ stub.post(uri, JSON.dump(payload)) { [200, {}, ''] }
end
subject.push(payload).should be_true
end
@@ -362,11 +362,11 @@
let(:uri) { '/api/push/batch/' }
it 'is true when the request was successful' do
stub_requests do |stub|
- stub.post(uri, MultiJson.encode(payload)) { [200, {}, ''] }
+ stub.post(uri, JSON.dump(payload)) { [200, {}, ''] }
end
subject.batch_push(message1, message2).should be_true
end
@@ -386,11 +386,11 @@
let(:uri) { '/api/push/broadcast/' }
it 'is true when the request is successful' do
stub_requests do |stub|
- stub.post(uri, MultiJson.encode(payload)) { [200, {}, ''] }
+ stub.post(uri, JSON.dump(payload)) { [200, {}, ''] }
end
subject.broadcast(payload).should be_true
end
@@ -412,11 +412,11 @@
let(:uri) { '/api/device_tokens/feedback/?since=1970-01-01T00%3A00%3A00Z' }
it 'is the response body for a successful request' do
stub_requests do |stub|
- stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(response_body)] }
+ stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, JSON.dump(response_body)] }
end
subject.feedback(since)
end
@@ -484,11 +484,11 @@
let(:uri) { "/api/device_tokens/#{device_token}/tags/" }
it 'is the collection of tags on a device when request is successful' do
stub_requests do |stub|
- stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(response_body)] }
+ stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, JSON.dump(response_body)] }
end
subject.device_tags(device_token).should eq(response_body)
end
@@ -556,10 +556,10 @@
let(:response_body) { { :tags => %w[foo bar baz] } }
it 'is true when request is successful' do
stub_requests do |stub|
- stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, MultiJson.encode(response_body)] }
+ stub.get(uri) { [200, { 'Content-Type' => 'application/json' }, JSON.dump(response_body)] }
end
subject.tags
end