Created
May 22, 2013 20:50
-
-
Save cored/a479a39a37af788a4492 to your computer and use it in GitHub Desktop.
This file contains 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
class Timeout; end | |
class Timeout::Error < StandardError; end | |
class ActiveResource; end | |
class ActiveResource::TimeoutError < StandardError; end | |
class ActiveResource::ServerError < StandardError; end | |
class Hash | |
def add(key, value) | |
self[key] = value | |
end | |
end | |
require_relative '../../../../lib/models/authorization/authorization_connection_validator' | |
describe AuthorizationConnectionValidator do | |
subject { authorization } | |
before { AuthorizationConnectionValidator.validate(authorization) } | |
context "when errors is empty" do | |
context "when system is not dummy" do | |
let(:authorization) { stub(errors:Hash.new, ticketmaster:tm, system:'github') } | |
context "when ticketmaster credentials are invalid" do | |
let(:tm) { stub valid?:false } | |
its(:errors) { should have_key :authentication } | |
end | |
context "when ticketmaster credentials are valid" do | |
let(:tm) { stub valid?:true } | |
its(:errors) { should be_empty } | |
end | |
end | |
context "when system is dummy" do | |
let(:authorization) { stub errors:Hash.new, system:'dummy' } | |
its(:errors) { should be_empty } | |
end | |
end | |
context "when ticketmaster throw exceptions" do | |
let(:authorization) { stub errors:Hash.new, system:'dummy' } | |
before { authorization.should_receive(:ticketmaster) { exception } } | |
context "when Timeout::Error" do | |
let(:exception) { throw Timeout::Error } | |
its(:errors) { should == "" } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment