blob: 5d90364ae923b63964518932d3931f655bf4e02c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# frozen_string_literal: true
require 'spec_helper'
require 'rspec-parameterized'
RSpec.describe 'JSON validator patch' do
using RSpec::Parameterized::TableSyntax
let(:schema) { '{"format": "string"}' }
subject { JSON::Validator.validate(schema, data) }
context 'with invalid JSON' do
where(:data) do
[
'https://example.com',
'/tmp/test.txt'
]
end
with_them do
it 'does not attempt to open a file or URI' do
allow(File).to receive(:read).and_call_original
allow(URI).to receive(:open).and_call_original
expect(File).not_to receive(:read).with(data)
expect(URI).not_to receive(:open).with(data)
expect(subject).to be true
end
end
end
context 'with valid JSON' do
let(:data) { %({ 'somekey': 'value' }) }
it 'validates successfully' do
expect(subject).to be true
end
end
end
|