Sha256: 56f22f64ec6db8d8a411aab5cb2ae15911f16cd82dd21c7c5f72da9e5d1552bc

Contents?: true

Size: 1.72 KB

Versions: 7

Compression:

Stored size: 1.72 KB

Contents

Feature: Building a model from a form
  In order to turn user input into a model
  As a developer
  I wish to user a defined form to build a model

  @form @basic @build
  Scenario: Basic Form
    Given I have a form defined as:
      """Ruby
        class MyForm
          include PR::Form

          field :event_name, :string
          field :start_date, :date

        end
      """
    And I have preloaded the form with data:
      """Ruby
        @form = MyForm.new
        @form.event_name = 'Event'
        @form.start_date = '31/03/2013'
      """
    And I have a model defined as:
      """Ruby
        class Event < Struct.new(:event_name,:start_date)
        end
      """
    When I build my model from the form:
      """Ruby
        @model = Event.new
        PR::BuildModel[ @form, @model ]
      """
    Then my model should have a string for event_name "Event"
    And my model should have a date for start_date `Date.civil(2013,3,31)`


  @form @macro @build
  Scenario: Basic Form using macro
    Given I have a form defined as:
      """Ruby
        class MyForm
          include PR::Form

          field :event_name, :string
          field :start_date, :date

        end
      """
    And I have preloaded the form with data:
      """Ruby
        @form = MyForm.new
        @form.event_name = 'Event'
        @form.start_date = '31/03/2013'
      """
    And I have a model defined as:
      """Ruby
        class AnEvent < Struct.new(:event_name,:start_date)
        end
      """
    When I build my model from the form:
      """Ruby
        @form.build_model (@model = AnEvent.new)
      """
    Then my model should have a string for event_name "Event"
    And my model should have a date for start_date `Date.civil(2013,3,31)`

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pr-1.0.0 features/building_models_from_form.feature
pr-0.0.7 features/building_models_from_form.feature
pr-0.0.6 features/building_models_from_form.feature
pr-0.0.5 features/building_models_from_form.feature
pr-0.0.4 features/building_models_from_form.feature
pr-0.0.3 features/building_models_from_form.feature
pr-0.0.2 features/building_models_from_form.feature