aruba 0.12.0 → 0.13.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -1
  3. data/History.md +75 -55
  4. data/Rakefile +1 -1
  5. data/aruba.gemspec +0 -1
  6. data/features/api/command/run_simple.feature +37 -2
  7. data/features/api/command/stderr.feature +46 -0
  8. data/features/api/command/stdout.feature +46 -0
  9. data/features/configuration/activate_announcer_on_command_failure.feature +38 -0
  10. data/features/steps/command/run.feature +28 -0
  11. data/features/steps/command/shell.feature +155 -0
  12. data/features/steps/core/announce.feature +80 -0
  13. data/features/support/aruba.rb +3 -2
  14. data/lib/aruba/api/command.rb +7 -10
  15. data/lib/aruba/colorizer.rb +108 -0
  16. data/lib/aruba/config.rb +4 -2
  17. data/lib/aruba/cucumber/command.rb +12 -0
  18. data/lib/aruba/cucumber/hooks.rb +10 -0
  19. data/lib/aruba/errors.rb +6 -0
  20. data/lib/aruba/event_bus.rb +59 -0
  21. data/lib/aruba/event_bus/name_resolver.rb +168 -0
  22. data/lib/aruba/generators/script_file.rb +46 -0
  23. data/lib/aruba/matchers/path/have_permissions.rb +1 -1
  24. data/lib/aruba/platforms/announcer.rb +30 -23
  25. data/lib/aruba/platforms/filesystem_status.rb +68 -0
  26. data/lib/aruba/platforms/simple_table.rb +14 -7
  27. data/lib/aruba/platforms/unix_platform.rb +11 -2
  28. data/lib/aruba/platforms/unix_which.rb +0 -2
  29. data/lib/aruba/platforms/windows_which.rb +0 -2
  30. data/lib/aruba/processes/basic_process.rb +8 -0
  31. data/lib/aruba/processes/spawn_process.rb +31 -12
  32. data/lib/aruba/rspec.rb +12 -8
  33. data/lib/aruba/runtime.rb +2 -2
  34. data/lib/aruba/setup.rb +5 -2
  35. data/lib/aruba/version.rb +1 -1
  36. data/script/bootstrap +8 -0
  37. data/spec/aruba/api_spec.rb +1 -1
  38. data/spec/aruba/platform/simple_table_spec.rb +2 -2
  39. data/spec/event_bus/name_resolver_spec.rb +68 -0
  40. data/spec/event_bus_spec.rb +160 -0
  41. data/spec/spec_helper.rb +0 -3
  42. data/spec/support/configs/aruba.rb +5 -0
  43. metadata +22 -17
data/lib/aruba/runtime.rb CHANGED
@@ -2,7 +2,7 @@ require 'aruba/config'
2
2
  require 'aruba/aruba_path'
3
3
  require 'aruba/config_wrapper'
4
4
  require 'aruba/events'
5
- require 'event/bus'
5
+ require 'aruba/event_bus'
6
6
 
7
7
  module Aruba
8
8
  # Runtime of aruba
@@ -40,7 +40,7 @@ module Aruba
40
40
  attr_accessor :config, :environment, :logger, :command_monitor, :announcer, :event_bus
41
41
 
42
42
  def initialize(opts = {})
43
- @event_bus = ::Event::Bus.new(::Event::NameResolver.new(Aruba::Events))
43
+ @event_bus = EventBus.new(EventBus::NameResolver.new(Aruba::Events))
44
44
  @announcer = opts.fetch(:announcer, Aruba.platform.announcer.new)
45
45
  @config = opts.fetch(:config, ConfigWrapper.new(Aruba.config.make_copy, @event_bus))
46
46
  @environment = opts.fetch(:environment, Aruba.platform.environment_variables.new)
data/lib/aruba/setup.rb CHANGED
@@ -37,6 +37,7 @@ module Aruba
37
37
  runtime.announcer.announce :command, event.entity.commandline
38
38
  runtime.announcer.announce :timeout, 'exit', event.entity.exit_timeout
39
39
  runtime.announcer.announce :timeout, 'io wait', event.entity.io_wait_timeout
40
+ runtime.announcer.announce :wait_time, 'startup wait time', event.entity.startup_wait_time
40
41
  runtime.announcer.announce :full_environment, event.entity.environment
41
42
  end
42
43
  )
@@ -52,8 +53,10 @@ module Aruba
52
53
  runtime.event_bus.register(
53
54
  :command_stopped,
54
55
  proc do |event|
55
- runtime.announcer.announce :stdout, event.entity.stdout
56
- runtime.announcer.announce :stderr, event.entity.stderr
56
+ runtime.announcer.announce(:stdout) { event.entity.stdout }
57
+ runtime.announcer.announce(:stderr) { event.entity.stderr }
58
+ runtime.announcer.announce(:command_content) { event.entity.content }
59
+ runtime.announcer.announce(:command_filesystem_status) { event.entity.filesystem_status }
57
60
  end
58
61
  )
59
62
 
data/lib/aruba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Aruba
2
- VERSION = '0.12.0'
2
+ VERSION = '0.13.0'
3
3
  end
data/script/bootstrap CHANGED
@@ -13,6 +13,14 @@ echo -ne "$info_msg Checking if ruby installed? "
13
13
  which 'ruby' >/dev/null 2>error.log || ( echo -e "$error_msg\n\nCould not find \`ruby\`. Please install ruby or add it to PATH"; output_error_log; exit 1 )
14
14
  echo OK
15
15
 
16
+ echo -ne "$info_msg Checking if bash installed? "
17
+ which 'bash' >/dev/null 2>error.log || ( echo -e "$error_msg\n\nCould not find \`bash\`. Please install bash or add it to PATH"; output_error_log; exit 1 )
18
+ echo OK
19
+
20
+ echo -ne "$info_msg Checking if zsh installed? "
21
+ which 'zsh' >/dev/null 2>error.log || ( echo -e "$error_msg\n\nCould not find \`zsh\`. Please install zsh or add it to PATH"; output_error_log; exit 1 )
22
+ echo OK
23
+
16
24
  echo -e "$info_msg rubygem \"bundler\" "
17
25
  gem install bundler
18
26
 
@@ -1081,7 +1081,7 @@ describe Aruba::Api do
1081
1081
  context 'enabled' do
1082
1082
  before :each do
1083
1083
  @aruba.aruba.announcer = instance_double 'Aruba::Platforms::Announcer'
1084
- expect(@aruba.aruba.announcer).to receive(:announce).with(:stdout, "hello world\n")
1084
+ expect(@aruba.aruba.announcer).to receive(:announce).with(:stdout) { "hello world\n" }
1085
1085
  allow(@aruba.aruba.announcer).to receive(:announce)
1086
1086
  end
1087
1087
 
@@ -11,13 +11,13 @@ RSpec.describe '.simple_table' do
11
11
  end
12
12
  let(:rows) { ['# key1 => value', '# key2 => value'] }
13
13
 
14
- it { expect(Aruba.platform.simple_table(hash)).to eq rows }
14
+ it { expect(Aruba.platform.simple_table(hash).to_s).to eq rows.join("\n") }
15
15
  end
16
16
 
17
17
  context 'when empty hash' do
18
18
  let(:hash) { {} }
19
19
  let(:rows) { [] }
20
20
 
21
- it { expect(Aruba.platform.simple_table(hash)).to eq rows }
21
+ it { expect(Aruba.platform.simple_table(hash).to_s).to eq rows.join("\n") }
22
22
  end
23
23
  end
