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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5c34aebfc216d58f1acd41aafa8719f25df2f60
4
- data.tar.gz: 6ee0f30d94650af91490ac76ec018bd17dbe0679
3
+ metadata.gz: 9a7c6149ab2f54a6582c74ce8e96170397c3c686
4
+ data.tar.gz: d0318f0db83881b3d4880da7a8355fed12677088
5
5
  SHA512:
6
- metadata.gz: c7fd5f224f99ec35e5987f615f2b09655cd71f2f0bfbcdd0ac647c94f2332579b242793db80f6f7d6835b3b58e9ffc819b68dd0c689dd1e6a7c621b587845d2e
7
- data.tar.gz: 129383591a0bf9ce56c656db70b1ebb424fb47b99bfb76bf04a67cbcda3089385be8a5536164e5ad6fb5d905c74db77caf5cb88463e49b1426c327db143e1112
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 RestClient::RequestTimeout => @error
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 (ore any other).
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.3.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
@@ -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'
@@ -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
- self.catcher.execute(block)
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
- self.catcher.when_visiting(uri)
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 'you not using VCR...' if VCR.nil?
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?
@@ -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.3.0 ruby lib
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.3.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.3.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