title: Cucumber: How to write definition steps in Ruby Capybara
body: <p>I am new to cucumber and have the simplest setup of cucumber/ruby/capybara/selenium driver.</p>
  
  <p>I have a scenario outline such as:</p>
  
  <pre><code>Feature: Country of user is displayed
  Scenario Outline: CountryCode of User is displayed based on his Country selected.
  Given the user is on the test page
  When I select my "&lt;Country&gt;" 
  And the testpage is loaded
  Then the "&lt;CountryCode&gt;" is displayed
  
  Examples:
   | Country       | CountryCode |
   | Canada        | CA          |
   | United States | US          |
  </code></pre>
  
  <p>step Definition:</p>
  
  <pre><code> Given(/^the user is on the test page$/) do
   visit 'http://....'
  end
  
  When(/^I select my "([^"]*)"$/) do |table|
   select([Country], :from =&gt; 'id-of-dropdown')
   click_on('Submit')
  end
  
  When(/^the testpage is loaded$/) do
   pending # Write code here that turns the phrase above into concrete actions
  end
  
  Then(/^the "([^"]*)" from UserSetLocation is displayed$/) do |arg1|
   pending # Write code here that turns the phrase above into concrete actions
  end
  </code></pre>
  
  <p>my env.rb file:</p>
  
  <pre><code>require 'rubygems'
  require 'capybara'
  require 'capybara/dsl'
  require 'rspec'
  
  Capybara.run_server = false
  #Set default driver as Selenium
  Capybara.default_driver = :selenium
  #Set default driver as webkit (browserless)
  #Capybara.javascript_driver = :webkit
  #Set default selector as css
  Capybara.default_selector = :css
  
  #Syncronization related settings
  module Helpers
   def without_resynchronize
    page.driver.options[:resynchronize] = false
    yield
    page.driver.options[:resynchronize] = true
   end
  end
  World(Capybara::DSL, Helpers)
  </code></pre>
  
  <p>The issue I have is what is the correct syntax to pull the value from the datatable, country column for:</p>
  
  <pre><code>When(/^I enter my "([^"]*)"$/) do |table|
     select([Country], :from =&gt; 'id-of-dropdown')
  </code></pre>
  
  <p>the following works, but I don't want to write this same step for every country, that datatable will potentially include dozens of countries.</p>
  
  <pre><code>select("Canada", :from =&gt; 'id-of-dropdown')
  </code></pre>
  
  <p>I realized perhaps my env.rb is missing info or I am simply not using the right syntax?
  I have literally been searching online and on this site for days, and any help would be greatly appreciated!
  Thank you for your time.
  Melie</p>