Created
September 20, 2012 14:14
-
-
Save brianknapp/3756197 to your computer and use it in GitHub Desktop.
clean tweet gateway contract tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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