aruba 2.1.0 → 2.3.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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +90 -39
  3. data/CONTRIBUTING.md +0 -1
  4. data/LICENSE +19 -17
  5. data/README.md +5 -6
  6. data/exe/aruba +3 -2
  7. data/lib/aruba/api/bundler.rb +4 -2
  8. data/lib/aruba/api/commands.rb +10 -8
  9. data/lib/aruba/api/core.rb +34 -32
  10. data/lib/aruba/api/environment.rb +4 -2
  11. data/lib/aruba/api/filesystem.rb +17 -19
  12. data/lib/aruba/api/text.rb +5 -3
  13. data/lib/aruba/api.rb +13 -11
  14. data/lib/aruba/{platforms/aruba_logger.rb → aruba_logger.rb} +4 -2
  15. data/lib/aruba/aruba_path.rb +4 -2
  16. data/lib/aruba/basic_configuration/option.rb +2 -0
  17. data/lib/aruba/basic_configuration.rb +15 -13
  18. data/lib/aruba/cli.rb +10 -8
  19. data/lib/aruba/colorizer.rb +2 -0
  20. data/lib/aruba/command.rb +10 -6
  21. data/lib/aruba/{platforms/command_monitor.rb → command_monitor.rb} +7 -5
  22. data/lib/aruba/config/jruby.rb +11 -9
  23. data/lib/aruba/config_wrapper.rb +4 -2
  24. data/lib/aruba/configuration.rb +17 -15
  25. data/lib/aruba/console/help.rb +7 -5
  26. data/lib/aruba/console.rb +12 -11
  27. data/lib/aruba/contracts/absolute_path.rb +3 -1
  28. data/lib/aruba/contracts/enum.rb +3 -1
  29. data/lib/aruba/contracts/is_power_of_two.rb +4 -2
  30. data/lib/aruba/contracts/relative_path.rb +3 -1
  31. data/lib/aruba/cucumber/command.rb +108 -99
  32. data/lib/aruba/cucumber/environment.rb +9 -7
  33. data/lib/aruba/cucumber/file.rb +4 -2
  34. data/lib/aruba/cucumber/hooks.rb +31 -29
  35. data/lib/aruba/cucumber/parameter_types.rb +4 -1
  36. data/lib/aruba/cucumber/testing_frameworks.rb +20 -18
  37. data/lib/aruba/cucumber.rb +10 -8
  38. data/lib/aruba/errors.rb +2 -6
  39. data/lib/aruba/event_bus.rb +8 -47
  40. data/lib/aruba/events.rb +15 -7
  41. data/lib/aruba/file_size.rb +3 -1
  42. data/lib/aruba/generators/script_file.rb +4 -2
  43. data/lib/aruba/hooks.rb +2 -0
  44. data/lib/aruba/in_config_wrapper.rb +3 -1
  45. data/lib/aruba/initializer.rb +25 -42
  46. data/lib/aruba/matchers/base/message_indenter.rb +3 -1
  47. data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
  48. data/lib/aruba/matchers/command/have_exit_status.rb +2 -0
  49. data/lib/aruba/matchers/command/have_finished_in_time.rb +2 -0
  50. data/lib/aruba/matchers/command/have_output.rb +3 -1
  51. data/lib/aruba/matchers/command/have_output_on_stderr.rb +2 -0
  52. data/lib/aruba/matchers/command/have_output_on_stdout.rb +2 -0
  53. data/lib/aruba/matchers/command/have_output_size.rb +21 -5
  54. data/lib/aruba/matchers/command.rb +3 -1
  55. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +3 -1
  56. data/lib/aruba/matchers/directory/have_sub_directory.rb +4 -2
  57. data/lib/aruba/matchers/directory.rb +3 -1
  58. data/lib/aruba/matchers/environment.rb +3 -1
  59. data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +7 -5
  60. data/lib/aruba/matchers/file/be_an_existing_executable.rb +3 -1
  61. data/lib/aruba/matchers/file/be_an_existing_file.rb +3 -1
  62. data/lib/aruba/matchers/file/have_file_content.rb +2 -0
  63. data/lib/aruba/matchers/file/have_file_size.rb +2 -0
  64. data/lib/aruba/matchers/file/have_same_file_content.rb +3 -1
  65. data/lib/aruba/matchers/file.rb +3 -1
  66. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -0
  67. data/lib/aruba/matchers/path/be_an_absolute_path.rb +2 -0
  68. data/lib/aruba/matchers/path/be_an_existing_path.rb +2 -0
  69. data/lib/aruba/matchers/path/have_permissions.rb +3 -1
  70. data/lib/aruba/matchers/path.rb +3 -1
  71. data/lib/aruba/matchers/string/include_output_string.rb +3 -1
  72. data/lib/aruba/matchers/string/match_output_string.rb +3 -1
  73. data/lib/aruba/matchers/string/output_string_eq.rb +3 -1
  74. data/lib/aruba/matchers/string.rb +3 -1
  75. data/lib/aruba/platform.rb +4 -2
  76. data/lib/aruba/platforms/announcer.rb +16 -14
  77. data/lib/aruba/platforms/aruba_file_creator.rb +2 -0
  78. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +3 -1
  79. data/lib/aruba/platforms/determine_disk_usage.rb +3 -1
  80. data/lib/aruba/platforms/determine_file_size.rb +2 -0
  81. data/lib/aruba/platforms/filesystem_status.rb +3 -1
  82. data/lib/aruba/platforms/local_environment.rb +9 -1
  83. data/lib/aruba/platforms/simple_table.rb +4 -2
  84. data/lib/aruba/platforms/unix_command_string.rb +4 -2
  85. data/lib/aruba/platforms/unix_environment_variables.rb +4 -2
  86. data/lib/aruba/platforms/unix_platform.rb +32 -26
  87. data/lib/aruba/platforms/unix_which.rb +3 -1
  88. data/lib/aruba/platforms/windows_command_string.rb +3 -18
  89. data/lib/aruba/platforms/windows_environment_variables.rb +3 -1
  90. data/lib/aruba/platforms/windows_platform.rb +12 -6
  91. data/lib/aruba/platforms/windows_which.rb +7 -5
  92. data/lib/aruba/processes/basic_process.rb +5 -3
  93. data/lib/aruba/processes/debug_process.rb +8 -6
  94. data/lib/aruba/processes/in_process.rb +11 -8
  95. data/lib/aruba/processes/spawn_process.rb +110 -37
  96. data/lib/aruba/rspec.rb +8 -6
  97. data/lib/aruba/runtime.rb +9 -7
  98. data/lib/aruba/setup.rb +8 -6
  99. data/lib/aruba/version.rb +3 -1
  100. data/lib/aruba.rb +3 -1
  101. metadata +24 -99
  102. data/lib/aruba/event_bus/name_resolver.rb +0 -158
