rspec-webservice_matchers 4.9.0 → 4.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +35 -0
  3. data/HISTORY.md +13 -0
  4. data/README.md +11 -15
  5. data/circle.yml +2 -0
  6. data/lib/rspec/webservice_matchers/be_fast.rb +2 -46
  7. data/lib/rspec/webservice_matchers/be_status.rb +3 -2
  8. data/lib/rspec/webservice_matchers/be_up.rb +2 -24
  9. data/lib/rspec/webservice_matchers/enforce_https_everywhere.rb +7 -6
  10. data/lib/rspec/webservice_matchers/have_a_valid_cert.rb +3 -2
  11. data/lib/rspec/webservice_matchers/redirect_helpers.rb +5 -4
  12. data/lib/rspec/webservice_matchers/redirect_permanently_to.rb +2 -1
  13. data/lib/rspec/webservice_matchers/redirect_temporarily_to.rb +2 -1
  14. data/lib/rspec/webservice_matchers/version.rb +2 -1
  15. data/lib/web_test/be_fast.rb +59 -0
  16. data/lib/web_test/be_up.rb +25 -0
  17. data/lib/web_test/util.rb +105 -0
  18. data/rspec-webservice_matchers.gemspec +10 -9
  19. data/spec/failure_matchers.rb +16 -0
  20. data/spec/rspec/webservice_matchers/{protcol_spec.rb → protocol_spec.rb} +5 -8
  21. data/spec/rspec/webservice_matchers/public_api_spec.rb +6 -5
  22. data/spec/rspec/webservice_matchers/redirect_spec.rb +19 -18
  23. data/spec/rspec/webservice_matchers/ssl_spec.rb +72 -47
  24. data/spec/spec_helper.rb +3 -54
  25. data/spec/web_mock_config.rb +54 -0
  26. data/spec/web_test/be_up_spec.rb +93 -0
  27. data/spec/web_test/util_spec.rb +6 -0
  28. metadata +53 -35
  29. data/lib/rspec/webservice_matchers/util.rb +0 -97
  30. data/spec/rspec/webservice_matchers/be_fast_spec.rb +0 -28
  31. data/spec/rspec/webservice_matchers/be_up_spec.rb +0 -94
  32. data/spec/rspec/webservice_matchers/page_speed_spec.rb +0 -37
@@ -1,94 +0,0 @@
1
- # frozen_string_literal: true
2
- require 'spec_helper'
3
- require 'rspec/webservice_matchers/be_up'
4
-
5
- include RSpec::WebserviceMatchers
6
-
7
- describe BeUp do
8
- describe '#test' do
9
- it 'handles a simple 200' do
10
- result = BeUp.test url: 'http://www.website.com/'
11
- expect( result.success? ).to be true
12
- expect( result.status_code ).to be 200
13
- end
14
-
15
- it 'handles a simple 200 as a domain' do
16
- result = BeUp.test domain: 'www.website.com'
17
- expect( result.success? ).to be true
18
- expect( result.status_code ).to be 200
19
- end
20
-
21
- it 'handles a 404' do
22
- result = BeUp.test url: 'http://notfound.com/no.txt'
23
- expect( result.success? ).to be false
24
- expect( result.status_code ).to be 404
25
- end
26
- end
27
-
28
-
29
- describe BeUp::TestResult do
30
- it 'requires :success' do
31
- expect {
32
- BeUp::TestResult.new { |r| r.status_code = 200 }
33
- }.to raise_error(ArgumentError)
34
- end
35
-
36
- it 'requires :status_code' do
37
- expect {
38
- BeUp::TestResult.new { |r| r.success = true }
39
- }.to raise_error(ArgumentError)
40
- end
41
-
42
- it 'accepts boolean :success & integer :status_code' do
43
- result = BeUp::TestResult.new do |r|
44
- r.status_code = 404
45
- r.success = false
46
- end
47
- expect( result ).to be_an_instance_of(BeUp::TestResult)
48
- end
49
-
50
- it 'requires boolean :success' do
51
- expect {
52
- BeUp::TestResult.new do |r|
53
- r.status_code = 200
54
- r.success = 1
55
- end
56
- }.to raise_error(ArgumentError)
57
- end
58
-
59
- it 'requires integer :status_code' do
60
- expect {
61
- BeUp::TestResult.new do |r|
62
- r.status_code = '404'
63
- r.success = false
64
- end
65
- }.to raise_error(ArgumentError)
66
- end
67
-
68
- it 'cannot have status < 100' do
69
- expect {
70
- BeUp::TestResult.new do |r|
71
- r.status_code = -5
72
- r.success = false
73
- end
74
- }.to raise_error(ArgumentError)
75
- end
76
-
77
- it 'cannot have status > 510' do
78
- expect {
79
- BeUp::TestResult.new do |r|
80
- r.status_code = 511
81
- r.success = false
82
- end
83
- }.to raise_error(ArgumentError)
84
- end
85
-
86
- it 'allows status 510' do
87
- result = BeUp::TestResult.new do |r|
88
- r.status_code = 510
89
- r.success = false
90
- end
91
- expect( result ).to be_an_instance_of(BeUp::TestResult)
92
- end
93
- end
94
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
- # Specs for all of the PageSpeed code and matchers.
3
-
4
- require 'spec_helper'
5
- require 'rspec/webservice_matchers'
6
- require 'rspec/webservice_matchers/util'
7
-
8
- SAMPLE_JSON_RESPONSE = 'spec/fixtures/pagespeed.json'
9
-
10
- describe RSpec::WebserviceMatchers::BeFast do
11
- describe '#parse' do
12
- it 'can parse the overall score' do
13
- api_response = File.read(SAMPLE_JSON_RESPONSE)
14
- data = RSpec::WebserviceMatchers::BeFast.parse(json: api_response)
15
- expect(data[:score]).to eq(85)
16
- end
17
- end
18
-
19
- describe '#be_fast' do
20
- it 'performs a Google PageSpeed Insights API query on a fast site' do
21
- expect('nonstop.qa').to be_fast
22
- end
23
-
24
- it 'raises a friendly error if the api key has not been set' do
25
- # Remove the key
26
- key = ENV['WEBSERVICE_MATCHER_INSIGHTS_KEY']
27
- ENV['WEBSERVICE_MATCHER_INSIGHTS_KEY'] = nil
28
-
29
- expect {
30
- expect('nonstop.qa').not_to be_fast
31
- }.to raise_error(RuntimeError, /API key/)
32
-
33
- # Replace the key
34
- ENV['WEBSERVICE_MATCHER_INSIGHTS_KEY'] = key
35
- end
36
- end
37
- end