Skip to content

Instantly share code, notes, and snippets.

@sicktastic
Last active August 11, 2016 21:58
Show Gist options
  • Save sicktastic/48bbd182b617984bcf6a0e38e56312de to your computer and use it in GitHub Desktop.
Save sicktastic/48bbd182b617984bcf6a0e38e56312de to your computer and use it in GitHub Desktop.
Simple feature spec where User creates student record
FactoryGirl.define do
factory :student do
first_name "Doctor"
last_name "Who"
story "Doctor Who is a British science-fiction television programme produced by the BBC since 1963."
end
end
require "rails_helper"
feature "User creates Student" do
scenario "successfully" do
student = build(:student)
submit_student first_name: student.first_name, last_name: student.last_name, story: student.story
expect(page).to have_content "Doctor Who"
end
scenario "with empty data" do
submit_student first_name: "", last_name: "", story: ""
expect(page).to have_content "can't be blank"
end
private
def submit_student(first_name:, last_name:, story:)
visit new_student_path
fill_in "First Name", with: first_name
fill_in "Last Name", with: last_name
fill_in "Story", with: story
click_on "Create Student"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment