Skip to content

Commit

Permalink
Add tests for invalid JSON and duplicate keys handling
Browse files Browse the repository at this point in the history
  • Loading branch information
buty4649 committed Jun 13, 2024
1 parent 7dafb92 commit ede214b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions spec/filter/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,34 @@
it { expect(last_command_started).to have_output output_string_eq output }
end
end

context 'when inptut is invalid JSON' do
describe 'Error message' do
let(:input) { '{"foo": "bar"' }

let(:args) { '-j _' }
let(:expect_output) do
'Error: failed to parse JSON: unexpected end of data position: 14'
end

it_behaves_like 'a failed exec'
end
end

context 'with duplicate keys in the input object' do
describe 'Output string' do
let(:input) { '{"foo": "bar", "foo": "baz"}' }

let(:args) { '-j _' }
let(:expect_output) do
<<~JSON
{
"foo": "baz"
}
JSON
end

it_behaves_like 'a successful exec'
end
end
end

0 comments on commit ede214b

Please sign in to comment.