httpspec_simple 0.1.3 → 0.1.4
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 +4 -4
- data/lib/httpspec_simple/request.rb +24 -0
- data/lib/httpspec_simple/version.rb +1 -1
- data/lib/httpspec_simple.rb +1 -1
- data/spec/httpspec_simple/custom_matcher_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a47b69da7c2f5656023f20e39b79bb2e069634a
|
4
|
+
data.tar.gz: e74966e7e67152725d5491d8e33f4a39b441f6b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 752d6eb3c09df394e4e67bb1f23f515d0903960a0f129a1a1635059c2ac75ddf2bc523459ce2dd7323a27ae9f2f8bff12c60daffeafa145a3c04daccb58a943d
|
7
|
+
data.tar.gz: 5598cd7768922a731bcc011c55a650436433f929786324598772980f3690caeb510794142250a13683771ac10a28f737a48c6de10a00349e0d6a64d37ab2ec8f
|
@@ -68,4 +68,28 @@ module HttpspecSimple
|
|
68
68
|
end
|
69
69
|
|
70
70
|
class RequestError < StandardError; end
|
71
|
+
|
72
|
+
class RequestContainer
|
73
|
+
def self.subclass(url, opt = {})
|
74
|
+
sub = Class.new(self) do
|
75
|
+
def to_s; self.class.to_s; end
|
76
|
+
def response_time; self.class.response_time; end
|
77
|
+
def status; self.class.status; end
|
78
|
+
def body; self.class.body; end
|
79
|
+
end
|
80
|
+
class << sub
|
81
|
+
def url=(_url); @url = _url; end
|
82
|
+
def opt=(_opt); @opt = _opt; end
|
83
|
+
def request; @request ||= Request.new(@url, @opt); end
|
84
|
+
def to_s; request.to_s; end
|
85
|
+
def response_time; request.response_time; end
|
86
|
+
def status; request.status; end
|
87
|
+
def body; request.body; end
|
88
|
+
end
|
89
|
+
sub.url = url
|
90
|
+
sub.opt = opt
|
91
|
+
sub.status if opt[:immediately]
|
92
|
+
sub
|
93
|
+
end
|
94
|
+
end
|
71
95
|
end
|
data/lib/httpspec_simple.rb
CHANGED
@@ -10,5 +10,5 @@ def base_url url
|
|
10
10
|
RSpec.configuration.base_url = url
|
11
11
|
end
|
12
12
|
def request path, opt={}
|
13
|
-
HttpspecSimple::
|
13
|
+
HttpspecSimple::RequestContainer.subclass("#{RSpec.configuration.base_url}#{path}", opt)
|
14
14
|
end
|
@@ -4,7 +4,7 @@ describe 'custom matchers' do
|
|
4
4
|
describe '#be_http_ok' do
|
5
5
|
it "should check status code" do
|
6
6
|
response = nil
|
7
|
-
server_start { response = request('/') }
|
7
|
+
server_start { response = request('/', :immediately => true) }
|
8
8
|
expect {
|
9
9
|
response.should be_http_ok
|
10
10
|
}.not_to raise_error
|
@@ -14,7 +14,7 @@ describe 'custom matchers' do
|
|
14
14
|
describe '#respond_within(num).seconds' do
|
15
15
|
it "should check response time" do
|
16
16
|
requests, response = server_start('/' => Proc.new {|req, res| sleep 2 }) do
|
17
|
-
request('/')
|
17
|
+
request('/', :immediately => true)
|
18
18
|
end
|
19
19
|
response.should respond_within(3).seconds
|
20
20
|
expect {
|
@@ -26,7 +26,7 @@ describe 'custom matchers' do
|
|
26
26
|
describe '#retrieve_body_including(string)' do
|
27
27
|
it "should check response body" do
|
28
28
|
requests, response = server_start('/' => Proc.new {|req, res| res.body = "<div>body string</div>" }) do
|
29
|
-
request('/')
|
29
|
+
request('/', :immediately => true)
|
30
30
|
end
|
31
31
|
response.should retrieve_body_including 'dy st'
|
32
32
|
end
|
@@ -35,7 +35,7 @@ describe 'custom matchers' do
|
|
35
35
|
describe '#retrieve_body_matching(regexp)' do
|
36
36
|
it "should check response body" do
|
37
37
|
requests, response = server_start('/' => Proc.new {|req, res| res.body = "<div>body string</div>" }) do
|
38
|
-
request('/')
|
38
|
+
request('/', :immediately => true)
|
39
39
|
end
|
40
40
|
response.should retrieve_body_matching %r|<div>(.+?)</div>|
|
41
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpspec_simple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koji NAKAMURA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|