Skip to content

Loading…

fix minitest assertions count #215

Merged
merged 1 commit into from

2 participants

@mokevnin

No description provided.

@bblimke bblimke merged commit 88ad2e3 into bblimke:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 6, 2012
  1. @mokevnin

    fix minitest assertions count

    mokevnin committed
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 1 deletion.
  1. +9 −0 lib/webmock/minitest.rb
  2. +1 −0 minitest/test_webmock.rb
  3. +11 −0 minitest/webmock_spec.rb
  4. +1 −1 test/shared_test.rb
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
Something went wrong with that request. Please try again.