Sha256: 5986c6cddeaa81915e464421d5426e00d738de144e411e61c7d96f0f3465d0e3
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
require 'spec_helper' describe 'Fitbit Subscriptions' do include Rack::Test::Methods let(:app) { Jawbit::FitbitRack.new subscription_id, consumer_secret } let(:subscription_id) { 'sub' } let(:consumer_secret) { '12345678901234567890123456789012' } let(:subscriptions) { [] } def subscribe(&block) subscriptions << ActiveSupport::Notifications.subscribe( 'notification.fitbit', &block ) end after :each do subscriptions.each do |subscription| ActiveSupport::Notifications.unsubscribe(subscription) end end it 'returns a 204' do post '/' expect(last_response.status).to eq(204) end it 'fires an event' do notification = false subscribe { |*args| notification = true } post '/' expect(notification).to eq(true) end it 'includes the JSON body' do subscribe { |*args| event = ActiveSupport::Notifications::Event.new *args expect(event.payload[:json]).to eq([{'foo' => 'bar'}]) } post '/', '[{"foo":"bar"}]' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jawbit-0.0.3 | spec/acceptance/fitbit_notifications_spec.rb |
jawbit-0.0.2 | spec/acceptance/notifications_spec.rb |