so_stub_very_test 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -6
- data/lib/so_stub_very_test.rb +14 -3
- data/lib/so_stub_very_test/version.rb +1 -1
- data/test/so_stub_very_test_test.rb +11 -1
- metadata +14 -16
- data/test/test_helper.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: 48977d4bd260a29d49b27f536a904fd53c304bfc
|
4
|
+
data.tar.gz: cbd0add11392b011f633f0a39b82529d0be7d791
|
5
|
+
!binary "U0hBNTEy":
|
6
|
+
metadata.gz: 00c3a931c15c6fe9a451fcfda7bb2d4f3891d65210270308ab26ee6139f8e4290c4b776cca35d2cd761599ca29599316379f5f88d4c8a000e33d64cb75e9a2de
|
7
|
+
data.tar.gz: a8525b615d6aeb5cd70aeab40b44b34cf6ece596c892d7cdbaf11b7c55f23fea2572cd4b4e81f770e60ce379d9bf46f965a21dc287bfffdbf3eecee9076b8d06
|
data/lib/so_stub_very_test.rb
CHANGED
@@ -27,11 +27,18 @@ module SoStubVeryTest
|
|
27
27
|
validate_host(host)
|
28
28
|
validate_path_given(path)
|
29
29
|
|
30
|
-
unless path.is_a?
|
30
|
+
unless is_request_options?(path) || path.is_a?(String)
|
31
31
|
response = path
|
32
32
|
path = ""
|
33
33
|
end
|
34
34
|
|
35
|
+
if is_request_options?(path)
|
36
|
+
request = path
|
37
|
+
path = request[:path]
|
38
|
+
else
|
39
|
+
request = {}
|
40
|
+
end
|
41
|
+
|
35
42
|
validate_single_response(block, response)
|
36
43
|
|
37
44
|
if block
|
@@ -42,7 +49,7 @@ module SoStubVeryTest
|
|
42
49
|
path = replace_path_params(path)
|
43
50
|
path = create_path_regexp(path)
|
44
51
|
|
45
|
-
request
|
52
|
+
request.merge!(method: verb, path: path)
|
46
53
|
|
47
54
|
if host = get_request_host(host)
|
48
55
|
request[:host] = host
|
@@ -113,6 +120,10 @@ module SoStubVeryTest
|
|
113
120
|
stub_host || host || default_host
|
114
121
|
end
|
115
122
|
|
123
|
+
def is_request_options?(options)
|
124
|
+
options.is_a?(Hash) && options.has_key?(:path)
|
125
|
+
end
|
126
|
+
|
116
127
|
def replace_path_params(path)
|
117
128
|
path.gsub /:[^\/]+/, '[^\/]+'
|
118
129
|
end
|
@@ -134,7 +145,7 @@ module SoStubVeryTest
|
|
134
145
|
end
|
135
146
|
|
136
147
|
def validate_path_given(path)
|
137
|
-
if stub_paths.empty? && !path.is_a?(String)
|
148
|
+
if stub_paths.empty? && !(is_request_options?(path) || path.is_a?(String))
|
138
149
|
raise NoPathGivenError, "Must provide a path to stub requests for"
|
139
150
|
end
|
140
151
|
end
|
@@ -1,4 +1,9 @@
|
|
1
|
-
require "
|
1
|
+
require "so_stub_very_test"
|
2
|
+
require "excon"
|
3
|
+
require "minitest"
|
4
|
+
require "minitest/autorun"
|
5
|
+
require "minitest/pride"
|
6
|
+
require "minitest/unit"
|
2
7
|
|
3
8
|
class TestSoStubVeryTest < Minitest::Test
|
4
9
|
include SoStubVeryTest
|
@@ -34,6 +39,11 @@ class TestSoStubVeryTest < Minitest::Test
|
|
34
39
|
assert_equal Excon.stubs, [[{ path: /\A\/foo\Z/, method: :delete }, body: [true]]]
|
35
40
|
end
|
36
41
|
|
42
|
+
def test_can_pass_request_params
|
43
|
+
stub_get({ path: "/foo", headers: { "Accept" => "bar" } }, [true])
|
44
|
+
assert_equal Excon.stubs, [[{ path: /\A\/foo\Z/, headers: { "Accept" => "bar" }, method: :get }, body: [true]]]
|
45
|
+
end
|
46
|
+
|
37
47
|
def test_performs_param_substitution
|
38
48
|
stub_get "/foo/:bar", body: [true]
|
39
49
|
assert_equal Excon.stubs, [[{ path: Regexp.new('\A/foo/[^\/]+\Z'), method: :get }, body: [true]]]
|
metadata
CHANGED
@@ -1,61 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: so_stub_very_test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Clem
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.25'
|
20
|
-
- -
|
20
|
+
- - ! '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 0.25.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0.25'
|
30
|
-
- -
|
30
|
+
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.25.1
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - ~>
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '1.5'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.5'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ! '>='
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
description: build sensible default Excon stubs...and then build more of them
|
@@ -65,7 +65,7 @@ executables: []
|
|
65
65
|
extensions: []
|
66
66
|
extra_rdoc_files: []
|
67
67
|
files:
|
68
|
-
-
|
68
|
+
- .gitignore
|
69
69
|
- Gemfile
|
70
70
|
- LICENSE.txt
|
71
71
|
- README.md
|
@@ -74,7 +74,6 @@ files:
|
|
74
74
|
- lib/so_stub_very_test/version.rb
|
75
75
|
- so_stub_very_test.gemspec
|
76
76
|
- test/so_stub_very_test_test.rb
|
77
|
-
- test/test_helper.rb
|
78
77
|
homepage: https://github.com/jclem/so_stub_very_test
|
79
78
|
licenses:
|
80
79
|
- MIT
|
@@ -85,21 +84,20 @@ require_paths:
|
|
85
84
|
- lib
|
86
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
86
|
requirements:
|
88
|
-
- -
|
87
|
+
- - ! '>='
|
89
88
|
- !ruby/object:Gem::Version
|
90
89
|
version: '0'
|
91
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
91
|
requirements:
|
93
|
-
- -
|
92
|
+
- - ! '>='
|
94
93
|
- !ruby/object:Gem::Version
|
95
94
|
version: '0'
|
96
95
|
requirements: []
|
97
96
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.0.3
|
99
98
|
signing_key:
|
100
99
|
specification_version: 4
|
101
100
|
summary: so stub...very test...much excon...wow
|
102
101
|
test_files:
|
103
102
|
- test/so_stub_very_test_test.rb
|
104
|
-
- test/test_helper.rb
|
105
103
|
has_rdoc:
|