Sha256: 18f75a4d90a5e052abf94d3c91c548c121a47d01b785030eb5dd4f549144d55c

Contents?: true

Size: 1.94 KB

Versions: 17

Compression:

Stored size: 1.94 KB

Contents

##########################################################
# RE_FORM_STEPS
#
#   Then the "[form field]" field should be required
#   Then the "[form field]" field should be blank
#   Then the "[form field]" field should be "[value]"
#   Then the "[form field]" select field should be "[value]"
#   Then the "[form field]" field should be "[model]" "[field]"
#   Then the "[form field]" select field should be "[model]" "[field]"
#   When I enter "[model]" "[field]" as the "[form_field]"

Then /^the "([^\"]*)" field should be required$/ do |form_field|
  field_id = field_labeled(form_field).id
  response.should have_tag("label[for=#{field_id}] + span.re-form-required")
end

Then /^the "([^\"]*)" field should be blank$/ do |form_field|
  begin
    field_named(form_field).value.should be_blank
  rescue
    field_labeled(form_field).value.should be_blank
  end
end

Then /^the "([^\"]*)" field should be "([^\"]*)"$/ do |form_field, value|  
  begin
    field_named(form_field).value.should == value
  rescue
    field_labeled(form_field).value.should == value
  end  
end

Then /^the "([^\"]*)" select field should be "([^\"]*)"$/ do |form_field, value|  
  begin
    field_named(form_field).element.css("option[selected=selected]").first.content.should == value
  rescue
    field_labeled(form_field).element.css("option[selected=selected]").first.content.should == value
  end  
end


Then /^the "([^\"]*)" field should be "([^\"]*)" "([^\"]*)"$/ do |form_field, model, field|  
  tmp_model = instance_variable_get("@#{model}")
  tmp_model.should_not be_nil
  
  begin
    field_named(form_field).value.should == tmp_model[field.to_sym]
  rescue
    field_labeled(form_field).value.should == tmp_model[field.to_sym]
  end  
end

When /^I enter "([^\"]*)" "([^\"]*)" as the "([^\"]*)"$/ do |model, field, form_field|
  klass = Kernel.const_get(model.classify)
  klass.should_not be_nil

  tmp_model = klass.make_unsaved  
  fill_in(form_field, :with => tmp_model[field.to_sym]) 
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rules_engine-0.2.0 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.10 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.9 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.8 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.7 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.6 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.5 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.4 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.3 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.1 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.1.0 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.0.8 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.0.7 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.0.6 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.0.5 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.0.4 rails_generators/templates/features/step_definitions/common/re_form_steps.rb
rules_engine-0.0.3 rails_generators/templates/features/step_definitions/common/re_form_steps.rb