Can you explain me what function of merge method here?
it "should reject email addresses identical up to case" do
upcased_email = @attr[:email].upcase
User.create!(@attr.merge(:email => upcased_email))
user_with_duplicate_email = User.new(@attr)
user_with_duplicate_email.should_not be_valid
end
How it works?
It is simply merging the email key back into the hash map (once its value has been lower cased):
http://www.ruby-doc.org/core-1.9.3/Hash.html#method-i-merge