features/step_definitions/remi_step.rb in remi-0.3.1 vs features/step_definitions/remi_step.rb in remi-0.3.2

- old
+ new

@@ -122,11 +122,10 @@ @brt.run_transforms if st == 'target' expect(@brt.send(st.to_sym).data_subject.df.vectors.to_a).to eq @brt.send(st.to_sym).fields.field_names end - ### Source Given /^the source '([[:alnum:]\s\-_]+)'$/ do |arg| @brt.add_source(arg) end @@ -217,10 +216,24 @@ Given /^the source field is not a valid email address$/ do @brt.source.field.value = 'invalid!example.com' end +Given /^the source field '([^']+)' is a valid email address$/ do |source_field| + step "the source field '#{source_field}'" + + source_name, source_field_name = @brt.sources.parse_full_field(source_field) + @brt.sources[source_name].fields[source_field_name].value = 'valid@example.com' +end + +Given /^the source field '([^']+)' is not a valid email address$/ do |source_field| + step "the source field '#{source_field}'" + + source_name, source_field_name = @brt.sources.parse_full_field(source_field) + @brt.sources[source_name].fields[source_field_name].value = 'invalid!example.com' +end + ### Target Given /^the target '([[:alnum:]\s\-_]+)'$/ do |arg| @brt.add_target(arg) end @@ -240,10 +253,17 @@ Array(target_names).each do |target_name| expect(@brt.targets[target_name].fields[target_field_name].value).to eq (@brt.sources[source_name].fields[source_field_name].value) end end +Then /^the target field '([^']+)' has the label '([^']+)'$/ do |target_field, label| + step "the target field '#{target_field}'" + data_field = @brt.targets.fields.next + expect(data_field.metadata[:label]).to eq label + expect(data_field.name).to eq target_field +end + Then /^the target field '([^']+)' is copied from the source field$/ do |target_field| @brt.sources.fields.each do |source_field| step "the target field '#{target_field}' is copied from the source field '#{source_field.full_name}'" end end @@ -481,12 +501,13 @@ step "the source field '#{source_field}'" step "the target field '#{target_field}'" source_name, source_field_name = @brt.sources.parse_full_field(source_field) target_names, target_field_name = @brt.targets.parse_full_field(target_field, multi: true) + inferred_type = target_format =~ /(%H|%M|%S)/ ? :datetime : :date source_format = @brt.sources[source_name].fields[source_field_name].metadata[:in_format] - source_reformatted = Remi::Transform::FormatDate.new(in_format: source_format, out_format: target_format).to_proc + source_reformatted = Remi::Transform::FormatDate.new(in_format: source_format, out_format: target_format, type: inferred_type).to_proc .call(@brt.sources[source_name].fields[source_field_name].value) @brt.run_transforms target_names.each do |target_name| expect(@brt.targets[target_name].fields[target_field_name].value).to eq source_reformatted