Skip to content

Instantly share code, notes, and snippets.

@jkarnowski
Created March 1, 2016 18:11
Show Gist options
  • Select an option

  • Save jkarnowski/c4664108a62c0d61e32f to your computer and use it in GitHub Desktop.

Select an option

Save jkarnowski/c4664108a62c0d61e32f to your computer and use it in GitHub Desktop.
require_relative 'grocery_list'
describe GroceryList do
# creates an object to use | consider: what's the scope of sunday_groceries?
let(:sunday_groceries) { GroceryList.new }
it 'creates a grocery list object' do
expect(sunday_groceries).to be_instance_of GroceryList
end
it "has an empty list" do
expect(sunday_groceries.list).to be_a Array
end
# describe provides documentation | consider: what do you want to read in the command line about the tests?
describe "adding things to a list" do
describe "#add" do
# opening of the test block
it 'adds one new item to the list' do
sunday_groceries.add("wine")
# ACTUAL matched with (compared to) EXPECTED
expect(sunday_groceries.list).to include "wine"
end
end
end
describe "deleting items from the list" do
describe "#remove" do
it 'removes one item from the list' do
sunday_groceries.add("wine")
sunday_groceries.remove("wine")
expect(sunday_groceries.list.length).to eq 0
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment