Skip to content

Commit

Permalink
Struct#to_h: Add specs (Ruby 2.0) [redmine:6276]
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Apr 16, 2012
1 parent dc5ecdd commit 2082ef4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/struct/to_h_spec.rb
@@ -0,0 +1,17 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

ruby_version_is "2.0" do
describe "Struct#to_h" do
it "returns a Hash with members as keys" do
car = StructClasses::Car.new('Ford', 'Ranger')
car.to_h.should == {:make => "Ford", :model => "Ranger", :year => nil}
end

it "returns a Hash that is independent from the struct" do
car = StructClasses::Car.new('Ford', 'Ranger')
car.to_h[:make] = 'Suzuki'
car.make.should == 'Ford'
end
end
end

0 comments on commit 2082ef4

Please sign in to comment.