Skip to content

Commit

Permalink
Update try_spec.rb to test deconstruction
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkalderimis authored Jul 22, 2024
1 parent 8cf78b0 commit 8bf9753
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/unit/try_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
it { is_expected.to eql(described_class.new([ZeroDivisionError], "foo")) }
it { is_expected.not_to eql(error[division_error]) }

it "deconstructs to the value" do
expect(subject.deconstruct).to eq ["foo"]
end

it "dumps to string" do
expect(subject.to_s).to eql('Try::Value("foo")')
expect(value[[], unit].to_s).to eql("Try::Value()")
Expand Down Expand Up @@ -210,6 +214,10 @@
let(:upcase_value) { described_class.new([ZeroDivisionError], "FOO") }
let(:upcase_error) { try::Error.new(division_error) }

it "deconstructs to the exception" do
expect(subject.deconstruct).to eq [division_error]
end

describe ".call" do
it "is an alias for new" do
expect(try::Error.(division_error)).to eql(subject)
Expand Down

0 comments on commit 8bf9753

Please sign in to comment.