spec/middleware/repeater_spec.rb in faraday-conductivity-0.3.0 vs spec/middleware/repeater_spec.rb in faraday-conductivity-0.3.1

- old
+ new

@@ -1,19 +1,17 @@ -require 'spec_helper' +RSpec.describe Faraday::Conductivity::Repeater do -describe Faraday::Conductivity::Repeater do - let(:connection) { Faraday.new(url: $service_double_url) { |faraday| faraday.use :repeater, mode: :rapid, retries: 6 faraday.response :raise_error faraday.adapter Faraday.default_adapter } } it "retries after timeouts" do - get_with_max(4).body.should eq "fast" + expect(get_with_max(4).body).to eq "fast" end it "gives up after a number of retries" do expect { get_with_max(20) }.to raise_error(Faraday::Error::TimeoutError) end @@ -32,24 +30,24 @@ end it "waits according to a pattern" do pattern = MyPattern.new - Faraday::Conductivity::Repeater::Pattern.should_receive(:new).and_return(pattern) + expect(Faraday::Conductivity::Repeater::Pattern).to receive(:new).and_return(pattern) get_with_max(6) - pattern.waited.should eq pattern.waited.sort + expect(pattern.waited).to eq pattern.waited.sort end it "handles other errors too" do connection = Faraday.new(url: "http://blabla.bla") { |faraday| faraday.use :repeater, mode: :rapid, retries: 2 faraday.adapter Faraday.default_adapter } pattern = double :pattern - Faraday::Conductivity::Repeater::Pattern.should_receive(:new).and_return(pattern) - pattern.should_receive(:wait).with(1).ordered - pattern.should_receive(:wait).with(2).ordered + expect(Faraday::Conductivity::Repeater::Pattern).to receive(:new).and_return(pattern) + expect(pattern).to receive(:wait).with(1).ordered + expect(pattern).to receive(:wait).with(2).ordered expect { connection.get("/") }.to raise_error(Faraday::Error::ConnectionFailed) end def get_with_max(num)