diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a7138d2..757a39a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,6 +10,9 @@ jobs: ruby: - '2.6' - '2.7' + - '3.0' + - '3.1' + - '3.2' name: Ruby ${{ matrix.ruby }} RSpec steps: - uses: actions/checkout@v2 diff --git a/.gitignore b/.gitignore index 7d2ff24..e6435e5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ .bundle Gemfile.lock pkg/* +/spec/examples.txt .idea .rvmrc diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..c99d2e7 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/lib/hash_mapper.rb b/lib/hash_mapper.rb index 499e923..2a67ad6 100644 --- a/lib/hash_mapper.rb +++ b/lib/hash_mapper.rb @@ -2,9 +2,6 @@ require 'hash_mapper/version' -$:.unshift(File.dirname(__FILE__)) unless -$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) - def require_active_support require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/hash/indifferent_access' diff --git a/spec/hash_mapper_spec.rb b/spec/hash_mapper_spec.rb index 9ffc0e1..31d9c62 100644 --- a/spec/hash_mapper_spec.rb +++ b/spec/hash_mapper_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper.rb' - class OneLevel extend HashMapper map from('/name'), to('/nombre') @@ -156,7 +154,7 @@ class WithArrays class PersonWithBlock extend HashMapper - def self.normalize(*_) + def self.normalize(*_, **_) super end map from('/names/first'){|n| n.gsub('+','')}, to('/first_name'){|n| "+++#{n}+++"} @@ -396,7 +394,7 @@ class C < B end it "should not affect other mappers" do - expect(NotRelated.normalize('n' => 'nn')).to eq({n: {n: 'nn'}}) + expect(NotRelated.normalize({ 'n' => 'nn' })).to eq({n: {n: 'nn'}}) end end @@ -409,17 +407,17 @@ class MixedMappings describe "dealing with strings and symbols" do it "should be able to normalize from a nested hash with string keys" do - expect(MixedMappings.normalize( + expect(MixedMappings.normalize({ 'big' => {'jobs' => 5}, 'timble' => 3.2 - )).to eq({dodo: 5, bingo: {biscuit: 3.2}}) + })).to eq({dodo: 5, bingo: {biscuit: 3.2}}) end it "should not symbolized keys in value hashes" do - expect(MixedMappings.normalize( + expect(MixedMappings.normalize({ 'big' => {'jobs' => 5}, 'timble' => {'string key' => 'value'} - )).to eq({dodo: 5, bingo: {biscuit: {'string key' => 'value'}}}) + })).to eq({dodo: 5, bingo: {biscuit: {'string key' => 'value'}}}) end end @@ -433,9 +431,9 @@ class DefaultValues describe "default values" do it "should use a default value whenever a key is not set" do - expect(DefaultValues.normalize( + expect(DefaultValues.normalize({ 'without_default' => 'some_value' - )).to eq({ not_defaulted: 'some_value', defaulted: 'the_default_value' }) + })).to eq({ not_defaulted: 'some_value', defaulted: 'the_default_value' }) end it "should not use a default if a key is set (even if the value is falsy)" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f7a332d..042834e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,7 +11,11 @@ config.expect_with :rspec do |c| c.syntax = :expect end + + config.example_status_persistence_file_path = "spec/examples.txt" + + config.order = :random + Kernel.srand config.seed end -$:.unshift(File.dirname(__FILE__) + '/../lib') require 'hash_mapper'