@@ -69,6 +69,38 @@ def find_implementation_block(registry, scope, name)
69
69
expect ( Kernel ) . to_not respond_to ( shared_method_name )
70
70
end
71
71
72
+ if RSpec ::Support ::RubyFeatures . required_kw_args_supported?
73
+ it 'supports required keyword arguments' do
74
+ binding . eval ( <<-CODE , __FILE__ , __LINE__ )
75
+ group.__send__ shared_method_name, "shared context" do |foo:|
76
+ it "has an expected value" do
77
+ expect(foo).to eq("bar")
78
+ end
79
+ end
80
+
81
+ group.it_behaves_like "shared context", foo: "bar"
82
+ group.it_behaves_like "shared context", { foo: "bar" }
83
+ CODE
84
+ expect ( group . run ) . to eq true
85
+ end
86
+ end
87
+
88
+ if RSpec ::Support ::RubyFeatures . kw_args_supported?
89
+ it 'supports optional keyword arguments' do
90
+ binding . eval ( <<-CODE , __FILE__ , __LINE__ )
91
+ group.__send__ shared_method_name, "shared context" do |foo: nil|
92
+ it "has an expected value" do
93
+ expect(foo).to eq("bar")
94
+ end
95
+ end
96
+
97
+ group.it_behaves_like "shared context", foo: "bar"
98
+ group.it_behaves_like "shared context", { foo: "bar" }
99
+ CODE
100
+ expect ( group . run ) . to eq true
101
+ end
102
+ end
103
+
72
104
it "displays a warning when adding an example group without a block" , :unless => RUBY_VERSION == '1.8.7' do
73
105
expect_warning_with_call_site ( __FILE__ , __LINE__ + 1 )
74
106
group . send ( shared_method_name , 'name but no block' )
@@ -543,20 +575,6 @@ def self.bar; 'bar'; end
543
575
expect ( group ) . to have_example_descriptions ( "a different spec" )
544
576
end
545
577
end
546
-
547
- if RSpec ::Support ::RubyFeatures . required_kw_args_supported?
548
- binding . eval ( <<-CODE , __FILE__ , __LINE__ )
549
- context "supporting kwargs" do
550
- __send__ shared_method_name, "shared context" do |foo:|
551
- it "has an expected value" do
552
- expect(foo).to eq("bar")
553
- end
554
- end
555
-
556
- it_behaves_like "shared context", foo: "bar"
557
- end
558
- CODE
559
- end
560
578
end
561
579
end
562
580
end
0 commit comments