Skip to content

Commit fd3e8d8

Browse files
committed
Add HEAD and PATCH
1 parent 8d258f8 commit fd3e8d8

File tree

9 files changed

+65
-13
lines changed

9 files changed

+65
-13
lines changed

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ GEM
5252
multi_json (1.3.5)
5353
mustache (0.99.4)
5454
nokogiri (1.5.2)
55-
rack (1.4.1)
55+
rack (1.5.2)
5656
rack-oauth2 (0.14.4)
5757
activesupport (>= 2.3)
5858
attr_required (>= 0.0.5)
@@ -62,7 +62,7 @@ GEM
6262
rack (>= 1.1)
6363
rack-protection (1.2.0)
6464
rack
65-
rack-test (0.6.1)
65+
rack-test (0.6.2)
6666
rack (>= 1.0)
6767
rake (0.9.2.2)
6868
rspec (2.10.0)
@@ -99,7 +99,7 @@ DEPENDENCIES
9999
capybara
100100
fakefs
101101
rack-oauth2 (>= 0.14.4)
102-
rack-test (>= 0.5.5)
102+
rack-test (>= 0.6.2)
103103
rake
104104
rspec_api_documentation!
105105
sinatra

example/Gemfile.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ../
33
specs:
4-
rspec_api_documentation (0.7.0)
4+
rspec_api_documentation (0.8.0)
55
activesupport (>= 3.0.0)
66
i18n (>= 0.1.0)
77
json (>= 1.4.6)
@@ -40,7 +40,7 @@ GEM
4040
activesupport (= 3.1.3)
4141
activesupport (3.1.3)
4242
multi_json (~> 1.0)
43-
addressable (2.2.8)
43+
addressable (2.3.3)
4444
arel (2.2.1)
4545
builder (3.0.0)
4646
coffee-rails (3.1.1)
@@ -50,7 +50,7 @@ GEM
5050
coffee-script-source
5151
execjs
5252
coffee-script-source (1.1.3)
53-
crack (0.3.1)
53+
crack (0.3.2)
5454
diff-lcs (1.1.3)
5555
erubis (2.7.0)
5656
execjs (1.2.12)
@@ -77,7 +77,7 @@ GEM
7777
multi_json (1.0.4)
7878
mustache (0.99.4)
7979
polyglot (0.3.3)
80-
rack (1.3.5)
80+
rack (1.3.10)
8181
rack-cache (1.1)
8282
rack (>= 0.4)
8383
rack-mount (0.8.3)
@@ -86,7 +86,7 @@ GEM
8686
rack
8787
rack-ssl (1.3.2)
8888
rack
89-
rack-test (0.6.1)
89+
rack-test (0.6.2)
9090
rack (>= 1.0)
9191
raddocs (0.1.0)
9292
haml
@@ -148,9 +148,9 @@ GEM
148148
uglifier (1.1.0)
149149
execjs (>= 0.3.0)
150150
multi_json (>= 1.0.2)
151-
webmock (1.8.7)
151+
webmock (1.10.1)
152152
addressable (>= 2.2.7)
153-
crack (>= 0.1.7)
153+
crack (>= 0.3.2)
154154

155155
PLATFORMS
156156
ruby

example/spec/acceptance/orders_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
end
2525
end
2626

27+
head "/orders" do
28+
example_request "Getting the headers" do
29+
response_headers["Content-Type"].should == "application/json; charset=utf-8"
30+
end
31+
end
32+
2733
post "/orders" do
2834
parameter :name, "Name of order"
2935
parameter :paid, "If the order has been paid for"

features/patch.feature

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Feature: Example Request with PATCH
2+
Background:
3+
Given a file named "app.rb" with:
4+
"""
5+
class App
6+
def self.call(env)
7+
if env["REQUEST_METHOD"] == "PATCH"
8+
[200, {}, ["Hello, world"]]
9+
else
10+
[404, {}, ["ERROR"]]
11+
end
12+
end
13+
end
14+
"""
15+
And a file named "app_spec.rb" with:
16+
"""
17+
require "rspec_api_documentation"
18+
require "rspec_api_documentation/dsl"
19+
20+
RspecApiDocumentation.configure do |config|
21+
config.app = App
22+
end
23+
24+
resource "Example Request" do
25+
patch "/" do
26+
example_request "Trying out patch" do
27+
status.should eq(200)
28+
end
29+
end
30+
end
31+
"""
32+
When I run `rspec app_spec.rb --require ./app.rb --format RspecApiDocumentation::ApiFormatter`
33+
34+
Scenario: Output should have the correct error line
35+
Then the output should contain "1 example, 0 failures"
36+
And the exit status should be 0

gemfiles/minimum_dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gem "i18n", "0.4.0"
88
gem "mustache", "0.99.4"
99
gem "webmock", "1.8.8"
1010
gem "json", "1.4.6"
11-
gem "rack-test", "0.5.5"
11+
gem "rack-test", "0.6.2"
1212
gem "rack-oauth2", "0.14.4"
1313

1414
gem "fakefs"

lib/rspec_api_documentation/client_base.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ def delete(*args)
2121
process :delete, *args
2222
end
2323

24+
def head(*args)
25+
process :head, *args
26+
end
27+
28+
def patch(*args)
29+
process :patch, *args
30+
end
31+
2432
def response_status
2533
status
2634
end

lib/rspec_api_documentation/dsl/resource.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def self.define_action(method)
1919
define_action :post
2020
define_action :put
2121
define_action :delete
22+
define_action :head
23+
define_action :patch
2224

2325
def callback(*args, &block)
2426
require 'webmock'

rspec_api_documentation.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
2626
s.add_development_dependency "aruba"
2727
s.add_development_dependency "capybara"
2828
s.add_development_dependency "rake"
29-
s.add_development_dependency "rack-test", ">= 0.5.5"
29+
s.add_development_dependency "rack-test", ">= 0.6.2"
3030
s.add_development_dependency "rack-oauth2", ">= 0.14.4"
3131

3232
s.files = Dir.glob("lib/**/*") + Dir.glob("templates/**/*")

spec/dsl_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
end
2727
end
2828

29-
[:post, :get, :put, :delete].each do |http_method|
29+
[:post, :get, :put, :delete, :head, :patch].each do |http_method|
3030
send(http_method, "/path") do
3131
specify { example.example_group.description.should eq("#{http_method.to_s.upcase} /path") }
3232

0 commit comments

Comments
 (0)