cotweet-fakeweb 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.autotest +5 -0
  2. data/.gitignore +7 -0
  3. data/CHANGELOG +215 -0
  4. data/LICENSE.txt +19 -0
  5. data/README.rdoc +189 -0
  6. data/Rakefile +67 -0
  7. data/fakeweb.gemspec +126 -0
  8. data/lib/fake_web.rb +215 -0
  9. data/lib/fake_web/ext/net_http.rb +72 -0
  10. data/lib/fake_web/registry.rb +127 -0
  11. data/lib/fake_web/responder.rb +122 -0
  12. data/lib/fake_web/response.rb +10 -0
  13. data/lib/fake_web/stub_socket.rb +15 -0
  14. data/lib/fake_web/utility.rb +90 -0
  15. data/lib/fakeweb.rb +2 -0
  16. data/test/fixtures/google_response_from_curl +12 -0
  17. data/test/fixtures/google_response_with_transfer_encoding +17 -0
  18. data/test/fixtures/google_response_without_transfer_encoding +11 -0
  19. data/test/fixtures/test_example.txt +1 -0
  20. data/test/fixtures/test_txt_file +3 -0
  21. data/test/test_allow_net_connect.rb +168 -0
  22. data/test/test_deprecations.rb +54 -0
  23. data/test/test_fake_authentication.rb +92 -0
  24. data/test/test_fake_web.rb +590 -0
  25. data/test/test_fake_web_open_uri.rb +58 -0
  26. data/test/test_helper.rb +90 -0
  27. data/test/test_last_request.rb +29 -0
  28. data/test/test_missing_open_uri.rb +25 -0
  29. data/test/test_missing_pathname.rb +37 -0
  30. data/test/test_other_net_http_libraries.rb +36 -0
  31. data/test/test_precedence.rb +79 -0
  32. data/test/test_query_string.rb +45 -0
  33. data/test/test_regexes.rb +157 -0
  34. data/test/test_response_headers.rb +79 -0
  35. data/test/test_trailing_slashes.rb +53 -0
  36. data/test/test_utility.rb +83 -0
  37. data/test/vendor/right_http_connection-1.2.4/History.txt +59 -0
  38. data/test/vendor/right_http_connection-1.2.4/Manifest.txt +7 -0
  39. data/test/vendor/right_http_connection-1.2.4/README.txt +54 -0
  40. data/test/vendor/right_http_connection-1.2.4/Rakefile +103 -0
  41. data/test/vendor/right_http_connection-1.2.4/lib/net_fix.rb +160 -0
  42. data/test/vendor/right_http_connection-1.2.4/lib/right_http_connection.rb +435 -0
  43. data/test/vendor/right_http_connection-1.2.4/setup.rb +1585 -0
  44. data/test/vendor/samuel-0.2.1/.document +5 -0
  45. data/test/vendor/samuel-0.2.1/.gitignore +5 -0
  46. data/test/vendor/samuel-0.2.1/LICENSE +20 -0
  47. data/test/vendor/samuel-0.2.1/README.rdoc +70 -0
  48. data/test/vendor/samuel-0.2.1/Rakefile +62 -0
  49. data/test/vendor/samuel-0.2.1/VERSION +1 -0
  50. data/test/vendor/samuel-0.2.1/lib/samuel.rb +52 -0
  51. data/test/vendor/samuel-0.2.1/lib/samuel/net_http.rb +10 -0
  52. data/test/vendor/samuel-0.2.1/lib/samuel/request.rb +96 -0
  53. data/test/vendor/samuel-0.2.1/samuel.gemspec +69 -0
  54. data/test/vendor/samuel-0.2.1/test/request_test.rb +193 -0
  55. data/test/vendor/samuel-0.2.1/test/samuel_test.rb +42 -0
  56. data/test/vendor/samuel-0.2.1/test/test_helper.rb +66 -0
  57. data/test/vendor/samuel-0.2.1/test/thread_test.rb +32 -0
  58. metadata +167 -0