@@ -1,6 +1,8 @@
1
- require "aruba/aruba_path"
2
- require "aruba/api"
3
- require "aruba/platform"
1
+ # frozen_string_literal: true
2
+
3
+ require 'aruba/aruba_path'
4
+ require 'aruba/api'
5
+ require 'aruba/platform'
4
6
  World(Aruba::Api)
5
7
 
6
8
  Around do |_, block|
@@ -10,10 +12,10 @@ end
10
12
  Before do
11
13
  # ... so every change needs to be done later
12
14
  prepend_environment_variable(
13
- "PATH",
15
+ 'PATH',
14
16
  aruba.config.command_search_paths.join(File::PATH_SEPARATOR) + File::PATH_SEPARATOR
15
17
  )
16
- set_environment_variable "HOME", aruba.config.home_directory
18
+ set_environment_variable 'HOME', aruba.config.home_directory
17
19
  end
18
20
 
19
21
  After do
@@ -21,68 +23,68 @@ After do
21
23
  aruba.command_monitor.clear
22
24
  end
23
25
 
24
- Before("@no-clobber") do
26
+ Before('@no-clobber') do
25
27
  setup_aruba(false)
26
28
  end
27
29
 
28
- Before("~@no-clobber") do
30
+ Before('~@no-clobber') do
29
31
  setup_aruba
30
32
  end
31
33
 
32
- Before("@puts") do
34
+ Before('@puts') do
33
35
  aruba.announcer.mode = :puts
34
36
  end
35
37
 
