Skip to content

Instantly share code, notes, and snippets.

@radavis
Last active May 19, 2020 15:44
Show Gist options
  • Save radavis/9bafb2930fa3f6f9e441782cf7631250 to your computer and use it in GitHub Desktop.
Save radavis/9bafb2930fa3f6f9e441782cf7631250 to your computer and use it in GitHub Desktop.

The Path from Idea to Software

User Story -> Acceptance Criteria -> Feature Test

Generic User Story

As a ...
I want ...
So that ...

User Story

As an Urban Explorer,
I want to record an experience,
So that I can share things to do in a city with others.

Acceptance Criteria

  • - Need to be able to record the name of the location, description.
  • - Recording price, date/time are optional fields.
  • - If I fill out the form correctly, I should get a successful message.
  • - If I any required fields, I'm sent back to the form with error messages.

Feature Test

# spec/features/create_experience_spec.rb

feature "create experience" do
  scenario "fill out form correctly" do
    # given
    user = create(:user)
    sign_in user

    visit root_path

    # when
    click_link "Add New Experience"
    fill_in "Name", with: "Visit Avana Sushi"
    fill_in "Location", with: "Boston, MA"
    fill_in "Description", with: "Best sushi in town"
    fill_in "Price", with: "$10"
    click_link "Create Experience"

    # then
    expect(page).to have_content("New experience created")
  end

  scenario "forgot some fields" do
    # set up (create models, sign in)
    # visit a page
    # interact with page (fill_in, click links and buttons)
    # expect something
  end

  scenario "forgot some fields" do
    # set up (create models, sign in)
    # visit a page
    # interact with page (fill_in, click links and buttons)
    # expect something
  end
end
def sign_in(user)
  visit root_path
  click_link "Sign in"
  fill_in "Email", with: user.email
  fill_in "Password", with: user.password
  click_button "Sign in"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment