rspec-webservice_matchers 4.7.0 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e910c637218f32738b9f69d6024155c66177af7c
4
- data.tar.gz: 2a80630a36c09f9a932492845b884caba45cc3fe
3
+ metadata.gz: 84b04d57afcf3304b365847eb967f17d58dcc8fe
4
+ data.tar.gz: 9bc97809c2a5b529a8e839b28d6f30ca3442eabc
5
5
  SHA512:
6
- metadata.gz: 80ec85daf1a0cabfe52139572c08559edd40f7722ccfd02a9aa436d7a84f92328d5021c88d1075c7db4b006f5b169c2d841e5d6984783e761e92d36d4b97adf3
7
- data.tar.gz: 9e233f2fedfcbf95f9c65e8b2f079fbfaaa5092650b211a647a7268cbcee1ec97694654337c8dbfa0c621f2c61bd0209b405dc4b4022af0b0b405dbfa7c060d6
6
+ metadata.gz: dd84d2cca79481db41a0a48f225cfdd19f2a76ee2d267a801d6a050c201f8e2038a98ae9cfd1ae86f6e182c714dec6d32f86072416406586b818c35f00d48e7a
7
+ data.tar.gz: 0a6936ab5a9ed0d9afadb09db9679bf15ddd3178a0525849e513a4cdcf4264bbd228ddb03c86186222a1b064528f287642b4eb5df87502c3922fc3aded341c7a
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ 4.8.0
2
+ -----
3
+ Adds the new public API, beginning with the `be_up` matcher.
4
+
1
5
  4.7.0
2
6
  -----
3
7
  Reduced the RSpec dependencies to rspec-core and rspec-expectations.
data/circle.yml ADDED
@@ -0,0 +1,3 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.3.0
@@ -1,22 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
  require 'rspec/webservice_matchers/util'
3
+ require 'validated_object'
3
4
 
5
+ # Pass when the response code is 200, following redirects if necessary.
4
6
  module RSpec
5
7
  module WebserviceMatchers
6
8
  module BeUp
7
- # Pass when the response code is 200, following redirects if necessary.
9
+
10
+ class TestResult < ValidatedObject::Base
11
+ attr_accessor :success, :status_code
12
+ alias success? success
13
+
14
+ validates :success, inclusion: [true, false]
15
+ validates :status_code, inclusion: 100..510
16
+ end
17
+
18
+
19
+ def self.test(url:nil, domain:nil)
20
+ raise 'Must specify a url or domain' if url.nil? && domain.nil?
21
+
22
+ TestResult.new do |r|
23
+ r.status_code = Util.status(url || domain, follow: true)
24
+ r.success = (r.status_code == 200)
25
+ end
26
+ end
27
+
28
+
8
29
  RSpec::Matchers.define :be_up do
9
30
  status = nil
10
31
 
11
32
  match do |url_or_domain_name|
12
- status = Util.status(url_or_domain_name, follow: true)
13
- status == 200
33
+ result = BeUp.test(url: url_or_domain_name)
34
+ status = result.status_code
35
+ result.success?
14
36
  end
15
37
 
16
38
  failure_message do
17
39
  "Received status #{status}"
18
40
  end
19
41
  end
42
+
20
43
  end
21
44
  end
22
45
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module RSpec
3
3
  module WebserviceMatchers
4
- VERSION = '4.7.0'
4
+ VERSION = '4.8.0'
5
5
  end
6
6
  end
@@ -21,13 +21,15 @@ Gem::Specification.new do |spec|
21
21
  spec.required_ruby_version = '>= 2.1.0'
22
22
 
23
23
  spec.add_development_dependency 'bundler', '~> 1.3'
24
- spec.add_development_dependency 'rake'
25
24
  spec.add_development_dependency 'pry'
25
+ spec.add_development_dependency 'rake'
26
26
  spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'rspec_junit_formatter', '0.2.2'
27
28
  spec.add_development_dependency 'webmock'
28
29
 
29
30
  spec.add_runtime_dependency 'rspec-core', '~> 3.0'
30
31
  spec.add_runtime_dependency 'rspec-expectations', '~> 3.0'
31
32
  spec.add_runtime_dependency 'faraday'
32
33
  spec.add_runtime_dependency 'faraday_middleware'
34
+ spec.add_runtime_dependency 'validated_object'
33
35
  end
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+ require 'rspec/webservice_matchers/be_up'
4
+
5
+ include RSpec::WebserviceMatchers::BeUp
6
+
7
+ describe RSpec::WebserviceMatchers::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 TestResult do
30
+ it 'requires :success' do
31
+ expect {
32
+ TestResult.new { |r| r.status_code = 200 }
33
+ }.to raise_error(ArgumentError)
34
+ end
35
+
36
+ it 'requires :status_code' do
37
+ expect {
38
+ 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 = TestResult.new do |r|
44
+ r.status_code = 404
45
+ r.success = false
46
+ end
47
+ expect( result ).to be_an_instance_of(TestResult)
48
+ end
49
+
50
+ it 'requires boolean :success' do
51
+ expect {
52
+ 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
+ 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
+ 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
+ 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 = TestResult.new do |r|
88
+ r.status_code = 510
89
+ r.success = false
90
+ end
91
+ expect( result ).to be_an_instance_of(TestResult)
92
+ end
93
+ end
94
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-webservice_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0
4
+ version: 4.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: pry
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec_junit_formatter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.2.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.2.2
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: webmock
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +150,20 @@ dependencies:
136
150
  - - ">="
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: validated_object
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  description: Black-box web app configuration testing
140
168
  email:
141
169
  - robb@weblaws.org
@@ -144,12 +172,12 @@ extensions: []
144
172
  extra_rdoc_files: []
145
173
  files:
146
174
  - ".gitignore"
147
- - ".travis.yml"
148
175
  - Gemfile
149
176
  - HISTORY.md
150
177
  - LICENSE.txt
151
178
  - README.md
152
179
  - Rakefile
180
+ - circle.yml
153
181
  - lib/rspec/webservice_matchers.rb
154
182
  - lib/rspec/webservice_matchers/be_fast.rb
155
183
  - lib/rspec/webservice_matchers/be_status.rb
@@ -163,6 +191,7 @@ files:
163
191
  - lib/rspec/webservice_matchers/version.rb
164
192
  - rspec-webservice_matchers.gemspec
165
193
  - spec/fixtures/pagespeed.json
194
+ - spec/rspec/webservice_matchers/be_up_spec.rb
166
195
  - spec/rspec/webservice_matchers/page_speed_spec.rb
167
196
  - spec/rspec/webservice_matchers/protcol_spec.rb
168
197
  - spec/rspec/webservice_matchers/public_api_spec.rb
@@ -195,6 +224,7 @@ specification_version: 4
195
224
  summary: Black-box web app configuration testing
196
225
  test_files:
197
226
  - spec/fixtures/pagespeed.json
227
+ - spec/rspec/webservice_matchers/be_up_spec.rb
198
228
  - spec/rspec/webservice_matchers/page_speed_spec.rb
199
229
  - spec/rspec/webservice_matchers/protcol_spec.rb
200
230
  - spec/rspec/webservice_matchers/public_api_spec.rb
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - "2.1"
4
- - "2.2"