Sha256: 6bf5daf545daec091f08b23f38adde6542da40cdb7bcef2669104087fd314ba0

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
require 'spec_helper'
require 'web_test/be_fast'

RSpec.describe WebTest::BeFast do
  it { is_expected.not_to be_nil }

  describe '#test' do
    it 'handles a fast site' do
      result = WebTest::BeFast.test url: 'http://nonstop.qa'
      expect(result.success?).to be true
      expect(result.score).to be >= 85
    end
  end

  describe '#parse' do
    it 'can parse the overall score' do
      api_response = File.read(SAMPLE_PAGESPEED_JSON_RESPONSE)
      data = WebTest::BeFast.parse json: api_response
      expect(data[:score]).to eq 85
    end
  end

  describe WebTest::BeFast::TestResult do
    it 'requires :success' do
      expect do
        WebTest::BeFast::TestResult.new {}
      end.to raise_error(ArgumentError, /success/i)
    end

    it 'requires :score' do
      expect do
        WebTest::BeFast::TestResult.new { |r| r.success = true }
      end.to raise_error(ArgumentError, /score/i)
    end

    it 'requires :response' do
      expect do
        WebTest::BeFast::TestResult.new { |r|
          r.success = true
          r.score = 90
        }
      end.to raise_error(ArgumentError, /response/i)      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspec-webservice_matchers-4.12.1 spec/web_test/be_fast_spec.rb
rspec-webservice_matchers-4.12.0 spec/web_test/be_fast_spec.rb
rspec-webservice_matchers-4.11.0 spec/web_test/be_fast_spec.rb