camcorder 0.0.4 → 0.0.5

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
2
  SHA1:
3
- metadata.gz: 7103fb50fcbc4807446de2a20603dd46b9106243
4
- data.tar.gz: 39f797f45138310163a948b6348e08eee8233231
3
+ metadata.gz: 68fbef39e7482a92f0c2af93505a965472c6656a
4
+ data.tar.gz: c9adbd62f8b13932228fcd710913ebf47d563605
5
5
  SHA512:
6
- metadata.gz: 12bb3b00c04e8492b20901726a3046f324b67156ce6dfbeac7c467dea335e7089b7117a8259540524ed715027439e02e94c4e87c727674fe32060debab2e9e9b
7
- data.tar.gz: 5891884aa8bc345319b0ea368672997ed15b8d824bf4b81f7ea9fde811e36a149b7e9c02c67617dc9af6403998f98bd3a6a916be742e81940f2b0c191f15527c
6
+ metadata.gz: 351b73bb0144a7aa5ba2b3222c8a5ef565c8ca25b7814257d582f88f4925cc0b5e96d858200751374e202b39b5cd60a87fc00ff7d7727fd30b1c01ef9ab99efb
7
+ data.tar.gz: 04d8870652ef01baec50c687bec8793b69d2bf36305562dc7c56ea2a318ad9aa56a865ee590f5b0f6cf1fa925c9b82ae2d6b566b6428d73d80fcb31ae4e8bd15
data/README.md CHANGED
@@ -5,7 +5,11 @@ Need to have VCR-like functionality for more than just http? Wait no more. This
5
5
  ```ruby
6
6
  require 'camcorder'
7
7
 
8
- imap = Camcorder::Proxy.new(Net::IMAP, imap_host, imap_port, imap_ssl, nil, false)
8
+ //Need recorder
9
+
10
+ recorder = Camcorder::Recorder.new('recordings.json')
11
+
12
+ imap = Camcorder::Proxy.new(recorder, Net::IMAP, imap_host, imap_port, imap_ssl, nil, false)
9
13
  imap.login(username, decrypted_password)
10
14
  imap.search(query)
11
15
  imap.disconnect
@@ -73,4 +73,19 @@ module Camcorder
73
73
  end
74
74
  end
75
75
 
76
+ #
77
+ # Similar to `VCR.use_cassette`
78
+ #
79
+ def self.use_recordings(klass, name, &block)
80
+ recorder = Recorder.new(File.join(self.config.recordings_dir, "#{name}.yaml"))
81
+ begin
82
+ self.intercept_constructor(klass, recorder)
83
+
84
+ recorder.transaction do
85
+ yield
86
+ end
87
+ ensure
88
+ self.deintercept_constructor(klass)
89
+ end
90
+ end
76
91
  end
@@ -2,17 +2,27 @@
2
2
  # Setup the camcorder before every test
3
3
  #
4
4
  RSpec.configure do |config|
5
-
5
+
6
6
  recording_name_for = lambda do |metadata|
7
- description = metadata[:description]
7
+ description = if metadata[:description].empty?
8
+ # we have an "it { is_expected.to be something }" block
9
+ metadata[:scoped_id]
10
+ else
11
+ metadata[:description]
12
+ end
13
+ example_group = if metadata.key?(:example_group)
14
+ metadata[:example_group]
15
+ else
16
+ metadata[:parent_example_group]
17
+ end
8
18
 
9
- if example_group = metadata[:example_group]
10
- [recording_name_for[example_group], description].reject{|d| !d || d == ''}.join('/')
19
+ if example_group
20
+ [recording_name_for[example_group], description].join('/')
11
21
  else
12
22
  description
13
23
  end
14
24
  end
15
-
25
+
16
26
  config.around(:each) do |example|
17
27
  name = recording_name_for[example.metadata].gsub(/[^\w\-\/]+/, '_')
18
28
  filename = File.join(Camcorder.config.recordings_dir, "#{name}.yml")
@@ -1,3 +1,3 @@
1
1
  module Camcorder
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -51,4 +51,19 @@ describe Camcorder do
51
51
 
52
52
  end
53
53
 
54
+ describe '.use recordings' do
55
+ it 'should return a proxy' do
56
+ Camcorder.use_recordings(TestObject, 'use_recordings_should_return_a_proxy') do
57
+ obj = TestObject.new
58
+ expect(obj).to be_a(Camcorder::Proxy)
59
+ end
60
+ end
61
+
62
+ it 'should have recorder set' do
63
+ Camcorder.use_recordings(TestObject, 'use_recordings_should_have_recorder_set') do
64
+ obj = TestObject.new
65
+ expect(obj.recorder).to be_a(Camcorder::Recorder)
66
+ end
67
+ end
68
+ end
54
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camcorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gordon L. Hempton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-08 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  requirements: []
94
94
  rubyforge_project:
95
- rubygems_version: 2.2.2
95
+ rubygems_version: 2.4.5.1
96
96
  signing_key:
97
97
  specification_version: 4
98
98
  summary: VCR-like recording for arbitrary method invocations.