diff --git a/features/redefining_same_client.feature b/features/redefining_same_client.feature new file mode 100644 index 00000000..09f7a233 --- /dev/null +++ b/features/redefining_same_client.feature @@ -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 diff --git a/lib/rspec_api_documentation/configuration.rb b/lib/rspec_api_documentation/configuration.rb index c4721674..fcc2a773 100644 --- a/lib/rspec_api_documentation/configuration.rb +++ b/lib/rspec_api_documentation/configuration.rb @@ -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}