aruba 0.7.4 → 0.8.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.nav +12 -0
- data/.rspec +1 -0
- data/.rubocop.yml +12 -0
- data/.simplecov +2 -0
- data/.travis.yml +5 -6
- data/Gemfile +53 -26
- data/History.md +17 -0
- data/LICENSE +1 -1
- data/README.md +45 -19
- data/Rakefile +12 -2
- data/TODO.md +3 -0
- data/aruba.gemspec +19 -8
- data/cucumber.yml +1 -1
- data/features/api/cd.feature +119 -0
- data/features/api/command/run.feature +37 -0
- data/features/api/command/which.feature +37 -0
- data/features/api/environment/append_environment_variable.feature +118 -0
- data/features/api/environment/prepend_environment_variable.feature +118 -0
- data/features/api/environment/set_environment_variable.feature +252 -0
- data/features/configuration/exit_timeout.feature +51 -0
- data/features/configuration/fixtures_directories.feature +31 -0
- data/features/configuration/fixtures_path_prefix.feature +24 -0
- data/features/configuration/io_timeout.feature +31 -0
- data/features/configuration/keep_ansi.feature +31 -0
- data/features/configuration/root_directory.feature +31 -0
- data/features/configuration/working_directory.feature +32 -0
- data/features/fixtures/cli-app/.gitignore +9 -0
- data/features/fixtures/cli-app/.rspec +2 -0
- data/features/fixtures/cli-app/README.md +34 -0
- data/features/fixtures/cli-app/Rakefile +1 -0
- data/features/fixtures/cli-app/bin/cli +6 -0
- data/features/fixtures/cli-app/cli-app.gemspec +26 -0
- data/features/fixtures/cli-app/features/support/env.rb +1 -0
- data/features/fixtures/cli-app/lib/cli/app.rb +13 -0
- data/features/fixtures/cli-app/lib/cli/app/version.rb +5 -0
- data/features/fixtures/cli-app/script/console +14 -0
- data/features/fixtures/cli-app/spec/cli/app_spec.rb +7 -0
- data/features/fixtures/cli-app/spec/spec_helper.rb +10 -0
- data/features/fixtures/copy/file.txt +1 -1
- data/features/hooks/after/command.feature +34 -0
- data/features/hooks/before/command.feature +61 -0
- data/features/matchers/directory/have_sub_directory.feature +110 -0
- data/features/matchers/file/be_existing_file.feature +82 -0
- data/features/matchers/file/have_file_content.feature +123 -0
- data/features/matchers/file/have_file_size.feature +107 -0
- data/features/matchers/path/be_an_absolute_path.feature +74 -0
- data/features/matchers/path/be_an_existing_path.feature +97 -0
- data/features/matchers/path/have_permissions.feature +118 -0
- data/features/matchers/timeouts.feature +48 -0
- data/features/step_definitions/aruba_dev_steps.rb +69 -1
- data/features/steps/commands/exit_statuses.feature +136 -0
- data/features/steps/commands/in_process.feature +129 -0
- data/features/steps/commands/run.feature +36 -0
- data/features/steps/environment/home_variable.feature +49 -0
- data/features/steps/environment/set_environment_variable.feature +34 -0
- data/features/support/aruba.rb +5 -0
- data/features/support/env.rb +8 -4
- data/lib/aruba.rb +20 -8
- data/lib/aruba/announcer.rb +1 -0
- data/lib/aruba/api.rb +18 -1179
- data/lib/aruba/api/command.rb +351 -0
- data/lib/aruba/api/core.rb +141 -0
- data/lib/aruba/api/deprecated.rb +549 -0
- data/lib/aruba/api/environment.rb +61 -0
- data/lib/aruba/api/filesystem.rb +305 -0
- data/lib/aruba/api/rvm.rb +39 -0
- data/lib/aruba/aruba_path.rb +75 -0
- data/lib/aruba/basic_configuration.rb +208 -0
- data/lib/aruba/basic_configuration/option.rb +25 -0
- data/lib/aruba/config.rb +43 -30
- data/lib/aruba/config/jruby.rb +14 -0
- data/lib/aruba/config_wrapper.rb +17 -0
- data/lib/aruba/contracts/relative_path.rb +13 -0
- data/lib/aruba/creators/aruba_file_creator.rb +32 -0
- data/lib/aruba/creators/aruba_fixed_size_file_creator.rb +32 -0
- data/lib/aruba/cucumber.rb +87 -53
- data/lib/aruba/cucumber/hooks.rb +65 -10
- data/lib/aruba/environment.rb +121 -0
- data/lib/aruba/errors.rb +3 -0
- data/lib/aruba/extensions/string/strip.rb +24 -0
- data/lib/aruba/hooks.rb +54 -0
- data/lib/aruba/jruby.rb +4 -9
- data/lib/aruba/matchers/command.rb +1 -79
- data/lib/aruba/matchers/command/be_successfully_executed.rb +30 -0
- data/lib/aruba/matchers/command/have_exit_status.rb +47 -0
- data/lib/aruba/matchers/command/have_finished_in_time.rb +42 -0
- data/lib/aruba/matchers/directory.rb +1 -59
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +34 -0
- data/lib/aruba/matchers/directory/have_sub_directory.rb +49 -0
- data/lib/aruba/matchers/file.rb +1 -177
- data/lib/aruba/matchers/file/be_an_existing_file.rb +34 -0
- data/lib/aruba/matchers/file/have_file_content.rb +58 -0
- data/lib/aruba/matchers/file/have_file_size.rb +43 -0
- data/lib/aruba/matchers/file/have_same_file_content.rb +44 -0
- data/lib/aruba/matchers/path.rb +1 -99
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +21 -0
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +32 -0
- data/lib/aruba/matchers/path/be_an_existing_path.rb +33 -0
- data/lib/aruba/matchers/path/have_permissions.rb +60 -0
- data/lib/aruba/matchers/path/match_path_pattern.rb +41 -0
- data/lib/aruba/matchers/rspec.rb +0 -0
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
- data/lib/aruba/platform.rb +230 -0
- data/lib/aruba/process_monitor.rb +23 -5
- data/lib/aruba/processes/basic_process.rb +35 -1
- data/lib/aruba/processes/debug_process.rb +26 -15
- data/lib/aruba/processes/in_process.rb +21 -9
- data/lib/aruba/processes/spawn_process.rb +29 -19
- data/lib/aruba/reporting.rb +2 -0
- data/lib/aruba/rspec.rb +61 -13
- data/lib/aruba/runtime.rb +33 -0
- data/script/bootstrap +4 -6
- data/spec/aruba/api/runtime_spec.rb +28 -0
- data/spec/aruba/api_spec.rb +129 -126
- data/spec/aruba/aruba_path_spec.rb +65 -0
- data/spec/aruba/basic_configuration_spec.rb +5 -0
- data/spec/aruba/config_wrapper_spec.rb +25 -0
- data/spec/aruba/configuration_spec.rb +5 -0
- data/spec/aruba/jruby_spec.rb +34 -18
- data/spec/aruba/matchers/directory_spec.rb +6 -7
- data/spec/aruba/matchers/file_spec.rb +16 -20
- data/spec/aruba/matchers/path_spec.rb +14 -11
- data/spec/aruba/rspec_spec.rb +15 -0
- data/spec/aruba/runtime_spec.rb +29 -0
- data/spec/aruba/spawn_process_spec.rb +2 -2
- data/spec/spec_helper.rb +10 -2
- data/spec/support/configs/rspec.rb +1 -1
- data/spec/support/matchers/option.rb +35 -0
- data/spec/support/shared_contexts/aruba.rb +10 -8
- data/spec/support/shared_examples/configuration.rb +116 -0
- metadata +182 -33
- data/.rvmrc +0 -1
- data/features/before_cmd_hooks.feature +0 -61
- data/features/command_environment_variables.feature +0 -31
- data/features/custom_ruby_process.feature +0 -12
- data/features/exit_statuses.feature +0 -30
- data/features/support/custom_main.rb +0 -28
- data/lib/aruba/matchers/mode.rb +0 -52
- data/lib/aruba/utils.rb +0 -21
@@ -0,0 +1,47 @@
|
|
1
|
+
# @!method have_exit_status(status)
|
2
|
+
# This matchers checks if <command> has exit status <status>
|
3
|
+
#
|
4
|
+
# @param [Integer] status
|
5
|
+
# The value of the exit status
|
6
|
+
#
|
7
|
+
# @return [TrueClass, FalseClass] The result
|
8
|
+
#
|
9
|
+
# false:
|
10
|
+
# * if command does not have exit status
|
11
|
+
# true:
|
12
|
+
# * if command has exit status
|
13
|
+
#
|
14
|
+
# @example Use matcher
|
15
|
+
#
|
16
|
+
# RSpec.describe do
|
17
|
+
# it { expect(last_command).to have_exit_status(0) }
|
18
|
+
# end
|
19
|
+
RSpec::Matchers.define :have_exit_status do |expected|
|
20
|
+
match do |actual|
|
21
|
+
@old_actual = actual
|
22
|
+
|
23
|
+
@announcer ||= Aruba::Announcer.new(
|
24
|
+
self,
|
25
|
+
:stdout => @announce_stdout,
|
26
|
+
:stderr => @announce_stderr,
|
27
|
+
:dir => @announce_dir,
|
28
|
+
:cmd => @announce_cmd,
|
29
|
+
:env => @announce_env
|
30
|
+
)
|
31
|
+
|
32
|
+
@old_actual.stop(@announcer) unless @old_actual.stopped?
|
33
|
+
@actual = actual.exit_status
|
34
|
+
|
35
|
+
next false unless @old_actual.respond_to? :exit_status
|
36
|
+
|
37
|
+
values_match? expected, @actual
|
38
|
+
end
|
39
|
+
|
40
|
+
failure_message do |actual|
|
41
|
+
format(%(expected that command "%s" has exit status of "%s", but has "%s".), @old_actual.commandline, expected.to_s, actual.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
failure_message_when_negated do |actual|
|
45
|
+
format(%(expected that command "%s" does not have exit status of "%s", but has "%s".), @old_actual.commandline, expected.to_s, actual.to_s)
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# @!method run_too_long
|
2
|
+
# This matchers checks if <command> run too long. Say the timeout is 10
|
3
|
+
# seconds and it takes <command> to finish in 15. This matchers will succeed.
|
4
|
+
#
|
5
|
+
# @return [TrueClass, FalseClass] The result
|
6
|
+
#
|
7
|
+
# false:
|
8
|
+
# * if command not to run too long
|
9
|
+
# true:
|
10
|
+
# * if command run too long
|
11
|
+
#
|
12
|
+
# @example Use matcher
|
13
|
+
#
|
14
|
+
# RSpec.describe do
|
15
|
+
# it { expect(last_command).to run_too_long }
|
16
|
+
# it { expect(last_command).not_to run_too_long }
|
17
|
+
# it { expect(last_command).to finish_its_run_in_time }
|
18
|
+
# end
|
19
|
+
# RSpec::Matchers.define :run_too_long do
|
20
|
+
RSpec::Matchers.define :have_finished_in_time do
|
21
|
+
match do |actual|
|
22
|
+
@old_actual = actual
|
23
|
+
@actual = @old_actual.commandline
|
24
|
+
|
25
|
+
@announcer ||= Aruba::Announcer.new(
|
26
|
+
self,
|
27
|
+
:stdout => @announce_stdout,
|
28
|
+
:stderr => @announce_stderr,
|
29
|
+
:dir => @announce_dir,
|
30
|
+
:cmd => @announce_cmd,
|
31
|
+
:env => @announce_env
|
32
|
+
)
|
33
|
+
|
34
|
+
@old_actual.stop(@announcer) unless @old_actual.stopped?
|
35
|
+
|
36
|
+
next false unless @old_actual.respond_to? :timed_out?
|
37
|
+
|
38
|
+
@old_actual.timed_out? == false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
RSpec::Matchers.define_negated_matcher :run_too_long, :have_finished_in_time
|
@@ -1,59 +1 @@
|
|
1
|
-
|
2
|
-
RSpec::Matchers.define :be_existing_directory do |_|
|
3
|
-
match do |actual|
|
4
|
-
directory?(actual)
|
5
|
-
end
|
6
|
-
|
7
|
-
failure_message do |actual|
|
8
|
-
format("expected that directory \"%s\" exists", actual)
|
9
|
-
end
|
10
|
-
|
11
|
-
failure_message_when_negated do |actual|
|
12
|
-
format("expected that directory \"%s\" does not exist", actual)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# @!method have_sub_directory(sub_directory)
|
17
|
-
# This matchers checks if <directory> has given sub-directory
|
18
|
-
#
|
19
|
-
# @param [Array] sub_directory
|
20
|
-
# A list of sub-directory relative to current directory
|
21
|
-
#
|
22
|
-
# @return [TrueClass, FalseClass] The result
|
23
|
-
#
|
24
|
-
# false:
|
25
|
-
# * if directory does not have sub-directory
|
26
|
-
# true:
|
27
|
-
# * if directory has sub-directory
|
28
|
-
#
|
29
|
-
# @example Use matcher with single directory
|
30
|
-
#
|
31
|
-
# RSpec.describe do
|
32
|
-
# it { expect('dir1.d').to have_sub_directory('subdir.1.d') }
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# @example Use matcher with multiple directories
|
36
|
-
#
|
37
|
-
# RSpec.describe do
|
38
|
-
# it { expect('dir1.d').to have_sub_directory(['subdir.1.d', 'subdir.2.d']) }
|
39
|
-
# end
|
40
|
-
RSpec::Matchers.define :have_sub_directory do |expected|
|
41
|
-
match do |actual|
|
42
|
-
next false unless directory?(actual)
|
43
|
-
|
44
|
-
expected_files = Array(expected).map { |p| File.join(actual, p) }
|
45
|
-
existing_files = list(actual)
|
46
|
-
|
47
|
-
(expected_files - existing_files).empty?
|
48
|
-
end
|
49
|
-
|
50
|
-
diffable
|
51
|
-
|
52
|
-
failure_message do |actual|
|
53
|
-
format("expected that directory \"%s\" has the following sub-directories: %s.", actual, Array(expected).join(', '))
|
54
|
-
end
|
55
|
-
|
56
|
-
failure_message_when_negated do |actual|
|
57
|
-
format("expected that directory \"%s\" does not have the following sub-directories: %s.", actual, Array(expected).join(', '))
|
58
|
-
end
|
59
|
-
end
|
1
|
+
Aruba::Platform.require_matching_files('../directory/**/*.rb', __FILE__)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# @!method be_an_existing_directory
|
2
|
+
# This matchers checks if <directory> exists in filesystem
|
3
|
+
#
|
4
|
+
# @return [TrueClass, FalseClass] The result
|
5
|
+
#
|
6
|
+
# false:
|
7
|
+
# * if directory does not exist
|
8
|
+
# true:
|
9
|
+
# * if directory exists
|
10
|
+
#
|
11
|
+
# @example Use matcher
|
12
|
+
#
|
13
|
+
# RSpec.describe do
|
14
|
+
# it { expect(directory1).to be_an_existing_directory }
|
15
|
+
# end
|
16
|
+
RSpec::Matchers.define :be_an_existing_directory do |_|
|
17
|
+
match do |actual|
|
18
|
+
stop_processes!
|
19
|
+
|
20
|
+
next false unless actual.is_a? String
|
21
|
+
|
22
|
+
directory?(actual)
|
23
|
+
end
|
24
|
+
|
25
|
+
failure_message do |actual|
|
26
|
+
format("expected that directory \"%s\" exists", actual)
|
27
|
+
end
|
28
|
+
|
29
|
+
failure_message_when_negated do |actual|
|
30
|
+
format("expected that directory \"%s\" does not exist", actual)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Matchers.alias_matcher :an_existing_directory, :be_an_existing_directory
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# @!method have_sub_directory(sub_directory)
|
2
|
+
# This matchers checks if <directory> has given sub-directory
|
3
|
+
#
|
4
|
+
# @param [Array] sub_directory
|
5
|
+
# A list of sub-directory relative to current directory
|
6
|
+
#
|
7
|
+
# @return [TrueClass, FalseClass] The result
|
8
|
+
#
|
9
|
+
# false:
|
10
|
+
# * if directory does not have sub-directory
|
11
|
+
# true:
|
12
|
+
# * if directory has sub-directory
|
13
|
+
#
|
14
|
+
# @example Use matcher with single directory
|
15
|
+
#
|
16
|
+
# RSpec.describe do
|
17
|
+
# it { expect('dir1.d').to have_sub_directory('subdir.1.d') }
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# @example Use matcher with multiple directories
|
21
|
+
#
|
22
|
+
# RSpec.describe do
|
23
|
+
# it { expect('dir1.d').to have_sub_directory(['subdir.1.d', 'subdir.2.d']) }
|
24
|
+
# it { expect(directories).to include a_directory_with_sub_directory(['subdir.1.d', 'subdir.2.d']) }
|
25
|
+
# end
|
26
|
+
RSpec::Matchers.define :have_sub_directory do |expected|
|
27
|
+
match do |actual|
|
28
|
+
next false unless directory?(actual)
|
29
|
+
|
30
|
+
@old_actual = actual
|
31
|
+
@actual = list(actual)
|
32
|
+
|
33
|
+
@expected = Array(expected).map { |p| File.join(@old_actual, p) }
|
34
|
+
|
35
|
+
(@expected - @actual).empty?
|
36
|
+
end
|
37
|
+
|
38
|
+
diffable
|
39
|
+
|
40
|
+
failure_message do |actual|
|
41
|
+
format("expected that directory \"%s\" has the following sub-directories: %s.", actual.join(', '), expected)
|
42
|
+
end
|
43
|
+
|
44
|
+
failure_message_when_negated do |actual|
|
45
|
+
format("expected that directory \"%s\" does not have the following sub-directories: %s.", actual.join(', '), expected)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
RSpec::Matchers.alias_matcher :a_directory_having_sub_directory, :have_sub_directory
|
data/lib/aruba/matchers/file.rb
CHANGED
@@ -1,177 +1 @@
|
|
1
|
-
|
2
|
-
# This matchers checks if <file1> has the same content like <file2>
|
3
|
-
#
|
4
|
-
# @param [String] file_name
|
5
|
-
# The name of the file which should be compared with the file in the
|
6
|
-
# `expect()`-call.
|
7
|
-
#
|
8
|
-
# @return [TrueClass, FalseClass] The result
|
9
|
-
#
|
10
|
-
# false:
|
11
|
-
# * if file1 is not equal file2
|
12
|
-
# true:
|
13
|
-
# * if file1 is equal file2
|
14
|
-
#
|
15
|
-
# @example Use matcher
|
16
|
-
#
|
17
|
-
# RSpec.describe do
|
18
|
-
# it { expect(file1).to have_same_file_content_like(file2) }
|
19
|
-
# end
|
20
|
-
RSpec::Matchers.define :have_same_file_content_like do |expected|
|
21
|
-
match do |actual|
|
22
|
-
FileUtils.compare_file(
|
23
|
-
expand_path(actual),
|
24
|
-
expand_path(expected)
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
failure_message do |actual|
|
29
|
-
format("expected that file \"%s\" is the same as file \"%s\".", actual, expected)
|
30
|
-
end
|
31
|
-
|
32
|
-
failure_message_when_negated do |actual|
|
33
|
-
format("expected that file \"%s\" differs from file \"%s\".", actual, expected)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# @!method be_existing_file
|
38
|
-
# This matchers checks if <file> exists in filesystem
|
39
|
-
#
|
40
|
-
# @return [TrueClass, FalseClass] The result
|
41
|
-
#
|
42
|
-
# false:
|
43
|
-
# * if file does not exist
|
44
|
-
# true:
|
45
|
-
# * if file exists
|
46
|
-
#
|
47
|
-
# @example Use matcher
|
48
|
-
#
|
49
|
-
# RSpec.describe do
|
50
|
-
# it { expect(file1).to be_existing_file }
|
51
|
-
# end
|
52
|
-
RSpec::Matchers.define :be_existing_file do |_|
|
53
|
-
match do |actual|
|
54
|
-
next false unless actual.is_a? String
|
55
|
-
|
56
|
-
file?(actual)
|
57
|
-
end
|
58
|
-
|
59
|
-
failure_message do |actual|
|
60
|
-
format("expected that file \"%s\" exists", actual)
|
61
|
-
end
|
62
|
-
|
63
|
-
failure_message_when_negated do |actual|
|
64
|
-
format("expected that file \"%s\" does not exist", actual)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# @!method be_existing_files
|
69
|
-
# This matchers checks if <files> exists in filessystem
|
70
|
-
#
|
71
|
-
# @return [TrueClass, FalseClass] The result
|
72
|
-
#
|
73
|
-
# false:
|
74
|
-
# * if files does not exist
|
75
|
-
# true:
|
76
|
-
# * if files exists
|
77
|
-
#
|
78
|
-
# @example Use matcher
|
79
|
-
#
|
80
|
-
# RSpec.describe do
|
81
|
-
# it { expect(%w(file1 file2)).to be_existing_files }
|
82
|
-
# end
|
83
|
-
RSpec::Matchers.define :be_existing_files do |_|
|
84
|
-
match do |actual|
|
85
|
-
next false unless actual.is_a? Array
|
86
|
-
|
87
|
-
actual.all? { |f| file?(f) }
|
88
|
-
end
|
89
|
-
|
90
|
-
failure_message do |actual|
|
91
|
-
format("expected that files \"%s\" exists", actual.join(', '))
|
92
|
-
end
|
93
|
-
|
94
|
-
failure_message_when_negated do |actual|
|
95
|
-
format("expected that files \"%s\" does not exist", actual.join(', '))
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# @!method have_file_content(content)
|
100
|
-
# This matchers checks if <file> has content. `content` can be a string,
|
101
|
-
# regexp or an RSpec matcher.
|
102
|
-
#
|
103
|
-
# @param [String, Regexp, Matcher] content
|
104
|
-
# Specifies the content of the file
|
105
|
-
#
|
106
|
-
# @return [TrueClass, FalseClass] The result
|
107
|
-
#
|
108
|
-
# false:
|
109
|
-
# * if file does not exist
|
110
|
-
# * if file content is not equal string
|
111
|
-
# * if file content does not include regexp
|
112
|
-
# * if file content does not match the content specification
|
113
|
-
#
|
114
|
-
# true:
|
115
|
-
# * if file content includes regexp
|
116
|
-
# * if file content is equal string
|
117
|
-
# * if file content matches the content specification
|
118
|
-
#
|
119
|
-
# @example Use matcher with string
|
120
|
-
#
|
121
|
-
# RSpec.describe do
|
122
|
-
# it { expect(file1).to have_file_content('a') }
|
123
|
-
# end
|
124
|
-
#
|
125
|
-
# @example Use matcher with regexp
|
126
|
-
#
|
127
|
-
# RSpec.describe do
|
128
|
-
# it { expect(file1).to have_file_content(/a/) }
|
129
|
-
# end
|
130
|
-
#
|
131
|
-
# @example Use matcher with an RSpec matcher
|
132
|
-
#
|
133
|
-
# RSpec.describe do
|
134
|
-
# it { expect(file1).to have_file_content(a_string_starting_with 'a') }
|
135
|
-
# end
|
136
|
-
RSpec::Matchers.define :have_file_content do |expected|
|
137
|
-
match do |actual|
|
138
|
-
next false unless file? actual
|
139
|
-
|
140
|
-
values_match?(expected, File.read(expand_path(actual)).chomp)
|
141
|
-
end
|
142
|
-
|
143
|
-
description { "have file content: #{description_of expected}" }
|
144
|
-
end
|
145
|
-
|
146
|
-
# @!method have_file_size(size)
|
147
|
-
# This matchers checks if path has file size
|
148
|
-
#
|
149
|
-
# @param [Fixnum] size
|
150
|
-
# The size to check
|
151
|
-
#
|
152
|
-
# @return [TrueClass, FalseClass] The result
|
153
|
-
#
|
154
|
-
# false:
|
155
|
-
# * if path does not have size
|
156
|
-
# true:
|
157
|
-
# * if path has size
|
158
|
-
#
|
159
|
-
# @example Use matcher
|
160
|
-
#
|
161
|
-
# RSpec.describe do
|
162
|
-
# it { expect('file.txt').to have_file_size(0) }
|
163
|
-
# end
|
164
|
-
RSpec::Matchers.define :have_file_size do |expected|
|
165
|
-
match do |actual|
|
166
|
-
next false unless File.file? expand_path(actual)
|
167
|
-
File.size(expand_path(actual)) == expected
|
168
|
-
end
|
169
|
-
|
170
|
-
failure_message do |actual|
|
171
|
-
format("expected that file \"%s\" has size \"%s\", but has \"%s\"", actual, File.size(expand_path(actual)), expected)
|
172
|
-
end
|
173
|
-
|
174
|
-
failure_message_when_negated do |actual|
|
175
|
-
format("expected that file \"%s\" does not have size \"%s\", but has \"%s\"", actual, File.size(expand_path(actual)), expected)
|
176
|
-
end
|
177
|
-
end
|
1
|
+
Aruba::Platform.require_matching_files('../file/**/*.rb', __FILE__)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# @!method be_an_existing_file
|
2
|
+
# This matchers checks if <file> exists in filesystem
|
3
|
+
#
|
4
|
+
# @return [TrueClass, FalseClass] The result
|
5
|
+
#
|
6
|
+
# false:
|
7
|
+
# * if file does not exist
|
8
|
+
# true:
|
9
|
+
# * if file exists
|
10
|
+
#
|
11
|
+
# @example Use matcher
|
12
|
+
#
|
13
|
+
# RSpec.describe do
|
14
|
+
# it { expect(file1).to be_an_existing_file }
|
15
|
+
# end
|
16
|
+
RSpec::Matchers.define :be_an_existing_file do |_|
|
17
|
+
match do |actual|
|
18
|
+
stop_processes!
|
19
|
+
|
20
|
+
next false unless actual.is_a? String
|
21
|
+
|
22
|
+
file?(actual)
|
23
|
+
end
|
24
|
+
|
25
|
+
failure_message do |actual|
|
26
|
+
format("expected that file \"%s\" exists", actual)
|
27
|
+
end
|
28
|
+
|
29
|
+
failure_message_when_negated do |actual|
|
30
|
+
format("expected that file \"%s\" does not exist", actual)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Matchers.alias_matcher :an_existing_file, :be_an_existing_file
|