camcorder 0.0.3 → 0.0.4

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: 89096f4a1f052334ca47a32755400159a4e17db0
4
- data.tar.gz: bd317603915f7fa901529dd48ef09a1361d81370
3
+ metadata.gz: 7103fb50fcbc4807446de2a20603dd46b9106243
4
+ data.tar.gz: 39f797f45138310163a948b6348e08eee8233231
5
5
  SHA512:
6
- metadata.gz: a9836f7c0991832dd8612b42a45cace1ff75989bb9c888450d7ffc4ce64cdbed130b4f0b134d61056cd03b6203dbde638d02fed4c87c8966ced3bb1d5ea64d24
7
- data.tar.gz: afefa67a4185e008672c521d3fa2ee8a4740e34c5af9a44d4c2b7eb26a883feadd9aeeb2866319dc8f41bc7c979a6ac377767f12f19724205f5f09d128e8895f
6
+ metadata.gz: 12bb3b00c04e8492b20901726a3046f324b67156ce6dfbeac7c467dea335e7089b7117a8259540524ed715027439e02e94c4e87c727674fe32060debab2e9e9b
7
+ data.tar.gz: 5891884aa8bc345319b0ea368672997ed15b8d824bf4b81f7ea9fde811e36a149b7e9c02c67617dc9af6403998f98bd3a6a916be742e81940f2b0c191f15527c
@@ -1,13 +1,15 @@
1
1
  module Camcorder
2
-
2
+
3
3
  class Configuration
4
-
4
+
5
5
  attr_accessor :recordings_dir
6
-
6
+ attr_accessor :verify_recordings
7
+
7
8
  def initialize
8
9
  @recordings_dir = ''
10
+ @verify_recordings = true
9
11
  end
10
-
12
+
11
13
  end
12
-
14
+
13
15
  end
@@ -8,10 +8,11 @@ module Camcorder
8
8
  attr_reader :recordings
9
9
  attr_reader :filename
10
10
 
11
- def initialize(filename)
11
+ def initialize(filename, verify_recordings: Camcorder.config.verify_recordings)
12
12
  @filename = filename
13
13
  @recordings = {}
14
14
  @changed = false
15
+ @verify_recordings = verify_recordings
15
16
  end
16
17
 
17
18
  def transaction(&block)
@@ -51,7 +52,7 @@ module Camcorder
51
52
  ensure
52
53
  @changed = true
53
54
  if recordings.has_key?(key)
54
- if recordings[key] != recording
55
+ unless verify_recordings(recordings[key], recording)
55
56
  raise RecordingError.new(key)
56
57
  end
57
58
  else
@@ -62,6 +63,16 @@ module Camcorder
62
63
  end
63
64
  end
64
65
 
66
+ def verify_recordings(a, b)
67
+ if @verify_recordings.is_a?(Proc)
68
+ @verify_recordings.call(a, b)
69
+ elsif @verify_recordings
70
+ a == b
71
+ else
72
+ true
73
+ end
74
+ end
75
+
65
76
  end
66
77
 
67
78
  end
@@ -1,3 +1,3 @@
1
1
  module Camcorder
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -24,6 +24,67 @@ describe Camcorder::Recorder do
24
24
  end
25
25
  end
26
26
 
27
+ context 'when recordings with same key return different results' do
28
+
29
+ after { File.delete(filename) }
30
+
31
+ let(:filename) { 'spec/fixtures/bad_verification.yml'}
32
+
33
+ it 'raises' do
34
+ expect {
35
+ subject.transaction do
36
+ subject.record 'key' do
37
+ 'dis be da result'
38
+ end
39
+ subject.record 'key' do
40
+ 'dis be a diff result'
41
+ end
42
+ end
43
+ }.to raise_error(Camcorder::RecordingError)
44
+ end
45
+
46
+ context 'when verify_recordings: false' do
47
+
48
+ before { Camcorder.config.verify_recordings = false }
49
+ after { Camcorder.config.verify_recordings = true }
50
+
51
+ it 'does not raise' do
52
+ expect {
53
+ subject.transaction do
54
+ subject.record 'key' do
55
+ 'dis be da result'
56
+ end
57
+ subject.record 'key' do
58
+ 'dis be a diff result'
59
+ end
60
+ end
61
+ }.to_not raise_error
62
+ end
63
+
64
+ end
65
+
66
+
67
+ context 'when verify_recordigs is a proc' do
68
+ before { Camcorder.config.verify_recordings = -> (a,b) { a.value[0..3] == b.value[0..3] } }
69
+ after { Camcorder.config.verify_recordings = true }
70
+
71
+ it 'does not raise' do
72
+ expect {
73
+ subject.transaction do
74
+ subject.record 'key' do
75
+ 'dis be da result'
76
+ end
77
+ subject.record 'key' do
78
+ 'dis be a diff result'
79
+ end
80
+ end
81
+ }.to_not raise_error
82
+ end
83
+
84
+ end
85
+
86
+ end
87
+
27
88
  it 'should error on unknown key' do
28
89
  expect {
29
90
  subject.transaction do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: camcorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gordon L. Hempton