Sha256: 2a3ffa3f8da4e9d37088a4cce6f614b040e2e19104929edd5d703326665f673a

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

Feature: Splitting a file into multiple files

  The `transform` block can take multiple output file parameters, in which case the `output` command can be used
  to specify which file to write to.


  Scenario:
    Given a file named "command_script.rb" with:
    """
    file :items do
      field :name
    end

    file :items_not_a do
      field :name
    end

    file :items_not_b do
      field :name
    end

    transform :items, into: [:items_not_a, :items_not_b] do |record|
      if record[:name].start_with? "a"
        output record, to: :items_not_b
      elsif record[:name].start_with? "b"
        output record, to: :items_not_a
      else
        output record, to: [:items_not_a, :items_not_b]
      end
    end
    """
    And a file named "items.csv" with:
    """
    name
    a
    b
    c
    """
    When I run `forge command_script.rb`
    Then the exit status should be 0
    And the following files should exist:
      | items_not_a.csv |
      | items_not_b.csv |
    And the file "items_not_a.csv" should contain exactly:
    """
    name
    b
    c

    """
    And the file "items_not_b.csv" should contain exactly:
    """
    name
    a
    c

    """

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
data_forge-0.1.1 features/transform/outputting_to_multiple_files.feature
data_forge-0.1 features/transform/outputting_to_multiple_files.feature