Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also test against Ruby 3.x #26

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.bundle
Gemfile.lock
pkg/*
/spec/examples.txt
.idea
.rvmrc
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
3 changes: 0 additions & 3 deletions lib/hash_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
18 changes: 8 additions & 10 deletions spec/hash_mapper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'spec_helper.rb'

class OneLevel
extend HashMapper
map from('/name'), to('/nombre')
Expand Down Expand Up @@ -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}+++"}
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'