Skip to content

Commit 4445631

Browse files
committed
Refactor spec/encapsulated_helper_spec.rb to not include EncapsuledHelper on itself
1 parent 7a075be commit 4445631

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

spec/encapsulated_helper_spec.rb

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,23 @@
33
require "spec_helper"
44

55
describe Split::EncapsulatedHelper do
6-
include Split::EncapsulatedHelper
6+
let(:context_shim) { Split::EncapsulatedHelper::ContextShim.new(double(request: request)) }
77

88
describe "ab_test" do
99
before do
1010
allow_any_instance_of(Split::EncapsulatedHelper::ContextShim).to receive(:ab_user)
1111
.and_return(mock_user)
1212
end
1313

14-
context "when params raises an error" do
15-
before do
16-
allow(self).to receive(:params).and_raise(NoMethodError)
17-
end
18-
19-
it "should not raise an error " do
20-
expect { params }.to raise_error(NoMethodError)
21-
expect { ab_test("link_color", "blue", "red") }.not_to raise_error
22-
end
23-
end
24-
2514
it "calls the block with selected alternative" do
26-
expect { |block| ab_test("link_color", "red", "red", &block) }.to yield_with_args("red", {})
15+
expect { |block| context_shim.ab_test("link_color", "red", "red", &block) }.to yield_with_args("red", {})
2716
end
2817

2918
context "inside a view" do
3019
it "works inside ERB" do
3120
require "erb"
3221
template = ERB.new(<<-ERB.split(/\s+/s).map(&:strip).join(" "), nil, "%")
33-
foo <% ab_test(:foo, '1', '2') do |alt, meta| %>
22+
foo <% context_shim.ab_test(:foo, '1', '2') do |alt, meta| %>
3423
static <%= alt %>
3524
<% end %>
3625
ERB

0 commit comments

Comments
 (0)