Skip to content

Commit

Permalink
Add test coverage for Errors#to_json
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorrall committed Mar 1, 2020
1 parent 7faba28 commit c3c3fe7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion spec/simple_command/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,18 @@
it "returrns the full messages array" do
expect(errors.full_messages).to eq ["Attr1 has an error", "Attr2 has an error", "Attr2 has two errors"]
end

end

describe "#to_json" do
it "groups errors by key values" do
errors.add :attr1, 'has an error'
errors.add :attr2, 'has an error'
errors.add :attr2, 'has two errors'

expect(JSON.parse(errors.to_json)).to eq(
"attr1" => ["has an error"],
"attr2" => ["has an error", "has two errors"]
)
end
end
end

0 comments on commit c3c3fe7

Please sign in to comment.