Skip to content

Commit

Permalink
Merge pull request #64 from maxim/fix-ci-false-negative
Browse files Browse the repository at this point in the history
Fix CI build, Ruby 2.3-2.4 incompatibility, accidental ActiveSupport dependency, and rubocop
  • Loading branch information
nepalez committed Jun 8, 2019
2 parents 422d331 + 239ecf8 commit 3167b5a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ AllCops:
TargetRubyVersion: 2.3
Exclude:
- lib/tasks/*.rake
- vendor/**/*
- tmp/**/*

Bundler/DuplicatedGem:
Enabled: false
Expand Down Expand Up @@ -36,6 +38,9 @@ Style/Lambda:
Style/LambdaCall:
Enabled: false

Style/ModuleFunction:
Enabled: false

Style/RescueModifier:
Exclude:
- spec/**/*.rb
Expand Down
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@ language: ruby
cache: bundler
bundler_args: --without benchmarks tools
script:
- bundle exec rake spec
- bundle exec rspec
- bundle exec rubocop
rvm:
- 2.3.8
- 2.4.6
- 2.5.5
- 2.6.3
- jruby-9.2.7.0
- jruby-9000
- rbx-3
- ruby-head
- truffleruby
env:
global:
- JRUBY_OPTS='--dev -J-Xmx1024M'
matrix:
allow_failures:
- rvm: rbx-3
- rvm: ruby-head
- rvm: jruby-head
- rvm: truffleruby
Expand Down
2 changes: 1 addition & 1 deletion lib/dry/initializer/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def add_definition(option, name, type, block, **opts)
source: name,
type: type,
block: block,
**opts,
**opts
}

options = Dispatchers.call(opts)
Expand Down
5 changes: 2 additions & 3 deletions lib/dry/initializer/struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class << self
undef_method :param

def new(options)
super Hash(options).transform_keys(&:to_sym)
super Hash(options).each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
end
alias call new
end
Expand All @@ -22,8 +22,7 @@ def to_h
.class
.dry_initializer
.attributes(self)
.transform_values { |v| __hashify(v) }
.stringify_keys
.each_with_object({}) { |(k, v), h| h[k.to_s] = __hashify(v) }
end

private
Expand Down
4 changes: 4 additions & 0 deletions spec/nested_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ class Test::Xyz
it "builds the type" do
expect(subject.x.y.z).to eq "42"
end

it "converts the nested type to hash" do
expect(subject.x.to_h).to eq("y" => { "z" => "42" })
end
end

context "with nested and wrapped definitions" do
Expand Down
4 changes: 2 additions & 2 deletions spec/type_argument_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class Test::Foo
subject { Test::Foo.new 1, bar: "2" }

it "raises TypeError" do
expect { subject }.to raise_error TypeError, /1/
expect { subject }.to raise_error Dry::Types::ConstraintError, /1/
end
end

context "in case of option mismatch" do
subject { Test::Foo.new "1", bar: 2 }

it "raises TypeError" do
expect { subject }.to raise_error TypeError, /2/
expect { subject }.to raise_error Dry::Types::ConstraintError, /2/
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/type_constraint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Test::Foo
subject { Test::Foo.new 1 }

it "raises ArgumentError" do
expect { subject }.to raise_error TypeError, /1/
expect { subject }.to raise_error Dry::Types::ConstraintError, /1/
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/value_coercion_via_dry_types_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe "value coercion via dry-types" do
before do
module Test::Types
include Dry::Types.module
include Dry.Types
end

class Test::Foo
Expand Down

0 comments on commit 3167b5a

Please sign in to comment.