File tree Expand file tree Collapse file tree 2 files changed +27
-8
lines changed Expand file tree Collapse file tree 2 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,8 @@ module HelperExampleGroup
12
12
13
13
# @private
14
14
module ClassMethods
15
- def determine_default_helper_class ( _ignore )
16
- described_class
15
+ def determine_constant_from_test_name ( _ignore )
16
+ described_class if yield ( described_class )
17
17
end
18
18
end
19
19
Original file line number Diff line number Diff line change 2
2
3
3
module RSpec ::Rails
4
4
describe HelperExampleGroup do
5
- module ::FoosHelper ; end
5
+ module ::FoosHelper
6
+ class InternalClass
7
+ end
8
+ end
9
+
6
10
subject { HelperExampleGroup }
7
11
8
12
it_behaves_like "an rspec-rails example group mixin" , :helper ,
@@ -48,11 +52,26 @@ def _view
48
52
49
53
describe HelperExampleGroup ::ClassMethods do
50
54
describe "determine_default_helper_class" do
51
- it "returns the helper module passed to describe" do
52
- helper_spec = Object . new . extend HelperExampleGroup ::ClassMethods
53
- allow ( helper_spec ) . to receive ( :described_class ) { FoosHelper }
54
- expect ( helper_spec . determine_default_helper_class ( "ignore this" ) ) .
55
- to eq ( FoosHelper )
55
+ let ( :group ) do
56
+ RSpec ::Core ::ExampleGroup . describe do
57
+ include HelperExampleGroup
58
+ end
59
+ end
60
+
61
+ context "the described is a module" do
62
+ it "returns the module" do
63
+ allow ( group ) . to receive ( :described_class ) { FoosHelper }
64
+ expect ( group . determine_default_helper_class ( "ignore this" ) ) .
65
+ to eq ( FoosHelper )
66
+ end
67
+ end
68
+
69
+ context "the described is a class" do
70
+ it "returns nil" do
71
+ allow ( group ) . to receive ( :described_class ) { FoosHelper ::InternalClass }
72
+ expect ( group . determine_default_helper_class ( "ignore this" ) ) .
73
+ to be_nil
74
+ end
56
75
end
57
76
end
58
77
end
You can’t perform that action at this time.
0 commit comments