Last active
August 11, 2016 21:58
-
-
Save sicktastic/48bbd182b617984bcf6a0e38e56312de to your computer and use it in GitHub Desktop.
Simple feature spec where User creates student record
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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