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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8bea5981613aaddffae3b7321fd518e334f52b58
4
- data.tar.gz: ab5194c35b3fa09d9719803f0a0ad77c75324e8c
5
- SHA512:
6
- metadata.gz: 047c0bb072bcd48c962cdcb806b87a268ee7798e03871cce6d01bb5c439d7e42aeec27dd750d5202f34e9168b68b03ea8791367cd04509ade8dc1ca3dca270c9
7
- data.tar.gz: a9dacada5866084ecaddbd228802a1c25eb9ea43281c9c6cf3644303993a86cfde72ebf664e7f6b7f3804e9e3d7c8841831507c16d2822dad82438e0ca9b8f5e
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: 48977d4bd260a29d49b27f536a904fd53c304bfc
4
+ data.tar.gz: cbd0add11392b011f633f0a39b82529d0be7d791
5
+ !binary "U0hBNTEy":
6
+ metadata.gz: 00c3a931c15c6fe9a451fcfda7bb2d4f3891d65210270308ab26ee6139f8e4290c4b776cca35d2cd761599ca29599316379f5f88d4c8a000e33d64cb75e9a2de
7
+ data.tar.gz: a8525b615d6aeb5cd70aeab40b44b34cf6ece596c892d7cdbaf11b7c55f23fea2572cd4b4e81f770e60ce379d9bf46f965a21dc287bfffdbf3eecee9076b8d06
@@ -27,11 +27,18 @@ module SoStubVeryTest
27
27
  validate_host(host)
28
28
  validate_path_given(path)
29
29
 
30
- unless path.is_a? String
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 = { method: verb, path: path }
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,3 +1,3 @@
1
1
  module SoStubVeryTest
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,4 +1,9 @@
1
- require "test_helper"
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.3
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-02 00:00:00.000000000 Z
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
- - ".gitignore"
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.2.0
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:
@@ -1,5 +0,0 @@
1
- require "so_stub_very_test"
2
- require "excon"
3
- require "minitest/autorun"
4
- require "minitest/pride"
5
- require "minitest/unit"