sham_rack 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGUzNjMxMzE4N2M3NDA3ZWY2ZDQ5NWIzZDg2Mjg2ZjJhMmNiYWQxMA==
5
+ data.tar.gz: !binary |-
6
+ M2I4NDc5Njg5YTE0MzAwYjczYzZkYjA0ZWQ5OTExYjYxNTE5YzM5MQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZGJmZTUwOGIwMDhkY2Q4MTY3NmFkMWNkYjk2MmNiMWRjMGZmZDk2MWQ3YWFj
10
+ YzZlNzEwYzFhYmQ0M2NlM2MxYjViMzIwYTAwZWI4N2FlZjc3NjM3MjcwYzRi
11
+ MjJiYTEyMWRhOTNiY2IyYzVlOGIyOTg1ZmJjMDg0NmZmY2RmNWU=
12
+ data.tar.gz: !binary |-
13
+ ZGQxNGYxNmFjNjViZTQzZThmOWQ5MWI4YTExZTg5N2YzMGJlMTcwZjViNTEy
14
+ ZDVhNGQ2Y2QyODcyZTk4YThmMmEwNzAxNzM2ZmU4NzIxM2U3Yzg5ZDIzMTY4
15
+ MTA2NmI1NDkyNTAyZmJjYzgzMjg5MGJkNmQyMGQwYTg0YWZlYzE=
data/Rakefile CHANGED
@@ -1,13 +1,12 @@
1
1
  require "rubygems"
2
2
  require "rake"
3
3
 
4
- require "spec/rake/spectask"
5
-
6
4
  task "default" => "spec"
7
5
 
8
- Spec::Rake::SpecTask.new do |t|
9
- t.spec_opts = ["--colour", "--format", "nested"]
10
- t.spec_files = FileList['spec/**/*_spec.rb']
6
+ require "rspec/core/rake_task"
7
+
8
+ RSpec::Core::RakeTask.new do |t|
9
+ t.rspec_opts = ["--colour", "--format", "nested"]
11
10
  end
12
11
 
13
12
  require 'bundler'
@@ -74,6 +74,7 @@ module ShamRack
74
74
  def build_response(rack_response)
75
75
  status, headers, body = rack_response
76
76
  code, message = status.to_s.split(" ", 2)
77
+ message ||= Rack::Utils::HTTP_STATUS_CODES[code.to_i]
77
78
  response = Net::HTTPResponse.send(:response_class, code).new("Sham", code, message)
78
79
  response.instance_variable_set(:@body, assemble_body(body))
79
80
  response.instance_variable_set(:@read, true)
@@ -1,3 +1,3 @@
1
1
  module ShamRack
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
  end
@@ -148,28 +148,56 @@ describe ShamRack do
148
148
  before(:each) do
149
149
  ShamRack.at("www.greetings.com") do
150
150
  [
151
- "201 Created",
151
+ "456 Foo Bar",
152
152
  { "Content-Type" => "text/plain", "X-Foo" => "bar" },
153
153
  ["BODY"]
154
154
  ]
155
155
  end
156
- @response = Net::HTTP.get_response(URI.parse("http://www.greetings.com/"))
157
156
  end
158
157
 
158
+ let(:response) { Net::HTTP.get_response(URI.parse("http://www.greetings.com/")) }
159
+
159
160
  it "has status returned by app" do
160
- @response.code.should == "201"
161
+ response.code.should == "456"
162
+ end
163
+
164
+ it "has status message returned by app" do
165
+ response.message.should == "Foo Bar"
161
166
  end
162
167
 
163
168
  it "has body returned by app" do
164
- @response.body.should == "BODY"
169
+ response.body.should == "BODY"
165
170
  end
166
171
 
167
172
  it "has Content-Type returned by app" do
168
- @response.content_type.should == "text/plain"
173
+ response.content_type.should == "text/plain"
169
174
  end
170
175
 
171
176
  it "has other headers returned by app" do
172
- @response["x-foo"].should =="bar"
177
+ response["x-foo"].should =="bar"
178
+ end
179
+
180
+ context "when the app returns a numeric status" do
181
+
182
+ before(:each) do
183
+ ShamRack.at("www.greetings.com") do
184
+ [
185
+ 201,
186
+ { "Content-Type" => "text/plain" },
187
+ ["BODY"]
188
+ ]
189
+ end
190
+ @response = Net::HTTP.get_response(URI.parse("http://www.greetings.com/"))
191
+ end
192
+
193
+ it "has status returned by app" do
194
+ response.code.should == "201"
195
+ end
196
+
197
+ it "derives a status message" do
198
+ response.message.should == "Created"
199
+ end
200
+
173
201
  end
174
202
 
175
203
  end
@@ -1,9 +1,9 @@
1
1
  require "rubygems"
2
- require "spec"
2
+ require "rspec"
3
3
  require "rr"
4
4
 
5
- Spec::Runner.configure do |config|
6
- config.mock_with RR::Adapters::Rspec
5
+ RSpec.configure do |config|
6
+ config.mock_with :rr
7
7
  end
8
8
 
9
9
  require "test_apps"
metadata CHANGED
@@ -1,32 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sham_rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
5
- prerelease:
4
+ version: 1.3.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mike Williams
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-05-01 00:00:00.000000000 Z
11
+ date: 2013-03-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rack
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
14
+ prerelease: false
15
+ version_requirements: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
20
+ name: rack
21
+ requirement: !ruby/object:Gem::Requirement
26
22
  requirements:
27
23
  - - ! '>='
28
24
  - !ruby/object:Gem::Version
29
25
  version: '0'
26
+ type: :runtime
30
27
  description: ShamRack plumbs Net::HTTP directly into Rack, for quick and easy HTTP
31
28
  testing.
32
29
  email: mdub@dogbiscuit.org
@@ -51,33 +48,26 @@ files:
51
48
  - benchmark/hello_app.rb
52
49
  homepage: http://github.com/mdub/sham_rack
53
50
  licenses: []
51
+ metadata: {}
54
52
  post_install_message:
55
53
  rdoc_options: []
56
54
  require_paths:
57
55
  - lib
58
56
  required_ruby_version: !ruby/object:Gem::Requirement
59
- none: false
60
57
  requirements:
61
58
  - - ! '>='
62
59
  - !ruby/object:Gem::Version
63
60
  version: '0'
64
- segments:
65
- - 0
66
- hash: -1856658297304903275
67
61
  required_rubygems_version: !ruby/object:Gem::Requirement
68
- none: false
69
62
  requirements:
70
63
  - - ! '>='
71
64
  - !ruby/object:Gem::Version
72
65
  version: '0'
73
- segments:
74
- - 0
75
- hash: -1856658297304903275
76
66
  requirements: []
77
67
  rubyforge_project: shamrack
78
- rubygems_version: 1.8.21
68
+ rubygems_version: 2.0.0
79
69
  signing_key:
80
- specification_version: 3
70
+ specification_version: 4
81
71
  summary: Net::HTTP-to-Rack plumbing
82
72
  test_files:
83
73
  - spec/sham_rack/stub_web_service_spec.rb