Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 33 lines (27 sloc) 0.831 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
require 'test_helper'

class IndifferentHashTest < ActiveSupport::TestCase
  setup do
    @hash = Devise::IndifferentHash.new
  end

  test "it overwrites getter and setter" do
    @hash[:foo] = "bar"
    assert_equal "bar", @hash["foo"]
    assert_equal "bar", @hash[:foo]

    @hash["foo"] = "baz"
    assert_equal "baz", @hash["foo"]
    assert_equal "baz", @hash[:foo]
  end

  test "it overwrites update" do
    @hash.update :foo => "bar"
    assert_equal "bar", @hash["foo"]
    assert_equal "bar", @hash[:foo]

    @hash.update "foo" => "baz"
    assert_equal "baz", @hash["foo"]
    assert_equal "baz", @hash[:foo]
  end

  test "it returns a Hash on to_hash" do
    @hash[:foo] = "bar"
    assert_equal Hash["foo", "bar"], @hash.to_hash
    assert_kind_of Hash, @hash.to_hash
  end
end if defined?(Devise::IndifferentHash)
Something went wrong with that request. Please try again.