@@ -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 ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cotweet-fakeweb
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 3
9
+ - 0
10
+ version: 1.3.0
11
+ platform: ruby
12
+ authors:
13
+ - Chris Kampmeier
14
+ - Blaine Cook
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-08-22 00:00:00 -07:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: mocha
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 49
31
+ segments:
32
+ - 0
33
+ - 9
34
+ - 5
35
+ version: 0.9.5
36
+ type: :development
37
+ version_requirements: *id001
38
+ description: FakeWeb is a helper for faking web requests in Ruby. It works at a global level, without modifying code or writing extensive stubs.
39
+ email:
40
+ - chris@kampers.net
41
+ - romeda@gmail.com
42
+ executables: []
43
+
44
+ extensions: []
45
+
46
+ extra_rdoc_files:
47
+ - LICENSE.txt
48
+ - README.rdoc
49
+ files:
50
+ - .autotest
51
+ - .gitignore
52
+ - CHANGELOG
53
+ - LICENSE.txt
54
+ - README.rdoc
55
+ - Rakefile
56
+ - fakeweb.gemspec
57
+ - lib/fake_web.rb
58
+ - lib/fake_web/ext/net_http.rb
59
+ - lib/fake_web/registry.rb
60
+ - lib/fake_web/responder.rb
61
+ - lib/fake_web/response.rb
62
+ - lib/fake_web/stub_socket.rb
63
+ - lib/fake_web/utility.rb
64
+ - lib/fakeweb.rb
65
+ - test/fixtures/google_response_from_curl
66
+ - test/fixtures/google_response_with_transfer_encoding
67
+ - test/fixtures/google_response_without_transfer_encoding
68
+ - test/fixtures/test_example.txt
69
+ - test/fixtures/test_txt_file
70
+ - test/test_allow_net_connect.rb
71
+ - test/test_deprecations.rb
72
+ - test/test_fake_authentication.rb
73
+ - test/test_fake_web.rb
74
+ - test/test_fake_web_open_uri.rb
75
+ - test/test_helper.rb
76
+ - test/test_last_request.rb
77
+ - test/test_missing_open_uri.rb
78
+ - test/test_missing_pathname.rb
79
+ - test/test_other_net_http_libraries.rb
80
+ - test/test_precedence.rb
81
+ - test/test_query_string.rb
82
+ - test/test_regexes.rb
83
+ - test/test_response_headers.rb
84
+ - test/test_trailing_slashes.rb
85
+ - test/test_utility.rb
86
+ - test/vendor/right_http_connection-1.2.4/History.txt
87
+ - test/vendor/right_http_connection-1.2.4/Manifest.txt
88
+ - test/vendor/right_http_connection-1.2.4/README.txt
89
+ - test/vendor/right_http_connection-1.2.4/Rakefile
90
+ - test/vendor/right_http_connection-1.2.4/lib/net_fix.rb
91
+ - test/vendor/right_http_connection-1.2.4/lib/right_http_connection.rb
92
+ - test/vendor/right_http_connection-1.2.4/setup.rb
93
+ - test/vendor/samuel-0.2.1/.document
94
+ - test/vendor/samuel-0.2.1/.gitignore
95
+ - test/vendor/samuel-0.2.1/LICENSE
96
+ - test/vendor/samuel-0.2.1/README.rdoc
97
+ - test/vendor/samuel-0.2.1/Rakefile
98
+ - test/vendor/samuel-0.2.1/VERSION
99
+ - test/vendor/samuel-0.2.1/lib/samuel.rb
100
+ - test/vendor/samuel-0.2.1/lib/samuel/net_http.rb
101
+ - test/vendor/samuel-0.2.1/lib/samuel/request.rb
102
+ - test/vendor/samuel-0.2.1/samuel.gemspec
103
+ - test/vendor/samuel-0.2.1/test/request_test.rb
104
+ - test/vendor/samuel-0.2.1/test/samuel_test.rb
105
+ - test/vendor/samuel-0.2.1/test/test_helper.rb
106
+ - test/vendor/samuel-0.2.1/test/thread_test.rb
107
+ has_rdoc: true
108
+ homepage: http://github.com/chrisk/fakeweb
109
+ licenses: []
110
+
111
+ post_install_message:
112
+ rdoc_options:
113
+ - --charset=UTF-8
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
124
+ version: "0"
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ hash: 3
131
+ segments:
132
+ - 0
133
+ version: "0"
134
+ requirements: []
135
+
136
+ rubyforge_project: fakeweb
137
+ rubygems_version: 1.3.7
138
+ signing_key:
139
+ specification_version: 3
140
+ summary: A tool for faking responses to HTTP requests
141
+ test_files:
142
+ - test/test_allow_net_connect.rb
143
+ - test/test_deprecations.rb
144
+ - test/test_fake_authentication.rb
145
+ - test/test_fake_web.rb
146
+ - test/test_fake_web_open_uri.rb
147
+ - test/test_helper.rb
148
+ - test/test_last_request.rb
149
+ - test/test_missing_open_uri.rb
150
+ - test/test_missing_pathname.rb
151
+ - test/test_other_net_http_libraries.rb
152
+ - test/test_precedence.rb
153
+ - test/test_query_string.rb
154
+ - test/test_regexes.rb
155
+ - test/test_response_headers.rb
156
+ - test/test_trailing_slashes.rb
157
+ - test/test_utility.rb
158
+ - test/vendor/right_http_connection-1.2.4/lib/net_fix.rb
159
+ - test/vendor/right_http_connection-1.2.4/lib/right_http_connection.rb
160
+ - test/vendor/right_http_connection-1.2.4/setup.rb
161
+ - test/vendor/samuel-0.2.1/lib/samuel/net_http.rb
162
+ - test/vendor/samuel-0.2.1/lib/samuel/request.rb
163
+ - test/vendor/samuel-0.2.1/lib/samuel.rb
164
+ - test/vendor/samuel-0.2.1/test/request_test.rb
165
+ - test/vendor/samuel-0.2.1/test/samuel_test.rb
166
+ - test/vendor/samuel-0.2.1/test/test_helper.rb
167
+ - test/vendor/samuel-0.2.1/test/thread_test.rb