Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 8715908

Browse files
committed
Avoid calling method on example group class
Without this a `NoMethodError` is raised: undefined method `call' for :next_runnable_index_for:Symbol
1 parent 1f4b333 commit 8715908

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/rspec/core/example.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def initialize(example_group_class, description, user_metadata, example_block=ni
180180

181181
@metadata = Metadata::ExampleHash.create(
182182
@example_group_class.metadata, user_metadata,
183-
example_group_class.method(:next_runnable_index_for),
183+
lambda { |file| example_group_class.next_runnable_index_for(file) },
184184
description, example_block
185185
)
186186

spec/rspec/core/example_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,4 +797,20 @@ def expect_pending_result(example)
797797
expect(example.reporter).to be reporter
798798
end
799799
end
800+
801+
it 'allows extensions to add `method` to the DSL without causing problems' do
802+
http_testing_extension = Module.new do
803+
attr_reader :http_method
804+
def method(meth); @http_method = meth; end
805+
end
806+
807+
describe_successfully do
808+
extend http_testing_extension
809+
method :get
810+
811+
it "allows `method` to specify the HTTP method" do
812+
expect(self.class.http_method).to eq(:get)
813+
end
814+
end
815+
end
800816
end

0 commit comments

Comments
 (0)