aruba 1.0.0.pre.alpha.2 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/PULL_REQUEST_TEMPLATE.md +2 -1
- data/.rspec +0 -1
- data/.rubocop.yml +46 -182
- data/.rubocop_todo.yml +216 -0
- data/.simplecov +7 -5
- data/.travis.yml +56 -40
- data/.yardopts +3 -0
- data/CHANGELOG.md +1312 -0
- data/CONTRIBUTING.md +175 -83
- data/Gemfile +5 -69
- data/LICENSE +1 -1
- data/README.md +58 -21
- data/Rakefile +27 -54
- data/appveyor.yml +7 -10
- data/aruba.gemspec +38 -19
- data/bin/console +3 -12
- data/cucumber.yml +4 -22
- data/exe/aruba +1 -1
- data/fixtures/cli-app/README.md +1 -1
- data/fixtures/cli-app/Rakefile +1 -1
- data/fixtures/cli-app/bin/aruba-test-cli +1 -1
- data/fixtures/cli-app/cli-app.gemspec +4 -4
- data/fixtures/cli-app/lib/cli/app.rb +1 -1
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +3 -3
- data/fixtures/cli-app/lib/cli/app/version.rb +1 -1
- data/fixtures/cli-app/spec/spec_helper.rb +3 -2
- data/fixtures/empty-app/Rakefile +1 -1
- data/fixtures/empty-app/cli-app.gemspec +4 -4
- data/fixtures/empty-app/lib/cli/app.rb +0 -2
- data/fixtures/empty-app/lib/cli/app/version.rb +1 -1
- data/fixtures/getting-started-app/Gemfile +1 -1
- data/lib/aruba/api.rb +8 -15
- data/lib/aruba/api/bundler.rb +16 -0
- data/lib/aruba/api/commands.rb +272 -0
- data/lib/aruba/api/core.rb +82 -43
- data/lib/aruba/api/environment.rb +24 -7
- data/lib/aruba/api/filesystem.rb +66 -64
- data/lib/aruba/api/text.rb +17 -11
- data/lib/aruba/aruba_path.rb +25 -111
- data/lib/aruba/basic_configuration.rb +8 -25
- data/lib/aruba/basic_configuration/option.rb +2 -2
- data/lib/aruba/cli.rb +4 -1
- data/lib/aruba/colorizer.rb +10 -99
- data/lib/aruba/command.rb +4 -0
- data/lib/aruba/config/jruby.rb +15 -5
- data/lib/aruba/config_wrapper.rb +17 -2
- data/lib/aruba/configuration.rb +107 -0
- data/lib/aruba/console.rb +5 -7
- data/lib/aruba/console/help.rb +5 -2
- data/lib/aruba/contracts/absolute_path.rb +3 -3
- data/lib/aruba/contracts/is_power_of_two.rb +2 -2
- data/lib/aruba/contracts/relative_path.rb +3 -3
- data/lib/aruba/cucumber.rb +0 -3
- data/lib/aruba/cucumber/command.rb +227 -190
- data/lib/aruba/cucumber/environment.rb +1 -1
- data/lib/aruba/cucumber/file.rb +56 -50
- data/lib/aruba/cucumber/hooks.rb +10 -63
- data/lib/aruba/cucumber/testing_frameworks.rb +76 -50
- data/lib/aruba/event_bus.rb +4 -2
- data/lib/aruba/event_bus/name_resolver.rb +10 -10
- data/lib/aruba/events.rb +2 -1
- data/lib/aruba/hooks.rb +3 -5
- data/lib/aruba/in_config_wrapper.rb +10 -3
- data/lib/aruba/initializer.rb +40 -34
- data/lib/aruba/matchers/base/base_matcher.rb +2 -11
- data/lib/aruba/matchers/base/message_indenter.rb +19 -0
- data/lib/aruba/matchers/base/object_formatter.rb +2 -7
- data/lib/aruba/matchers/collection/include_an_object.rb +11 -13
- data/lib/aruba/matchers/command/be_successfully_executed.rb +8 -4
- data/lib/aruba/matchers/command/have_exit_status.rb +16 -4
- data/lib/aruba/matchers/command/have_finished_in_time.rb +5 -5
- data/lib/aruba/matchers/command/have_output.rb +12 -5
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +4 -2
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +4 -2
- data/lib/aruba/matchers/command/have_output_size.rb +2 -2
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +5 -7
- data/lib/aruba/matchers/directory/have_sub_directory.rb +10 -7
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +2 -4
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +4 -6
- data/lib/aruba/matchers/file/be_an_existing_file.rb +5 -7
- data/lib/aruba/matchers/file/have_file_content.rb +4 -4
- data/lib/aruba/matchers/file/have_file_size.rb +8 -8
- data/lib/aruba/matchers/file/have_same_file_content.rb +9 -12
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +2 -4
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +3 -5
- data/lib/aruba/matchers/path/be_an_existing_path.rb +4 -6
- data/lib/aruba/matchers/path/have_permissions.rb +8 -8
- data/lib/aruba/matchers/string/include_output_string.rb +8 -10
- data/lib/aruba/matchers/string/match_output_string.rb +9 -11
- data/lib/aruba/matchers/string/output_string_eq.rb +7 -9
- data/lib/aruba/platform.rb +0 -8
- data/lib/aruba/platforms/announcer.rb +60 -85
- data/lib/aruba/platforms/aruba_file_creator.rb +4 -2
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +8 -3
- data/lib/aruba/platforms/aruba_logger.rb +22 -2
- data/lib/aruba/platforms/command_monitor.rb +15 -102
- data/lib/aruba/platforms/determine_disk_usage.rb +56 -19
- data/lib/aruba/platforms/filesystem_status.rb +9 -9
- data/lib/aruba/platforms/local_environment.rb +2 -2
- data/lib/aruba/platforms/simple_table.rb +3 -11
- data/lib/aruba/platforms/unix_command_string.rb +7 -4
- data/lib/aruba/platforms/unix_environment_variables.rb +19 -26
- data/lib/aruba/platforms/unix_platform.rb +18 -39
- data/lib/aruba/platforms/unix_which.rb +3 -2
- data/lib/aruba/platforms/windows_command_string.rb +20 -7
- data/lib/aruba/platforms/windows_environment_variables.rb +42 -30
- data/lib/aruba/platforms/windows_platform.rb +4 -0
- data/lib/aruba/platforms/windows_which.rb +9 -4
- data/lib/aruba/processes/basic_process.rb +21 -27
- data/lib/aruba/processes/debug_process.rb +16 -5
- data/lib/aruba/processes/in_process.rb +20 -9
- data/lib/aruba/processes/spawn_process.rb +64 -36
- data/lib/aruba/rspec.rb +28 -31
- data/lib/aruba/runtime.rb +16 -7
- data/lib/aruba/setup.rb +32 -17
- data/lib/aruba/tasks/docker_helpers.rb +4 -2
- data/lib/aruba/version.rb +1 -1
- metadata +194 -64
- data/History.md +0 -612
- data/bin/bootstrap +0 -34
- data/bin/build +0 -3
- data/bin/release +0 -3
- data/fixtures/spawn_process/stderr.sh +0 -3
- data/lib/aruba/api/command.rb +0 -309
- data/lib/aruba/api/deprecated.rb +0 -895
- data/lib/aruba/api/rvm.rb +0 -44
- data/lib/aruba/config.rb +0 -101
- data/lib/aruba/cucumber/rvm.rb +0 -3
- data/lib/aruba/in_process.rb +0 -14
- data/lib/aruba/jruby.rb +0 -4
- data/lib/aruba/matchers/path/match_path_pattern.rb +0 -41
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +0 -25
- data/lib/aruba/platforms/disk_usage_calculator.rb +0 -20
- data/lib/aruba/spawn_process.rb +0 -11
@@ -4,7 +4,7 @@
|
|
4
4
|
# @param [Integer] status
|
5
5
|
# The value of the exit status
|
6
6
|
#
|
7
|
-
# @return [
|
7
|
+
# @return [Boolean] The result
|
8
8
|
#
|
9
9
|
# false:
|
10
10
|
# * if command does not have exit status
|
@@ -23,16 +23,28 @@ RSpec::Matchers.define :have_exit_status do |expected|
|
|
23
23
|
@old_actual.stop
|
24
24
|
@actual = actual.exit_status
|
25
25
|
|
26
|
-
|
26
|
+
unless @old_actual.respond_to? :exit_status
|
27
|
+
raise "Expected #{@old_actual} to respond to #exit_status"
|
28
|
+
end
|
27
29
|
|
28
30
|
values_match? expected, @actual
|
29
31
|
end
|
30
32
|
|
31
33
|
failure_message do |actual|
|
32
|
-
format(
|
34
|
+
format(
|
35
|
+
%(expected that command "%s" has exit status of "%s", but has "%s".),
|
36
|
+
@old_actual.commandline,
|
37
|
+
expected.to_s,
|
38
|
+
actual.to_s
|
39
|
+
)
|
33
40
|
end
|
34
41
|
|
35
42
|
failure_message_when_negated do |actual|
|
36
|
-
format(
|
43
|
+
format(
|
44
|
+
%(expected that command "%s" does not have exit status of "%s", but has "%s".),
|
45
|
+
@old_actual.commandline,
|
46
|
+
expected.to_s,
|
47
|
+
actual.to_s
|
48
|
+
)
|
37
49
|
end
|
38
50
|
end
|
@@ -4,7 +4,7 @@ require 'rspec/expectations/version'
|
|
4
4
|
# This matchers checks if <command> run too long. Say the timeout is 10
|
5
5
|
# seconds and it takes <command> to finish in 15. This matchers will succeed.
|
6
6
|
#
|
7
|
-
# @return [
|
7
|
+
# @return [Boolean] The result
|
8
8
|
#
|
9
9
|
# false:
|
10
10
|
# * if command not to run too long
|
@@ -24,7 +24,9 @@ RSpec::Matchers.define :have_finished_in_time do
|
|
24
24
|
@old_actual = actual
|
25
25
|
@actual = @old_actual.commandline
|
26
26
|
|
27
|
-
|
27
|
+
unless @old_actual.respond_to? :timed_out?
|
28
|
+
raise "Expected #{@old_actual} to respond to #timed_out?"
|
29
|
+
end
|
28
30
|
|
29
31
|
@old_actual.stop
|
30
32
|
|
@@ -32,6 +34,4 @@ RSpec::Matchers.define :have_finished_in_time do
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
|
36
|
-
RSpec::Matchers.define_negated_matcher :run_too_long, :have_finished_in_time
|
37
|
-
end
|
37
|
+
RSpec::Matchers.define_negated_matcher :run_too_long, :have_finished_in_time
|
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'aruba/matchers/base/message_indenter'
|
2
|
+
|
1
3
|
# @!method have_output
|
2
4
|
# This matchers checks if <command> has created output
|
3
5
|
#
|
4
|
-
# @return [
|
6
|
+
# @return [Boolean] The result
|
5
7
|
#
|
6
8
|
# false:
|
7
9
|
# * if command has not created output
|
@@ -17,7 +19,9 @@ RSpec::Matchers.define :have_output do |expected|
|
|
17
19
|
match do |actual|
|
18
20
|
@old_actual = actual
|
19
21
|
|
20
|
-
|
22
|
+
unless @old_actual.respond_to? :output
|
23
|
+
raise "Expected #{@old_actual} to respond to #output"
|
24
|
+
end
|
21
25
|
|
22
26
|
@old_actual.stop
|
23
27
|
|
@@ -29,8 +33,11 @@ RSpec::Matchers.define :have_output do |expected|
|
|
29
33
|
diffable
|
30
34
|
|
31
35
|
description { "have output: #{description_of expected}" }
|
32
|
-
end
|
33
36
|
|
34
|
-
|
35
|
-
|
37
|
+
failure_message do |_actual|
|
38
|
+
"expected `#{@old_actual.commandline}` to have output #{description_of expected}\n" \
|
39
|
+
"but was:\n#{Aruba::Matchers::Base::MessageIndenter.indent_multiline_message @actual}"
|
40
|
+
end
|
36
41
|
end
|
42
|
+
|
43
|
+
RSpec::Matchers.alias_matcher :a_command_having_output, :have_output
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# @!method have_output_on_stderr
|
2
2
|
# This matchers checks if <command> has created output on stderr
|
3
3
|
#
|
4
|
-
# @return [
|
4
|
+
# @return [Boolean] The result
|
5
5
|
#
|
6
6
|
# false:
|
7
7
|
# * if command has not created output on stderr
|
@@ -17,7 +17,9 @@ RSpec::Matchers.define :have_output_on_stderr do |expected|
|
|
17
17
|
match do |actual|
|
18
18
|
@old_actual = actual
|
19
19
|
|
20
|
-
|
20
|
+
unless @old_actual.respond_to? :stderr
|
21
|
+
raise "Expected #{@old_actual} to respond to #stderr"
|
22
|
+
end
|
21
23
|
|
22
24
|
@old_actual.stop
|
23
25
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# @!method have_output_on_stdout
|
2
2
|
# This matchers checks if <command> has created output on stdout
|
3
3
|
#
|
4
|
-
# @return [
|
4
|
+
# @return [Boolean] The result
|
5
5
|
#
|
6
6
|
# false:
|
7
7
|
# * if command has not created output on stdout
|
@@ -17,7 +17,9 @@ RSpec::Matchers.define :have_output_on_stdout do |expected|
|
|
17
17
|
match do |actual|
|
18
18
|
@old_actual = actual
|
19
19
|
|
20
|
-
|
20
|
+
unless @old_actual.respond_to? :stdout
|
21
|
+
raise "Expected #{@old_actual} to respond to #stdout"
|
22
|
+
end
|
21
23
|
|
22
24
|
@old_actual.stop
|
23
25
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# @param [String] output
|
5
5
|
# The content which should be checked
|
6
6
|
#
|
7
|
-
# @return [
|
7
|
+
# @return [Boolean] The result
|
8
8
|
#
|
9
9
|
# false:
|
10
10
|
# * if output does not have size
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# end
|
19
19
|
RSpec::Matchers.define :have_output_size do |expected|
|
20
20
|
match do |actual|
|
21
|
-
|
21
|
+
raise "Expected #{actual} to respond to #size" unless actual.respond_to? :size
|
22
22
|
|
23
23
|
@actual = actual.size
|
24
24
|
values_match? expected, @actual
|
@@ -3,7 +3,7 @@ require 'rspec/expectations/version'
|
|
3
3
|
# @!method be_an_existing_directory
|
4
4
|
# This matchers checks if <directory> exists in filesystem
|
5
5
|
#
|
6
|
-
# @return [
|
6
|
+
# @return [Boolean] The result
|
7
7
|
#
|
8
8
|
# false:
|
9
9
|
# * if directory does not exist
|
@@ -19,20 +19,18 @@ RSpec::Matchers.define :be_an_existing_directory do |_|
|
|
19
19
|
match do |actual|
|
20
20
|
stop_all_commands
|
21
21
|
|
22
|
-
|
22
|
+
raise 'String expected' unless actual.is_a? String
|
23
23
|
|
24
24
|
directory?(actual)
|
25
25
|
end
|
26
26
|
|
27
27
|
failure_message do |actual|
|
28
|
-
format(
|
28
|
+
format('expected that directory "%s" exists', actual)
|
29
29
|
end
|
30
30
|
|
31
31
|
failure_message_when_negated do |actual|
|
32
|
-
format(
|
32
|
+
format('expected that directory "%s" does not exist', actual)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
RSpec::Matchers.alias_matcher :an_existing_directory, :be_an_existing_directory
|
38
|
-
end
|
36
|
+
RSpec::Matchers.alias_matcher :an_existing_directory, :be_an_existing_directory
|
@@ -6,7 +6,7 @@ require 'rspec/expectations/version'
|
|
6
6
|
# @param [Array] sub_directory
|
7
7
|
# A list of sub-directory relative to current directory
|
8
8
|
#
|
9
|
-
# @return [
|
9
|
+
# @return [Boolean] The result
|
10
10
|
#
|
11
11
|
# false:
|
12
12
|
# * if directory does not have sub-directory
|
@@ -23,7 +23,8 @@ require 'rspec/expectations/version'
|
|
23
23
|
#
|
24
24
|
# RSpec.describe do
|
25
25
|
# it { expect('dir1.d').to have_sub_directory(['subdir.1.d', 'subdir.2.d']) }
|
26
|
-
# it { expect(directories)
|
26
|
+
# it { expect(directories)
|
27
|
+
# . to include a_directory_with_sub_directory(['subdir.1.d', 'subdir.2.d']) }
|
27
28
|
# end
|
28
29
|
RSpec::Matchers.define :have_sub_directory do |expected|
|
29
30
|
match do |actual|
|
@@ -40,14 +41,16 @@ RSpec::Matchers.define :have_sub_directory do |expected|
|
|
40
41
|
diffable
|
41
42
|
|
42
43
|
failure_message do |actual|
|
43
|
-
format(
|
44
|
+
format('expected that directory "%s" has the following sub-directories: %s.',
|
45
|
+
actual.join(', '),
|
46
|
+
expected)
|
44
47
|
end
|
45
48
|
|
46
49
|
failure_message_when_negated do |actual|
|
47
|
-
format(
|
50
|
+
format('expected that directory "%s" does not have the following sub-directories: %s.',
|
51
|
+
actual.join(', '),
|
52
|
+
expected)
|
48
53
|
end
|
49
54
|
end
|
50
55
|
|
51
|
-
|
52
|
-
RSpec::Matchers.alias_matcher :a_directory_having_sub_directory, :have_sub_directory
|
53
|
-
end
|
56
|
+
RSpec::Matchers.alias_matcher :a_directory_having_sub_directory, :have_sub_directory
|
@@ -3,7 +3,7 @@ require 'rspec/expectations/version'
|
|
3
3
|
# @!method be_a_command_found_in_path
|
4
4
|
# This matchers checks if <command> can be found in path
|
5
5
|
#
|
6
|
-
# @return [
|
6
|
+
# @return [Boolean] The result
|
7
7
|
#
|
8
8
|
# false:
|
9
9
|
# * if command was not found in PATH
|
@@ -31,6 +31,4 @@ RSpec::Matchers.define :be_a_command_found_in_path do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
RSpec::Matchers.alias_matcher :a_command_found_in_path, :be_a_command_found_in_path
|
36
|
-
end
|
34
|
+
RSpec::Matchers.alias_matcher :a_command_found_in_path, :be_a_command_found_in_path
|
@@ -4,7 +4,7 @@ require 'shellwords'
|
|
4
4
|
# @!method be_an_existing_executable
|
5
5
|
# This matchers checks if <file> exists in filesystem
|
6
6
|
#
|
7
|
-
# @return [
|
7
|
+
# @return [Boolean] The result
|
8
8
|
#
|
9
9
|
# false:
|
10
10
|
# * if file does not exist
|
@@ -24,14 +24,12 @@ RSpec::Matchers.define :be_an_existing_executable do |_|
|
|
24
24
|
end
|
25
25
|
|
26
26
|
failure_message do |actual|
|
27
|
-
format(
|
27
|
+
format('expected that executable "%s" exists', actual)
|
28
28
|
end
|
29
29
|
|
30
30
|
failure_message_when_negated do |actual|
|
31
|
-
format(
|
31
|
+
format('expected that executable "%s" does not exist', actual)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
RSpec::Matchers.alias_matcher :an_existing_executable, :be_an_existing_executable
|
37
|
-
end
|
35
|
+
RSpec::Matchers.alias_matcher :an_existing_executable, :be_an_existing_executable
|
@@ -3,7 +3,7 @@ require 'rspec/expectations/version'
|
|
3
3
|
# @!method be_an_existing_file
|
4
4
|
# This matchers checks if <file> exists in filesystem
|
5
5
|
#
|
6
|
-
# @return [
|
6
|
+
# @return [Boolean] The result
|
7
7
|
#
|
8
8
|
# false:
|
9
9
|
# * if file does not exist
|
@@ -19,20 +19,18 @@ RSpec::Matchers.define :be_an_existing_file do |_|
|
|
19
19
|
match do |actual|
|
20
20
|
stop_all_commands
|
21
21
|
|
22
|
-
|
22
|
+
raise 'String expected' unless actual.is_a? String
|
23
23
|
|
24
24
|
file?(actual)
|
25
25
|
end
|
26
26
|
|
27
27
|
failure_message do |actual|
|
28
|
-
format(
|
28
|
+
format('expected that file "%s" exists', actual)
|
29
29
|
end
|
30
30
|
|
31
31
|
failure_message_when_negated do |actual|
|
32
|
-
format(
|
32
|
+
format('expected that file "%s" does not exist', actual)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
RSpec::Matchers.alias_matcher :an_existing_file, :be_an_existing_file
|
38
|
-
end
|
36
|
+
RSpec::Matchers.alias_matcher :an_existing_file, :be_an_existing_file
|
@@ -7,7 +7,7 @@ require 'rspec/expectations/version'
|
|
7
7
|
# @param [String, Regexp, Matcher] content
|
8
8
|
# Specifies the content of the file
|
9
9
|
#
|
10
|
-
# @return [
|
10
|
+
# @return [Boolean] The result
|
11
11
|
#
|
12
12
|
# false:
|
13
13
|
# * if file does not exist
|
@@ -54,9 +54,9 @@ RSpec::Matchers.define :have_file_content do |expected|
|
|
54
54
|
values_match?(@expected, @actual)
|
55
55
|
end
|
56
56
|
|
57
|
+
diffable if expected.is_a? String
|
58
|
+
|
57
59
|
description { "have file content: #{description_of expected}" }
|
58
60
|
end
|
59
61
|
|
60
|
-
|
61
|
-
RSpec::Matchers.alias_matcher :a_file_having_content, :have_file_content
|
62
|
-
end
|
62
|
+
RSpec::Matchers.alias_matcher :a_file_having_content, :have_file_content
|
@@ -6,7 +6,7 @@ require 'rspec/expectations/version'
|
|
6
6
|
# @param [Fixnum] size
|
7
7
|
# The size to check
|
8
8
|
#
|
9
|
-
# @return [
|
9
|
+
# @return [Boolean] The result
|
10
10
|
#
|
11
11
|
# false:
|
12
12
|
# * if path does not have size
|
@@ -33,15 +33,15 @@ RSpec::Matchers.define :have_file_size do |expected|
|
|
33
33
|
values_match?(@expected, @actual)
|
34
34
|
end
|
35
35
|
|
36
|
-
failure_message do |
|
37
|
-
format(
|
36
|
+
failure_message do |_actual|
|
37
|
+
format('expected that file "%s" has size "%s", but has "%s"',
|
38
|
+
@old_actual, @actual, @expected)
|
38
39
|
end
|
39
40
|
|
40
|
-
failure_message_when_negated do |
|
41
|
-
format(
|
41
|
+
failure_message_when_negated do |_actual|
|
42
|
+
format('expected that file "%s" does not have size "%s", but has "%s"',
|
43
|
+
@old_actual, @actual, @expected)
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
|
46
|
-
RSpec::Matchers.alias_matcher :a_file_of_size, :have_file_size
|
47
|
-
end
|
47
|
+
RSpec::Matchers.alias_matcher :a_file_of_size, :have_file_size
|
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'rspec/expectations/version'
|
2
|
-
|
3
2
|
require 'fileutils'
|
4
3
|
|
5
|
-
# @!method
|
4
|
+
# @!method have_same_file_content_as(file_name)
|
6
5
|
# This matchers checks if <file1> has the same content like <file2>
|
7
6
|
#
|
8
7
|
# @param [String] file_name
|
9
8
|
# The name of the file which should be compared with the file in the
|
10
9
|
# `expect()`-call.
|
11
10
|
#
|
12
|
-
# @return [
|
11
|
+
# @return [Boolean] The result
|
13
12
|
#
|
14
13
|
# false:
|
15
14
|
# * if file1 is not equal file2
|
@@ -19,10 +18,10 @@ require 'fileutils'
|
|
19
18
|
# @example Use matcher
|
20
19
|
#
|
21
20
|
# RSpec.describe do
|
22
|
-
# it { expect(file1).to
|
23
|
-
# it { expect(files).to include
|
21
|
+
# it { expect(file1).to have_same_file_content_as(file2) }
|
22
|
+
# it { expect(files).to include a_file_with_same_content_as(file2) }
|
24
23
|
# end
|
25
|
-
RSpec::Matchers.define :
|
24
|
+
RSpec::Matchers.define :have_same_file_content_as do |expected|
|
26
25
|
match do |actual|
|
27
26
|
stop_all_commands
|
28
27
|
|
@@ -31,18 +30,16 @@ RSpec::Matchers.define :have_same_file_content_like do |expected|
|
|
31
30
|
@actual = expand_path(actual)
|
32
31
|
@expected = expand_path(expected)
|
33
32
|
|
34
|
-
FileUtils.compare_file(@actual
|
33
|
+
FileUtils.compare_file(@actual, @expected)
|
35
34
|
end
|
36
35
|
|
37
36
|
failure_message do |actual|
|
38
|
-
format(
|
37
|
+
format('expected that file "%s" is the same as file "%s".', actual, expected)
|
39
38
|
end
|
40
39
|
|
41
40
|
failure_message_when_negated do |actual|
|
42
|
-
format(
|
41
|
+
format('expected that file "%s" differs from file "%s".', actual, expected)
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
|
47
|
-
RSpec::Matchers.alias_matcher :a_file_with_same_content_like, :have_same_file_content_like
|
48
|
-
end
|
45
|
+
RSpec::Matchers.alias_matcher :a_file_with_same_content_as, :have_same_file_content_as
|
@@ -7,7 +7,7 @@ require 'rspec/expectations/version'
|
|
7
7
|
# @param [String, Regexp, Matcher] pattern
|
8
8
|
# Specifies the pattern
|
9
9
|
#
|
10
|
-
# @return [
|
10
|
+
# @return [Boolean] The result
|
11
11
|
#
|
12
12
|
# false:
|
13
13
|
# * if pattern does not match
|
@@ -20,6 +20,4 @@ require 'rspec/expectations/version'
|
|
20
20
|
# RSpec.describe do
|
21
21
|
# it { expect(files).to include a_path_matching_pattern /asdf/ }
|
22
22
|
# end
|
23
|
-
|
24
|
-
RSpec::Matchers.alias_matcher :a_path_matching_pattern, :match
|
25
|
-
end
|
23
|
+
RSpec::Matchers.alias_matcher :a_path_matching_pattern, :match
|
@@ -3,7 +3,7 @@ require 'rspec/expectations/version'
|
|
3
3
|
# @!method be_an_absolute_path
|
4
4
|
# This matchers checks if <path> exists in filesystem
|
5
5
|
#
|
6
|
-
# @return [
|
6
|
+
# @return [Boolean] The result
|
7
7
|
#
|
8
8
|
# false:
|
9
9
|
# * if path is not absolute
|
@@ -27,10 +27,8 @@ RSpec::Matchers.define :be_an_absolute_path do |_|
|
|
27
27
|
end
|
28
28
|
|
29
29
|
failure_message_when_negated do |actual|
|
30
|
-
format(
|
30
|
+
format('expected that path "%s" is not absolute, but it is', actual)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
RSpec::Matchers.alias_matcher :an_absolute_path, :be_an_absolute_path
|
36
|
-
end
|
34
|
+
RSpec::Matchers.alias_matcher :an_absolute_path, :be_an_absolute_path
|