Sha256: 337bd3d74e024cf00d1663a0c082f78bebf8fbd2851ee55885670791061bc423

Contents?: true

Size: 928 Bytes

Versions: 1

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true
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_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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-webservice_matchers-4.10.0 spec/web_test/be_fast_spec.rb