@@ -0,0 +1,68 @@
1
+ require 'aruba/event_bus/name_resolver'
2
+
3
+ describe Aruba::EventBus::NameResolver do
4
+ subject(:resolver) { described_class.new(default_name_space) }
5
+ let(:default_name_space) { 'Events' }
6
+ let(:resolved_name) { resolver.transform(original_name) }
7
+
8
+ before :each do
9
+ stub_const('Events::MyEvent', Class.new)
10
+ stub_const('Events::MyEvent', Class.new)
11
+ end
12
+
13
+ describe '#transform' do
14
+ context 'when name is string' do
15
+ context 'when simple' do
16
+ let(:original_name) { 'Events::MyEvent' }
17
+ it { expect(resolved_name).to eq Events::MyEvent }
18
+ end
19
+
20
+ context 'when prefixed' do
21
+ let(:original_name) { '::Events::MyEvent' }
22
+ it { expect(resolved_name).to eq Events::MyEvent }
23
+ end
24
+ end
25
+
26
+ context 'when name is class' do
27
+ context 'when simple' do
28
+ let(:original_name) { Events::MyEvent }
29
+ it { expect(resolved_name).to eq Events::MyEvent }
30
+ end
31
+
32
+ context 'when prefixed' do
33
+ let(:original_name) { ::Events::MyEvent }
34
+ it { expect(resolved_name).to eq Events::MyEvent }
35
+ end
36
+ end
37
+
38
+ context 'when name is symbol' do
39
+ let(:original_name) { :my_event }
40
+ it { expect(resolved_name).to eq Events::MyEvent }
41
+ end
42
+
43
+ context 'when namespace ...' do
44
+ before :each do
45
+ stub_const('MyLib::Events::MyEvent', Class.new)
46
+ end
47
+
48
+ context 'when is string' do
49
+ let!(:default_name_space) { 'MyLib::Events' }
50
+ let!(:original_name) { :my_event }
51
+
52
+ it { expect(resolved_name).to eq MyLib::Events::MyEvent }
53
+ end
54
+
55
+ context 'when is module' do
56
+ let!(:default_name_space) { MyLib::Events }
57
+ let!(:original_name) { :my_event }
58
+
59
+ it { expect(resolved_name).to eq MyLib::Events::MyEvent }
60
+ end
61
+ end
62
+
63
+ context 'when invalid' do
64
+ let(:original_name) { 1 }
65
+ it { expect { resolved_name }.to raise_error Aruba::EventNameResolveError, /Transforming "1"/ }
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,160 @@
1
+ require 'aruba/event_bus'
2
+
3
+ # rubocop:disable Style/Documentation
4
+ module Events
5
+ class TestEvent; end
6
+ class AnotherTestEvent; end
7
+ module MalformedTestEvent; end
8
+ end
9
+
10
+ class MyHandler
11
+ def call(*); end
12
+ end
13
+
14
+ class MyMalformedHandler; end
15
+ # rubocop:enable Style/Documentation
16
+
17
+ describe Aruba::EventBus do
18
+ subject(:bus) { described_class.new(name_resolver) }
19
+
20
+ let(:name_resolver) { instance_double('Events::NameResolver') }
21
+
22
+ let!(:event_klass) { Events::TestEvent }
23
+ let!(:event_name) { event_klass }
24
+ let!(:event_instance) { Events::TestEvent.new }
25
+
26
+ let!(:another_event_klass) { Events::AnotherTestEvent }
27
+ let!(:another_event_name) { another_event_klass }
28
+ let!(:another_event_instance) { Events::AnotherTestEvent.new }
29
+
30
+ describe '#notify' do
31
+ before(:each) do
32
+ allow(name_resolver).to receive(:transform).with(event_name).and_return(event_klass)
33
+ end
34
+
35
+ context 'when subscriber to event, the block is called and get\'s an instance of the event passed as payload' do
36
+ before :each do
37
+ bus.register(event_klass) do |event|
38
+ @received_payload = event
39
+ end
40
+
41
+ bus.notify event_instance
42
+ end
43
+
44
+ it { expect(@received_payload).to eq(event_instance) }
45
+ end
46
+
47
+ context 'when not subscriber to event' do
48
+ before :each do
49
+ @received_payload = false
50
+ bus.register(event_klass) { @received_payload = true }
51
+ bus.notify another_event_instance
52
+ end
53
+
54
+ it { expect(@received_payload).to eq(false) }
55
+ end
56
+
57
+ context 'when event is not an instance of event class' do
58
+ let!(:event_name) { :test_event }
59
+ let(:received_payload) { [] }
60
+
61
+ before :each do
62
+ bus.register(event_name, proc {})
63
+ end
64
+
65
+ it { expect { bus.notify event_klass }.to raise_error Aruba::NoEventError }
66
+ end
67
+ end
68
+
69
+ describe '#register' do
70
+ before(:each) do
71
+ allow(name_resolver).to receive(:transform).with(event_name).and_return(event_klass)
72
+ end
73
+
74
+ context 'when valid subscriber' do
75
+ context 'when multiple instances are given' do
76
+ let(:received_events) { [] }
77
+
78
+ before :each do
79
+ bus.register(Events::TestEvent) do |event|
80
+ received_events << event
81
+ end
82
+ bus.register(Events::TestEvent) do |event|
83
+ received_events << event
84
+ end
85
+
86
+ bus.notify event_instance
87
+ end
88
+
89
+ it { expect(received_events.length).to eq 2 }
90
+ it { expect(received_events).to all eq event_instance }
91
+ end
92
+
93
+ context 'when is string' do
94
+ let!(:event_name) { event_klass.to_s }
95
+ let(:received_payload) { [] }
96
+
97
+ before :each do
98
+ bus.register(event_klass.to_s) do |event|
99
+ received_payload << event
100
+ end
101
+
102
+ bus.notify event_instance
103
+ end
104
+
105
+ it { expect(received_payload).to include event_instance }
106
+ end
107
+
108
+ context 'when is symbol and event is defined in the default namespace given to NameResolver.new' do
109
+ let!(:event_name) { :test_event }
110
+ let(:received_payload) { [] }
111
+
112
+ before :each do
113
+ bus.register(event_name) do |event|
114
+ received_payload << event
115
+ end
116
+
117
+ bus.notify event_instance
118
+ end
119
+
120
+ it { expect(received_payload).to include event_instance }
121
+ end
122
+ end
123
+
124
+ context 'when valid custom handler' do
125
+ context 'when single event class' do
126
+ before(:each) do
127
+ allow(name_resolver).to receive(:transform).with(event_name).and_return(event_klass)
128
+ end
129
+
130
+ before :each do
131
+ bus.register(event_klass, MyHandler.new)
132
+ end
133
+
134
+ it { expect { bus.notify event_instance }.not_to raise_error }
135
+ end
136
+
137
+ context 'when list of event classes' do
138
+ before(:each) do
139
+ allow(name_resolver).to receive(:transform).with(event_name).and_return(event_klass)
140
+ allow(name_resolver).to receive(:transform).with(another_event_name).and_return(another_event_klass)
141
+ end
142
+
143
+ before :each do
144
+ bus.register([event_klass, another_event_klass], MyHandler.new)
145
+ end
146
+
147
+ it { expect { bus.notify event_instance }.not_to raise_error }
148
+ it { expect { bus.notify another_event_instance }.not_to raise_error }
149
+ end
150
+ end
151
+
152
+ context 'when malformed custom handler' do
153
+ it { expect { bus.register(event_klass, MyMalformedHandler.new) }.to raise_error ArgumentError }
154
+ end
155
+
156
+ context 'when no handler is given' do
157
+ it { expect { bus.register(event_klass) }.to raise_error ArgumentError }
158
+ end
159
+ end
160
+ end
data/spec/spec_helper.rb CHANGED
@@ -10,9 +10,6 @@ SimpleCov.start
10
10
  require 'bundler'
