Permalink
Browse files

Struct#to_h: Add specs (Ruby 2.0) [redmine:6276]

  • Loading branch information...
1 parent dc5ecdd commit 2082ef46d46e55167c1663d7a58fc1688765cd7a @marcandre marcandre committed Apr 11, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 core/struct/to_h_spec.rb
View
@@ -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.