require "spec_helper"

describe HideMyAss::Request do

  let(:url)     { "127.0.0.1" }
  let(:res)     { double(on_complete: nil).as_null_object }
  let(:hydra)   { double.as_null_object }
  let(:proxies) { [{host: "1.2.3.4", port: "80"}] }
  let(:proxy)   { "http://#{proxies[0][:host]}:#{proxies[0][:port]}" }

  before do
    HideMyAss.stub(:hydra).and_return(hydra)
    HideMyAss.stub(:proxies).and_return(proxies)
  end

  [:get, :post, :put, :delete].each do |http_method|
    describe ".#{http_method}" do
      it "passes :#{http_method} message to typhoeus" do
        Typhoeus::Request.should_receive(:new).
          with(url, { :method => http_method }.merge(proxy: proxy)).
          and_return(res)

        HideMyAss.send(http_method, url)
      end
    end
  end

end
require "spec_helper"

describe HideMyAss::Request do

  let(:url)     { "127.0.0.1" }
  let(:res)     { double(on_complete: nil).as_null_object }
  let(:hydra)   { double.as_null_object }
  let(:proxies) { [{host: "1.2.3.4", port: "80"}] }
  let(:proxy)   { "http://#{proxies[0][:host]}:#{proxies[0][:port]}" }

  before do
    allow(HideMyAss).to receive(:hydra).and_return(hydra)
    allow(HideMyAss).to receive(:proxies).and_return(proxies)
  end

  [:get, :post, :put, :delete].each do |http_method|
    describe ".#{http_method}" do
      it "passes :#{http_method} message to typhoeus" do
        expect(Typhoeus::Request).to receive(:new).
          with(url, { :method => http_method }.merge(proxy: proxy)).
          and_return(res)

        HideMyAss.send(http_method, url)
      end
    end
  end

end
Convert specs to RSpec 3.0.0 syntax with Transpec
Convert specs to RSpec 3.0.0 syntax with Transpec

This conversion is done by Transpec 2.2.4 with the following command:
    transpec

* 2 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 1 conversion
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

For more details: https://github.com/yujinakayama/transpec#supported-conversions
