diff --git a/lib/split/encapsulated_helper.rb b/lib/split/encapsulated_helper.rb index 4797c809..a78f9877 100644 --- a/lib/split/encapsulated_helper.rb +++ b/lib/split/encapsulated_helper.rb @@ -14,16 +14,12 @@ module EncapsulatedHelper class ContextShim include Split::Helper - def initialize(context, original_params) + def initialize(context) @context = context - @_params = original_params end def ab_user @ab_user ||= Split::Persistence.adapter.new(@context) end - def params - @_params - end end def ab_test(*arguments) @@ -51,8 +47,7 @@ def ab_test_finished(*arguments) # instantiate and memoize a context shim in case of multiple ab_test* calls def split_context_shim - _params = defined?(params) ? params : {} - @split_context_shim ||= ContextShim.new(self, _params) + @split_context_shim ||= ContextShim.new(self) end end end diff --git a/spec/encapsulated_helper_spec.rb b/spec/encapsulated_helper_spec.rb new file mode 100644 index 00000000..e92851fb --- /dev/null +++ b/spec/encapsulated_helper_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe Split::EncapsulatedHelper do + include Split::EncapsulatedHelper + + before do + @persistence_adapter = Split.configuration.persistence + Split.configuration.persistence = Hash + end + + after do + Split.configuration.persistence = @persistence_adapter + end + + def params + raise NoMethodError, 'This method is not really defined' + end + + describe "ab_test" do + it "should not raise an error when params raises an error" do + lambda { ab_test('link_color', 'blue', 'red') }.should_not raise_error + end + end +end