Skip to content

Commit e35913a

Browse files
committed
Add specs to reach 100% branch coverage
1 parent 3ba0e23 commit e35913a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

spec/lib/http/form_data/urlencoded_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55

66
let(:data) { { "foo[bar]" => "test" } }
77

8-
it "raises ArgumentError when given a non-Hash top-level value" do
8+
it "raises ArgumentError when given a non-Enumerable top-level value" do
99
expect { described_class.new(42) }.to raise_error(HTTP::FormData::Error)
1010
end
1111

12+
it "raises ArgumentError when default encoder receives a non-Hash top-level value" do
13+
expect { described_class.encoder.call(42) }.to raise_error(ArgumentError, /value must be a Hash/)
14+
end
15+
1216
it "supports any Enumerables of pairs" do
1317
form_data = described_class.new([%w[foo bar], ["foo", %w[baz moo]]])
1418

@@ -95,6 +99,10 @@
9599
it "switches form encoder implementation" do
96100
expect(form_data.to_s).to eq('{"foo[bar]":"test"}')
97101
end
102+
103+
it "raises ArgumentError when implementation does not respond to #call" do
104+
expect { described_class.encoder = "not callable" }.to raise_error(ArgumentError)
105+
end
98106
end
99107

100108
context "with custom instance level encoder" do

spec/support/simplecov.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515

1616
SimpleCov.start do
1717
add_filter "/spec/"
18-
minimum_coverage 100
18+
enable_coverage :branch
19+
minimum_coverage :line => 100, :branch => 100
1920
end

0 commit comments

Comments
 (0)