test/client_test.rb in vault-usage-client-0.0.5 vs test/client_test.rb in vault-usage-client-0.0.6
- old
+ new
@@ -64,11 +64,11 @@
detail = {type: 'web',
description: 'bundle exec bin/web',
kernel: 'us-east-1-a'}
Excon.stub(method: :put) do |request|
assert_equal('application/json', request[:headers]['Content-Type'])
- assert_equal(detail, JSON.parse(request[:body], {symbolize_keys: true}))
+ assert_equal(detail, MultiJson.load(request[:body], {symbolize_keys: true}))
Excon.stubs.pop
{status: 201}
end
@client.open_usage_event(@event_id, @product_name, @app_hid, @start_time,
detail)
@@ -150,11 +150,11 @@
assert_equal('443', request[:port])
assert_equal("/users/#{@user_hid}/usage/#{iso_format(@start_time)}/" +
"#{iso_format(@stop_time)}",
request[:path])
Excon.stubs.pop
- {status: 200, body: JSON.generate({events: []})}
+ {status: 200, body: MultiJson.dump({events: []})}
end
assert_equal([], @client.usage_for_user(@user_hid, @start_time,
@stop_time))
end
@@ -162,21 +162,21 @@
# They're passed to the server using query string arguments.
def test_usage_for_user_with_exclude
Excon.stub(method: :get) do |request|
assert_equal({exclude: 'platform:dyno:physical'}, request[:query])
Excon.stubs.pop
- {status: 200, body: JSON.generate({events: []})}
+ {status: 200, body: MultiJson.dump({events: []})}
end
assert_equal([], @client.usage_for_user(@user_hid, @start_time, @stop_time,
['platform:dyno:physical']))
end
def test_usage_for_user_with_callback_url
Excon.stub(method: :get) do |request|
assert_equal({callback_url: 'http://example.com'}, request[:query])
Excon.stubs.pop
- {status: 200, body: JSON.generate({job_id: 'DEADBEEF'})}
+ {status: 200, body: MultiJson.dump({job_id: 'DEADBEEF'})}
end
assert_equal('DEADBEEF',
@client.usage_for_user(@user_hid, @start_time, @stop_time, nil,'http://example.com'))
end
@@ -186,11 +186,11 @@
def test_usage_for_user_with_many_excludes
Excon.stub(method: :get) do |request|
assert_equal({exclude: 'platform:dyno:physical,addons:memcache:100mb'},
request[:query])
Excon.stubs.pop
- {status: 200, body: JSON.generate({events: []})}
+ {status: 200, body: MultiJson.dump({events: []})}
end
assert_equal([], @client.usage_for_user(@user_hid, @start_time, @stop_time,
['platform:dyno:physical',
'addons:memcache:100mb']))
end
@@ -199,11 +199,11 @@
# not passing one at all.
def test_usage_for_user_with_empty_exclude
Excon.stub(method: :get) do |request|
assert_equal({}, request[:query])
Excon.stubs.pop
- {status: 200, body: JSON.generate({events: []})}
+ {status: 200, body: MultiJson.dump({events: []})}
end
assert_equal([], @client.usage_for_user(@user_hid, @start_time, @stop_time,
[]))
end
@@ -216,10 +216,10 @@
product: @product_name,
consumer: @app_hid,
start_time: iso_format(@start_time),
stop_time: iso_format(@stop_time),
detail: {}}]
- {status: 200, body: JSON.generate({events: events})}
+ {status: 200, body: MultiJson.dump({events: events})}
end
assert_equal([{id: @event_id,
product: @product_name,
consumer: @app_hid,
start_time: @start_time,