Skip to content

Instantly share code, notes, and snippets.

View michael-harrison's full-sized avatar

Michael Harrison michael-harrison

View GitHub Profile
@michael-harrison
michael-harrison / test_file_existance.rb
Last active August 29, 2015 13:57
RSpec Test Patterns
# Test the existance of a file after a method call
it('will create a file') do
expect { subject.create_the_file }.to change { File.exists? my_file }.from(false).to(true)
end
@michael-harrison
michael-harrison / hash.md
Last active August 29, 2015 13:57
Hash to hash, dust to dust, experiment we must

Just had a quick look at the Ruby source and it looks like it doesn't compare the hash but uses the key object's == method to identify the right key. So to test the theory I did some experiments:

2.0.0-p247 :010 > test = {}
 => {} 
2.0.0-p247 :011 > a = [1,2]
 => [1, 2] 
2.0.0-p247 :012 > test[a]
 => nil 
2.0.0-p247 :013 > test[a] = 'cool'

=> "cool"