11
11
  Bundler.require
12
12
 
13
- # Activate RSpec Integration
14
- require 'aruba/rspec'
15
-
16
13
  # Loading support files
17
14
  if RUBY_VERSION < '1.9'
18
15
  Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
@@ -0,0 +1,5 @@
1
+ require 'aruba/rspec'
2
+
3
+ Aruba.configure do |config|
4
+ config.activate_announcer_on_command_failure = [:stderr, :stdout, :command]
5
+ 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.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aslak Hellesøy
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2016-01-03 00:00:00.000000000 Z
16
+ date: 2016-01-26 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: cucumber
@@ -99,20 +99,6 @@ dependencies:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0.19'
102
- - !ruby/object:Gem::Dependency
103
- name: event-bus
104
- requirement: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '0.2'
109
- type: :runtime
110
- prerelease: false
111
- version_requirements: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - "~>"
114
- - !ruby/object:Gem::Version
115
- version: '0.2'
116
102
  - !ruby/object:Gem::Dependency
117
103
  name: bundler
118
104
  requirement: !ruby/object:Gem::Requirement
@@ -162,6 +148,8 @@ files:
162
148
  - features/api/command/run.feature
163
149
  - features/api/command/run_simple.feature
164
150
  - features/api/command/send_signal.feature
151
+ - features/api/command/stderr.feature
152
+ - features/api/command/stdout.feature
165
153
  - features/api/command/stop.feature
166
154
  - features/api/command/stop_all_commands.feature
167
155
  - features/api/command/terminate_all_commands.feature
@@ -187,6 +175,7 @@ files:
187
175
  - features/api/text/unescape_text.feature
188
176
  - features/cli/console.feature
189
177
  - features/cli/init.feature
178
+ - features/configuration/activate_announcer_on_command_failure.feature
190
179
  - features/configuration/command_runtime_environment.feature
191
180
  - features/configuration/console_history_file.feature
192
181
  - features/configuration/exit_timeout.feature
@@ -233,6 +222,7 @@ files:
233
222
  - features/steps/command/output.feature
234
223
  - features/steps/command/run.feature
235
224
  - features/steps/command/send_signal.feature
225
+ - features/steps/command/shell.feature
236
226
  - features/steps/command/stderr.feature
237
227
  - features/steps/command/stdout.feature
238
228
  - features/steps/command/stop.feature
@@ -302,6 +292,7 @@ files:
302
292
  - lib/aruba/basic_configuration.rb
