Skip to content

Commit

Permalink
Fixes undefining client_method when set to the same client_method
Browse files Browse the repository at this point in the history
  • Loading branch information
natesalisbury committed Feb 28, 2018
1 parent d7a6961 commit eeaeb74
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
33 changes: 33 additions & 0 deletions features/redefining_same_client.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Feature: Redefining the client method to the same method
Background:
Given a file named "app.rb" with:
"""
class App
def self.call(env)
[200, {}, ["Hello, world"]]
end
end
"""
And a file named "app_spec.rb" with:
"""
require "rspec_api_documentation"
require "rspec_api_documentation/dsl"
RspecApiDocumentation.configure do |config|
config.app = App
config.client_method = :client
end
resource "Example Request" do
get "/" do
example_request "Trying out get" do
expect(status).to eq(200)
end
end
end
"""
When I run `rspec app_spec.rb --require ./app.rb --format RspecApiDocumentation::ApiFormatter`

Scenario: Output should have the correct error line
Then the output should contain "1 example, 0 failures"
And the exit status should be 0
2 changes: 2 additions & 0 deletions lib/rspec_api_documentation/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def self.add_setting(name, opts = {})
}

def client_method=(new_client_method)
return if new_client_method == client_method

RspecApiDocumentation::DSL::Resource.module_eval <<-RUBY
alias :#{new_client_method} #{client_method}
undef #{client_method}
Expand Down

0 comments on commit eeaeb74

Please sign in to comment.