Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 33 lines (27 sloc) 0.831 kb
ec5bfe9 @josevalim Ensure to convert keys on indifferent hash.
josevalim authored
1 require 'test_helper'
2
3 class IndifferentHashTest < ActiveSupport::TestCase
4 setup do
5 @hash = Devise::IndifferentHash.new
6 end
7
8 test "it overwrites getter and setter" do
9 @hash[:foo] = "bar"
10 assert_equal "bar", @hash["foo"]
11 assert_equal "bar", @hash[:foo]
12
13 @hash["foo"] = "baz"
14 assert_equal "baz", @hash["foo"]
15 assert_equal "baz", @hash[:foo]
16 end
17
18 test "it overwrites update" do
19 @hash.update :foo => "bar"
20 assert_equal "bar", @hash["foo"]
21 assert_equal "bar", @hash[:foo]
22
23 @hash.update "foo" => "baz"
24 assert_equal "baz", @hash["foo"]
25 assert_equal "baz", @hash[:foo]
26 end
27
28 test "it returns a Hash on to_hash" do
29 @hash[:foo] = "bar"
30 assert_equal Hash["foo", "bar"], @hash.to_hash
31 assert_kind_of Hash, @hash.to_hash
32 end
33 end if defined?(Devise::IndifferentHash)
Something went wrong with that request. Please try again.