Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes undefining client_method when set to the same client_method #372

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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