fakeweb 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG +11 -0
  3. data/Rakefile +7 -7
  4. data/fakeweb.gemspec +41 -7
  5. data/lib/fake_web.rb +4 -1
  6. data/lib/fake_web/VERSION +1 -0
  7. data/lib/fake_web/ext/net_http.rb +18 -8
  8. data/lib/fake_web/registry.rb +8 -21
  9. data/lib/fake_web/utility.rb +28 -17
  10. data/test/test_fake_web.rb +1 -1
  11. data/test/test_other_net_http_libraries.rb +37 -0
  12. data/test/test_regexes.rb +17 -12
  13. data/test/test_utility.rb +0 -21
  14. data/test/vendor/right_http_connection-1.2.4/History.txt +59 -0
  15. data/test/vendor/right_http_connection-1.2.4/Manifest.txt +7 -0
  16. data/test/vendor/right_http_connection-1.2.4/README.txt +54 -0
  17. data/test/vendor/right_http_connection-1.2.4/Rakefile +103 -0
  18. data/test/vendor/right_http_connection-1.2.4/lib/net_fix.rb +160 -0
  19. data/test/vendor/right_http_connection-1.2.4/lib/right_http_connection.rb +435 -0
  20. data/test/vendor/right_http_connection-1.2.4/setup.rb +1585 -0
  21. data/test/vendor/samuel-0.2.1/.document +5 -0
  22. data/test/vendor/samuel-0.2.1/.gitignore +5 -0
  23. data/test/vendor/samuel-0.2.1/LICENSE +20 -0
  24. data/test/vendor/samuel-0.2.1/README.rdoc +70 -0
  25. data/test/vendor/samuel-0.2.1/Rakefile +62 -0
  26. data/test/vendor/samuel-0.2.1/VERSION +1 -0
  27. data/test/vendor/samuel-0.2.1/lib/samuel.rb +52 -0
  28. data/test/vendor/samuel-0.2.1/lib/samuel/net_http.rb +10 -0
  29. data/test/vendor/samuel-0.2.1/lib/samuel/request.rb +96 -0
  30. data/test/vendor/samuel-0.2.1/samuel.gemspec +69 -0
  31. data/test/vendor/samuel-0.2.1/test/request_test.rb +193 -0
  32. data/test/vendor/samuel-0.2.1/test/samuel_test.rb +42 -0
  33. data/test/vendor/samuel-0.2.1/test/test_helper.rb +66 -0
  34. data/test/vendor/samuel-0.2.1/test/thread_test.rb +32 -0
  35. metadata +36 -3
  36. data/VERSION +0 -1
@@ -0,0 +1,42 @@
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
@@ -0,0 +1,66 @@
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
@@ -0,0 +1,32 @@
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakeweb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Kampmeier
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-08-31 00:00:00 -07:00
13
+ date: 2009-11-02 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -40,9 +40,9 @@ files:
40
40
  - LICENSE.txt
41
41
  - README.rdoc
42
42
  - Rakefile
43
- - VERSION
44
43
  - fakeweb.gemspec
45
44
  - lib/fake_web.rb
45
+ - lib/fake_web/VERSION
46
46
  - lib/fake_web/ext/net_http.rb
47
47
  - lib/fake_web/registry.rb
48
48
  - lib/fake_web/responder.rb
@@ -62,12 +62,34 @@ files:
62
62
  - test/test_fake_web_open_uri.rb
63
63
  - test/test_helper.rb
64
64
  - test/test_missing_open_uri.rb
65
+ - test/test_other_net_http_libraries.rb
65
66
  - test/test_precedence.rb
66
67
  - test/test_query_string.rb
67
68
  - test/test_regexes.rb
68
69
  - test/test_response_headers.rb
69
70
  - test/test_trailing_slashes.rb
70
71
  - test/test_utility.rb
72
+ - test/vendor/right_http_connection-1.2.4/History.txt
73
+ - test/vendor/right_http_connection-1.2.4/Manifest.txt
74
+ - test/vendor/right_http_connection-1.2.4/README.txt
75
+ - test/vendor/right_http_connection-1.2.4/Rakefile
76
+ - test/vendor/right_http_connection-1.2.4/lib/net_fix.rb
77
+ - test/vendor/right_http_connection-1.2.4/lib/right_http_connection.rb
78
+ - test/vendor/right_http_connection-1.2.4/setup.rb
79
+ - test/vendor/samuel-0.2.1/.document
80
+ - test/vendor/samuel-0.2.1/.gitignore
81
+ - test/vendor/samuel-0.2.1/LICENSE
82
+ - test/vendor/samuel-0.2.1/README.rdoc
83
+ - test/vendor/samuel-0.2.1/Rakefile
84
+ - test/vendor/samuel-0.2.1/VERSION
85
+ - test/vendor/samuel-0.2.1/lib/samuel.rb
86
+ - test/vendor/samuel-0.2.1/lib/samuel/net_http.rb
87
+ - test/vendor/samuel-0.2.1/lib/samuel/request.rb
88
+ - test/vendor/samuel-0.2.1/samuel.gemspec
89
+ - test/vendor/samuel-0.2.1/test/request_test.rb
90
+ - test/vendor/samuel-0.2.1/test/samuel_test.rb
91
+ - test/vendor/samuel-0.2.1/test/test_helper.rb
92
+ - test/vendor/samuel-0.2.1/test/thread_test.rb
71
93
  has_rdoc: true
72
94
  homepage: http://github.com/chrisk/fakeweb
73
95
  licenses: []
@@ -104,9 +126,20 @@ test_files:
104
126
  - test/test_fake_web_open_uri.rb
105
127
  - test/test_helper.rb
106
128
  - test/test_missing_open_uri.rb
129
+ - test/test_other_net_http_libraries.rb
107
130
  - test/test_precedence.rb
108
131
  - test/test_query_string.rb
109
132
  - test/test_regexes.rb
110
133
  - test/test_response_headers.rb
111
134
  - test/test_trailing_slashes.rb
112
135
  - test/test_utility.rb
136
+ - test/vendor/right_http_connection-1.2.4/lib/net_fix.rb
137
+ - test/vendor/right_http_connection-1.2.4/lib/right_http_connection.rb
138
+ - test/vendor/right_http_connection-1.2.4/setup.rb
139
+ - test/vendor/samuel-0.2.1/lib/samuel/net_http.rb
140
+ - test/vendor/samuel-0.2.1/lib/samuel/request.rb
141
+ - test/vendor/samuel-0.2.1/lib/samuel.rb
142
+ - test/vendor/samuel-0.2.1/test/request_test.rb
143
+ - test/vendor/samuel-0.2.1/test/samuel_test.rb
144
+ - test/vendor/samuel-0.2.1/test/test_helper.rb
145
+ - test/vendor/samuel-0.2.1/test/thread_test.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.2.6