rspec-webservice_matchers 1.1.1 → 1.1.2

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: 3aca3e244bcc6fba59a64f758e107b9999b4a42a
4
- data.tar.gz: c6168cb912525614671e2538edc946c0be787447
3
+ metadata.gz: 89064b80f84f72a5fd43886b4ef08bddfdd25eab
4
+ data.tar.gz: d0da9d277e5023d76d52fd5ca524492434266b10
5
5
  SHA512:
6
- metadata.gz: 3d56795b8f888bf11c74e2cbc79904b0bad918e5ea99d23f8f178d86dfe3d517bf52110dfe4e0681bea82ebd496ddc8f178eb7560956911baa25753d5ae0eeb9
7
- data.tar.gz: 813f7c6dbf6bd14837135163517b2233ee559dcf1516064e92f47da139f565978107620d09705ae4600735d6ee22bddb1194d5ac7cf9c4088ffedd6af558d49f
6
+ metadata.gz: 338608ed8145220d05925acf13eb5bad0aba255f5452154af1c01f91e188142dd857a45e02caa2dbcf9f7bea05b50e4d190e70fc2635ce75dcc949f883ee0c0f
7
+ data.tar.gz: 0bc6ca8f292510bc568e5e1bf4735d76fe426bc104eec4454f919c6e261dc9f72bce935f4bc6ab5a89754b764822404b9cb92c47f558951d787d6867bbd0c8f9
@@ -14,8 +14,8 @@ module RSpec
14
14
 
15
15
  # Test by seeing if Curl retrieves without complaining
16
16
  begin
17
- conn = Faraday.new(:url => "https://#{domain_name_or_url}")
18
- response = conn.head
17
+ conn = Faraday.new
18
+ response = conn.head("https://#{domain_name_or_url}")
19
19
  return true
20
20
  rescue
21
21
  # Not serving SSL, expired, or incorrect domain name in certificate
@@ -37,18 +37,17 @@ module RSpec
37
37
  # Pass successfully if we get a 301 to the place we intend.
38
38
  RSpec::Matchers.define :redirect_permanently_to do |expected|
39
39
  match do |url|
40
- conn = Faraday.new(:url => url)
41
- response = conn.head
42
- response.status == 301 && response.headers['Location'] == expected
40
+ response = Faraday.new.head(url)
41
+ # binding.pry
42
+ response.status == 301 && response.headers['location'] == expected
43
43
  end
44
44
  end
45
45
 
46
46
  # Pass successfully if we get a 302 or 307 to the place we intend.
47
47
  RSpec::Matchers.define :redirect_temporarily_to do |expected|
48
48
  match do |url|
49
- conn = Faraday.new(:url => url)
50
- response = conn.head
51
- [302, 307].include?(response.status) && response.headers['Location'] == expected
49
+ response = Faraday.new.head(url)
50
+ [302, 307].include?(response.status) && response.headers['location'] == expected
52
51
  end
53
52
  end
54
53
 
@@ -58,9 +57,8 @@ module RSpec
58
57
  # 3. which is correctly configured
59
58
  RSpec::Matchers.define :enforce_https_everywhere do
60
59
  match do |domain_name|
61
- conn = Faraday.new(:url => "http://#{domain_name}")
62
- response = conn.head
63
- new_url = response.headers['Location']
60
+ response = Faraday.new.head("http://#{domain_name}")
61
+ new_url = response.headers['location']
64
62
  (response.status == 301) && (/https/ === new_url) && (RSpec::WebserviceMatchers.has_valid_ssl_cert?(new_url))
65
63
  end
66
64
  end
@@ -70,8 +68,7 @@ module RSpec
70
68
  RSpec::Matchers.define :be_status do |expected|
71
69
  match do |url_or_domain_name|
72
70
  url = RSpec::WebserviceMatchers.make_url(url_or_domain_name)
73
- conn = Faraday.new(:url => url)
74
- response = conn.head
71
+ response = Faraday.new.head(url)
75
72
  response.status == expected
76
73
  end
77
74
  end
@@ -81,11 +78,11 @@ module RSpec
81
78
  RSpec::Matchers.define :be_up do
82
79
  match do |url_or_domain_name|
83
80
  url = RSpec::WebserviceMatchers.make_url(url_or_domain_name)
84
- conn = Faraday.new(url) do |c|
81
+ conn = Faraday.new do |c|
85
82
  c.use FaradayMiddleware::FollowRedirects, limit: 5
86
83
  c.adapter :net_http
87
84
  end
88
- response = conn.head
85
+ response = conn.head(url)
89
86
  response.status == 200
90
87
  end
91
88
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module WebserviceMatchers
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
@@ -1,11 +1,13 @@
1
1
  require 'rspec/webservice_matchers'
2
2
 
3
3
  #
4
- # TODO: Set up a server for these. (Or a mock?)
4
+ # TODO: Set up a server for these. (Or a mock?)
5
+ # Faraday supports testing: we can use that now.
5
6
  #
6
7
  describe 'redirect_permanently_to' do
7
8
  it 'passes when receiving a 301 to the given URL' do
8
9
  expect('http://weblaws.org').to redirect_permanently_to('http://www.weblaws.org/')
10
+ expect('http://www.getquisitive.com/press-kit/').to redirect_permanently_to 'http://getquisitive.com/press-kit/'
9
11
  end
10
12
  end
11
13
 
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.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robb Shecter