Skip to content

Commit

Permalink
Merge pull request #3 from iknow/ruby3
Browse files Browse the repository at this point in the history
Ruby 3.0 support
  • Loading branch information
thefloweringash authored Mar 2, 2021
2 parents 56436bb + d06b1b7 commit 3245bb9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ workflows:
- test:
name: 'ruby 2.6'
ruby-version: "2.6"
- test:
name: 'ruby 2.7'
ruby-version: "2.7"
- test:
name: 'ruby 3.0'
ruby-version: "3.0"
- publish:
filters:
branches:
Expand Down
2 changes: 1 addition & 1 deletion lib/safe_values/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SafeValues
VERSION = "1.0.1"
VERSION = "1.0.2"
end
6 changes: 3 additions & 3 deletions lib/value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def with(#{params.join(", ")})
end
end

def with(hash = {})
return self if hash.empty?
self.class.with(to_h.merge(hash))
def with(**kwargs)
return self if kwargs.empty?
self.class.with(**to_h.merge(kwargs))
end
end
14 changes: 14 additions & 0 deletions spec/unit/value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
v.a = 10
expect(v.a).to eq(10)
end

it "can update values via .with" do
v = value.new(1, 2).with(a: 10)
expect(v.a).to eq(10)
expect(v.b).to eq(2)
end
end

context "with optional arguments" do
Expand All @@ -67,6 +73,14 @@
expect(v.d).to eq(40)
end

it "can update values via .with" do
v = value.new(10, 20, 30, 40).with(a: 11, c: 31)
expect(v.a).to eq(11)
expect(v.b).to eq(20)
expect(v.c).to eq(31)
expect(v.d).to eq(40)
end

it "raises an error unless all required positional arguments are provided" do
expect { value.new(1) }.to raise_error(ArgumentError, /wrong number of arguments/)
end
Expand Down

0 comments on commit 3245bb9

Please sign in to comment.