Sha256: 78c1afb2753fec73bf87bcf2707d42a2ecf23c0771e6bcdfb45216a8ae34fa63
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require File.dirname(__FILE__) + '/../spec_helper.rb' describe "SuperModel::Base #new method with a hash containing one key-value pair" do before(:all) do class Person < SuperModel::Base has :name end end after(:all) do Object.send(:remove_const, :Person) end it "should be able to initialize attributes correctly from a hash" do p = Person.new(:name => 'McLovin') p.name.should == 'McLovin' end end describe "SuperModel::Base #new method with a hash containing more than one key-value pair" do before(:all) do class Person < SuperModel::Base has :name has :age, :which_is => :number, :with_default_value => 25 end end after(:all) do Object.send(:remove_const, :Person) end it "should be able to initialize attributes correctly from the hash" do p = Person.new(:name => 'McLovin', :age => 12) p.name.should == 'McLovin' p.age.should == 12 end end describe "SuperModel::Base #new method with a block (and self being passed to the block)" do before(:all) do class Dog < SuperModel::Base has :name has :age, :which_is => :number has :collar end end after(:all) do Object.send(:remove_const, :Dog) end it "should be able to initialize all the attributes correctly" do dog = Dog.new do |d| d.name = "Buster" d.age = 2 d.collar = "Stray" end dog.name.should == "Buster" dog.age.should == 2 dog.collar.should == "Stray" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
arunthampi-supermodel-0.1.0 | spec/base/initialize_spec.rb |