1212
1313 describe "ab_test" do
1414 it "should not raise an error when passed strings for alternatives" do
15- expect ( lambda { ab_test ( 'xyz' , '1' , '2' , '3' ) } ) . not_to raise_error
15+ expect { ab_test ( 'xyz' , '1' , '2' , '3' ) } . not_to raise_error
1616 end
1717
1818 it "should not raise an error when passed an array for alternatives" do
19- expect ( lambda { ab_test ( 'xyz' , [ '1' , '2' , '3' ] ) } ) . not_to raise_error
19+ expect { ab_test ( 'xyz' , [ '1' , '2' , '3' ] ) } . not_to raise_error
2020 end
2121
2222 it "should raise the appropriate error when passed integers for alternatives" do
23- expect ( lambda { ab_test ( 'xyz' , 1 , 2 , 3 ) } ) . to raise_error ( ArgumentError )
23+ expect { ab_test ( 'xyz' , 1 , 2 , 3 ) } . to raise_error ( ArgumentError )
2424 end
2525
2626 it "should raise the appropriate error when passed symbols for alternatives" do
27- expect ( lambda { ab_test ( 'xyz' , :a , :b , :c ) } ) . to raise_error ( ArgumentError )
27+ expect { ab_test ( 'xyz' , :a , :b , :c ) } . to raise_error ( ArgumentError )
2828 end
2929
3030 it "should not raise error when passed an array for goals" do
31- expect ( lambda { ab_test ( { 'link_color' => [ "purchase" , "refund" ] } , 'blue' , 'red' ) } ) . not_to raise_error
31+ expect { ab_test ( { 'link_color' => [ "purchase" , "refund" ] } , 'blue' , 'red' ) } . not_to raise_error
3232 end
3333
3434 it "should not raise error when passed just one goal" do
35- expect ( lambda { ab_test ( { 'link_color' => "purchase" } , 'blue' , 'red' ) } ) . not_to raise_error
35+ expect { ab_test ( { 'link_color' => "purchase" } , 'blue' , 'red' ) } . not_to raise_error
3636 end
3737
3838 it "raises an appropriate error when processing combined expirements" do
4444 }
4545 }
4646 Split ::ExperimentCatalog . find_or_create ( 'combined_exp_1' )
47- expect ( lambda { ab_test ( 'combined_exp_1' ) } ) . to raise_error ( Split ::InvalidExperimentsFormatError )
47+ expect { ab_test ( 'combined_exp_1' ) } . to raise_error ( Split ::InvalidExperimentsFormatError )
4848 end
4949
5050 it "should assign a random alternative to a new user when there are an equal number of alternatives assigned" do
6767 it 'should not increment the counter for an experiment that the user is not participating in' do
6868 ab_test ( 'link_color' , 'blue' , 'red' )
6969 e = Split ::ExperimentCatalog . find_or_create ( 'button_size' , 'small' , 'big' )
70- expect ( lambda {
70+ expect {
7171 # User shouldn't participate in this second experiment
7272 ab_test ( 'button_size' , 'small' , 'big' )
73- } ) . not_to change { e . participant_count }
73+ } . not_to change { e . participant_count }
7474 end
7575
7676 it 'should not increment the counter for an ended experiment' do
7777 e = Split ::ExperimentCatalog . find_or_create ( 'button_size' , 'small' , 'big' )
7878 e . winner = 'small'
79- expect ( lambda {
79+ expect {
8080 a = ab_test ( 'button_size' , 'small' , 'big' )
8181 expect ( a ) . to eq ( 'small' )
82- } ) . not_to change { e . participant_count }
82+ } . not_to change { e . participant_count }
8383 end
8484
8585 it 'should not increment the counter for an not started experiment' do
8686 expect ( Split . configuration ) . to receive ( :start_manually ) . and_return ( true )
8787 e = Split ::ExperimentCatalog . find_or_create ( 'button_size' , 'small' , 'big' )
88- expect ( lambda {
88+ expect {
8989 a = ab_test ( 'button_size' , 'small' , 'big' )
9090 expect ( a ) . to eq ( 'small' )
91- } ) . not_to change { e . participant_count }
91+ } . not_to change { e . participant_count }
9292 end
9393
9494 it "should return the given alternative for an existing user" do
370370 e . winner = 'small'
371371 a = ab_test ( 'button_size' , 'small' , 'big' )
372372 expect ( a ) . to eq ( 'small' )
373- expect ( lambda {
373+ expect {
374374 ab_finished ( 'button_size' )
375- } ) . not_to change { Split ::Alternative . new ( a , 'button_size' ) . completed_count }
375+ } . not_to change { Split ::Alternative . new ( a , 'button_size' ) . completed_count }
376376 end
377377
378378 it "should clear out the user's participation from their session" do
431431 # receive the control for button_size. As the user is not participating in
432432 # the button size experiment, finishing it should not increase the
433433 # completion count for that alternative.
434- expect ( lambda {
434+ expect {
435435 ab_finished ( 'button_size' )
436- } ) . not_to change { Split ::Alternative . new ( 'small' , 'button_size' ) . completed_count }
436+ } . not_to change { Split ::Alternative . new ( 'small' , 'button_size' ) . completed_count }
437437 end
438438 end
439439
@@ -875,13 +875,13 @@ def should_finish_experiment(experiment_name, should_finish=true)
875875
876876 describe 'ab_test' do
877877 it 'should raise an exception' do
878- expect ( lambda { ab_test ( 'link_color' , 'blue' , 'red' ) } ) . to raise_error ( Errno ::ECONNREFUSED )
878+ expect { ab_test ( 'link_color' , 'blue' , 'red' ) } . to raise_error ( Errno ::ECONNREFUSED )
879879 end
880880 end
881881
882882 describe 'finished' do
883883 it 'should raise an exception' do
884- expect ( lambda { ab_finished ( 'link_color' ) } ) . to raise_error ( Errno ::ECONNREFUSED )
884+ expect { ab_finished ( 'link_color' ) } . to raise_error ( Errno ::ECONNREFUSED )
885885 end
886886 end
887887
@@ -893,12 +893,12 @@ def should_finish_experiment(experiment_name, should_finish=true)
893893 end
894894
895895 it "should not attempt to connect to redis" do
896- expect ( lambda { ab_test ( 'link_color' , 'blue' , 'red' ) } ) . not_to raise_error
896+ expect { ab_test ( 'link_color' , 'blue' , 'red' ) } . not_to raise_error
897897 end
898898
899899 it "should return control variable" do
900900 expect ( ab_test ( 'link_color' , 'blue' , 'red' ) ) . to eq ( 'blue' )
901- expect ( lambda { ab_finished ( 'link_color' ) } ) . not_to raise_error
901+ expect { ab_finished ( 'link_color' ) } . not_to raise_error
902902 end
903903 end
904904 end
@@ -912,7 +912,7 @@ def should_finish_experiment(experiment_name, should_finish=true)
912912
913913 describe 'ab_test' do
914914 it 'should not raise an exception' do
915- expect ( lambda { ab_test ( 'link_color' , 'blue' , 'red' ) } ) . not_to raise_error
915+ expect { ab_test ( 'link_color' , 'blue' , 'red' ) } . not_to raise_error
916916 end
917917
918918 it 'should call db_failover_on_db_error proc with error as parameter' do
@@ -971,7 +971,7 @@ def should_finish_experiment(experiment_name, should_finish=true)
971971
972972 describe 'finished' do
973973 it 'should not raise an exception' do
974- expect ( lambda { ab_finished ( 'link_color' ) } ) . not_to raise_error
974+ expect { ab_finished ( 'link_color' ) } . not_to raise_error
975975 end
976976
977977 it 'should call db_failover_on_db_error proc with error as parameter' do
@@ -1086,16 +1086,16 @@ def should_finish_experiment(experiment_name, should_finish=true)
10861086
10871087 it "fails gracefully if config is missing experiment" do
10881088 Split . configuration . experiments = { :other_experiment => { :foo => "Bar" } }
1089- expect ( lambda { ab_test :my_experiment } ) . to raise_error ( Split ::ExperimentNotFound )
1089+ expect { ab_test :my_experiment } . to raise_error ( Split ::ExperimentNotFound )
10901090 end
10911091
10921092 it "fails gracefully if config is missing" do
1093- expect ( lambda { Split . configuration . experiments = nil } ) . to raise_error ( Split ::InvalidExperimentsFormatError )
1093+ expect { Split . configuration . experiments = nil } . to raise_error ( Split ::InvalidExperimentsFormatError )
10941094 end
10951095
10961096 it "fails gracefully if config is missing alternatives" do
10971097 Split . configuration . experiments [ :my_experiment ] = { :foo => "Bar" }
1098- expect ( lambda { ab_test :my_experiment } ) . to raise_error ( NoMethodError )
1098+ expect { ab_test :my_experiment } . to raise_error ( NoMethodError )
10991099 end
11001100 end
11011101
0 commit comments