rspec-webservice_matchers 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc5dff69f7d8e076b45349e851cffed6c3154dae
4
- data.tar.gz: 234b5ec72bbb82e23535f5650ea7ea7bffd9bae1
3
+ metadata.gz: 5d0db24cd17e0dc1da5656291cf823dc6edd8823
4
+ data.tar.gz: 88cb9edbd5986e4ad036cec34445a8c4a150a9b0
5
5
  SHA512:
6
- metadata.gz: 0e62ebf6d183a2aa82bb4f595342e55b4b54a4de1b6afbd4c11f4d54485510858ae7c9071e8272849665d2dae88eb9cce2216c1c622b74d2009eacbabeffc2af
7
- data.tar.gz: 3079c979f64cb292ede888caed703afeef2c936740efa068b2762791204951afbf6063d1cda781ff198a9ea93c6fa2faed26d9930d86dc2e0af6096a1ffa21f4
6
+ metadata.gz: 687ea5c0d7d5bc1197c327ade4d7f5fc0daa7d586950ace47b0326dda17c63cd95e1e40e076ae4fa8fdf83a4b60ec3e071b9b325e0f6781dfb989a04c7c0b739
7
+ data.tar.gz: 920efc3653699436d52518840eb4a83597463c54194a803265b9f84ffd1502567763a81fa552b9169f713194bbe0acc8d0b165530f4d25311ddb1b81fdaef384
@@ -106,8 +106,18 @@ module RSpec
106
106
  # Pass when the response code is 200, following redirects
107
107
  # if necessary.
108
108
  RSpec::Matchers.define :be_up do
109
+ actual_status = nil
110
+
109
111
  match do |url_or_domain_name|
110
- RSpec::WebserviceMatchers.up?(url_or_domain_name)
112
+ url = RSpec::WebserviceMatchers.make_url(url_or_domain_name)
113
+ conn = RSpec::WebserviceMatchers.connection(follow: true)
114
+ response = conn.head(url)
115
+ actual_status = response.status
116
+ actual_status == 200
117
+ end
118
+
119
+ failure_message_for_should do
120
+ "Received status #{actual_status}"
111
121
  end
112
122
  end
113
123
 
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module WebserviceMatchers
3
- VERSION = "1.4.1"
3
+ VERSION = "1.4.2"
4
4
  end
5
5
  end
@@ -34,6 +34,7 @@ end
34
34
  describe 'be_up' do
35
35
  it 'follows redirects when necessary' do
36
36
  'perm-redirector.com'.should be_up
37
+ 'temp-redirector.org'.should be_up
37
38
  end
38
39
 
39
40
  it 'can also handle a simple 200' do
@@ -43,4 +44,10 @@ describe 'be_up' do
43
44
  it 'is available via a public API' do
44
45
  RSpec::WebserviceMatchers.up?('http://www.website.com/').should be true
45
46
  end
47
+
48
+ it 'gives relevant error output' do
49
+ expect {
50
+ expect('http://notfound.com/no.txt').to be_up
51
+ }.to fail_matching(/404/)
52
+ end
46
53
  end
@@ -1,32 +1,32 @@
1
+ require 'spec_helper'
1
2
  require 'rspec/webservice_matchers'
2
3
 
3
- #
4
- # TODO: Set up a server for these. (Or a mock?)
5
- # Faraday supports testing: we can use that now.
6
- #
7
4
 
8
5
  describe 'redirect_permanently_to' do
9
6
  it 'passes when receiving a 301 to the given URL' do
10
- expect('http://weblaws.org').to redirect_permanently_to('http://www.weblaws.org/')
11
- expect('http://www.getquisitive.com/press-kit/').to redirect_permanently_to 'http://getquisitive.com/press-kit/'
7
+ expect('http://perm-redirector.com').to redirect_permanently_to('http://www.website.com/')
12
8
  end
13
9
 
14
10
  it 'handles domain names gracefully' do
15
- expect('weblaws.org').to redirect_permanently_to('www.weblaws.org/')
11
+ expect('perm-redirector.com').to redirect_permanently_to('www.website.com/')
16
12
  end
17
13
 
18
14
  it 'handles missing final slash' do
19
- expect('weblaws.org').to redirect_permanently_to('www.weblaws.org')
15
+ expect('perm-redirector.com').to redirect_permanently_to('www.website.com')
20
16
  end
21
17
  end
22
18
 
23
19
 
24
20
  describe 'redirect_temporarily_to' do
25
21
  it 'passes when it gets a 302' do
26
- 'http://www.oregonlaws.org/cms/about_us'.should redirect_temporarily_to 'http://www.weblaws.org/cms/about_us'
22
+ 'http://temp-redirector.org'.should redirect_temporarily_to 'http://a-page.com/a/page.txt'
27
23
  end
28
24
 
29
- # TODO: Set up the mock server and test these
30
- it 'handles domain names gracefully'
31
- it 'passes when it gets a 307'
25
+ it 'handles domain names gracefully' do
26
+ 'temp-redirector.org'.should redirect_temporarily_to 'a-page.com/a/page.txt'
27
+ end
28
+
29
+ it 'passes when it gets a 307' do
30
+ 'temp-307-redirector.net'.should redirect_temporarily_to 'a-page.com/a/page.txt'
31
+ end
32
32
  end
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,12 @@ RSpec.configure do |config|
11
11
  WebMock.stub_request(:any, 'perm-redirector.com')
12
12
  .to_return(status: 301, headers: {Location: 'http://www.website.com/'})
13
13
 
14
+ WebMock.stub_request(:any, 'temp-redirector.org')
15
+ .to_return(status: 302, headers: {Location: 'http://a-page.com/a/page.txt'})
16
+
17
+ WebMock.stub_request(:any, 'temp-307-redirector.net')
18
+ .to_return(status: 307, headers: {Location: 'http://a-page.com/a/page.txt'})
19
+
14
20
  WebMock.allow_net_connect!
15
21
  end
16
22
  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: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter