Skip to content

Instantly share code, notes, and snippets.

@timwingfield
Created February 7, 2012 18:43
Show Gist options
  • Save timwingfield/1761174 to your computer and use it in GitHub Desktop.
Save timwingfield/1761174 to your computer and use it in GitHub Desktop.
Our little Parent initializer
describe Parent do
describe "initializing a new parent" do
context "and using a hash" do
Given { @hash = {:id => "55", :name => "Spongebob" } }
When { @parent = Parent.new @hash }
Then { @parent.name.should == "Spongebob" }
Then { @parent.id.should == "55" }
end
context "and not using a hash" do
Then { lambda {Parent.new}.should raise_error(ArgumentError) }
end
end
end
class Parent
attr_accessor :role, :name, :id
def initialize(args)
args.each {|k,v| send("#{k}=",v)}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment