so_stub_very_test 0.0.0 → 0.0.1
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/README.md +11 -2
- data/lib/so_stub_very_test/version.rb +1 -1
- data/lib/so_stub_very_test.rb +3 -3
- 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: c98f18e778b94cc8312353b40d917eed8fa2a6c0
|
4
|
+
data.tar.gz: 73b845747f0b0f01ccf719035096e905683ea035
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b81585a91b7c564420cd467b3d0a76bcf43daddd708b133ad8abb22d0ef728d7083422975d654e94cb6a739cd937920940a8829dd85a6e27056b44e73f88a4f0
|
7
|
+
data.tar.gz: 502736a9beab4a7a42289950bbbd6f4de9c09c3aed8bb354a8d2fb262f9a4c7828b6ca9f27be341e5f337fbeada97ad9f04b804bf3a3ed1084d0ad926b14b804
|
data/README.md
CHANGED
@@ -57,7 +57,7 @@ stub_get "/foo" do
|
|
57
57
|
body: "no meme here"
|
58
58
|
}
|
59
59
|
end
|
60
|
-
# Equivalent: Excon.stub({ path: /\A\/foo\Z/, method: :
|
60
|
+
# Equivalent: Excon.stub({ path: /\A\/foo\Z/, method: :get }, { body: "no meme here" })
|
61
61
|
```
|
62
62
|
|
63
63
|
SoStubVeryTest will naïvely turn path parameters (any group of non-`/` preceded
|
@@ -132,6 +132,15 @@ SoStubVeryTest.defaults do
|
|
132
132
|
end
|
133
133
|
```
|
134
134
|
|
135
|
+
### Clearing the Stubs
|
136
|
+
|
137
|
+
You can clear any non-default stubs with this cool method:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
SoStubVeryTest.clear_custom_stubs
|
141
|
+
# congratulations you have defeated the stubs
|
142
|
+
```
|
143
|
+
|
135
144
|
## Testing with SoStubVeryTest
|
136
145
|
|
137
146
|
### For RSpec
|
@@ -185,7 +194,7 @@ class TestDoges < Minitest::Test
|
|
185
194
|
|
186
195
|
def test_the_doge
|
187
196
|
stub_get "/doge", "hi from doge"
|
188
|
-
assert_equal "hi from doge", Excon.get({ path: "/doge" })
|
197
|
+
assert_equal "hi from doge", Excon.get({ path: "/doge" }).body
|
189
198
|
end
|
190
199
|
end
|
191
200
|
```
|
data/lib/so_stub_very_test.rb
CHANGED
@@ -10,7 +10,7 @@ module SoStubVeryTest
|
|
10
10
|
|
11
11
|
def namespace(path, host = nil, &block)
|
12
12
|
if stub_paths.any? && stub_host != host
|
13
|
-
raise MixedNamespacesError
|
13
|
+
raise MixedNamespacesError, "Namespaces can't be mixed (#{stub_host} and #{host == nil ? "nil" : host})"
|
14
14
|
end
|
15
15
|
|
16
16
|
stub_paths << path
|
@@ -134,13 +134,13 @@ module SoStubVeryTest
|
|
134
134
|
|
135
135
|
def validate_path_given(path)
|
136
136
|
if stub_paths.empty? && !path.is_a?(String)
|
137
|
-
raise NoPathGivenError
|
137
|
+
raise NoPathGivenError, "Must provide a path to stub requests for"
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
141
|
def validate_single_response(block, response)
|
142
142
|
if block && response
|
143
|
-
raise AmbiguousResponseError
|
143
|
+
raise AmbiguousResponseError, "Must provide only either a response object or a block"
|
144
144
|
end
|
145
145
|
end
|
146
146
|
end
|