36
- Before("@announce-command") do
38
+ Before('@announce-command') do
37
39
  aruba.announcer.activate :command
38
40
  end
39
41
 
40
- Before("@announce-command-content") do
42
+ Before('@announce-command-content') do
41
43
  aruba.announcer.activate :command_content
42
44
  end
43
45
 
44
- Before("@announce-command-filesystem-status") do
46
+ Before('@announce-command-filesystem-status') do
45
47
  aruba.announcer.activate :command_filesystem_status
46
48
  end
47
49
 
48
- Before("@announce-output") do
50
+ Before('@announce-output') do
49
51
  aruba.announcer.activate :stdout
50
52
  aruba.announcer.activate :stderr
51
53
  end
52
54
 
53
- Before("@announce-stdout") do
55
+ Before('@announce-stdout') do
54
56
  aruba.announcer.activate :stdout
55
57
  end
56
58
 
57
- Before("@announce-stderr") do
59
+ Before('@announce-stderr') do
58
60
  aruba.announcer.activate :stderr
59
61
  end
60
62
 
61
- Before("@announce-directory") do
63
+ Before('@announce-directory') do
62
64
  aruba.announcer.activate :directory
63
65
  end
64
66
 
65
- Before("@announce-stop-signal") do
67
+ Before('@announce-stop-signal') do
66
68
  aruba.announcer.activate :stop_signal
67
69
  end
68
70
 
69
- Before("@announce-full-environment") do
71
+ Before('@announce-full-environment') do
70
72
  aruba.announcer.activate :full_environment
71
73
  end
72
74
 
73
- Before("@announce-changed-environment") do
75
+ Before('@announce-changed-environment') do
74
76
  aruba.announcer.activate :changed_environment
75
77
  end
76
78
 
77
- Before("@announce-timeout") do
79
+ Before('@announce-timeout') do
78
80
  aruba.announcer.activate :timeout
79
81
  end
80
82
 
81
- Before("@announce-wait-time") do
83
+ Before('@announce-wait-time') do
82
84
  aruba.announcer.activate :wait_time
83
85
  end
84
86
 
85
- Before("@announce") do
87
+ Before('@announce') do
86
88
  aruba.announcer.activate :changed_environment
87
89
  aruba.announcer.activate :command
88
90
  aruba.announcer.activate :directory
@@ -98,30 +100,30 @@ Before("@announce") do
98
100
  aruba.announcer.activate :command_filesystem_status
99
101
  end
100
102
 
101
- Before("@keep-ansi-escape-sequences") do
103
+ Before('@keep-ansi-escape-sequences') do
102
104
  aruba.config.remove_ansi_escape_sequences = false
103
105
  end
104
106
 
105
- Before "@mocked-home-directory" do
106
- set_environment_variable "HOME", expand_path(".")
107
+ Before '@mocked-home-directory' do
108
+ set_environment_variable 'HOME', expand_path('.')
107
109
  end
108
110
 
109
- Before("@disable-bundler") do
111
+ Before('@disable-bundler') do
110
112
  unset_bundler_env_vars
111
113
  end
112
114
 
113
- Before("@debug") do
115
+ Before('@debug') do
114
116
  aruba.config.command_launcher = :debug
115
117
  end
116
118
 
117
- Before("@command-launcher-spawn") do
119
+ Before('@command-launcher-spawn') do
118
120
  aruba.config.command_launcher = :spawn
119
121
  end
120
122
 
121
- Before("@command-launcher-in-process") do
123
+ Before('@command-launcher-in-process') do
122
124
  aruba.config.command_launcher = :in_process
123
125
  end
124
126
 
125
- Before("@command-launcher-debug") do
127
+ Before('@command-launcher-debug') do
126
128
  aruba.config.command_launcher = :debug
127
129
  end
@@ -1 +1,4 @@
1
- ParameterType(name: "channel", regexp: "output|stderr|stdout", transformer: ->(name) { name })
1
+ # frozen_string_literal: true
2
+
3
+ ParameterType(name: 'channel', regexp: 'output|stderr|stdout', transformer: ->(name) { name })
4
+ ParameterType(name: 'command', regexp: '`([^`]*)`', transformer: ->(name) { name })
@@ -1,25 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Cucumber
2
4
  Then(/^the feature(?:s)? should not(?: all)? pass$/) do
3
5
  step 'the output should contain " failed)"'
4
- step "the exit status should be 1"
6
+ step 'the exit status should be 1'
5
7
  end
6
8
 
7
9
  # Cucumber
8
10
  Then(/^the feature(?:s)? should(?: all)? pass$/) do
9
11
  step 'the output should not contain " failed)"'
10
12
  step 'the output should not contain " undefined)"'
11
- step "the exit status should be 0"
13
+ step 'the exit status should be 0'
12
14
  end
13
15
 
14
16
  # Cucumber
15
17
  Then(/^the feature(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string|
16
18
  step 'the output should contain " failed)"'
17
- step "the exit status should be 1"
19
+ step 'the exit status should be 1'
18
20
 
19
21
  if regex
20
22
  step "the output should match %r<#{string}>"
21
23
  else
22
- step "the output should contain:", string
24
+ step 'the output should contain:', string
23
25
  end
24
26
  end
25
27
 
@@ -27,12 +29,12 @@ end
27
29
  Then(/^the feature(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string|
28
30
  step 'the output should not contain " failed)"'
29
31
  step 'the output should not contain " undefined)"'
30
- step "the exit status should be 0"
32
+ step 'the exit status should be 0'
31
33
 
32
34
  if regex
33
35
  step "the output should match %r<#{string}>"
34
36
  else
35
- step "the output should contain:", string
37
+ step 'the output should contain:', string
36
38
  end
37
39
  end
38
40
 
@@ -45,36 +47,36 @@ Then(/^the spec(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) \
45
47
  step %(the output should contain "#{count_failures} failures")
46
48
  end
47
49
 
48
- step "the exit status should be 1"
50
+ step 'the exit status should be 1'
49
51
  end
50
52
 
51
53
  # RSpec
52
54
  Then(/^the spec(?:s)? should all pass$/) do
53
55
  step 'the output should contain "0 failures"'
54
- step "the exit status should be 0"
56
+ step 'the exit status should be 0'
55
57
  end
56
58
 
57
59
  # RSpec
58
60
  Then(/^the spec(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string|
59
61
  step 'the output should not contain "0 failures"'
60
- step "the exit status should be 1"
62
+ step 'the exit status should be 1'
61
63
 
62
64
  if regex
63
65
  step "the output should match %r<#{string}>"
64
66
  else
65
- step "the output should contain:", string
67
+ step 'the output should contain:', string
66
68
  end
67
69
  end
68
70
 
69
71
  # RSpec
70
72
  Then(/^the spec(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string|
71
73
  step 'the output should contain "0 failures"'
72
- step "the exit status should be 0"
74
+ step 'the exit status should be 0'
73
75
 
74
76
  if regex
75
77
  step "the output should match %r<#{string}>"
76
78
  else
77
- step "the output should contain:", string
79
+ step 'the output should contain:', string
78
80
  end
79
81
  end
80
82
 
@@ -87,35 +89,35 @@ Then(/^the tests(?:s)? should not(?: all)? pass(?: with (\d+) failures?)?$/) \
87
89
  step %(the output should contain "#{count_failures} errors")
88
90
  end
89
91
 
90
- step "the exit status should be 1"
92
+ step 'the exit status should be 1'
91
93
  end
92
94
 
93
95
  # Minitest
94
96
  Then(/^the tests(?:s)? should all pass$/) do
95
97
  step 'the output should contain "0 errors"'
96
- step "the exit status should be 0"
98
+ step 'the exit status should be 0'
97
99
  end
98
100
 
99
101
  # Minitest
100
102
  Then(/^the test(?:s)? should not(?: all)? pass with( regex)?:$/) do |regex, string|
101
103
  step 'the output should contain "0 errors"'
102
- step "the exit status should be 1"
104
+ step 'the exit status should be 1'
103
105
 
104
106
  if regex
105
107
  step "the output should match %r<#{string}>"
106
108
  else
107
- step "the output should contain:", string
109
+ step 'the output should contain:', string
108
110
  end
109
111
  end
110
112
 
111
113
  # Minitest
112
114
  Then(/^the test(?:s)? should(?: all)? pass with( regex)?:$/) do |regex, string|
113
115
  step 'the output should not contain "0 errors"'
114
- step "the exit status should be 0"
116
+ step 'the exit status should be 0'
115
117
 
116
118
  if regex
117
119
  step "the output should match %r<#{string}>"
118
120
  else
119
- step "the output should contain:", string
121
+ step 'the output should contain:', string
120
122
  end
121
123
  end
@@ -1,9 +1,11 @@
1
- require "aruba/version"
1
+ # frozen_string_literal: true
2
2
 
3
- require "aruba/api"
4
- require "aruba/cucumber/hooks"
5
- require "aruba/cucumber/parameter_types"
6
- require "aruba/cucumber/command"
7
- require "aruba/cucumber/environment"
8
- require "aruba/cucumber/file"
9
- require "aruba/cucumber/testing_frameworks"
3
+ require 'aruba/version'
4
+
5
+ require 'aruba/api'
6
+ require 'aruba/cucumber/hooks'
7
+ require 'aruba/cucumber/parameter_types'
8
+ require 'aruba/cucumber/command'
9
+ require 'aruba/cucumber/environment'
10
+ require 'aruba/cucumber/file'
11
+ require 'aruba/cucumber/testing_frameworks'
data/lib/aruba/errors.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aruba
2
4
  # Standard error
3
5
  class Error < StandardError; end
@@ -28,10 +30,4 @@ module Aruba
28
30
  # Raised if command was already started, otherwise aruba forgets about the
29
31
  # previous pid and you've got hidden commands run
30
32
  class CommandAlreadyStartedError < Error; end
31
-
32
- # Raised if an event name cannot be resolved
33
- class EventNameResolveError < StandardError; end
34
-
35
- # Raised if given object is not an event
36
- class NoEventError < StandardError; end
37
33
  end
@@ -1,5 +1,6 @@
1
- require "aruba/event_bus/name_resolver"
2
- require "aruba/errors"
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber/core/event_bus'
3
4
 
4
5
  module Aruba
5
6
  # Event bus
@@ -7,55 +8,15 @@ module Aruba
7
8
  # Implements and in-process pub-sub events broadcaster allowing multiple observers
8
9
  # to subscribe to different events that fire as your tests are executed.
9
10
  #
10
- class EventBus
11
- # Create EventBus
12
- #
13
- # @param [#transform] resolver
14
- # A resolver which transforms Symbol, String, Class into an event Class.
15
- def initialize(resolver)
16
- @resolver = resolver
17
- @handlers = Hash.new { |h, k| h[k] = [] }
18
- end
19
-
20
- # Register for an event
21
- #
22
- # @param [String, Symbol, Class, Array] event_ids
23
- # If Array, register multiple events witht the same handler. If String,
24
- # Symbol, Class register handler for given event.
25
- #
26
- # @param [#call] handler_object
27
- # The handler object, needs to have method `#call`. Either
28
- # `handler_object` or `block` can be defined. The handler object gets the
29
- # event passed to `#call`.
30
- #
31
- # @yield
32
- # Handler block which gets the event passed as parameter.
33
- def register(event_ids, handler_object = nil, &handler_proc)
34
- handler = handler_proc || handler_object
35
-
36
- if handler.nil? || !handler.respond_to?(:call)
37
- raise ArgumentError, "Please pass either an object#call or a handler block"
11
+ class EventBus < Cucumber::Core::EventBus
12
+ def register(ids, handler_object = nil, &handler_proc)
13
+ Array(ids).each do |event_id|
14
+ on(event_id, handler_object, &handler_proc)
38
15
  end
39
-
40
- Array(event_ids).flatten.each do |id|
41
- @handlers[
42
- @resolver.transform(id).to_s
43
- ] << handler
44
- end
45
-
46
- nil
47
16
  end
48
17
 
49
- # Broadcast an event
50
- #
51
- # @param [Object] event
52
- # An object of registered event class. This object is passed to the event
53
- # handler.
54
- #
55
18
  def notify(event)
56
- raise NoEventError, "Please pass an event object, not a class" if event.is_a?(Class)
57
-
58
- @handlers[event.class.to_s].each { |handler| handler.call(event) }
19
+ broadcast(event)
59
20
  end
60
21
  end
61
22
  end
data/lib/aruba/events.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber/core/event'
4
+
1
5
  # Aruba
2
6
  module Aruba
3
7
  # Events
@@ -8,13 +12,7 @@ module Aruba
8
12
  # inherited by normal events
9
13
  #
10
14
  # @private
11
- class BasicEvent
12
- attr_reader :entity
13
-
14
- def initialize(entity)
15
- @entity = entity
16
- end
17
- end
15
+ class BasicEvent < Cucumber::Core::Event.new(:entity); end
18
16
 
19
17
  # Command was stopped
20
18
  class CommandStopped < BasicEvent; end
@@ -36,5 +34,15 @@ module Aruba
36
34
 
37
35
  # The configuration was changed
38
36
  class ChangedConfiguration < BasicEvent; end
37
+
38
+ def self.registry
39
+ [CommandStarted,
40
+ CommandStopped,
41
+ AddedEnvironmentVariable,
42
+ ChangedEnvironmentVariable,
43
+ DeletedEnvironmentVariable,
44
+ ChangedWorkingDirectory,
45
+ ChangedConfiguration].to_h { |klass| [klass.event_id, klass] }
46
+ end
39
47
  end
40
48
  end
@@ -1,4 +1,6 @@
1
- require "delegate"
1
+ # frozen_string_literal: true
2
+
3
+ require 'delegate'
2
4
 
3
5
  # Aruba
4
6
  module Aruba
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Aruba
2
4
  module Aruba
3
5
  # Generate script files on command line
@@ -23,7 +25,7 @@ module Aruba
23
25
 
24
26
  def header
25
27
  if script_starts_with_shebang?
26
- ""
28
+ ''
27
29
  elsif interpreter_is_absolute_path?
28
30
  format("#!%s\n", interpreter)
29
31
  elsif interpreter_is_just_the_name_of_shell?
@@ -40,7 +42,7 @@ module Aruba
40
42
  end
41
43
 
42
44
  def script_starts_with_shebang?
43
- content.start_with? "#!"
45
+ content.start_with? '#!'
44
46
  end
45
47
  end
46
48
  end
data/lib/aruba/hooks.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Aruba
2
4
  module Aruba
3
5
  # Aruba Hooks
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Aruba
2
4
  module Aruba
3
5
  # In config wrapper
@@ -16,7 +18,7 @@ module Aruba
16
18
 
17
19
  def method_missing(name, *args)
18
20
  if config.key? name
19
- raise ArgumentError, "Options take no argument" if args.any?
21
+ raise ArgumentError, 'Options take no argument' if args.any?
20
22
 
21
23
  config[name]
22
24
  else
@@ -1,5 +1,7 @@
1
- require "thor/group"
2
- require "thor/actions"
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor/group'
4
+ require 'thor/actions'
3
5
 
4
6
  # Aruba
5
7
  module Aruba
@@ -7,6 +9,7 @@ module Aruba
7
9
  #
8
10
  # Initialize project with aruba configuration files
9
11
  module Initializers
12
+ #
10
13
  # Common initializer
11
14
  #
12
15
  # @private
@@ -15,7 +18,7 @@ module Aruba
15
18
 
16
19
  # Add gem to gemfile
17
20
  def add_gem
18
- file = "Gemfile"
21
+ file = 'Gemfile'
19
22
  creator = if File.exist? file
20
23
  :append_to_file
21
24
  else
@@ -24,9 +27,9 @@ module Aruba
24
27
 
25
28
  content = if File.exist? file
26
29
  file_ends_with_carriage_return =
27
- File.open(file, "r").readlines.last.match(/.*\n$/)
30
+ File.open(file, 'r').readlines.last.match(/.*\n$/)
28
31
 
29
- prefix = file_ends_with_carriage_return ? "" : "\n"
32
+ prefix = file_ends_with_carriage_return ? '' : "\n"
30
33
 
31
34
  %(#{prefix}gem 'aruba', '~> #{Aruba::VERSION}')
32
35
  else
@@ -35,14 +38,9 @@ module Aruba
35
38
  send creator, file, content
36
39
  end
37
40
  end
38
- end
39
- end
40
41
 
41
- # Aruba
42
- module Aruba
43
- # Initializers
44
- module Initializers
45
- # Default Initializer
42
+ #
43
+ # Failing Initializer
46
44
  #
47
45
  # This handles invalid values for initializer.
48
46
  #
@@ -59,14 +57,8 @@ module Aruba
59
57
  end
60
58
  end
61
59
  end
62
- end
63
- end
64
60
 
65
- # Aruba
66
- module Aruba
67
- # Initializer
68
- module Initializers
69
- # Add aruba + rspec to project
61
+ # RSpec Initializer. Adds aruba + rspec to project
70
62
  #
71
63
  # @private
72
64
  class RSpecInitializer < Thor::Group
@@ -79,7 +71,7 @@ module Aruba
79
71
  end
80
72
 
81
73
  def create_helper
82
- file = "spec/spec_helper.rb"
74
+ file = 'spec/spec_helper.rb'
83
75
  creator = if File.exist? file
84
76
  :append_to_file
85
77
  else
@@ -95,19 +87,14 @@ module Aruba
95
87
  end
96
88
 
97
89
  def create_support_file
98
- create_file "spec/support/aruba.rb", <<~EOS
90
+ create_file 'spec/support/aruba.rb', <<~EOS
99
91
  require 'aruba/rspec'
100
92
  EOS
101
93
  end
102
94
  end
103
- end
104
- end
105
95
 
106
- # Aruba
107
- module Aruba
108
- # Initializer
109
- module Initializers
110
- # Add aruba + aruba to project
96
+ #
97
+ # Cucumber Initializer. Adds Aruba + Cucumber to project
111
98
  #
112
99
  # @private
113
100
  class CucumberInitializer < Thor::Group
@@ -120,19 +107,14 @@ module Aruba
120
107
  end
121
108
 
122
109
  def create_support_file
123
- create_file "features/support/aruba.rb", <<~EOS
110
+ create_file 'features/support/aruba.rb', <<~EOS
124
111
  require 'aruba/cucumber'
125
112
  EOS
126
113
  end
127
114
  end
128
- end
129
- end
130
115
 
131
- # Aruba
132
- module Aruba
133
- # Initializer
134
- module Initializers
135
- # Add aruba + minitest to project
116
+ #
117
+ # Minitest Initializer. Adds Aruba + Minitest to project
136
118
  #
137
119
  # @private
138
120
  class MiniTestInitializer < Thor::Group
@@ -145,7 +127,7 @@ module Aruba
145
127
  end
146
128
 
147
129
  def create_helper
148
- file = "test/test_helper.rb"
130
+ file = 'test/test_helper.rb'
149
131
  creator = if File.exist? file
150
132
  :append_to_file
151
133
  else
@@ -161,7 +143,7 @@ module Aruba
161
143
  end
162
144
 
163
145
  def create_example
164
- create_file "test/use_aruba_with_minitest.rb", <<~EOS
146
+ create_file 'test/use_aruba_with_minitest.rb', <<~EOS
165
147
  $LOAD_PATH.unshift File.expand_path('../test', __FILE__)
166
148
 
167
149
  require 'test_helper'
@@ -172,17 +154,18 @@ module Aruba
172
154
  include Aruba::Api
173
155
 
174
156
  def setup
175
- aruba_setup
157
+ setup_aruba
158
+ end
159
+
160
+ def test_dummy
161
+ skip "Add some real tests here"
176
162
  end
177
163
  end
178
164
  EOS
179
165
  end
180
166
  end
181
167
  end
182
- end
183
168
 
184
- # Aruba
185
- module Aruba
186
169
  # The whole initializer
187
170
  #
188
171
  # This one uses the specific initializers to generate the needed files.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Aruba
2
4
  module Matchers
3
5
  module Base
@@ -8,7 +10,7 @@ module Aruba
8
10
  module_function
9
11
 
10
12
  def indent_multiline_message(message)
11
- message = message.sub(/\n+\z/, "")
13
+ message = message.sub(/\n+\z/, '')
12
14
  message.lines.map do |line|
13
15
  /\S/.match?(line) ? " #{line}" : line
14
16
  end.join