Skip to content

Instantly share code, notes, and snippets.

@Solnse
Created December 23, 2011 04:02
Show Gist options
  • Save Solnse/1513091 to your computer and use it in GitHub Desktop.
Save Solnse/1513091 to your computer and use it in GitHub Desktop.
= form_for @card do |f|
-if @card.errors.any?
#error_explanation
%h2= "#{pluralize(@card.errors.count, "error")} prohibited this card from being saved:"
%ul
- @card.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :card_name
= f.text_field :card_name
.field
= f.label :card_type
= f.text_field :card_type
.actions
= f.submit 'Save New Card'
def add_card valid_card
visit '/cards/new'
fill_in "card_name", :with => card[:card_name]
fill_in "card_type", :with => card[:card_type]
click_button "Save New Card"
end
Feature: enter cards
In order to to have cards in the database
A user
Should be able to add cards to the database
Background: # features/cards/enter_cards.feature:6
Given I am logged in # features/step_definitions/user_steps.rb:28
Scenario: User enters a valid card # features/cards/enter_cards.feature:9
When I enter valid card data # features/step_definitions/card_steps.rb:27
cannot fill in, no text field, text area or password field with id, name, or label 'card_name' found (Capybara::ElementNotFound)
(eval):2:in `fill_in'
./features/step_definitions/card_steps.rb:19:in `add_card'
./features/step_definitions/card_steps.rb:28:in `/^I enter valid card data$/'
features/cards/enter_cards.feature:10:in `When I enter valid card data'
Then I should see a successful card added message # features/step_definitions/card_steps.rb:42
%h1 New card
= render 'form'
= link_to 'Back', cards_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment