Skip to content

Instantly share code, notes, and snippets.

@msassak
Created December 14, 2010 14:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msassak/740509 to your computer and use it in GitHub Desktop.
Save msassak/740509 to your computer and use it in GitHub Desktop.
#!/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
foo bar baz
apple banana strawberry
dog cat monkey
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>>|
@Radhakrishna-N
Copy link

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