webmock 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/CHANGELOG.md +17 -0
  2. data/README.md +13 -0
  3. data/VERSION +1 -1
  4. data/lib/webmock/errors.rb +5 -1
  5. data/lib/webmock/http_lib_adapters/httpclient.rb +10 -8
  6. data/lib/webmock/http_lib_adapters/net_http.rb +56 -64
  7. data/lib/webmock/http_lib_adapters/patron.rb +2 -3
  8. data/lib/webmock/util/headers.rb +18 -3
  9. data/lib/webmock/webmock.rb +12 -5
  10. data/spec/example_curl_output.txt +2 -0
  11. data/spec/httpclient_spec.rb +8 -0
  12. data/spec/httpclient_spec_helper.rb +9 -1
  13. data/spec/net_http_spec_helper.rb +10 -1
  14. data/spec/other_net_http_libs_spec.rb +0 -10
  15. data/spec/patron_spec_helper.rb +8 -2
  16. data/spec/response_spec.rb +4 -2
  17. data/spec/util/headers_spec.rb +17 -0
  18. data/spec/webmock_spec.rb +103 -15
  19. data/test/test_webmock.rb +1 -1
  20. data/webmock.gemspec +2 -23
  21. metadata +2 -23
  22. data/spec/vendor/samuel-0.2.1/.document +0 -5
  23. data/spec/vendor/samuel-0.2.1/.gitignore +0 -5
  24. data/spec/vendor/samuel-0.2.1/LICENSE +0 -20
  25. data/spec/vendor/samuel-0.2.1/README.rdoc +0 -70
  26. data/spec/vendor/samuel-0.2.1/Rakefile +0 -62
  27. data/spec/vendor/samuel-0.2.1/VERSION +0 -1
  28. data/spec/vendor/samuel-0.2.1/lib/samuel.rb +0 -52
  29. data/spec/vendor/samuel-0.2.1/lib/samuel/net_http.rb +0 -10
  30. data/spec/vendor/samuel-0.2.1/lib/samuel/request.rb +0 -96
  31. data/spec/vendor/samuel-0.2.1/samuel.gemspec +0 -69
  32. data/spec/vendor/samuel-0.2.1/test/request_test.rb +0 -193
  33. data/spec/vendor/samuel-0.2.1/test/samuel_test.rb +0 -42
  34. data/spec/vendor/samuel-0.2.1/test/test_helper.rb +0 -66
  35. data/spec/vendor/samuel-0.2.1/test/thread_test.rb +0 -32
@@ -1,42 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SamuelTest < Test::Unit::TestCase
4
-
5
- context "logger configuration" do
6
- setup do
7
- Samuel.logger = nil
8
- if Object.const_defined?(:RAILS_DEFAULT_LOGGER)
9
- Object.send(:remove_const, :RAILS_DEFAULT_LOGGER)
10
- end
11
- end
12
-
13
- teardown do
14
- Samuel.logger = nil
15
- end
16
-
17
- context "when Rails's logger is available" do
18
- setup { Object.const_set(:RAILS_DEFAULT_LOGGER, :mock_logger) }
19
-
20
- should "use the same logger" do
21
- assert_equal :mock_logger, Samuel.logger
22
- end
23
- end
24
-
25
- context "when Rails's logger is not available" do
26
- should "use a new Logger instance pointed to STDOUT" do
27
- assert_instance_of Logger, Samuel.logger
28
- assert_equal STDOUT, Samuel.logger.instance_variable_get(:"@logdev").dev
29
- end
30
- end
31
- end
32
-
33
-
34
- context ".reset_config" do
35
- should "reset the config to default vaules" do
36
- Samuel.config = {:foo => "bar"}
37
- Samuel.reset_config
38
- assert_equal({:label => nil, :labels => {"" => "HTTP"}, :filtered_params => []}, Samuel.config)
39
- end
40
- end
41
-
42
- end
@@ -1,66 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'mocha'
5
- require 'open-uri'
6
- require 'fakeweb'
7
-
8
- FakeWeb.allow_net_connect = false
9
-
10
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
- $LOAD_PATH.unshift(File.dirname(__FILE__))
12
- require 'samuel'
13
-
14
- class Test::Unit::TestCase
15
- TEST_LOG_PATH = File.join(File.dirname(__FILE__), 'test.log')
16
-
17
- def self.should_log_lines(expected_count)
18
- should "log #{expected_count} line#{'s' unless expected_count == 1}" do
19
- lines = File.readlines(TEST_LOG_PATH)
20
- assert_equal expected_count, lines.length
21
- end
22
- end
23
-
24
- def self.should_log_including(what)
25
- should "log a line including #{what.inspect}" do
26
- contents = File.read(TEST_LOG_PATH)
27
- if what.is_a?(Regexp)
28
- assert_match what, contents
29
- else
30
- assert contents.include?(what),
31
- "Expected #{contents.inspect} to include #{what.inspect}"
32
- end
33
- end
34
- end
35
-
36
- def self.should_log_at_level(level)
37
- level = level.to_s.upcase
38
- should "log at the #{level} level" do
39
- assert File.read(TEST_LOG_PATH).include?(" #{level} -- :")
40
- end
41
- end
42
-
43
- def self.should_raise_exception(klass)
44
- should "raise an #{klass} exception" do
45
- assert @exception.is_a?(klass)
46
- end
47
- end
48
-
49
- def self.should_have_config_afterwards_including(config)
50
- config.each_pair do |key, value|
51
- should "continue afterwards with Samuel.config[#{key.inspect}] set to #{value.inspect}" do
52
- assert_equal value, Samuel.config[key]
53
- end
54
- end
55
- end
56
-
57
- def setup_test_logger
58
- FileUtils.rm_rf TEST_LOG_PATH
59
- FileUtils.touch TEST_LOG_PATH
60
- Samuel.logger = Logger.new(TEST_LOG_PATH)
61
- end
62
-
63
- def teardown_test_logger
64
- FileUtils.rm_rf TEST_LOG_PATH
65
- end
66
- end
@@ -1,32 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ThreadTest < Test::Unit::TestCase
4
-
5
- context "when logging multiple requests at once" do
6
- setup do
7
- @log = StringIO.new
8
- Samuel.logger = Logger.new(@log)
9
- FakeWeb.register_uri(:get, /example\.com/, :status => [200, "OK"])
10
- threads = []
11
- 5.times do |i|
12
- threads << Thread.new(i) do |n|
13
- Samuel.with_config :label => "Example #{n}" do
14
- Thread.pass
15
- open "http://example.com/#{n}"
16
- end
17
- end
18
- end
19
- threads.each { |t| t.join }
20
- @log.rewind
21
- end
22
-
23
- should "not let configuration blocks interfere with eachother" do
24
- @log.each_line do |line|
25
- matches = %r|Example (\d+).*example\.com/(\d+)|.match(line)
26
- assert_not_nil matches
27
- assert_equal matches[1], matches[2]
28
- end
29
- end
30
- end
31
-
32
- end