Sha256: 34dd2496064c0943bf4013c87169f0696d5e3ad1b7470848bed2172c43723133
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require 'spec_helper' module Keikokuc describe Notification, '#publish' do it 'publishes to keikoku and stores an id' do fake_client = double Client.stub(new: fake_client) fake_client. should_receive(:post_notification).with do |args| args[:message].should == 'hello' end. and_return([{ id: 1 }, nil]) notification = build(:notification, message: 'hello') result = notification.publish result.should be_true notification.remote_id.should == 1 end it 'returns false when publishing fails and stores errors' do fake_client = double Client.stub(new: fake_client) fake_client. should_receive(:post_notification).with do |args| args[:message].should be_nil end. and_return([{ errors: { attributes: { message: ['is not present'] }}}, Keikokuc::Client::InvalidNotification]) notification = build(:notification, message: nil) result = notification.publish result.should be_false notification.remote_id.should be_nil notification.errors[:attributes][:message].should == ['is not present'] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
keikokuc-0.0.1 | spec/keikoku/notification_spec.rb |