Sha256: eaa17dc56b80de1e31aa39c21df5a64393253f37bd05829a6cf365fdd8368998

Contents?: true

Size: 758 Bytes

Versions: 17

Compression:

Stored size: 758 Bytes

Contents

RSpec.describe Percy::Capybara::HttpFetcher do
  it 'takes a URL and returns a response' do
    response = Percy::Capybara::HttpFetcher.fetch('https://i.imgur.com/Umkjdao.png')

    # Slightly magical hash, just a SHA-256 sum of the image above.
    expect(Digest::SHA256.hexdigest(response.body)).to eq(
      '4beb51550bef8e9e30d37ea8c13658e99bb01722062f218185e419af5ad93e13')
    expect(response.content_type).to eq('image/png')
  end
  it 'returns nil if fetch failed' do
    expect(Percy::Capybara::HttpFetcher.fetch('http://i.imgur.com/fake-image.png')).to be_nil
    expect(Percy::Capybara::HttpFetcher.fetch('http://i.imgur.com/fake image.png')).to be_nil
    # FIXME.
    # expect(Percy::Capybara::HttpFetcher.fetch('bad-url')).to be_nil
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
percy-capybara-2.4.0 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.3.6 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.3.5 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.3.4 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.3.3 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.3.2 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.3.1 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.3.0 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.3.0.pre.beta spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.2.1 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.2.0 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.1.1 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.1.0 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.0.1 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-2.0.0 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-1.2.0 spec/lib/percy/capybara/httpfetcher_spec.rb
percy-capybara-1.1.0 spec/lib/percy/capybara/httpfetcher_spec.rb