1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00
httparty/spec/httparty_spec.rb

907 lines
30 KiB
Ruby
Raw Normal View History

2009-07-19 19:17:33 -04:00
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2008-07-27 11:52:18 -04:00
RSpec.describe HTTParty do
before(:each) do
@klass = Class.new
@klass.instance_eval { include HTTParty }
end
describe "pem" do
it 'should set the pem content' do
@klass.pem 'PEM-CONTENT'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:pem]).to eq('PEM-CONTENT')
end
it "should set the password to nil if it's not provided" do
@klass.pem 'PEM-CONTENT'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:pem_password]).to be_nil
end
it 'should set the password' do
@klass.pem 'PEM-CONTENT', 'PASSWORD'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:pem_password]).to eq('PASSWORD')
end
end
describe "pkcs12" do
it 'should set the p12 content' do
@klass.pkcs12 'P12-CONTENT', 'PASSWORD'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:p12]).to eq('P12-CONTENT')
end
it 'should set the password' do
@klass.pkcs12 'P12-CONTENT', 'PASSWORD'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:p12_password]).to eq('PASSWORD')
end
end
describe 'ssl_version' do
it 'should set the ssl_version content' do
@klass.ssl_version :SSLv3
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:ssl_version]).to eq(:SSLv3)
end
end
describe 'ciphers' do
it 'should set the ciphers content' do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:ciphers]).to be_nil
@klass.ciphers 'RC4-SHA'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:ciphers]).to eq('RC4-SHA')
end
end
2012-03-28 11:51:31 -04:00
describe 'http_proxy' do
it 'should set the address' do
@klass.http_proxy 'proxy.foo.com', 80
options = @klass.default_options
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(options[:http_proxyaddr]).to eq('proxy.foo.com')
expect(options[:http_proxyport]).to eq(80)
2012-03-28 11:51:31 -04:00
end
it 'should set the proxy user and pass when they are provided' do
@klass.http_proxy 'proxy.foo.com', 80, 'user', 'pass'
options = @klass.default_options
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(options[:http_proxyuser]).to eq('user')
expect(options[:http_proxypass]).to eq('pass')
2012-03-28 11:51:31 -04:00
end
end
describe "base uri" do
before(:each) do
@klass.base_uri('api.foo.com/v1')
end
2008-11-08 11:18:25 -05:00
it "should have reader" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.base_uri).to eq('http://api.foo.com/v1')
2008-07-27 11:52:18 -04:00
end
2009-09-08 23:34:21 -04:00
2008-11-08 11:18:25 -05:00
it 'should have writer' do
@klass.base_uri('http://api.foobar.com')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.base_uri).to eq('http://api.foobar.com')
end
it 'should not modify the parameter during assignment' do
uri = 'http://api.foobar.com'
@klass.base_uri(uri)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(uri).to eq('http://api.foobar.com')
end
2008-07-27 11:52:18 -04:00
end
2009-09-08 23:34:21 -04:00
describe ".disable_rails_query_string_format" do
it "sets the query string normalizer to HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER" do
@klass.disable_rails_query_string_format
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:query_string_normalizer]).to eq(HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER)
end
end
describe ".normalize_base_uri" do
it "should add http if not present for non ssl requests" do
uri = HTTParty.normalize_base_uri('api.foobar.com')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(uri).to eq('http://api.foobar.com')
end
2009-09-08 23:34:21 -04:00
it "should add https if not present for ssl requests" do
uri = HTTParty.normalize_base_uri('api.foo.com/v1:443')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(uri).to eq('https://api.foo.com/v1:443')
end
2009-09-08 23:34:21 -04:00
it "should not remove https for ssl requests" do
uri = HTTParty.normalize_base_uri('https://api.foo.com/v1:443')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(uri).to eq('https://api.foo.com/v1:443')
end
it 'should not modify the parameter' do
uri = 'http://api.foobar.com'
HTTParty.normalize_base_uri(uri)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(uri).to eq('http://api.foobar.com')
end
it "should not treat uri's with a port of 4430 as ssl" do
uri = HTTParty.normalize_base_uri('http://api.foo.com:4430/v1')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(uri).to eq('http://api.foo.com:4430/v1')
end
end
2009-09-08 23:34:21 -04:00
describe "headers" do
def expect_headers(header = {})
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(HTTParty::Request).to receive(:new) \
.with(anything, anything, hash_including({ headers: header })) \
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
.and_return(double("mock response", perform: nil))
end
it "does not modify default_options when no arguments are passed" do
@klass.headers
expect(@klass.default_options[:headers]).to eq(nil)
end
it "should default to empty hash" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.headers).to eq({})
end
it "should be able to be updated" do
init_headers = {foo: 'bar', baz: 'spax'}
@klass.headers init_headers
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.headers).to eq(init_headers)
end
it "should be able to accept block as header value" do
init_headers = {foo: lambda {'bar'}}
@klass.headers init_headers
stub_request(:get, "http://example.com/").with(headers: {foo: 'bar'})
@klass.get('http://example.com/')
expect(@klass.headers).to eq(init_headers)
end
it "uses the class headers when sending a request" do
expect_headers(foo: 'bar')
@klass.headers(foo: 'bar')
@klass.get('')
end
it "merges class headers with request headers" do
expect_headers(baz: 'spax', foo: 'bar')
@klass.headers(foo: 'bar')
@klass.get('', headers: {baz: 'spax'})
end
it 'overrides class headers with request headers' do
expect_headers(baz: 'spax', foo: 'baz')
@klass.headers(foo: 'bar')
@klass.get('', headers: {baz: 'spax', foo: 'baz'})
end
context "with cookies" do
it 'utilizes the class-level cookies' do
expect_headers(foo: 'bar', 'cookie' => 'type=snickerdoodle')
@klass.headers(foo: 'bar')
@klass.cookies(type: 'snickerdoodle')
@klass.get('')
end
it 'adds cookies to the headers' do
expect_headers(foo: 'bar', 'cookie' => 'type=snickerdoodle')
@klass.headers(foo: 'bar')
@klass.get('', cookies: {type: 'snickerdoodle'})
end
it 'doesnt modify default headers' do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.headers).to eq({})
expect_headers('cookie' => 'type=snickerdoodle')
@klass.get('', cookies: {type: 'snickerdoodle'})
expect(@klass.headers).to eq({})
end
it 'adds optional cookies to the optional headers' do
expect_headers(baz: 'spax', 'cookie' => 'type=snickerdoodle')
@klass.get('', cookies: {type: 'snickerdoodle'}, headers: {baz: 'spax'})
end
end
2018-01-30 14:18:37 -05:00
context 'when posting file' do
let(:boundary) { '------------------------c772861a5109d5ef' }
let(:headers) do
{ 'Content-Type'=>"multipart/form-data; boundary=#{boundary}" }
end
before do
expect(HTTParty::Request::MultipartBoundary).to receive(:generate).and_return(boundary)
end
it 'changes content-type headers to multipart/form-data' do
stub_request(:post, "http://example.com/").with(headers: headers)
@klass.post('http://example.com', body: { file: File.open('spec/fixtures/tiny.gif')})
end
end
end
describe "cookies" do
def expect_cookie_header(s)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(HTTParty::Request).to receive(:new) \
.with(anything, anything, hash_including({ headers: { "cookie" => s } })) \
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
.and_return(double("mock response", perform: nil))
end
it "should not be in the headers by default" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
allow(HTTParty::Request).to receive(:new).and_return(double(nil, perform: nil))
@klass.get("")
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.headers.keys).not_to include("cookie")
end
it "should raise an ArgumentError if passed a non-Hash" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.cookies("nonsense")
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(ArgumentError)
end
it "should allow a cookie to be specified with a one-off request" do
expect_cookie_header "type=snickerdoodle"
@klass.get("", cookies: { type: "snickerdoodle" })
end
describe "when a cookie is set at the class level" do
before(:each) do
@klass.cookies({ type: "snickerdoodle" })
end
it "should include that cookie in the request" do
expect_cookie_header "type=snickerdoodle"
@klass.get("")
end
it "should pass the proper cookies when requested multiple times" do
2.times do
expect_cookie_header "type=snickerdoodle"
@klass.get("")
end
end
it "should allow the class defaults to be overridden" do
expect_cookie_header "type=chocolate_chip"
@klass.get("", cookies: { type: "chocolate_chip" })
end
end
describe "in a class with multiple methods that use different cookies" do
before(:each) do
@klass.instance_eval do
def first_method
get("first_method", cookies: { first_method_cookie: "foo" })
end
def second_method
get("second_method", cookies: { second_method_cookie: "foo" })
end
end
end
it "should not allow cookies used in one method to carry over into other methods" do
expect_cookie_header "first_method_cookie=foo"
@klass.first_method
expect_cookie_header "second_method_cookie=foo"
@klass.second_method
end
end
end
2009-09-08 23:34:21 -04:00
describe "default params" do
it "should default to empty hash" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_params).to eq({})
end
2009-09-08 23:34:21 -04:00
it "should be able to be updated" do
new_defaults = {foo: 'bar', baz: 'spax'}
@klass.default_params new_defaults
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_params).to eq(new_defaults)
end
end
2009-09-08 23:34:21 -04:00
describe "default timeout" do
it "should default to nil" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:timeout]).to eq(nil)
end
it "should support updating" do
@klass.default_timeout 10
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:timeout]).to eq(10)
end
2011-02-17 13:55:48 -05:00
it "should support floats" do
@klass.default_timeout 0.5
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:timeout]).to eq(0.5)
2011-02-17 13:55:48 -05:00
end
end
describe "debug_output" do
it "stores the given stream as a default_option" do
@klass.debug_output $stdout
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:debug_output]).to eq($stdout)
end
it "stores the $stderr stream by default" do
@klass.debug_output
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:debug_output]).to eq($stderr)
end
end
describe "basic http authentication" do
it "should work" do
@klass.basic_auth 'foobar', 'secret'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:basic_auth]).to eq({username: 'foobar', password: 'secret'})
end
2008-07-27 11:52:18 -04:00
end
2009-09-08 23:34:21 -04:00
describe "digest http authentication" do
it "should work" do
@klass.digest_auth 'foobar', 'secret'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:digest_auth]).to eq({username: 'foobar', password: 'secret'})
end
end
2009-09-08 23:34:21 -04:00
describe "parser" do
2010-07-18 14:16:56 -04:00
class CustomParser
def self.parse(body)
2015-04-18 07:15:24 -04:00
{sexy: true}
2010-07-18 14:16:56 -04:00
end
end
let(:parser) do
2015-04-18 06:39:39 -04:00
proc { |data, format| CustomParser.parse(data) }
2009-09-08 23:34:21 -04:00
end
it "should set parser options" do
@klass.parser parser
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:parser]).to eq(parser)
2009-09-08 23:34:21 -04:00
end
it "should be able parse response with custom parser" do
@klass.parser parser
2017-06-03 17:47:12 -04:00
stub_request(:get, 'http://twitter.com/statuses/public_timeline.xml')
.to_return(body: 'tweets')
2009-09-08 23:34:21 -04:00
custom_parsed_response = @klass.get('http://twitter.com/statuses/public_timeline.xml')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(custom_parsed_response[:sexy]).to eq(true)
2009-09-08 23:34:21 -04:00
end
it "raises UnsupportedFormat when the parser cannot handle the format" do
@klass.format :json
parser_class = Class.new(HTTParty::Parser)
parser_class::SupportedFormats = {}
expect do
@klass.parser parser_class
end.to raise_error(HTTParty::UnsupportedFormat)
end
it 'does not validate format whe custom parser is a proc' do
expect do
@klass.format :json
@klass.parser lambda {|body, format|}
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to_not raise_error
end
2009-09-08 23:34:21 -04:00
end
describe "uri_adapter" do
require 'forwardable'
class CustomURIAdaptor
extend Forwardable
def_delegators :@uri, :userinfo, :relative?, :query, :query=, :scheme, :path, :host, :port
def initialize uri
@uri = uri
end
def self.parse uri
new URI.parse uri
end
end
let(:uri_adapter) { CustomURIAdaptor }
it "should set the uri_adapter" do
@klass.uri_adapter uri_adapter
expect(@klass.default_options[:uri_adapter]).to be uri_adapter
end
it "should raise an ArgumentError if uri_adapter doesn't implement parse method" do
expect do
@klass.uri_adapter double()
end.to raise_error(ArgumentError)
end
it "should process a request with a uri instance parsed from the uri_adapter" do
uri = 'http://foo.com/bar'
stub_request(:get, uri).to_return(body: 'stuff')
@klass.uri_adapter uri_adapter
expect(@klass.get(uri).parsed_response).to eq('stuff')
end
end
describe "connection_adapter" do
let(:uri) { 'http://google.com/api.json' }
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
let(:connection_adapter) { double('CustomConnectionAdapter') }
it "should set the connection_adapter" do
@klass.connection_adapter connection_adapter
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:connection_adapter]).to be connection_adapter
end
it "should set the connection_adapter_options when provided" do
options = {foo: :bar}
@klass.connection_adapter connection_adapter, options
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:connection_adapter_options]).to be options
end
it "should not set the connection_adapter_options when not provided" do
@klass.connection_adapter connection_adapter
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:connection_adapter_options]).to be_nil
end
it "should process a request with a connection from the adapter" do
connection_adapter_options = {foo: :bar}
2015-04-18 06:29:00 -04:00
expect(connection_adapter).to receive(:call) { |u, o|
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(o[:connection_adapter_options]).to eq(connection_adapter_options)
2015-04-18 06:29:00 -04:00
HTTParty::ConnectionAdapter.call(u, o)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
}.with(URI.parse(uri), kind_of(Hash))
stub_request(:get, uri).to_return(body: 'stuff')
@klass.connection_adapter connection_adapter, connection_adapter_options
expect(@klass.get(uri).parsed_response).to eq('stuff')
end
end
describe "format" do
it "should allow xml" do
@klass.format :xml
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:format]).to eq(:xml)
end
2009-09-08 23:34:21 -04:00
2014-02-08 12:32:43 -05:00
it "should allow csv" do
@klass.format :csv
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:format]).to eq(:csv)
2014-02-08 12:32:43 -05:00
end
it "should allow json" do
@klass.format :json
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:format]).to eq(:json)
end
2009-09-08 23:34:21 -04:00
it "should allow plain" do
@klass.format :plain
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:format]).to eq(:plain)
end
2009-09-08 23:34:21 -04:00
it 'should not allow funky format' do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.format :foobar
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::UnsupportedFormat)
end
it 'should only print each format once with an exception' do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.format :foobar
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::UnsupportedFormat, "':foobar' Must be one of: csv, html, json, plain, xml")
end
it 'sets the default parser' do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:parser]).to be_nil
@klass.format :json
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:parser]).to eq(HTTParty::Parser)
end
it 'does not reset parser to the default parser' do
my_parser = lambda {}
@klass.parser my_parser
@klass.format :json
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.parser).to eq(my_parser)
end
end
describe "#no_follow" do
it "sets no_follow to false by default" do
@klass.no_follow
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:no_follow]).to be_falsey
end
it "sets the no_follow option to true" do
@klass.no_follow true
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:no_follow]).to be_truthy
end
end
describe "#maintain_method_across_redirects" do
it "sets maintain_method_across_redirects to true by default" do
@klass.maintain_method_across_redirects
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:maintain_method_across_redirects]).to be_truthy
end
it "sets the maintain_method_across_redirects option to false" do
@klass.maintain_method_across_redirects false
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:maintain_method_across_redirects]).to be_falsey
end
end
2014-07-31 08:18:13 -04:00
describe "#resend_on_redirect" do
it "sets resend_on_redirect to true by default" do
@klass.resend_on_redirect
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:resend_on_redirect]).to be_truthy
2014-07-31 08:18:13 -04:00
end
2014-07-31 08:18:13 -04:00
it "sets resend_on_redirect option to false" do
@klass.resend_on_redirect false
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:resend_on_redirect]).to be_falsey
2014-07-31 08:18:13 -04:00
end
end
describe ".follow_redirects" do
it "sets follow redirects to true by default" do
@klass.follow_redirects
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:follow_redirects]).to be_truthy
end
it "sets the follow_redirects option to false" do
@klass.follow_redirects false
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:follow_redirects]).to be_falsey
end
end
describe ".query_string_normalizer" do
it "sets the query_string_normalizer option" do
normalizer = proc {}
@klass.query_string_normalizer normalizer
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options[:query_string_normalizer]).to eq(normalizer)
end
end
describe ".raise_on" do
context 'when parameters is an array' do
it 'sets raise_on option' do
@klass.raise_on [500, 404]
expect(@klass.default_options[:raise_on]).to contain_exactly(404, 500)
end
end
context 'when parameters is a fixnum' do
it 'sets raise_on option' do
@klass.raise_on 404
expect(@klass.default_options[:raise_on]).to contain_exactly(404)
end
end
end
describe "with explicit override of automatic redirect handling" do
before do
@request = HTTParty::Request.new(Net::HTTP::Get, 'http://api.foo.com/v1', format: :xml, no_follow: true)
@redirect = stub_response 'first redirect', 302
@redirect['location'] = 'http://foo.com/bar'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
allow(HTTParty::Request).to receive_messages(new: @request)
end
it "should fail with redirected GET" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@error = @klass.get('/foo', no_follow: true)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
end
it "should fail with redirected POST" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.post('/foo', no_follow: true)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
end
2012-04-13 19:22:51 -04:00
it "should fail with redirected PATCH" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.patch('/foo', no_follow: true)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
2012-04-13 19:22:51 -04:00
end
it "should fail with redirected DELETE" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.delete('/foo', no_follow: true)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
end
2013-01-17 00:01:17 -05:00
it "should fail with redirected MOVE" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.move('/foo', no_follow: true)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
2013-01-17 00:01:17 -05:00
end
2013-02-07 09:34:32 -05:00
it "should fail with redirected COPY" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.copy('/foo', no_follow: true)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
2013-02-07 09:34:32 -05:00
end
it "should fail with redirected PUT" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.put('/foo', no_follow: true)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
end
it "should fail with redirected HEAD" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.head('/foo', no_follow: true)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
end
it "should fail with redirected OPTIONS" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
@klass.options('/foo', no_follow: true)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
end
it "should fail with redirected MKCOL" do
expect do
@klass.mkcol('/foo', no_follow: true)
end.to raise_error(HTTParty::RedirectionTooDeep) {|e| expect(e.response.body).to eq('first redirect')}
end
2008-07-28 13:32:35 -04:00
end
2009-09-08 23:34:21 -04:00
2015-08-22 14:03:18 -04:00
describe "head requests should follow redirects requesting HEAD only" do
before do
allow(HTTParty::Request).to receive(:new).
and_return(double("mock response", perform: nil))
end
it "should remain HEAD request across redirects, unless specified otherwise" do
expect(@klass).to receive(:ensure_method_maintained_across_redirects).with({})
@klass.head('/foo')
2015-08-22 14:03:18 -04:00
end
end
describe "#ensure_method_maintained_across_redirects" do
2015-08-22 14:03:18 -04:00
it "should set maintain_method_across_redirects option if unspecified" do
options = {}
@klass.send(:ensure_method_maintained_across_redirects, options)
expect(options[:maintain_method_across_redirects]).to be_truthy
end
2015-08-22 14:03:18 -04:00
it "should not set maintain_method_across_redirects option if value is present" do
options = { maintain_method_across_redirects: false }
@klass.send(:ensure_method_maintained_across_redirects, options)
expect(options[:maintain_method_across_redirects]).to be_falsey
2015-08-22 14:03:18 -04:00
end
end
describe "with multiple class definitions" do
before(:each) do
@klass.instance_eval do
base_uri "http://first.com"
default_params one: 1
end
@additional_klass = Class.new
@additional_klass.instance_eval do
include HTTParty
base_uri "http://second.com"
default_params two: 2
end
end
it "should not run over each others options" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@klass.default_options).to eq({ base_uri: 'http://first.com', default_params: { one: 1 } })
expect(@additional_klass.default_options).to eq({ base_uri: 'http://second.com', default_params: { two: 2 } })
end
end
2009-09-08 23:34:21 -04:00
describe "two child classes inheriting from one parent" do
before(:each) do
@parent = Class.new do
include HTTParty
def self.name
"Parent"
end
end
@child1 = Class.new(@parent)
@child2 = Class.new(@parent)
end
it "does not modify each others inherited attributes" do
@child1.default_params joe: "alive"
@child2.default_params joe: "dead"
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child1.default_options).to eq({ default_params: {joe: "alive"} })
expect(@child2.default_options).to eq({ default_params: {joe: "dead"} })
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@parent.default_options).to eq({ })
end
it "inherits default_options from the superclass" do
@parent.basic_auth 'user', 'password'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child1.default_options).to eq({basic_auth: {username: 'user', password: 'password'}})
@child1.basic_auth 'u', 'p' # modifying child1 has no effect on child2
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child2.default_options).to eq({basic_auth: {username: 'user', password: 'password'}})
end
it "doesn't modify the parent's default options" do
@parent.basic_auth 'user', 'password'
@child1.basic_auth 'u', 'p'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child1.default_options).to eq({basic_auth: {username: 'u', password: 'p'}})
@child1.basic_auth 'email', 'token'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child1.default_options).to eq({basic_auth: {username: 'email', password: 'token'}})
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@parent.default_options).to eq({basic_auth: {username: 'user', password: 'password'}})
end
it "doesn't modify hashes in the parent's default options" do
@parent.headers 'Accept' => 'application/json'
@child1.headers 'Accept' => 'application/xml'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@parent.default_options[:headers]).to eq({'Accept' => 'application/json'})
expect(@child1.default_options[:headers]).to eq({'Accept' => 'application/xml'})
end
it "works with lambda values" do
@child1.default_options[:imaginary_option] = lambda { "This is a new lambda "}
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child1.default_options[:imaginary_option]).to be_a Proc
end
it 'should dup the proc on the child class' do
imaginary_option = lambda { 2 * 3.14 }
@parent.default_options[:imaginary_option] = imaginary_option
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@parent.default_options[:imaginary_option].call).to eq(imaginary_option.call)
@child1.default_options[:imaginary_option]
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child1.default_options[:imaginary_option].call).to eq(imaginary_option.call)
expect(@child1.default_options[:imaginary_option]).not_to be_equal imaginary_option
end
it "inherits default_cookies from the parent class" do
@parent.cookies 'type' => 'chocolate_chip'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child1.default_cookies).to eq({"type" => "chocolate_chip"})
@child1.cookies 'type' => 'snickerdoodle'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child1.default_cookies).to eq({"type" => "snickerdoodle"})
expect(@child2.default_cookies).to eq({"type" => "chocolate_chip"})
end
it "doesn't modify the parent's default cookies" do
@parent.cookies 'type' => 'chocolate_chip'
@child1.cookies 'type' => 'snickerdoodle'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@child1.default_cookies).to eq({"type" => "snickerdoodle"})
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(@parent.default_cookies).to eq({"type" => "chocolate_chip"})
end
end
describe "grand parent with inherited callback" do
before do
@grand_parent = Class.new do
def self.inherited(subclass)
subclass.instance_variable_set(:@grand_parent, true)
end
end
@parent = Class.new(@grand_parent) do
include HTTParty
end
end
it "continues running the #inherited on the parent" do
child = Class.new(@parent)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(child.instance_variable_get(:@grand_parent)).to be_truthy
end
end
describe "#get" do
it "should be able to get html" do
stub_http_response_with('google.html')
expect(HTTParty.get('http://www.google.com').parsed_response).to eq(file_fixture('google.html'))
end
2009-09-08 23:34:21 -04:00
2012-02-15 14:46:01 -05:00
it "should be able to get chunked html" do
2015-04-17 19:39:52 -04:00
chunks = %w(Chunk1 Chunk2 Chunk3 Chunk4)
2012-02-15 14:46:01 -05:00
stub_chunked_http_response_with(chunks)
2014-12-06 20:37:34 -05:00
expect(
HTTParty.get('http://www.google.com') do |fragment|
expect(chunks).to include(fragment)
end.parsed_response
2014-12-06 20:37:34 -05:00
).to eq(chunks.join)
2012-02-15 14:46:01 -05:00
end
it "should return an empty body if stream_body option is turned on" do
2015-04-17 19:39:52 -04:00
chunks = %w(Chunk1 Chunk2 Chunk3 Chunk4)
options = {stream_body: true, format: 'html'}
stub_chunked_http_response_with(chunks, options)
2014-12-06 20:37:34 -05:00
expect(
HTTParty.get('http://www.google.com', options) do |fragment|
expect(chunks).to include(fragment)
end.parsed_response
2014-12-06 20:37:34 -05:00
).to eq(nil)
end
it "should be able parse response type json automatically" do
stub_http_response_with('twitter.json')
tweets = HTTParty.get('http://twitter.com/statuses/public_timeline.json')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(tweets.size).to eq(20)
expect(tweets.first['user']).to eq({
2009-09-08 23:34:21 -04:00
"name" => "Pyk",
"url" => nil,
"id" => "7694602",
"description" => nil,
"protected" => false,
"screen_name" => "Pyk",
"followers_count" => 1,
"location" => "Opera Plaza, California",
"profile_image_url" => "http://static.twitter.com/images/default_profile_normal.png"
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
})
end
2009-09-08 23:34:21 -04:00
it "should be able parse response type xml automatically" do
stub_http_response_with('twitter.xml')
tweets = HTTParty.get('http://twitter.com/statuses/public_timeline.xml')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(tweets['statuses'].size).to eq(20)
expect(tweets['statuses'].first['user']).to eq({
2009-09-08 23:34:21 -04:00
"name" => "Magic 8 Bot",
"url" => nil,
"id" => "17656026",
"description" => "ask me a question",
"protected" => "false",
"screen_name" => "magic8bot",
"followers_count" => "90",
"profile_image_url" => "http://s3.amazonaws.com/twitter_production/profile_images/65565851/8ball_large_normal.jpg",
"location" => nil
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
})
end
2009-09-08 23:34:21 -04:00
2014-02-08 12:32:43 -05:00
it "should be able parse response type csv automatically" do
stub_http_response_with('twitter.csv')
profile = HTTParty.get('http://twitter.com/statuses/profile.csv')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(profile.size).to eq(2)
2015-04-17 19:39:52 -04:00
expect(profile[0]).to eq(%w(name url id description protected screen_name followers_count profile_image_url location))
2015-04-18 06:29:00 -04:00
expect(profile[1]).to eq(["Magic 8 Bot", nil, "17656026", "ask me a question", "false", "magic8bot", "90", "http://s3.amazonaws.com/twitter_production/profile_images/65565851/8ball_large_normal.jpg", nil])
2014-02-08 12:32:43 -05:00
end
it "should not get undefined method add_node for nil class for the following xml" do
stub_http_response_with('undefined_method_add_node_for_nil.xml')
result = HTTParty.get('http://foobar.com')
2015-04-17 20:04:14 -04:00
expect(result.parsed_response).to eq({"Entities" => {"href" => "https://s3-sandbox.parature.com/api/v1/5578/5633/Account", "results" => "0", "total" => "0", "page_size" => "25", "page" => "1"}})
end
2009-09-08 23:34:21 -04:00
2009-01-28 13:17:39 -05:00
it "should parse empty response fine" do
stub_http_response_with('empty.xml')
result = HTTParty.get('http://foobar.com')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect(result).to be_nil
2009-01-28 13:17:39 -05:00
end
2009-10-28 17:39:14 -04:00
it "should accept http URIs" do
stub_http_response_with('google.html')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
2009-10-28 17:39:14 -04:00
HTTParty.get('http://google.com')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.not_to raise_error
2009-10-28 17:39:14 -04:00
end
it "should accept https URIs" do
stub_http_response_with('google.html')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
2009-10-28 17:39:14 -04:00
HTTParty.get('https://google.com')
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.not_to raise_error
2009-10-28 17:39:14 -04:00
end
it "should accept webcal URIs" do
2015-05-31 12:28:32 -04:00
uri = 'http://google.com/'
stub_request(:get, uri).to_return(body: 'stuff')
2015-05-31 12:28:32 -04:00
uri = 'webcal://google.com/'
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
2015-05-31 12:28:32 -04:00
HTTParty.get(uri)
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.not_to raise_error
2009-10-28 17:39:14 -04:00
end
it "should raise an InvalidURIError on URIs that can't be parsed at all" do
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
expect do
2009-10-28 17:39:14 -04:00
HTTParty.get("It's the one that says 'Bad URI'")
Convert specs to RSpec 3.1.7 syntax with Transpec This conversion is done by Transpec 2.3.8 with the following command: transpec -f spec * 328 conversions from: obj.should to: expect(obj).to * 238 conversions from: == expected to: eq(expected) * 42 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 26 conversions from: it { should ... } to: it { is_expected.to ... } * 26 conversions from: lambda { }.should to: expect { }.to * 21 conversions from: mock('something') to: double('something') * 21 conversions from: obj.stub(:message => value) to: allow(obj).to receive_messages(:message => value) * 19 conversions from: be_true to: be_truthy * 19 conversions from: its(:attr) { } to: describe '#attr' do subject { super().attr }; it { } end * 18 conversions from: obj.stub!(:message) to: allow(obj).to receive(:message) * 15 conversions from: obj.should_not_receive(:message) to: expect(obj).not_to receive(:message) * 10 conversions from: obj.should_not to: expect(obj).not_to * 7 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 6 conversions from: stub('something') to: double('something') * 5 conversions from: be_false to: be_falsey * 4 conversions from: expect { }.not_to raise_error(SpecificErrorClass) to: expect { }.not_to raise_error * 4 conversions from: lambda { }.should_not to: expect { }.not_to * 3 conversions from: =~ /pattern/ to: match(/pattern/) * 2 conversions from: obj.stub_chain(:message1, :message2) to: allow(obj).to receive_message_chain(:message1, :message2) * 1 conversion from: === expected to: be === expected * 1 conversion from: it { should_not ... } to: it { is_expected.not_to ... } For more details: https://github.com/yujinakayama/transpec#supported-conversions
2014-12-06 19:12:39 -05:00
end.to raise_error(URI::InvalidURIError)
2009-10-28 17:39:14 -04:00
end
end
2009-09-08 23:34:21 -04:00
end