Skip to content

Commit

Permalink
Fix warnings under 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
flash-gordon committed Jan 4, 2025
1 parent 8a33f49 commit 32e953f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ group :test do
gem "dry-struct"
gem "i18n", require: false
gem "json-schema"
gem "ostruct"
gem "transproc"
end

group :tools do
gem "pry-byebug"
gem "readline"
gem "redcarpet", platform: :mri
end

Expand Down
36 changes: 27 additions & 9 deletions spec/integration/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@

describe "#inspect" do
it "returns a string representation" do
expect(result.inspect).to eql(<<-STR.strip)
#<Dry::Schema::Result{:name=>"Jane"} errors={} path=[]>
STR
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
expect(result.inspect).to eql(<<-STR.strip)
#<Dry::Schema::Result{name: "Jane"} errors={} path=[]>
STR
else
expect(result.inspect).to eql(<<-STR.strip)
#<Dry::Schema::Result{:name=>"Jane"} errors={} path=[]>
STR
end
end
end

Expand Down Expand Up @@ -60,9 +66,15 @@

describe "#inspect" do
it "returns a string representation" do
expect(result.inspect).to eql(<<-STR.strip)
#<Dry::Schema::Result{:name=>""} errors={:name=>["must be filled"]} path=[]>
STR
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
expect(result.inspect).to eql(<<-STR.strip)
#<Dry::Schema::Result{name: ""} errors={name: ["must be filled"]} path=[]>
STR
else
expect(result.inspect).to eql(<<-STR.strip)
#<Dry::Schema::Result{:name=>""} errors={:name=>["must be filled"]} path=[]>
STR
end
end
end

Expand All @@ -81,9 +93,15 @@

describe "#inspect" do
it "returns a string representation" do
expect(result.at([:account, :name]).inspect).to eql(<<-STR.strip)
#<Dry::Schema::Result{:first=>"ojab"} errors={} path=[:account, :name]>
STR
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
expect(result.at([:account, :name]).inspect).to eql(<<-STR.strip)
#<Dry::Schema::Result{first: "ojab"} errors={} path=[:account, :name]>
STR
else
expect(result.at([:account, :name]).inspect).to eql(<<-STR.strip)
#<Dry::Schema::Result{:first=>"ojab"} errors={} path=[:account, :name]>
STR
end
end
end
end
Expand Down
12 changes: 9 additions & 3 deletions spec/unit/dry/schema/key_map_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,15 @@

describe "#inspect" do
it "returns a string representation" do
expect(key_map.inspect).to eql(<<-STR.strip)
#<Dry::Schema::KeyMap[:id, :name, {:contact=>[:email, :phone]}]>
STR
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
expect(key_map.inspect).to eql(<<-STR.strip)
#<Dry::Schema::KeyMap[:id, :name, {contact: [:email, :phone]}]>
STR
else
expect(key_map.inspect).to eql(<<-STR.strip)
#<Dry::Schema::KeyMap[:id, :name, {:contact=>[:email, :phone]}]>
STR
end
end
end
end
Expand Down
12 changes: 9 additions & 3 deletions spec/unit/dry/schema/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ class Test::UserSchema < Dry::Schema::Params
end

it "returns a representation of a params object" do
expect(klass.new.inspect).to eql(<<~STR.strip)
#<Test::UserSchema keys=["name"] rules={:name=>"key?(:name) AND key[name](filled? AND str?)"}>
STR
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0")
expect(klass.new.inspect).to eql(<<~STR.strip)
#<Test::UserSchema keys=["name"] rules={name: "key?(:name) AND key[name](filled? AND str?)"}>
STR
else
expect(klass.new.inspect).to eql(<<~STR.strip)
#<Test::UserSchema keys=["name"] rules={:name=>"key?(:name) AND key[name](filled? AND str?)"}>
STR
end
end

it "raises exception when definition is missing" do
Expand Down

0 comments on commit 32e953f

Please sign in to comment.