Created
December 6, 2013 21:55
-
-
Save pcorliss/7832781 to your computer and use it in GitHub Desktop.
Demonstration of non-default stub clearing between tests.
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
require 'rspec' | |
require 'typhoeus' | |
# This seems to fix the issue | |
#RSpec.configure do |config| | |
#config.before :each do | |
#Typhoeus::Config.block_connection = true | |
#Typhoeus::Expectation.clear | |
#end | |
#end | |
describe "Foo" do | |
it "asserts true is true" do | |
true.should == true | |
end | |
it "deliberately always passing test" do | |
typhoeus_response = Typhoeus::Response.new(:code => 200, :body => 'Success!') | |
Typhoeus.stub("http://example.com/unique/path").and_return(typhoeus_response) | |
# If I uncomment this everything works | |
# response = Typhoeus.get("http://example.com/unique/path") | |
true.should == true | |
end | |
it "should work as expected" do | |
typhoeus_response = Typhoeus::Response.new(:code => 500, :body => 'Failure!') | |
Typhoeus.stub("http://example.com/unique/path").and_return(typhoeus_response) | |
response = Typhoeus.get("http://example.com/unique/path") | |
response.body.should == 'Failure!' | |
response.success?.should == false | |
end | |
end | |
# Results in | |
# ~/git/typhoeus_bug: rspec -c | |
#..F | |
#Failures: | |
#1) Foo should work as expected | |
#Failure/Error: response.body.should == 'Failure!' | |
#expected: "Failure!" | |
#got: "Success!" (using ==) | |
## ./spec/foo_spec.rb:21:in `block (2 levels) in <top (required)>' | |
#Finished in 0.00064 seconds | |
#3 examples, 1 failure | |
#Failed examples: | |
#rspec ./spec/foo_spec.rb:17 # Foo should work as expected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment