httpspec_simple 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/httpspec_simple/custom_matchers.rb +11 -9
- data/lib/httpspec_simple/version.rb +1 -1
- data/spec/httpspec_simple/custom_matcher_spec.rb +26 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a17153f2999973bed4da7b117acc5789e2e23ed5
|
4
|
+
data.tar.gz: fb0ba71c3f65ce466c087bd5f75f42d3f9a9760a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
8
|
-
|
9
|
-
|
8
|
+
failure_message_for_should do |actual|
|
9
|
+
"expected: #{code}\n got: #{actual.status}"
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
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
|
|
@@ -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
|