Created
February 7, 2012 18:43
-
-
Save timwingfield/1761174 to your computer and use it in GitHub Desktop.
Our little Parent initializer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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