Skip to content

Instantly share code, notes, and snippets.

@Bodacious
Created October 15, 2010 15:48
Show Gist options
  • Save Bodacious/628417 to your computer and use it in GitHub Desktop.
Save Bodacious/628417 to your computer and use it in GitHub Desktop.
This is an example of Behaviour Driven Development...
# Here, I define my class...
class Animal
# nothing here yet
end
# and write a specification for how it should behave
# include all ruby libraries
require "rubygems"
# include rspec (ruby speccing gem)
require "rspec"
# here we describe the Animal class and how it should behave using plain english
describe Animal do
# we use sentences that start with "should" or "should not" so we are definite about what we expect from the code
it "should have an attribute called name" do
# set @animal to be a new Animal object
@animal = Animal.new
@animal.methods.should include("name")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment