httpspec_simple 0.1.8 → 0.1.9

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: c7a4a13d7119d5d2f05affddfb927380d85f57c4
4
- data.tar.gz: 3f71018eafd3e423a945b962d07edc8a54163ce9
3
+ metadata.gz: a17153f2999973bed4da7b117acc5789e2e23ed5
4
+ data.tar.gz: fb0ba71c3f65ce466c087bd5f75f42d3f9a9760a
5
5
  SHA512:
6
- metadata.gz: 70c10461277c63e4203225f5c902a6280bc85433bee02092e60b6db0c88a1ad975e023ea3087dc7903d5c6c55579aa66a219cc7d928cb15a9a716061ecb2bcd4
7
- data.tar.gz: af985c27b460a7a61b8127f29065cd1c509220fe27492f9772453c0c6aaa405e7b13212f949bdb604d4e3a706121efe8a38ebfafde11660c6b3123e4395a2524
6
+ metadata.gz: cb9e1a49c561af1b84473667689cc864ce71a3febf2d134d90426ae00dd1ddad784b03b993b8a2003e646f31f8125fe9e8ba63e2287f1a59ffb30776591b8737
7
+ data.tar.gz: 3c1112d456f941b93144bb12176337e29c5297955bfd222b75a4a7eb6d2706717d7af8dc73ed8224473724d3fa83292b64c1c1af87d192fda1c7babc4fcf5863
data/README.md CHANGED
@@ -54,6 +54,14 @@ Example passes if response is 301 and `Location` response header has a value whi
54
54
 
55
55
  Example passes if response is 302 and `Location` response header has a value which equals expected url
56
56
 
57
+ ### be_not_found
58
+
59
+ Example passes if response is 404
60
+
61
+ ### be_service_unavailable
62
+
63
+ Example passes if response is 503
64
+
57
65
  ### resond_within(n).seconds
58
66
 
59
67
  Example passes if response time is less than n seconds
@@ -1,15 +1,17 @@
1
1
  module HttpspecSimple
2
- RSpec::Matchers.define :be_http_ok do
3
- match do |actual|
4
- actual.status == '200'
5
- end
2
+ { '200' => 'be_http_ok', '404' => 'be_not_found', '503' => 'be_service_unavailable' }.each do |code, name|
3
+ RSpec::Matchers.define name.to_sym do
4
+ match do |actual|
5
+ actual.status == code
6
+ end
6
7
 
7
- failure_message_for_should do |actual|
8
- "expected: 200\n got: #{actual.status}"
9
- end
8
+ failure_message_for_should do |actual|
9
+ "expected: #{code}\n got: #{actual.status}"
10
+ end
10
11
 
11
- failure_message_for_should_not do |actual|
12
- "#{actual.to_s} would not be http ok"
12
+ failure_message_for_should_not do |actual|
13
+ "#{actual.to_s} would not #{name.gsub('_', ' ')}"
14
+ end
13
15
  end
14
16
  end
15
17
 
@@ -1,3 +1,3 @@
1
1
  module HttpspecSimple
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -59,6 +59,32 @@ describe 'custom matchers' do
59
59
  end
60
60
  end
61
61
 
62
+ describe '#be_not_found' do
63
+ it "should check status code 404" do
64
+ _, response = server_start('/' => Proc.new {|req, res|
65
+ res.status = '404'
66
+ }) do
67
+ response = request('/', :immediately => true)
68
+ end
69
+ expect {
70
+ response.should be_not_found
71
+ }.not_to raise_error
72
+ end
73
+ end
74
+
75
+ describe '#be_service_unavailable' do
76
+ it "should check status code 503" do
77
+ _, response = server_start('/' => Proc.new {|req, res|
78
+ res.status = '503'
79
+ }) do
80
+ response = request('/', :immediately => true)
81
+ end
82
+ expect {
83
+ response.should be_service_unavailable
84
+ }.not_to raise_error
85
+ end
86
+ end
87
+
62
88
  describe '#respond_within(num).seconds' do
63
89
  it "should check response time" do
64
90
  requests, response = server_start('/' => Proc.new {|req, res| sleep 2 }) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpspec_simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koji NAKAMURA