Skip to content

Instantly share code, notes, and snippets.

@dpickett
Last active December 17, 2015 21:49
Show Gist options
  • Save dpickett/5677528 to your computer and use it in GitHub Desktop.
Save dpickett/5677528 to your computer and use it in GitHub Desktop.
Actual integration spec from a live coding session at Launch Academy. No planets were harmed in the fulfillment of this acceptance criteria.
require 'spec_helper'
describe 'creating a planet destruction event' do
# As a grand moff of mass destruction
# I want to record planet destruction events
# So that I can demonstrate imperial awesomeness
# Acceptance Criteria
# * I must specify a planet name, star system, casualty count,
# and description
# * I get a congratulations that my planet destruction event was recorded
it 'creates a valid event when all required attribute are specified' do
prev_count = PlanetDestructionEvent.count
# I navigate to the new planet destruction event form
visit '/planet_destruction_events/new'
# I fill in required fields
fill_in "Planet name", with: 'Alderaan'
fill_in "Star system", with: 'Alderaan'
fill_in "Casualties", with: '300000000'
fill_in "Description", with: 'Oops! My bad!'
# I submit the form
click_button 'Create Planet destruction event'
# I verify that the destruction event was recorded
expect(PlanetDestructionEvent.count).to eql(prev_count + 1)
expect(page).to have_content('created')
end
it 'does not create an event when I miss a required attribute' do
prev_count = PlanetDestructionEvent.count
visit '/planet_destruction_events/new'
click_button 'Create Planet destruction event'
expect(PlanetDestructionEvent.count).to eql(prev_count)
expect(page).to have_content("can't be blank")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment