@@ -73,12 +73,12 @@ def self.find(_key); end
7373 let ( :expression ) { "<call.start_time.blank_if_nil><do_a_barrel_roll.downcase>" }
7474 let ( :mapping ) { { 'call.start_time' => 'hello' } }
7575
76- shared_examples "passes context_overrides to Context" do
76+ shared_examples "passes context_overrides with symbolized keys to Context" do
7777 it "calls Context.new with the expected overrides" do
7878 allow ( ParameterSubstitution ::Context ) . to receive ( :new ) . and_call_original
7979 subject
8080 expect ( ParameterSubstitution ::Context ) . to have_received ( :new ) . once . with (
81- hash_including ( test_context_overrides . merge (
81+ hash_including ( test_context_overrides . transform_keys ( & :to_sym ) . merge (
8282 input : test_expression ,
8383 mapping : test_mapping
8484 ) )
@@ -121,21 +121,30 @@ def self.find(_key); end
121121 end
122122
123123 context 'with non-default delimiters' do
124- include_examples "passes context_overrides to Context" do
125- let ( :test_expression ) { "[call.start_time.blank_if_nil][do_a_barrel_roll.downcase]" }
126- let ( :test_mapping ) { { } }
127- let ( :test_context_overrides ) do
128- {
129- required_parameters : [ "param1" , "param2" ] ,
130- parameter_start : "[" ,
131- parameter_end : "]" ,
132- destination_encoding : :json ,
133- allow_unknown_replacement_parameters : true ,
134- allow_nil : true ,
135- allow_unmatched_parameter_end : true
136- }
124+ let ( :test_expression ) { "[call.start_time.blank_if_nil][do_a_barrel_roll.downcase]" }
125+ let ( :test_mapping ) { { } }
126+ let ( :test_context_overrides ) do
127+ {
128+ required_parameters : [ "param1" , "param2" ] ,
129+ parameter_start : "[" ,
130+ parameter_end : "]" ,
131+ destination_encoding : :json ,
132+ allow_unknown_replacement_parameters : true ,
133+ allow_nil : true ,
134+ allow_unmatched_parameter_end : true
135+ }
136+ end
137+
138+ context 'with symbol override keys' do
139+ include_examples "passes context_overrides with symbolized keys to Context" do
140+ subject { ParameterSubstitution . find_tokens ( test_expression , mapping : test_mapping , context_overrides : test_context_overrides ) }
141+ end
142+ end
143+
144+ context 'with string override keys' do
145+ include_examples "passes context_overrides with symbolized keys to Context" do
146+ subject { ParameterSubstitution . find_tokens ( test_expression , mapping : test_mapping , context_overrides : test_context_overrides . transform_keys ( &:to_s ) ) }
137147 end
138- subject { ParameterSubstitution . find_tokens ( test_expression , mapping : test_mapping , context_overrides : test_context_overrides ) }
139148 end
140149 end
141150
@@ -157,21 +166,30 @@ def self.find(_key); end
157166 end
158167
159168 context 'with non-default delimiters' do
160- include_examples "passes context_overrides to Context" do
161- let ( :test_expression ) { "[call.start_time.blank_if_nil][do_a_barrel_roll.downcase]" }
162- let ( :test_mapping ) { { } }
163- let ( :test_context_overrides ) do
164- {
165- required_parameters : [ "param1" , "param2" ] ,
166- parameter_start : "[" ,
167- parameter_end : "]" ,
168- destination_encoding : :json ,
169- allow_unknown_replacement_parameters : true ,
170- allow_nil : true ,
171- allow_unmatched_parameter_end : true
172- }
169+ let ( :test_expression ) { "[call.start_time.blank_if_nil][do_a_barrel_roll.downcase]" }
170+ let ( :test_mapping ) { { } }
171+ let ( :test_context_overrides ) do
172+ {
173+ required_parameters : [ "param1" , "param2" ] ,
174+ parameter_start : "[" ,
175+ parameter_end : "]" ,
176+ destination_encoding : :json ,
177+ allow_unknown_replacement_parameters : true ,
178+ allow_nil : true ,
179+ allow_unmatched_parameter_end : true
180+ }
181+ end
182+
183+ context 'with symbol override keys' do
184+ include_examples "passes context_overrides with symbolized keys to Context" do
185+ subject { ParameterSubstitution . find_formatters ( test_expression , mapping : test_mapping , context_overrides : test_context_overrides ) }
186+ end
187+ end
188+
189+ context 'with string override keys' do
190+ include_examples "passes context_overrides with symbolized keys to Context" do
191+ subject { ParameterSubstitution . find_formatters ( test_expression , mapping : test_mapping , context_overrides : test_context_overrides . transform_keys ( &:to_s ) ) }
173192 end
174- subject { ParameterSubstitution . find_formatters ( test_expression , mapping : test_mapping , context_overrides : test_context_overrides ) }
175193 end
176194 end
177195
@@ -219,21 +237,30 @@ def self.find(_key); end
219237 end
220238
221239 context "with non-default delimiters" do
222- include_examples "passes context_overrides to Context" do
223- let ( :test_expression ) { "[foo]" }
224- let ( :test_mapping ) { default_mapping }
225- let ( :test_context_overrides ) do
226- {
227- required_parameters : [ "param1" , "param2" ] ,
228- parameter_start : "[" ,
229- parameter_end : "]" ,
230- destination_encoding : :json ,
231- allow_unknown_replacement_parameters : true ,
232- allow_nil : true ,
233- allow_unmatched_parameter_end : true
234- }
240+ let ( :test_expression ) { "[foo]" }
241+ let ( :test_mapping ) { default_mapping }
242+ let ( :test_context_overrides ) do
243+ {
244+ required_parameters : [ "param1" , "param2" ] ,
245+ parameter_start : "[" ,
246+ parameter_end : "]" ,
247+ destination_encoding : :json ,
248+ allow_unknown_replacement_parameters : true ,
249+ allow_nil : true ,
250+ allow_unmatched_parameter_end : true
251+ }
252+ end
253+
254+ context "with symbol override keys" do
255+ include_examples "passes context_overrides with symbolized keys to Context" do
256+ subject { ParameterSubstitution . find_warnings ( test_expression , mapping : test_mapping , context_overrides : test_context_overrides ) }
257+ end
258+ end
259+
260+ context "with string override keys" do
261+ include_examples "passes context_overrides with symbolized keys to Context" do
262+ subject { ParameterSubstitution . find_warnings ( test_expression , mapping : test_mapping , context_overrides : test_context_overrides . transform_keys ( &:to_s ) ) }
235263 end
236- subject { ParameterSubstitution . find_warnings ( test_expression , mapping : test_mapping , context_overrides : test_context_overrides ) }
237264 end
238265 end
239266
0 commit comments