Skip to content

Commit

Permalink
Get the tests green. Eliminate the String/Symbol equality
Browse files Browse the repository at this point in the history
  • Loading branch information
wycats committed Sep 10, 2010
1 parent 092e531 commit d87130d
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 40 deletions.
Empty file.
33 changes: 0 additions & 33 deletions spec/lib/models/hash_struct/hash_spec.rb
Expand Up @@ -26,37 +26,4 @@
e[:foo].should eql(:bar)
end

it "should treat string and hash keys as the same for writing, but not reading" do
e = SC::HashStruct.new
e['foo'] = :bar
e[:foo].should eql(:bar)

e[:foo2] = :bar
e['foo2'].should eql(nil)
end

it "should convert all keys to symbols (i.e. if you get keys, they will always be symbols)" do
e = SC::HashStruct.new
e['string'] = :foo
e[:symbol] = :foo

expected = [:string, :symbol]
idx=0
e.keys.sort { |a,b| a.to_s <=> b.to_s }.each do |k|
k.should eql(expected[idx])
idx += 1
end
end

it "should raise error if key cannot be converted to symbol" do
a = SC::HashStruct.new

# numbers respond to to_sym but return nil
lambda { a[1] = :foo }.should raise_error

# Object does not respond to to_sym
lambda { a[Object.new] = :foo }.should raise_error
end


end
7 changes: 0 additions & 7 deletions spec/lib/models/hash_struct/merge_spec.rb
Expand Up @@ -2,13 +2,6 @@

describe SC::HashStruct, 'merge!' do

it "should convert all keys to symbols - if symbol and string is passed, they will overrwite" do
a = SC::HashStruct.new
a.merge! :foo => :bar1, 'foo' => :bar2
a.keys.size.should eql(1)
a.keys.first.should eql(:foo)
end

it "should do nothing if we merge self!" do
a = SC::HashStruct.new :foo => :bar
a.merge! a
Expand Down

0 comments on commit d87130d

Please sign in to comment.