Permalink
Browse files

WebMock tries to use already loaded version of RSpec (1.x or 2.x) (pr…

…eviously it was loading Rspec 2.0 if available, even if RSpec 1.3 was already loaded)
  • Loading branch information...
1 parent 780beb7 commit 6eb8bb5002d33ed7e9f0a0f747e62568a3ea3e53 @bblimke committed Oct 3, 2010
Showing with 19 additions and 4 deletions.
  1. +8 −0 CHANGELOG.md
  2. +11 −4 lib/webmock/adapters/rspec.rb
@@ -1,5 +1,13 @@
#Changelog
+## Master
+
+* Fixed issue with both Rspec 1.x and 2.x being available.
+
+ WebMock now tries to use already loaded version of RSpec (1.x or 2.x). Previously it was loading Rspec 2.0 if available, even if RSpec 1.3 was already loaded.
+
+ Thanks to Hans de Graaff for reporting this.
+
## 1.3.5
* External requests can be disabled while allowing selected hosts. Thanks to Charles Li and Ryan Bigg
@@ -1,13 +1,20 @@
require 'webmock'
# RSpec 1.x and 2.x compatibility
-begin
- require 'rspec'
+if defined?(Rspec)
RSPEC_NAMESPACE = RSPEC_CONFIGURER = Rspec
-rescue LoadError
- require 'spec'
+elsif defined?(Spec)
RSPEC_NAMESPACE = Spec
RSPEC_CONFIGURER = Spec::Runner
+else
+ begin
+ require 'rspec'
+ RSPEC_NAMESPACE = RSPEC_CONFIGURER = Rspec
+ rescue LoadError
+ require 'spec'
+ RSPEC_NAMESPACE = Spec
+ RSPEC_CONFIGURER = Spec::Runner
+ end
end
require 'webmock/adapters/rspec/request_pattern_matcher'

0 comments on commit 6eb8bb5

Please sign in to comment.