httpspec_simple 0.1.3 → 0.1.4

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: cd5d9c54f71ba2d0a77591e82b3151857f9a8dac
4
- data.tar.gz: 95843a7989ef5a42220ec441c2763eea828bcb85
3
+ metadata.gz: 0a47b69da7c2f5656023f20e39b79bb2e069634a
4
+ data.tar.gz: e74966e7e67152725d5491d8e33f4a39b441f6b0
5
5
  SHA512:
6
- metadata.gz: d4d9c21b1ee6d3633e2c286594457e848e54f2dcae6b67e175da4eedcab84b80bfd72aa450bd3199530f4600b4b93b64999ea11829402409bf8a6d203d2a55cd
7
- data.tar.gz: d1a3b4c5951ceab8012add155dcdfc3584d64cf69f89ff00ae64b77c014a90a0b6bc66fab4efbbad354c131d519a8e0c2c69d473816dc0e2aab187dcd8310dff
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
@@ -1,3 +1,3 @@
1
1
  module HttpspecSimple
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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::Request.new("#{RSpec.configuration.base_url}#{path}", opt)
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.3
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-24 00:00:00.000000000 Z
11
+ date: 2013-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec