mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
4971d1a6e1
This conversion is done by Transpec 3.2.2 with the following command: transpec * 317 conversions from: obj.should to: expect(obj).to * 160 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 100 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 30 conversions from: lambda { }.should to: expect { }.to * 22 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 4 conversions from: obj.should_not to: expect(obj).not_to * 2 conversions from: == expected to: eq(expected) * 1 conversion from: expect(collection).to have_at_least(n).items to: expect(collection.size).to be >= n * 1 conversion from: obj.unstub(:message) to: allow(obj).to receive(:message).and_call_original For more details: https://github.com/yujinakayama/transpec#supported-conversions
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
require_relative '_lib'
|
|
|
|
describe RestClient::ParamsArray do
|
|
|
|
describe '.new' do
|
|
it 'accepts various types of containers' do
|
|
as_array = [[:foo, 123], [:foo, 456], [:bar, 789], [:empty, nil]]
|
|
[
|
|
[[:foo, 123], [:foo, 456], [:bar, 789], [:empty, nil]],
|
|
[{foo: 123}, {foo: 456}, {bar: 789}, {empty: nil}],
|
|
[{foo: 123}, {foo: 456}, {bar: 789}, {empty: nil}],
|
|
[{foo: 123}, [:foo, 456], {bar: 789}, {empty: nil}],
|
|
[{foo: 123}, [:foo, 456], {bar: 789}, [:empty]],
|
|
].each do |input|
|
|
expect(RestClient::ParamsArray.new(input).to_a).to eq as_array
|
|
end
|
|
|
|
expect(RestClient::ParamsArray.new([]).to_a).to eq []
|
|
expect(RestClient::ParamsArray.new([]).empty?).to eq true
|
|
end
|
|
|
|
it 'rejects various invalid input' do
|
|
expect {
|
|
RestClient::ParamsArray.new([[]])
|
|
}.to raise_error(IndexError)
|
|
|
|
expect {
|
|
RestClient::ParamsArray.new([[1,2,3]])
|
|
}.to raise_error(ArgumentError)
|
|
|
|
expect {
|
|
RestClient::ParamsArray.new([1,2,3])
|
|
}.to raise_error(NoMethodError)
|
|
end
|
|
end
|
|
end
|