aruba-doubles 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'aruba-doubles'
5
- s.version = '1.1.0'
5
+ s.version = '1.1.1'
6
6
  s.authors = ['Björn Albers']
7
7
  s.email = ['bjoernalbers@googlemail.com']
8
8
  s.description = 'Cucumber Steps to double Command Line Applications'
@@ -1,6 +1,7 @@
1
1
  module ArubaDoubles
2
2
  class Double
3
3
 
4
+ # Keeps track of registered doubles.
4
5
  @doubles = {}
5
6
 
6
7
  class << self
@@ -115,8 +116,8 @@ module ArubaDoubles
115
116
  # Create the executable double.
116
117
  # @return [String] full path to the double.
117
118
  def create(&block)
119
+ register
118
120
  self.instance_eval(&block) if block_given?
119
- self.class.doubles[@filename] = self
120
121
  content = self.to_ruby
121
122
  fullpath = File.join(self.class.bindir, filename)
122
123
  #puts "creating double: #{fullpath} with content:\n#{content}" # debug
@@ -142,8 +143,22 @@ module ArubaDoubles
142
143
 
143
144
  # Delete the executable double.
144
145
  def delete
146
+ deregister
145
147
  fullpath = File.join(self.class.bindir, filename)
146
148
  FileUtils.rm(fullpath) if File.exists?(fullpath)
147
149
  end
150
+
151
+ private
152
+
153
+ # Register the created double.
154
+ def register
155
+ self.class.doubles[filename] = self
156
+ end
157
+
158
+ # Deregister the deleted double.
159
+ def deregister
160
+ self.class.doubles.delete(filename)
161
+ end
162
+
148
163
  end
149
164
  end
@@ -257,12 +257,23 @@ describe ArubaDoubles::Double do
257
257
  end
258
258
 
259
259
  describe '#delete' do
260
- it 'should delete the executable file if it exists' do
260
+ before do
261
+ File.stub(:open).and_return(stub(:puts => nil, :close => nil))
262
+ FileUtils.stub(:chmod)
261
263
  ArubaDoubles::Double.stub(:bindir).and_return('/tmp/foo')
262
- double = ArubaDoubles::Double.new('bar')
264
+ @double = ArubaDoubles::Double.create('bar')
265
+ end
266
+
267
+ it 'should delete the executable file if it exists' do
263
268
  File.should_receive(:exists?).with('/tmp/foo/bar').and_return(true)
264
269
  FileUtils.should_receive(:rm).with('/tmp/foo/bar')
265
- double.delete
270
+ @double.delete
271
+ end
272
+
273
+ it 'should deregister the double' do
274
+ ArubaDoubles::Double.all.should include(@double)
275
+ @double.delete
276
+ ArubaDoubles::Double.all.should_not include(@double)
266
277
  end
267
278
  end
268
279
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aruba-doubles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber
16
- requirement: &70304475014040 !ruby/object:Gem::Requirement
16
+ requirement: &70185558974140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70304475014040
24
+ version_requirements: *70185558974140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70304475013040 !ruby/object:Gem::Requirement
27
+ requirement: &70185558973580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.6.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70304475013040
35
+ version_requirements: *70185558973580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70304475012120 !ruby/object:Gem::Requirement
38
+ requirement: &70185558972880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.9.2.2
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70304475012120
46
+ version_requirements: *70185558972880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: aruba
49
- requirement: &70304475011300 !ruby/object:Gem::Requirement
49
+ requirement: &70185558972260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.4.6
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70304475011300
57
+ version_requirements: *70185558972260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-cucumber
60
- requirement: &70304475010300 !ruby/object:Gem::Requirement
60
+ requirement: &70185558971700 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.7.3
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70304475010300
68
+ version_requirements: *70185558971700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: guard-rspec
71
- requirement: &70304475009200 !ruby/object:Gem::Requirement
71
+ requirement: &70185558971120 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 0.5.1
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70304475009200
79
+ version_requirements: *70185558971120
80
80
  description: Cucumber Steps to double Command Line Applications
81
81
  email:
82
82
  - bjoernalbers@googlemail.com
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: 884917047948355837
120
+ hash: 1055015783693989593
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements:
@@ -126,13 +126,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  segments:
128
128
  - 0
129
- hash: 884917047948355837
129
+ hash: 1055015783693989593
130
130
  requirements: []
131
131
  rubyforge_project:
132
132
  rubygems_version: 1.8.10
133
133
  signing_key:
134
134
  specification_version: 3
135
- summary: aruba-doubles-1.1.0
135
+ summary: aruba-doubles-1.1.1
136
136
  test_files:
137
137
  - features/define_output.feature
138
138
  - features/double_commands.feature