lib/remi/cucumber/business_rules.rb in remi-0.2.36 vs lib/remi/cucumber/business_rules.rb in remi-0.2.37

- old
+ new

@@ -291,16 +291,10 @@ h[k.symbolize] = v.to_a h end end - # For debugging only - def _df - @data_subject.df - end - - # Would like to have this return a new DataSubject and not a dataframe. # Need more robust duping to make that feasible. # Don't use results for anything more than size. def where(field_name, operation) @data_subject.df.where(@data_subject.df[field_name.symbolize(@data_subject.field_symbolizer)].recode { |v| operation.call(v) }) @@ -331,11 +325,17 @@ def stub_data @data_subject.stub_df if @data_subject.respond_to? :stub_df end def example_to_df(example) - example.to_df(@data_subject.df.row[0].to_h, field_symbolizer: @data_subject.field_symbolizer) + df = example.to_df(@data_subject.df.row[0].to_h, field_symbolizer: @data_subject.field_symbolizer) + data_subject.fields.each do |vector, metadata| + if metadata[:type] == :json + df[vector].recode! { |v| JSON.parse(v) rescue v } + end + end + df end def stub_data_with(example) stub_data @data_subject.df = example_to_df(example) @@ -484,10 +484,16 @@ def values vector.to_a.map(&:to_s) end def value=(arg) - vector.recode! { |v| arg } + typed_arg = if metadata[:type] == :json + JSON.parse(arg) + else + arg + end + + vector.recode! { |_v| typed_arg } end end class DataExampleCollection