Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated info on how to include WebMock in Test::Unit and RSpec withou…

…t polluting Kernel.
  • Loading branch information...
commit 2e88f99be8bdea04cd8b35b05399e4a3c5bc7e18 1 parent 9c8c463
Bartosz Blimke authored
Showing with 19 additions and 7 deletions.
  1. +7 −2 README.md
  2. +4 −0 spec/spec_helper.rb
  3. +8 −5 test/test_helper.rb
View
9 README.md
@@ -27,13 +27,17 @@ In your `test/test_helper.rb` add these two lines:
require 'webmock/test_unit'
- include WebMock
+ class Test::Unit::TestCase
+ include WebMock
+ end
or if you use RSpec add these lines to `spec/spec_helper`:
require 'webmock/rspec'
- include WebMock
+ Spec::Runner.configure do |config|
+ config.include WebMock
+ end
You can also use WebMock without RSpec or Test::Unit support:
@@ -432,6 +436,7 @@ People who submitted patches and new features or suggested improvements. Many th
* Nadim Bitar
* Myron Marston
* Sam Phillips
+* Jose Angel Cortinas
## Background
View
4 spec/spec_helper.rb
@@ -13,6 +13,10 @@
include WebMock
+Spec::Runner.configure do |config|
+ config.include WebMock
+end
+
def fail()
raise_error(Spec::Expectations::ExpectationNotMetError)
end
View
13 test/test_helper.rb
@@ -5,9 +5,12 @@
require 'webmock/test_unit'
require 'test/unit'
-include WebMock
-def assert_fail(message, &block)
- e = assert_raise(AssertionFailedError, &block)
- assert_equal(message, e.message)
-end
+class Test::Unit::TestCase
+ include WebMock
+
+ def assert_fail(message, &block)
+ e = assert_raise(AssertionFailedError, &block)
+ assert_equal(message, e.message)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.