Skip to content

Commit 8b1938e

Browse files
authored
Merge pull request #372 from natesalisbury/client_method
Fixes undefining client_method when set to the same client_method
2 parents d7a6961 + eeaeb74 commit 8b1938e

File tree

2 files changed

+35
-0
lines changed

2 files changed

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

lib/rspec_api_documentation/configuration.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ def self.add_setting(name, opts = {})
119119
}
120120

121121
def client_method=(new_client_method)
122+
return if new_client_method == client_method
123+
122124
RspecApiDocumentation::DSL::Resource.module_eval <<-RUBY
123125
alias :#{new_client_method} #{client_method}
124126
undef #{client_method}

0 commit comments

Comments
 (0)