Sha256: e78a8491e80082303646a149e2caed62b11a47198f56f9d8ed8b7ae0e9bd614d

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

Feature: Accessing command line parameters

  The following command line parameters are available in the command script during execution:
  - COMMAND_SCRIPT: The name of the command script currently executing.
  - PARAMS: The user-defined parameters passed to the script as a hash.


  Scenario: Accessing the command script
    Given a file named "config.rb" with:
    """
    File.write 'script_name.txt', COMMAND_SCRIPT
    """
    And a file named "command_script.rb" with:
    """
    require_relative 'config'
    """
    When I run `forge command_script.rb`
    Then the exit status should be 0
    And a file named "script_name.txt" should exist
    And the file "script_name.txt" should contain "command_script.rb"


  Scenario: Passing user-defined parameters to a file definition and a transform block
    Given a file named "command_script.rb" with:
    """
    file :items do
      file_name PARAMS[:data_file]
      field :id
    end

    transform :items do |record|
      record[:id] = PARAMS[:id]
      output record
    end
    """
    And a file named "ids.csv" with:
    """
    id
    1
    2
    3
    """
    When I run `forge -Udata_file=ids.csv -Uid=5 command_script.rb`
    Then the exit status should be 0
    And the file "ids.csv" should contain exactly:
    """
    id
    5
    5
    5

    """

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
data_forge-0.1.1 features/accessing_command_line_parameters.feature
data_forge-0.1 features/accessing_command_line_parameters.feature