Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix minitest assertions count

  • Loading branch information...
commit 66e89908c9fbfd0d73be3553f6f7aa88d7446e57 1 parent 5662ca4
@mokevnin mokevnin authored
View
9 lib/webmock/minitest.rb
@@ -10,6 +10,15 @@ def teardown_with_webmock
WebMock.reset!
end
alias_method :teardown, :teardown_with_webmock
+
+ [:assert_request_requested, :assert_request_not_requested].each do |name|
+ alias_method :"#{name}_without_assertions_count", name
+ define_method :"#{name}_with_assertions_count" do |*args|
+ self._assertions += 1
+ send :"#{name}_without_assertions_count", *args
+ end
+ alias_method name, :"#{name}_with_assertions_count"
+ end
end
WebMock::AssertionFailure.error_class = MiniTest::Assertion
View
1  minitest/test_webmock.rb
@@ -3,4 +3,5 @@
class MiniTestWebMock < MiniTest::Unit::TestCase
include SharedTest
+
end
View
11 minitest/webmock_spec.rb
@@ -8,6 +8,17 @@
@stub_https = stub_http_request(:any, "https://www.example.com")
end
+ it "should update assertions count" do
+ assert_equal 0, _assertions
+ http_request(:get, "http://www.example.com/")
+
+ assert_requested(@stub_http)
+ assert_equal 2, _assertions
+
+ assert_not_requested(:post, "http://www.example.com")
+ assert_equal 4, _assertions
+ end
+
it "should raise error on non stubbed request" do
lambda { http_request(:get, "http://www.example.net/") }.must_raise(WebMock::NetConnectNotAllowedError)
end
View
2  test/shared_test.rb
@@ -73,4 +73,4 @@ def test_verification_that_non_expected_stub_didnt_occur
assert_not_requested(@stub_http)
end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.