Skip to content

Instantly share code, notes, and snippets.

@rhysforyou
Created March 2, 2012 08:14
Show Gist options
  • Select an option

  • Save rhysforyou/1956721 to your computer and use it in GitHub Desktop.

Select an option

Save rhysforyou/1956721 to your computer and use it in GitHub Desktop.
Given /^I am on the new note page$/ do
visit new_note_path
end
When /^I fill out the new note form$/ do
@note = Factory.build :note
fill_in "note_title", with: @note.title
fill_in "note_content", with: @note.content
end
When /^I submit the form$/ do
click_button "submit"
end
Then /^I should see "([^"]*)"$/ do |content|
page.should have_content content
end
Given /^I have a note$/ do
@note = Factory :note
end
When /^I visit that note's edit page$/ do
visit edit_note_path(@note)
end
When /^I change the title to "([^"]*)"$/ do |title|
fill_in "note_title", with: title
end
When /^I change the content to "([^"]*)"$/ do |content|
fill_in "note_content", with: content
end
When /^I pick "([^"]*)" as the note's subject and submit the form$/ do |subject|
choose subject
click_button "submit"
@note.save.should be_true
@note.subject.name.should_not == "CSCI103"
end
Then /^the note's subject should be "([^"]*)"$/ do |subject|
@note.subject.name.should == subject
end
Feature: Organise by subjects
In order to better organise my notes
As a university student
I want to organise my notes based on subject
Scenario: Adding a subject
Given I am on the new subject page
When I fill in the name with "CSCI114" and submit the form
Then I should be informed that the subject was created
And I should see that subject
Scenario: Adding a subject without a name
Given I am on the new subject page
When I fill in the name with "" and submit the form
Then I should be informed that there were errors
And I should see the new subject page
Scenario: Assigning a subject to a note
Given I have a subject called "CSCI114"
And I have a note
And I visit that note's edit page
When I pick "CSCI114" as the note's subject and submit the form
Then the note's subject should be "CSCI114"
Given /^I am on the new subject page$/ do
visit new_subject_path
end
When /^I fill in the name with "([^"]*)" and submit the form$/ do |name|
@name = name
fill_in 'subject_name', with: name
click_button "submit"
end
Then /^I should be informed that the subject was created$/ do
page.should have_content "Subject was successfully created"
end
Then /^I should see that subject$/ do
page.should have_content(@name)
end
Then /^I should be informed that there were errors$/ do
page.should have_selector ".error"
end
Then /^I should see the new subject page$/ do
page.should have_content "New Subject"
end
Given /^I have a subject called "([^"]*)"$/ do |name|
@subject = Factory(:subject, name: name)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment