aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/ordered_hash_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-3/+3
|
* improve error message when include assertions failMichael Grosser2016-09-161-6/+6
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* Add three new rubocop rulesRafael Mendonça França2016-08-161-3/+3
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* modernizes hash syntax in activesupportXavier Noria2016-08-061-4/+4
|
* applies new string literal convention in activesupport/testXavier Noria2016-08-061-37/+37
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Fix OrderedHash.select to return self instance.Arthur Neves2014-03-071-1/+4
| | | | | | On ruby 2.1.1 the behavior of .select and .reject has changed. They will return a Hash new instance, so we need to override them to keep the instance object class.
* Moved all JSON core extensions into core_ext/object/jsonGodfrey Chan2013-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TL;DR The primary driver is to remove autoload surprise. This is related to #12106. (The root cause for that ticket is that json/add defines Regexp#to_json among others, but here I'll reproduce the problem without json/add.) Before: >> require 'active_support/core_ext/to_json' => true >> //.as_json NoMethodError: undefined method `as_json' for //:Regexp from (irb):3 from /Users/godfrey/.rvm/rubies/ruby-2.0.0-p195/bin/irb:16:in `<main>' >> //.to_json => "\"(?-mix:)\"" >> //.as_json => "(?-mix:)" After: >> require 'active_support/core_ext/to_json' => true >> //.as_json => "(?-mix:)" This is because ActiveSupport::JSON is autoloaded the first time Object#to_json is called, which causes additional core extentions (previously defined in active_support/json/encoding.rb) to be loaded. When someone require 'active_support/core_ext', the expectation is that it would add certain methods to the core classes NOW. The previous behaviour causes additional methods to be loaded the first time you call `to_json`, which could cause nasty surprises and other unplesant side-effects. This change moves all core extensions in to core_ext/json. AS::JSON is still autoloaded on first #to_json call, but since it nolonger include the core extensions, it should address the aforementioned bug. *Requiring core_ext/object/to_json now causes a deprecation warnning*
* refactor order hash testVipul A M2013-04-111-5/+1
|
* Missing require extract_optionsAkira Matsuda2013-01-311-0/+1
|
* Ruby 2 compat. Hash[] now raises on bad elements rather than ignoring them. ↵Jeremy Kemper2012-10-061-1/+0
| | | | No sense over-testing this MRI-specific behavior. See ruby/ruby@8d6add973ebcb3b4c1efbfaf07786550a3e219af
* Don't test language-level exception messagesJohn Firebaugh2012-07-271-5/+1
| | | | | | Ruby implementations should be free to produce exception messages that are not identical to MRI. For example, Rubinius produces 'Expected an even number, got 5'.
* use AS::TestCase as the base classAaron Patterson2012-01-051-1/+1
|
* No need to require psych since require yaml does that.Rafael Mendonça França2012-01-041-1/+0
|
* No need to use rescue block to require psychRafael Mendonça França2012-01-041-13/+9
|
* Initial pass at removing dead 1.8.x code from Active Support.José Valim2011-12-201-9/+4
| | | | | | There are a bunch of other implicit branches that adds 1.8.x specific code that still needs to be removed. Pull requests for those cases are welcome.
* Make `ActiveSupport::OrderedHash` extractable when using ↵Prem Sichanugrist2011-09-031-0/+5
| | | | | `Array#extract_options!` `ActiveSupport::OrderedHash` is actually a subclass of the hash, so it does make sense that it should be extractable from the array list.
* Fixes minor ruby 1.8 inconsistencyAndrew Radev2011-05-271-0/+23
| | | | | ActiveSupport::OrderedHash did not behave identically to Hash when given a block with a splat.
* Add missing requiresSantiago Pastorino2011-05-111-0/+1
|
* indifferent access should recurse Hash subclassesDavid Lee2011-05-081-0/+5
| | | | | | | | | | | | | | This commit makes Hash subclasses convert to HWIA by default for nested objects of subclasses of Hash, but allows certain subclasses to prevent nested conversion by introducing Hash#nested_under_indifferent_access that subclasses can overwrite. ActiveSupport::OrderedHash is one such subclass that overwrites +nested_under_indifferent_access+, since implicitly converting it to HWIA would remove the ordering of keys and values in Ruby 1.8. This change is necessary because commit ce9456e broke nested indifferent access conversion for all subclasses of Hash.
* just < 1.9 is fine and 1.9.1 is not supportedSantiago Pastorino2011-02-031-3/+3
|
* fix OrderedHash#each* methods to return Enumerators when called without a ↵Gabriel Horner2011-02-031-0/+6
| | | | | | block [#6366 state:resolved] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* OrderedHash#each* methods return self like Hash does [#6364 state:resolved]Gabriel Horner2011-02-021-3/+3
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* test that the custom ordered hash can be round-trippedAaron Patterson2011-01-041-0/+17
|
* use dots for method callsAaron Patterson2011-01-041-3/+8
|
* OrderedHash#select now preserves order [#5843 state:resolved]James A. Rosen2010-11-071-0/+8
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Exception handling more readableThiago Pradi2010-09-191-2/+2
| | | | | | [#5601 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Removes unused varsSantiago Pastorino2010-07-241-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* AS json refactor, move to_json implementation to core_ext and a cleanup a ↵Santiago Pastorino2010-07-011-0/+1
| | | | bit the code
* Oops. Make previous commit pass on 1.9.2.José Valim2010-06-261-1/+2
|
* Tidy up tests in previous commit since they did not assure an OrderedHash is ↵José Valim2010-06-261-3/+2
| | | | | | returned (the test would pass for an array and would pass by chance for hashes). [#4875 state:resolved]
* Add OrderedHash#invert to preserve order in ruby 1.8 [#4875]chaitanyav2010-06-261-0/+6
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Work around the fact the JSON gem was overwriting to_json implementation for ↵José Valim2010-06-261-0/+7
| | | | | | | all Ruby core classes. This is required because the JSON gem is incompatible with Rails behavior and was not allowing ActiveModel::Errors to be serialized. So we need to ensure Rails implementation is the one triggered. [#4890 state:resolved]
* Alias ActiveSupport::OrderedHash#update to ActiveSupport::OrderedHash.merge!Paul Mucur2010-06-251-0/+6
| | | | | | | | This ensures that an OrderedHash's keys are set up appropriately when using update. [#4973 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* revises implementation of AS::OrderedHash#merge!Xavier Noria2010-06-131-16/+17
|
* Revert "hash merging with a block ignores non-existing keys altogether"Xavier Noria2010-06-131-16/+17
| | | | | | This reverts commit 72f9fec607c4a72b2e88995d0cb32b16b96e9068. It is wrong, this feature is a little undocumented, doing some research.
* hash merging with a block ignores non-existing keys altogetherXavier Noria2010-06-131-17/+16
|
* re-organized test for merge into separate testsPaul Barry2010-06-131-13/+21
| | | | Signed-off-by: Xavier Noria <fxn@hashref.com>
* Support passing a block to ActiveSupport::OrderedHash's merge and merge! ↵Paul Mucur2010-06-131-0/+13
| | | | | | | | [#4838 state:committed] For better consistency with Ruby's own Hash implementation. Signed-off-by: Xavier Noria <fxn@hashref.com>
* Adding custom yaml (de-)serialization for OrderedHashGregor Schmidt2010-01-271-0/+24
| | | | | | [#3608 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Fix OrderedHash#replaceChris Hapgood2009-11-051-0/+7
| | | | Signed-off-by: Michael Koziarski <michael@koziarski.com>
* Fixed ActiveSupport::OrderedHash::[] work identically to ::Hash::[] in ruby ↵Brian Abreu2009-07-021-1/+24
| | | | | | 1.8.7 [#2832 state:resolved] Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
* ActiveSupport::OrderedHash[1,2,3,4] creates an OrderedHash instead of a Hash.Douglas F Shearer2009-05-111-0/+6
| | | | | | [#2615 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* ActiveSupport::OrderedHash#to_a method returns an ordered set of arrays. ↵Ken Collins2009-05-101-0/+4
| | | | | | | Matches ruby1.9's Hash#to_a. Signed-off-by: Michael Koziarski <michael@koziarski.com> [#2629 state:committed]
* Fix OrderedHash#inspect recursionJeremy Kemper2009-03-041-1/+7
|
* Fix OrderedHash#to_hash to return self instead of a new hash with self as ↵Jeremy Kemper2009-03-031-1/+5
| | | | default value
* Dup keys in OrderedHash to prevent them from being modified [#1676 ↵Brandon Keepers2009-01-161-1/+9
| | | | | | state:resolved] Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
* Make delete_if/reject faster and fix other mutatorsFrederick Cheung2008-12-151-0/+37
| | | | | | [#1559 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>