Skip to content

Instantly share code, notes, and snippets.

@brianknapp
Created September 20, 2012 14:14
Show Gist options
  • Save brianknapp/3756197 to your computer and use it in GitHub Desktop.
Save brianknapp/3756197 to your computer and use it in GitHub Desktop.
clean tweet gateway contract tests
require_relative '../../contracts/tweet_gateway_contract'
class TG < TweetGatewayContract
def save input
return input
end
end
class TGoutput < TweetGatewayContract
def save input
return :invalid => true, :data => input
end
end
describe TweetGatewayContract do
describe '.save' do
it 'should return a hash of the saved data with valid input' do
tg = TG.new
result = tg.save :text => 'foo'
result.should eq :text => 'foo'
end
it 'should raise an exception with invalid input' do
tg = TGoutput.new
expect { tg.save :text => 'foo', :test => 'explode' }.to raise_error(ContractInputError)
end
it 'should raise an exception with invalid saved data returned' do
tg = TGoutput.new
expect { tg.save :text => 'foo' }.to raise_error(ContractOutputError)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment