vcr-uri-catcher 0.3.0 → 0.4.0
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 +3 -4
- data/VERSION +1 -1
- data/features/library.feature +21 -0
- data/features/support/env.rb +1 -3
- data/lib/vcr-uri-catcher.rb +16 -3
- data/vcr-uri-catcher.gemspec +3 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a7c6149ab2f54a6582c74ce8e96170397c3c686
|
4
|
+
data.tar.gz: d0318f0db83881b3d4880da7a8355fed12677088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc0a07b41cde680441441485fb0bd9ec20ebef83ce761c7faef7936ab0a2b5ff51e4d5e25f7eae7d10f0424616bcff2614e753a62da29cbf6c3e6b4da9c4bd7a
|
7
|
+
data.tar.gz: 5421b932bbb68518b66a3e74c7b64617180e785e7ed74c6e52eb7163810b7683548dfbc610ab4592e68205babbf09368b0323200eb293339621f27dc23798452
|
data/README.MD
CHANGED
@@ -54,13 +54,12 @@ end
|
|
54
54
|
Given(/^I do:$/) do |code|
|
55
55
|
begin
|
56
56
|
eval code
|
57
|
-
rescue
|
58
|
-
rescue
|
59
|
-
raise
|
57
|
+
rescue => @error
|
60
58
|
end
|
61
59
|
end
|
62
60
|
```
|
63
|
-
> Here we catch the raised RestClient::RequestTimeout and put it in @error, so we can check it in the next step (
|
61
|
+
> Here we catch the raised RestClient::RequestTimeout and put it in @error, so we can check it in the next step (or any other).<br/>
|
62
|
+
|
64
63
|
|
65
64
|
```ruby
|
66
65
|
Then(/^I expect it to raise a (.*) error$/) do |error|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: Testing the libraries consistancy
|
2
|
+
Scenario: Getting an error when i don't pass anything to execute
|
3
|
+
When I do:
|
4
|
+
"""ruby
|
5
|
+
URICatcher::execute
|
6
|
+
"""
|
7
|
+
Then I expect it to raise a URICatcher::NoBlockGiven error
|
8
|
+
|
9
|
+
Scenario: Getting an error when i don't pass anything to when_visiting
|
10
|
+
When I do:
|
11
|
+
"""ruby
|
12
|
+
URICatcher::when_visiting
|
13
|
+
"""
|
14
|
+
Then I expect it to raise a ArgumentError error
|
15
|
+
|
16
|
+
Scenario: Getting an error when i don't pass a String or a RegExp to when_visiting
|
17
|
+
When I do:
|
18
|
+
"""ruby
|
19
|
+
URICatcher::when_visiting([1,2,3])
|
20
|
+
"""
|
21
|
+
Then I expect it to raise a URICatcher::NotStringOrRegexp error
|
data/features/support/env.rb
CHANGED
@@ -6,7 +6,5 @@ rescue Bundler::BundlerError => e
|
|
6
6
|
STDERR.puts "Run `bundle install` to install missing gems"
|
7
7
|
exit e.status_code
|
8
8
|
end
|
9
|
+
require_relative '../../lib/vcr-uri-catcher'
|
9
10
|
|
10
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
11
|
-
#require 'rspec/expectations'
|
12
|
-
require 'vcr-uri-catcher'
|
data/lib/vcr-uri-catcher.rb
CHANGED
@@ -1,19 +1,32 @@
|
|
1
|
+
|
1
2
|
class URICatcher
|
3
|
+
class NoBlockGiven < StandardError;end
|
4
|
+
class MissingVCR < StandardError;end
|
5
|
+
class MissingURI < StandardError;end
|
6
|
+
class NotStringOrRegexp < StandardError;end
|
2
7
|
def self.catcher
|
3
8
|
@catcher ||= Catcher.new
|
4
9
|
end
|
5
10
|
def self.execute(&block)
|
6
|
-
|
11
|
+
if block
|
12
|
+
self.catcher.execute(block)
|
13
|
+
else
|
14
|
+
raise NoBlockGiven
|
15
|
+
end
|
7
16
|
end
|
8
17
|
def self.when_visiting(uri)
|
9
|
-
|
18
|
+
if uri.is_a?(String) or uri.is_a?(Regexp)
|
19
|
+
self.catcher.when_visiting(uri)
|
20
|
+
else
|
21
|
+
raise NotStringOrRegexp
|
22
|
+
end
|
10
23
|
end
|
11
24
|
end
|
12
25
|
|
13
26
|
class Catcher
|
14
27
|
def initialize
|
15
28
|
@uris = {}
|
16
|
-
raise
|
29
|
+
raise URICatcher::MissingVCR if VCR.nil?
|
17
30
|
VCR.configure do |c|
|
18
31
|
c.before_http_request do |request|
|
19
32
|
catch_request(request) if active?
|
data/vcr-uri-catcher.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: vcr-uri-catcher 0.
|
5
|
+
# stub: vcr-uri-catcher 0.4.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "vcr-uri-catcher"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.4.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"features/cassettes/cucumber_tags/vcr.yml",
|
29
|
+
"features/library.feature",
|
29
30
|
"features/step_definitions/vcr-uri-catcher_steps.rb",
|
30
31
|
"features/support/env.rb",
|
31
32
|
"features/support/vcr.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcr-uri-catcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mischa Molhoek
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- Rakefile
|
167
167
|
- VERSION
|
168
168
|
- features/cassettes/cucumber_tags/vcr.yml
|
169
|
+
- features/library.feature
|
169
170
|
- features/step_definitions/vcr-uri-catcher_steps.rb
|
170
171
|
- features/support/env.rb
|
171
172
|
- features/support/vcr.rb
|