aruba 0.4.10 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/History.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [v0.4.11](https://github.com/cucumber/aruba/compare/v0.4.10...v0.4.11)
2
+ * Fix duplicated output (#91 Robert Wahler, Matt Wynne)
3
+ * Fix Gemspec format (#101 Matt Wynne)
4
+
1
5
  ## [v0.4.10](https://github.com/cucumber/aruba/compare/v0.4.9...v0.4.10)
2
6
  * Fix broken JRuby file following rename of hook (Thomas Reynolds)
3
7
  * Add terminate method to API (Taylor Carpenter)
data/Rakefile CHANGED
@@ -12,8 +12,14 @@ Cucumber::Rake::Task.new do |t|
12
12
  t.cucumber_opts = opts
13
13
  end
14
14
 
15
- task :spec do
16
- sh('rspec --color')
15
+ require 'rspec/core/rake_task'
16
+ desc "Run RSpec"
17
+ RSpec::Core::RakeTask.new do |spec|
18
+ spec.pattern = 'spec/**/*_spec.rb'
19
+ spec.rspec_opts = ['--color', '--format nested']
17
20
  end
18
21
 
19
- task :default => [:spec, :cucumber]
22
+ desc "Run tests, both RSpec and Cucumber"
23
+ task :test => [:spec, :cucumber]
24
+
25
+ task :default => :test
data/aruba.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'aruba'
5
- s.version = '0.4.10'
5
+ s.version = '0.4.11'
6
6
  s.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak", "Matt Wynne"]
7
7
  s.description = 'CLI Steps for Cucumber, hand-crafted for you in Aruba'
8
8
  s.summary = "aruba-#{s.version}"
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
 
12
12
  s.add_runtime_dependency 'cucumber', '>= 1.1.1'
13
13
  s.add_runtime_dependency 'childprocess', '>= 0.2.3'
14
- s.add_runtime_dependency 'ffi', '1.0.11'
14
+ s.add_runtime_dependency 'ffi', '>= 1.0.11'
15
15
  s.add_runtime_dependency 'rspec', '>= 2.7.0'
16
16
  s.add_development_dependency 'bcat', '>= 0.6.1'
17
17
  s.add_development_dependency 'rdiscount', '>= 1.6.8'
data/lib/aruba/api.rb CHANGED
@@ -267,8 +267,8 @@ module Aruba
267
267
  in_current_dir do
268
268
  Aruba.config.hooks.execute(:before_cmd, self, cmd)
269
269
 
270
- announce_or_puts("$ cd #{Dir.pwd}") if @announce_dir
271
- announce_or_puts("$ #{cmd}") if @announce_cmd
270
+ announcer.dir(Dir.pwd)
271
+ announcer.cmd(cmd)
272
272
 
273
273
  process = Process.new(cmd, exit_timeout, io_wait)
274
274
  register_process(cmd, process)
@@ -359,7 +359,7 @@ module Aruba
359
359
  end
360
360
 
361
361
  def set_env(key, value)
362
- announce_or_puts(%{$ export #{key}="#{value}"}) if @announce_env
362
+ announcer.env(key, value)
363
363
  original_env[key] = ENV.delete(key)
364
364
  ENV[key] = value
365
365
  end
@@ -384,13 +384,58 @@ module Aruba
384
384
  end
385
385
 
386
386
  def stop_process(process)
387
- @last_exit_status = process.stop(@aruba_keep_ansi)
388
- announce_or_puts(process.stdout(@aruba_keep_ansi)) if @announce_stdout
389
- announce_or_puts(process.stderr(@aruba_keep_ansi)) if @announce_stderr
387
+ @last_exit_status = process.stop(announcer, @aruba_keep_ansi)
390
388
  end
391
389
 
392
390
  def terminate_process(process)
393
391
  process.terminate(@aruba_keep_ansi)
394
392
  end
393
+
394
+ def announcer
395
+ Announcer.new(self,
396
+ :stdout => @announce_stdout,
397
+ :stderr => @announce_stderr,
398
+ :dir => @announce_dir,
399
+ :cmd => @announce_cmd,
400
+ :env => @announce_env)
401
+ end
402
+
403
+ class Announcer
404
+ def initialize(session, options = {})
405
+ @session, @options = session, options
406
+ end
407
+
408
+ def stdout(content)
409
+ return unless @options[:stdout]
410
+ print content
411
+ end
412
+
413
+ def stderr(content)
414
+ return unless @options[:stderr]
415
+ print content
416
+ end
417
+
418
+ def dir(dir)
419
+ return unless @options[:dir]
420
+ print "$ cd #{dir}"
421
+ end
422
+
423
+ def cmd(cmd)
424
+ return unless @options[:cmd]
425
+ print "$ #{cmd}"
426
+ end
427
+
428
+ def env(key, value)
429
+ return unless @options[:env]
430
+ print %{$ export #{key}="#{value}"}
431
+ end
432
+
433
+ private
434
+
435
+ def print(message)
436
+ @session.announce_or_puts(message)
437
+ end
438
+ end
439
+
395
440
  end
396
441
  end
data/lib/aruba/process.rb CHANGED
@@ -48,12 +48,14 @@ module Aruba
48
48
  end
49
49
  end
50
50
 
51
- def stop(keep_ansi)
52
- if @process
53
- stdout(keep_ansi) && stderr(keep_ansi) # flush output
51
+ def stop(reader, keep_ansi)
52
+ return unless @process
53
+ unless @process.exited?
54
+ reader.stdout stdout(keep_ansi)
55
+ reader.stderr stderr(keep_ansi)
54
56
  @process.poll_for_exit(@exit_timeout)
55
- @process.exit_code
56
57
  end
58
+ @process.exit_code
57
59
  end
58
60
 
59
61
  def terminate(keep_ansi)
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Aruba::Api do
4
+
5
+ before(:each) do
6
+ klass = Class.new {
7
+ include Aruba::Api
8
+
9
+ def set_tag(tag_name, value)
10
+ self.instance_variable_set "@#{tag_name.to_s}", value
11
+ end
12
+
13
+ def announce_or_puts(*args)
14
+ p caller[0..2]
15
+ end
16
+ }
17
+ @aruba = klass.new
18
+ end
19
+
20
+ describe 'current_dir' do
21
+ it "should return the current dir as 'tmp/aruba'" do
22
+ @aruba.current_dir.should match(/^tmp\/aruba$/)
23
+ end
24
+ end
25
+
26
+ describe 'tags' do
27
+ describe '@announce_stdout' do
28
+
29
+ context 'enabled' do
30
+ it "should announce to stdout exactly once" do
31
+ @aruba.should_receive(:announce_or_puts).once
32
+ @aruba.set_tag(:announce_stdout, true)
33
+ @aruba.run_simple("ruby -e 'puts \"hello world\"'", false)
34
+ @aruba.all_output.should match(/hello world/)
35
+ end
36
+ end
37
+
38
+ context 'disabled' do
39
+ it "should not announce to stdout" do
40
+ @aruba.should_not_receive(:announce_or_puts)
41
+ @aruba.set_tag(:announce_stdout, false)
42
+ @aruba.run_simple("ruby -e 'puts \"hello world\"'", false)
43
+ @aruba.all_output.should match(/hello world/)
44
+ end
45
+ end
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,33 @@
1
+ require 'aruba/process'
2
+
3
+ module Aruba
4
+ describe Process do
5
+
6
+ let(:process) { Process.new('echo "yo"', 0, 0.1) }
7
+
8
+ describe "#stdout" do
9
+ before { process.run! }
10
+
11
+ it "returns the stdout" do
12
+ process.stdout(false).should == "yo\n"
13
+ end
14
+
15
+ it "returns all the stdout, every time you call it" do
16
+ process.stdout(false).should == "yo\n"
17
+ process.stdout(false).should == "yo\n"
18
+ end
19
+
20
+ end
21
+
22
+ describe "#stop" do
23
+ before { process.run! }
24
+
25
+ it "sends any output to the reader" do
26
+ reader = stub.as_null_object
27
+ reader.should_receive(:stdout).with("yo\n")
28
+ process.stop(reader, false)
29
+ end
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,8 @@
1
+ require 'rspec/core'
2
+ require 'aruba/api'
3
+
4
+ RSpec.configure do |config|
5
+ config.filter_run :focus => true
6
+ config.run_all_when_everything_filtered = true
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aruba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.10
4
+ version: 0.4.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,11 +12,11 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2011-12-24 00:00:00.000000000 Z
15
+ date: 2011-12-27 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: cucumber
19
- requirement: &2156939920 !ruby/object:Gem::Requirement
19
+ requirement: &2156140500 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: 1.1.1
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *2156939920
27
+ version_requirements: *2156140500
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: childprocess
30
- requirement: &2156939200 !ruby/object:Gem::Requirement
30
+ requirement: &2156139860 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,21 +35,21 @@ dependencies:
35
35
  version: 0.2.3
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *2156939200
38
+ version_requirements: *2156139860
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: ffi
41
- requirement: &2156938420 !ruby/object:Gem::Requirement
41
+ requirement: &2156139040 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
- - - =
44
+ - - ! '>='
45
45
  - !ruby/object:Gem::Version
46
46
  version: 1.0.11
47
47
  type: :runtime
48
48
  prerelease: false
49
- version_requirements: *2156938420
49
+ version_requirements: *2156139040
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rspec
52
- requirement: &2156936800 !ruby/object:Gem::Requirement
52
+ requirement: &2156137020 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ! '>='
@@ -57,10 +57,10 @@ dependencies:
57
57
  version: 2.7.0
58
58
  type: :runtime
59
59
  prerelease: false
60
- version_requirements: *2156936800
60
+ version_requirements: *2156137020
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: bcat
63
- requirement: &2156936240 !ruby/object:Gem::Requirement
63
+ requirement: &2156135300 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ! '>='
@@ -68,10 +68,10 @@ dependencies:
68
68
  version: 0.6.1
69
69
  type: :development
70
70
  prerelease: false
71
- version_requirements: *2156936240
71
+ version_requirements: *2156135300
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: rdiscount
74
- requirement: &2156935720 !ruby/object:Gem::Requirement
74
+ requirement: &2156134580 !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
77
77
  - - ! '>='
@@ -79,10 +79,10 @@ dependencies:
79
79
  version: 1.6.8
80
80
  type: :development
81
81
  prerelease: false
82
- version_requirements: *2156935720
82
+ version_requirements: *2156134580
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
- requirement: &2156935260 !ruby/object:Gem::Requirement
85
+ requirement: &2152010020 !ruby/object:Gem::Requirement
86
86
  none: false
87
87
  requirements:
88
88
  - - ! '>='
@@ -90,7 +90,7 @@ dependencies:
90
90
  version: 0.9.2
91
91
  type: :development
92
92
  prerelease: false
93
- version_requirements: *2156935260
93
+ version_requirements: *2152010020
94
94
  description: CLI Steps for Cucumber, hand-crafted for you in Aruba
95
95
  email: cukes@googlegroups.com
96
96
  executables: []
@@ -99,6 +99,7 @@ extra_rdoc_files: []
99
99
  files:
100
100
  - .document
101
101
  - .gitignore
102
+ - .rspec
102
103
  - .rvmrc
103
104
  - .travis.yml
104
105
  - Gemfile
@@ -126,7 +127,10 @@ files:
126
127
  - lib/aruba/jruby.rb
127
128
  - lib/aruba/process.rb
128
129
  - lib/aruba/reporting.rb
130
+ - spec/aruba/api_spec.rb
129
131
  - spec/aruba/hooks_spec.rb
132
+ - spec/aruba/process_spec.rb
133
+ - spec/spec_helper.rb
130
134
  - templates/css/console.css
131
135
  - templates/css/filesystem.css
132
136
  - templates/css/pygments-autumn.css
@@ -155,7 +159,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
159
  version: '0'
156
160
  segments:
157
161
  - 0
158
- hash: -344874369697524024
162
+ hash: -1684218897228509684
159
163
  required_rubygems_version: !ruby/object:Gem::Requirement
160
164
  none: false
161
165
  requirements:
@@ -164,13 +168,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
168
  version: '0'
165
169
  segments:
166
170
  - 0
167
- hash: -344874369697524024
171
+ hash: -1684218897228509684
168
172
  requirements: []
169
173
  rubyforge_project:
170
174
  rubygems_version: 1.8.10
171
175
  signing_key:
172
176
  specification_version: 3
173
- summary: aruba-0.4.10
177
+ summary: aruba-0.4.11
174
178
  test_files:
175
179
  - features/before_cmd_hooks.feature
176
180
  - features/exit_statuses.feature
@@ -181,4 +185,7 @@ test_files:
181
185
  - features/output.feature
182
186
  - features/step_definitions/aruba_dev_steps.rb
183
187
  - features/support/env.rb
188
+ - spec/aruba/api_spec.rb
184
189
  - spec/aruba/hooks_spec.rb
190
+ - spec/aruba/process_spec.rb
191
+ - spec/spec_helper.rb