Skip to content

Commit

Permalink
Wrap keyword args definitions in eval blocks for 1.8.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Apr 5, 2020
1 parent 78f3a79 commit 1ed0a75
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/rspec/matchers/dsl_spec.rb
Expand Up @@ -30,6 +30,7 @@ def ok
end

if RSpec::Support::RubyFeatures.required_kw_args_supported?
binding.eval(<<-CODE, __FILE__, __LINE__)
def kw(a:)
a
end
Expand All @@ -38,9 +39,11 @@ def kw(a:)
RSpec::Matchers.define(:matcher_kw) {}
expect(matcher_kw.kw(a: 1)).to eq(1)
end
CODE
end

if RSpec::Support::RubyFeatures.kw_args_supported?
binding.eval(<<-CODE, __FILE__, __LINE__)
def optional_kw(a: nil)
a
end
Expand All @@ -49,6 +52,7 @@ def optional_kw(a: nil)
RSpec::Matchers.define(:matcher_optional_kw) {}
expect(matcher_optional_kw.optional_kw(a: 1)).to eq(1)
end
CODE
end

it "clears user instance variables between invocations" do
Expand Down

0 comments on commit 1ed0a75

Please sign in to comment.