Sha256: f8bfd4830a46c41ebf400b4b8598a89a67103d42b2d5aed217776da7fe51b8ac

Contents?: true

Size: 998 Bytes

Versions: 5

Compression:

Stored size: 998 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

5 entries across 5 versions & 1 rubygems

Version Path
cms_scanner-0.0.6 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.5 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.4 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.3 spec/shared_examples/browser_actions.rb
cms_scanner-0.0.2 spec/shared_examples/browser_actions.rb