Table#map_column! method #95

Merged
merged 1 commit into from Jan 26, 2014

Conversation

Projects
None yet
2 participants
@quaternion
Contributor

quaternion commented May 2, 2013

Adds #map_column! method to Table class. This method iterates through the column and assigns it the value returned by the block. Is identical to the same method in the cucumber.
Scenario:

Scenario: ...
  Given the following posts:
    | user | article |
    | Dave | post1   |
    | John | post2   |

Step:

step "the following posts:" do |table|
  table.map_column!(:user) { |name| User.find_by_name!(name) }
  table.hashes.each do |post|
    create(:post, post)
  end
end

This code raises error if column user does not exists in the scenario. If the user column is optional, use map_column! with strict option is false:

table.map_column!(:user, false) { ... }

jnicklas added a commit that referenced this pull request Jan 26, 2014

@jnicklas jnicklas merged commit c778956 into jnicklas:master Jan 26, 2014

1 check passed

default The Travis build passed
Details
@jnicklas

This comment has been minimized.

Show comment Hide comment
@jnicklas

jnicklas Jan 26, 2014

Owner

Thanks!

Owner

jnicklas commented Jan 26, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment