Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View csv-to-gherkin.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/usr/bin/env ruby
 
require 'csv'
 
class Converter
def initialize(feature)
@feature = feature
end
def to_gherkin
@feature.gsub!(/\|<<([\w\.]+)>>\|/) do |match|
rows = CSV.read($1).to_a
rows.inject('') do |output, row|
output << "| " << row.join(" |") << " |\n"
end
end
@feature
end
end
 
puts Converter.new(File.read(ARGV[0])).to_gherkin
View csv-to-gherkin.rb
1 2 3
foo, bar, baz
apple, banana, strawberry
dog, cat, monkey
View csv-to-gherkin.rb
1 2 3 4 5 6 7 8 9 10 11 12 13
Feature: My Feature
Scenario Outline: My scenario outline
Given <foo>
When <bar>
Then <baz>
 
Examples: Right here
| foo | bar | baz |
| aaa | bbb | ccc |
| 111 | 222 | 333 |
 
Examples: From elsewhere
|<<my_data.csv>>|

msassak : How can use this in my step definition , can you please give some guidance , it looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.