Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 51 lines (40 sloc) 2.003 kb
b457d38 @bblimke Added minitest spec to ensure webmock works with Minitest::Spec. Unfortu...
authored
1 require File.expand_path(File.dirname(__FILE__) + '/test_helper')
598a603 @bblimke Fixed file formatting
authored
2
b457d38 @bblimke Added minitest spec to ensure webmock works with Minitest::Spec. Unfortu...
authored
3 describe "Webmock" do
4 include HttpRequestTestHelper
598a603 @bblimke Fixed file formatting
authored
5
b457d38 @bblimke Added minitest spec to ensure webmock works with Minitest::Spec. Unfortu...
authored
6 before do
84ef7a7 @nfo Added Test::Unit methods +assert_stub_requested+ and +assert_stub_not_re...
nfo authored
7 @stub_http = stub_http_request(:any, "http://www.example.com")
8 @stub_https = stub_http_request(:any, "https://www.example.com")
b457d38 @bblimke Added minitest spec to ensure webmock works with Minitest::Spec. Unfortu...
authored
9 end
10
11 it "should raise error on non stubbed request" do
12 lambda { http_request(:get, "http://www.example.net/") }.must_raise(WebMock::NetConnectNotAllowedError)
13 end
14
15 it "should verify that expected request occured" do
16 http_request(:get, "http://www.example.com/")
17 assert_requested(:get, "http://www.example.com", :times => 1)
18 assert_requested(:get, "http://www.example.com")
19 end
20
84ef7a7 @nfo Added Test::Unit methods +assert_stub_requested+ and +assert_stub_not_re...
nfo authored
21 it "should verify that expected http stub occured" do
22 http_request(:get, "http://www.example.com/")
ed795fa @bblimke assert_requested and assert_not_requested can accept either method and u...
authored
23 assert_requested(@stub_http, :times => 1)
24 assert_requested(@stub_http)
84ef7a7 @nfo Added Test::Unit methods +assert_stub_requested+ and +assert_stub_not_re...
nfo authored
25 end
26
27 it "should verify that expected https stub occured" do
28 http_request(:get, "https://www.example.com/")
29 http_request(:get, "https://www.example.com/")
ed795fa @bblimke assert_requested and assert_not_requested can accept either method and u...
authored
30 assert_requested(@stub_https, :times => 2)
84ef7a7 @nfo Added Test::Unit methods +assert_stub_requested+ and +assert_stub_not_re...
nfo authored
31 end
32
b457d38 @bblimke Added minitest spec to ensure webmock works with Minitest::Spec. Unfortu...
authored
33 it "should verify that expect request didn't occur" do
34 expected_message = "The request GET http://www.example.com/ was expected to execute 1 time but it executed 0 times"
35 expected_message << "\n\nThe following requests were made:\n\nNo requests were made.\n============================================================"
36 assert_fail(expected_message) do
37 assert_requested(:get, "http://www.example.com")
38 end
39 end
40
84ef7a7 @nfo Added Test::Unit methods +assert_stub_requested+ and +assert_stub_not_re...
nfo authored
41 it "should verify that expect stub didn't occur" do
42 expected_message = "The request ANY http://www.example.com/ was expected to execute 1 time but it executed 0 times"
43 expected_message << "\n\nThe following requests were made:\n\nNo requests were made.\n============================================================"
44 assert_fail(expected_message) do
ed795fa @bblimke assert_requested and assert_not_requested can accept either method and u...
authored
45 assert_requested(@stub_http)
84ef7a7 @nfo Added Test::Unit methods +assert_stub_requested+ and +assert_stub_not_re...
nfo authored
46 end
47 end
48
b457d38 @bblimke Added minitest spec to ensure webmock works with Minitest::Spec. Unfortu...
authored
49 end
598a603 @bblimke Fixed file formatting
authored
50
Something went wrong with that request. Please try again.