@@ -86,11 +86,13 @@ def self.find(_key); end
8686 let ( :square_expression ) { "[call.start_time.blank_if_nil][do_a_barrel_roll.downcase]" }
8787
8888 it "returns tokens up to first dot when no mapping is provided" do
89- expect ( ParameterSubstitution . find_tokens ( square_expression , parameter_start : "[" , parameter_end : "]" ) ) . to eq ( [ 'call' , 'do_a_barrel_roll' ] )
89+ context_overrides = { parameter_start : "[" , parameter_end : "]" }
90+ expect ( ParameterSubstitution . find_tokens ( square_expression , context_overrides : context_overrides ) ) . to eq ( [ 'call' , 'do_a_barrel_roll' ] )
9091 end
9192
9293 it "returns tokens that exist in mapping when one is provided" do
93- expect ( ParameterSubstitution . find_tokens ( square_expression , mapping : mapping , parameter_start : "[" , parameter_end : "]" ) ) . to eq ( [ 'call.start_time' , 'do_a_barrel_roll' ] )
94+ context_overrides = { parameter_start : "[" , parameter_end : "]" }
95+ expect ( ParameterSubstitution . find_tokens ( square_expression , mapping : mapping , context_overrides : context_overrides ) ) . to eq ( [ 'call.start_time' , 'do_a_barrel_roll' ] )
9496 end
9597 end
9698 end
@@ -108,18 +110,20 @@ def self.find(_key); end
108110 let ( :square_expression ) { "[call.start_time.blank_if_nil][do_a_barrel_roll.downcase]" }
109111
110112 it "returns all formatters after first dot when no mapping is provided" do
111- expect ( ParameterSubstitution . find_formatters ( square_expression , parameter_start : "[" , parameter_end : "]" ) ) . to eq ( [ 'start_time' , 'blank_if_nil' , 'downcase' ] )
113+ context_overrides = { parameter_start : "[" , parameter_end : "]" }
114+ expect ( ParameterSubstitution . find_formatters ( square_expression , context_overrides : context_overrides ) ) . to eq ( [ 'start_time' , 'blank_if_nil' , 'downcase' ] )
112115 end
113116
114117 it "returns formatters after all tokens when mapping is provided" do
115- expect ( ParameterSubstitution . find_formatters ( square_expression , mapping : mapping , parameter_start : "[" , parameter_end : "]" ) ) . to eq ( [ 'blank_if_nil' , 'downcase' ] )
118+ context_overrides = { parameter_start : "[" , parameter_end : "]" }
119+ expect ( ParameterSubstitution . find_formatters ( square_expression , mapping : mapping , context_overrides : context_overrides ) ) . to eq ( [ 'blank_if_nil' , 'downcase' ] )
116120 end
117121 end
118122 end
119123
120124 context '#find_warnings' do
121125 let ( :expression_with_valid_params ) { "<foo>" }
122- let ( :expression_with_bad_paramss ) { "<bobby><bobby2>" }
126+ let ( :expression_with_bad_params ) { "<bobby><bobby2>" }
123127 let ( :expression_with_bad_methods ) { "<foo.test1.test2><foo.test3.test4><black.test1.test2>" }
124128 let ( :expression_with_bad_params_and_methods ) { "<bobby.test1.test2><bobby2.test3.test4>" }
125129 let ( :expression_with_mixed_bad_params_and_methods ) { "<bobby.test1.test2><foo.test3.test4>" }
@@ -133,7 +137,7 @@ def self.find(_key); end
133137
134138 context "when there are invalid parameters" do
135139 it "returns 2 warnings" do
136- expect ( ParameterSubstitution . find_warnings ( expression_with_bad_paramss ) ) . to eq ( [ "Unknown param 'bobby'" , "Unknown param 'bobby2'" ] )
140+ expect ( ParameterSubstitution . find_warnings ( expression_with_bad_params ) ) . to eq ( [ "Unknown param 'bobby'" , "Unknown param 'bobby2'" ] )
137141 end
138142 end
139143
@@ -158,17 +162,20 @@ def self.find(_key); end
158162 let ( :square_expression_with_bad_methods ) { "[foo.test1.test2][foo.test3.test4][black.test1.test2]" }
159163
160164 it "returns empty array for valid parameters" do
161- expect ( ParameterSubstitution . find_warnings ( square_expression_with_valid_params , mapping : default_mapping , parameter_start : "[" , parameter_end : "]" ) )
165+ context_overrides = { parameter_start : "[" , parameter_end : "]" }
166+ expect ( ParameterSubstitution . find_warnings ( square_expression_with_valid_params , mapping : default_mapping , context_overrides : context_overrides ) )
162167 . to eq ( [ ] )
163168 end
164169
165170 it "returns warnings for invalid parameters" do
166- expect ( ParameterSubstitution . find_warnings ( square_expression_with_bad_params , parameter_start : "[" , parameter_end : "]" ) )
171+ context_overrides = { parameter_start : "[" , parameter_end : "]" }
172+ expect ( ParameterSubstitution . find_warnings ( square_expression_with_bad_params , context_overrides : context_overrides ) )
167173 . to eq ( [ "Unknown param 'bobby'" , "Unknown param 'bobby2'" ] )
168174 end
169175
170176 it "returns warnings for invalid methods" do
171- expect ( ParameterSubstitution . find_warnings ( square_expression_with_bad_methods , mapping : default_mapping , parameter_start : "[" , parameter_end : "]" ) )
177+ context_overrides = { parameter_start : "[" , parameter_end : "]" }
178+ expect ( ParameterSubstitution . find_warnings ( square_expression_with_bad_methods , mapping : default_mapping , context_overrides : context_overrides ) )
172179 . to eq ( [ "Unknown methods 'test1', 'test2', 'test3', 'test4' used on parameter 'foo'" ,
173180 "Unknown methods 'test1', 'test2' used on parameter 'black'" ] )
174181 end
0 commit comments