303
293
  - lib/aruba/basic_configuration/option.rb
304
294
  - lib/aruba/cli.rb
295
+ - lib/aruba/colorizer.rb
305
296
  - lib/aruba/command.rb
306
297
  - lib/aruba/config.rb
307
298
  - lib/aruba/config/jruby.rb
@@ -321,9 +312,12 @@ files:
321
312
  - lib/aruba/cucumber/rvm.rb
322
313
  - lib/aruba/cucumber/testing_frameworks.rb
323
314
  - lib/aruba/errors.rb
315
+ - lib/aruba/event_bus.rb
316
+ - lib/aruba/event_bus/name_resolver.rb
324
317
  - lib/aruba/events.rb
325
318
  - lib/aruba/extensions/string/strip.rb
326
319
  - lib/aruba/file_size.rb
320
+ - lib/aruba/generators/script_file.rb
327
321
  - lib/aruba/hooks.rb
328
322
  - lib/aruba/in_config_wrapper.rb
329
323
  - lib/aruba/in_process.rb
@@ -373,6 +367,7 @@ files:
373
367
  - lib/aruba/platforms/determine_disk_usage.rb
374
368
  - lib/aruba/platforms/determine_file_size.rb
375
369
  - lib/aruba/platforms/disk_usage_calculator.rb
370
+ - lib/aruba/platforms/filesystem_status.rb
376
371
  - lib/aruba/platforms/local_environment.rb
377
372
  - lib/aruba/platforms/simple_table.rb
378
373
  - lib/aruba/platforms/unix_command_string.rb
@@ -417,8 +412,11 @@ files:
417
412
  - spec/aruba/rspec_spec.rb
418
413
  - spec/aruba/runtime_spec.rb
419
414
  - spec/aruba/spawn_process_spec.rb
415
+ - spec/event_bus/name_resolver_spec.rb
416
+ - spec/event_bus_spec.rb
420
417
  - spec/spec_helper.rb
421
418
  - spec/support/configs/.keep
419
+ - spec/support/configs/aruba.rb
422
420
  - spec/support/configs/pry.rb
423
421
  - spec/support/configs/rspec.rb
424
422
  - spec/support/helpers/.keep
@@ -475,7 +473,7 @@ rubyforge_project:
475
473
  rubygems_version: 2.5.1
476
474
  signing_key:
477
475
  specification_version: 4
478
- summary: aruba-0.12.0
476
+ summary: aruba-0.13.0
479
477
  test_files:
480
478
  - features/api/command/find_command.feature
481
479
  - features/api/command/last_command_started.feature
@@ -483,6 +481,8 @@ test_files:
483
481
  - features/api/command/run.feature
484
482
  - features/api/command/run_simple.feature
485
483
  - features/api/command/send_signal.feature
484
+ - features/api/command/stderr.feature
485
+ - features/api/command/stdout.feature
486
486
  - features/api/command/stop.feature
487
487
  - features/api/command/stop_all_commands.feature
488
488
  - features/api/command/terminate_all_commands.feature
@@ -508,6 +508,7 @@ test_files:
508
508
  - features/api/text/unescape_text.feature
509
509
  - features/cli/console.feature
510
510
  - features/cli/init.feature
511
+ - features/configuration/activate_announcer_on_command_failure.feature
511
512
  - features/configuration/command_runtime_environment.feature
512
513
  - features/configuration/console_history_file.feature
513
514
  - features/configuration/exit_timeout.feature
@@ -554,6 +555,7 @@ test_files:
554
555
  - features/steps/command/output.feature
555
556
  - features/steps/command/run.feature
556
557
  - features/steps/command/send_signal.feature
558
+ - features/steps/command/shell.feature
557
559
  - features/steps/command/stderr.feature
558
560
  - features/steps/command/stdout.feature
559
561
  - features/steps/command/stop.feature
@@ -605,8 +607,11 @@ test_files:
605
607
  - spec/aruba/rspec_spec.rb
606
608
  - spec/aruba/runtime_spec.rb
607
609
  - spec/aruba/spawn_process_spec.rb
610
+ - spec/event_bus/name_resolver_spec.rb
611
+ - spec/event_bus_spec.rb
608
612
  - spec/spec_helper.rb
609
613
  - spec/support/configs/.keep
614
+ - spec/support/configs/aruba.rb
610
615
  - spec/support/configs/pry.rb
611
616
  - spec/support/configs/rspec.rb
612
617
  - spec/support/helpers/.keep