Sha256: d48818f3ea103d96f44676af2be98fc9c1f5fa388ef070082b8f0817df69b88f

Contents?: true

Size: 996 Bytes

Versions: 12

Compression:

Stored size: 996 Bytes

Contents

shared_examples CMSScanner::Browser::Actions do
  let(:url)     { 'http://example.com/file.txt' }
  let(:browser) { CMSScanner::Browser }

  describe '#get, #post, #head' do
    [:get, :post, :head].each do |method|
      it 'calls the method and returns a Typhoeus::Response' do
        stub_request(method, url)

        expect(browser.send(method, url)).to be_a Typhoeus::Response
      end
    end
  end

  describe '#get_and_follow_location' do
    let(:redirection) { 'http://redirect.me' }

    it 'follows the location' do
      stub_request(:get, url).to_return(status: 301, headers: { location: redirection })
      stub_request(:get, redirection).to_return(status: 200, body: 'Got me')

      response = browser.get_and_follow_location(url)
      expect(response).to be_a Typhoeus::Response
      # Line below is not working due to an issue in Typhoeus/Webmock
      # See https://github.com/typhoeus/typhoeus/issues/279
      # expect(response.body).to eq 'Got me'
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cms_scanner-0.0.18 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.17 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.16 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.15 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.14 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.13 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.12 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.11 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.10 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.9 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.8 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.7 spec/shared_examples/browser_actions.rb