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