Top Level Namespace
Defined Under Namespace
Modules: Aruba, RSpec Classes: String
Instance Method Summary collapse
-
#be_a_command_found_in_path ⇒ TrueClass, FalseClass
This matchers checks if
can be found in path. -
#be_an_absolute_path ⇒ TrueClass, FalseClass
This matchers checks if
exists in filesystem. -
#be_an_existing_directory ⇒ TrueClass, FalseClass
This matchers checks if
exists in filesystem. -
#be_an_existing_executable ⇒ TrueClass, FalseClass
This matchers checks if
exists in filesystem. -
#be_an_existing_file ⇒ TrueClass, FalseClass
This matchers checks if
exists in filesystem. -
#be_an_existing_path ⇒ TrueClass, FalseClass
This matchers checks if
exists in filesystem. -
#be_successfuly_executed ⇒ TrueClass, FalseClass
This matchers checks if execution of
was successful. -
#have_exit_status(status) ⇒ TrueClass, FalseClass
This matchers checks if
has exit status . -
#have_file_content(content) ⇒ TrueClass, FalseClass
This matchers checks if
has content. -
#have_file_size(size) ⇒ TrueClass, FalseClass
This matchers checks if path has file size.
-
#have_output ⇒ TrueClass, FalseClass
This matchers checks if
has created output. -
#have_output_on_stderr ⇒ TrueClass, FalseClass
This matchers checks if
has created output on stderr. -
#have_output_on_stdout ⇒ TrueClass, FalseClass
This matchers checks if
has created output on stdout. -
#have_output_size(output) ⇒ TrueClass, FalseClass
This matchers checks if output has size.
-
#have_permissions(permissions) ⇒ TrueClass, FalseClass
This matchers checks if
or has permissions. -
#have_same_file_content_like(file_name) ⇒ TrueClass, FalseClass
This matchers checks if
has the same content like . -
#have_sub_directory(sub_directory) ⇒ TrueClass, FalseClass
This matchers checks if
has given sub-directory. -
#include_output_string(string) ⇒ TrueClass, FalseClass
This matchers checks if the output string of a command includes string.
-
#include_regexp(regexp) ⇒ TrueClass, FalseClass
This matchers checks if items of an
matches regexp. -
#match_output_string(string) ⇒ TrueClass, FalseClass
This matchers checks if the output string of a command matches regular expression.
-
#match_path_pattern(pattern) ⇒ TrueClass, FalseClass
This matchers checks if
/directories match . -
#output_string_eq(string) ⇒ TrueClass, FalseClass
This matchers checks if the output string of a command includes string.
-
#run_too_long ⇒ TrueClass, FalseClass
This matchers checks if
run too long.
Instance Method Details
#be_a_command_found_in_path ⇒ TrueClass, FalseClass
This matchers checks if
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aruba/matchers/file/be_a_command_found_in_path.rb', line 18 RSpec::Matchers.define :be_a_command_found_in_path do match do |actual| @actual = Shellwords.split(actual.commandline).first if actual.respond_to? :commandline !which(@actual).nil? end do |actual| format(%(expected that command "%s" can be found in PATH "#{ENV['PATH']}".), actual) end do |actual| format(%(expected that command "%s" cannot be found in PATH "#{ENV['PATH']}".), actual) end end |
#be_an_absolute_path ⇒ TrueClass, FalseClass
This matchers checks if
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aruba/matchers/path/be_an_absolute_path.rb', line 20 RSpec::Matchers.define :be_an_absolute_path do |_| match do |actual| absolute?(actual) end do |actual| format("expected that path \"%s\" is absolute, but it's not", actual) end do |actual| format("expected that path \"%s\" is not absolute, but it is", actual) end end |
#be_an_existing_directory ⇒ TrueClass, FalseClass
This matchers checks if
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aruba/matchers/directory/be_an_existing_directory.rb', line 18 RSpec::Matchers.define :be_an_existing_directory do |_| match do |actual| stop_all_commands next false unless actual.is_a? String directory?(actual) end do |actual| format("expected that directory \"%s\" exists", actual) end do |actual| format("expected that directory \"%s\" does not exist", actual) end end |
#be_an_existing_executable ⇒ TrueClass, FalseClass
This matchers checks if
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/aruba/matchers/file/be_an_existing_executable.rb', line 19 RSpec::Matchers.define :be_an_existing_executable do |_| match do |actual| @actual = Shellwords.split(actual.commandline).first if actual.respond_to? :commandline executable?(@actual) end do |actual| format("expected that executable \"%s\" exists", actual) end do |actual| format("expected that executable \"%s\" does not exist", actual) end end |
#be_an_existing_file ⇒ TrueClass, FalseClass
This matchers checks if
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aruba/matchers/file/be_an_existing_file.rb', line 18 RSpec::Matchers.define :be_an_existing_file do |_| match do |actual| stop_all_commands next false unless actual.is_a? String file?(actual) end do |actual| format("expected that file \"%s\" exists", actual) end do |actual| format("expected that file \"%s\" does not exist", actual) end end |
#be_an_existing_path ⇒ TrueClass, FalseClass
This matchers checks if
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/aruba/matchers/path/be_an_existing_path.rb', line 21 RSpec::Matchers.define :be_an_existing_path do |_| match do |actual| exist?(actual) end do |actual| format("expected that path \"%s\" exists", actual) end do |actual| format("expected that path \"%s\" does not exist", actual) end end |
#be_successfuly_executed ⇒ TrueClass, FalseClass
This matchers checks if execution of
23 24 25 26 27 28 29 30 |
# File 'lib/aruba/matchers/command/be_successfully_executed.rb', line 23 RSpec::Matchers.define :be_successfully_executed do match do |actual| @old_actual = actual @actual = @old_actual.commandline expect(@old_actual).to have_exit_status(0) end end |
#have_exit_status(status) ⇒ TrueClass, FalseClass
This matchers checks if
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/aruba/matchers/command/have_exit_status.rb', line 19 RSpec::Matchers.define :have_exit_status do |expected| match do |actual| @old_actual = actual @old_actual.stop @actual = actual.exit_status next false unless @old_actual.respond_to? :exit_status values_match? expected, @actual end do |actual| format(%(expected that command "%s" has exit status of "%s", but has "%s".), @old_actual.commandline, expected.to_s, actual.to_s) end do |actual| format(%(expected that command "%s" does not have exit status of "%s", but has "%s".), @old_actual.commandline, expected.to_s, actual.to_s) end end |
#have_file_content(content) ⇒ TrueClass, FalseClass
This matchers checks if content
can be a string,
regexp or an RSpec matcher.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/aruba/matchers/file/have_file_content.rb', line 41 RSpec::Matchers.define :have_file_content do |expected| match do |actual| stop_all_commands next false unless file? actual @actual = read(actual).join("\n").chomp @expected = if expected.is_a? String expected.chomp else expected end values_match?(@expected, @actual) end description { "have file content: #{description_of expected}" } end |
#have_file_size(size) ⇒ TrueClass, FalseClass
This matchers checks if path has file size
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/aruba/matchers/file/have_file_size.rb', line 23 RSpec::Matchers.define :have_file_size do |expected| match do |actual| stop_all_commands next false unless file?(actual) @old_actual = actual @actual = file_size(actual) @expected = expected.to_i values_match?(@expected, @actual) end do |actual| format("expected that file \"%s\" has size \"%s\", but has \"%s\"", @old_actual, @actual, @expected) end do |actual| format("expected that file \"%s\" does not have size \"%s\", but has \"%s\"", @old_actual, @actual, @expected) end end |
#have_output ⇒ TrueClass, FalseClass
This matchers checks if
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aruba/matchers/command/have_output.rb', line 16 RSpec::Matchers.define :have_output do |expected| match do |actual| @old_actual = actual next false unless @old_actual.respond_to? :output @old_actual.stop @actual = sanitize_text(actual.output) values_match?(expected, @actual) end diffable description { "have output: #{description_of expected}" } end |
#have_output_on_stderr ⇒ TrueClass, FalseClass
This matchers checks if
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aruba/matchers/command/have_output_on_stderr.rb', line 16 RSpec::Matchers.define :have_output_on_stderr do |expected| match do |actual| @old_actual = actual next false unless @old_actual.respond_to? :stderr @old_actual.stop @actual = sanitize_text(actual.stderr) values_match?(expected, @actual) end diffable description { "have output on stderr: #{description_of expected}" } end |
#have_output_on_stdout ⇒ TrueClass, FalseClass
This matchers checks if
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aruba/matchers/command/have_output_on_stdout.rb', line 16 RSpec::Matchers.define :have_output_on_stdout do |expected| match do |actual| @old_actual = actual next false unless @old_actual.respond_to? :stdout @old_actual.stop @actual = sanitize_text(actual.stdout) values_match?(expected, @actual) end diffable description { "have output on stdout: #{description_of expected}" } end |
#have_output_size(output) ⇒ TrueClass, FalseClass
This matchers checks if output has size.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/aruba/matchers/command/have_output_size.rb', line 19 RSpec::Matchers.define :have_output_size do |expected| match do |actual| next false unless actual.respond_to? :size @actual = actual.size values_match? expected, @actual end description { "output has size #{description_of expected}" } end |
#have_permissions(permissions) ⇒ TrueClass, FalseClass
This matchers checks if
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/aruba/matchers/path/have_permissions.rb', line 31 RSpec::Matchers.define :have_permissions do |expected| def (file) @actual = Aruba.platform.filesystem_status.new(file).mode end match do |actual| stop_all_commands @old_actual = actual @actual = ((@old_actual)) @expected = if expected.is_a? Integer expected.to_s(8) elsif expected.is_a? String expected.gsub(/^0*/, '') else expected end values_match? @expected, @actual end do |actual| format("expected that path \"%s\" has permissions \"%s\", but has \"%s\".", @old_actual, @expected, @actual) end do |actual| format("expected that path \"%s\" does not have permissions \"%s\", but has \"%s\".", @old_actual, @expected, @actual) end end |
#have_same_file_content_like(file_name) ⇒ TrueClass, FalseClass
This matchers checks if
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/aruba/matchers/file/have_same_file_content.rb', line 25 RSpec::Matchers.define :have_same_file_content_like do |expected| match do |actual| stop_all_commands next false unless file?(actual) && file?(expected) @actual = (actual) @expected = (expected) FileUtils.compare_file(@actual,@expected) end do |actual| format("expected that file \"%s\" is the same as file \"%s\".", actual, expected) end do |actual| format("expected that file \"%s\" differs from file \"%s\".", actual, expected) end end |
#have_sub_directory(sub_directory) ⇒ TrueClass, FalseClass
This matchers checks if
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/aruba/matchers/directory/have_sub_directory.rb', line 28 RSpec::Matchers.define :have_sub_directory do |expected| match do |actual| next false unless directory?(actual) @old_actual = actual @actual = list(actual) @expected = Array(expected).map { |p| File.join(@old_actual, p) } (@expected - @actual).empty? end diffable do |actual| format("expected that directory \"%s\" has the following sub-directories: %s.", actual.join(', '), expected) end do |actual| format("expected that directory \"%s\" does not have the following sub-directories: %s.", actual.join(', '), expected) end end |
#include_output_string(string) ⇒ TrueClass, FalseClass
This matchers checks if the output string of a command includes string.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/aruba/matchers/string/include_output_string.rb', line 20 RSpec::Matchers.define :include_output_string do |expected| match do |actual| @expected = Regexp.new(Regexp.escape(sanitize_text(expected.to_s)), Regexp::MULTILINE) @actual = sanitize_text(actual) values_match? @expected, @actual end diffable description { "string includes: #{description_of expected}" } end |
#include_regexp(regexp) ⇒ TrueClass, FalseClass
This matchers checks if items of an
19 20 21 22 23 24 25 |
# File 'lib/aruba/matchers/rspec_matcher_include_regexp.rb', line 19 RSpec::Matchers.define :include_regexp do |expected| match do |actual| Aruba.platform.deprecated('The use of "include_regexp"-matchers is deprecated. It will be removed soon.') !actual.grep(expected).empty? end end |
#match_output_string(string) ⇒ TrueClass, FalseClass
This matchers checks if the output string of a command matches regular expression.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/aruba/matchers/string/match_output_string.rb', line 20 RSpec::Matchers.define :match_output_string do |expected| match do |actual| @expected = Regexp.new(unescape_text(expected), Regexp::MULTILINE) @actual = sanitize_text(actual) values_match? @expected, @actual end diffable description { "output string matches: #{description_of expected}" } end |
#match_path_pattern(pattern) ⇒ TrueClass, FalseClass
This matchers checks if
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/aruba/matchers/path/match_path_pattern.rb', line 25 RSpec::Matchers.define :match_path_pattern do |_| match do |actual| Aruba.platform.deprecated('The use of `expect().to match_path_pattern` is deprecated. Please use `expect().to include pattern /regex/` instead.') next !actual.select { |a| a == expected }.empty? if expected.is_a? String !actual.grep(expected).empty? end do |actual| format("expected that path \"%s\" matches pattern \"%s\".", actual.join(", "), expected) end do |actual| format("expected that path \"%s\" does not match pattern \"%s\".", actual.join(", "), expected) end end |
#output_string_eq(string) ⇒ TrueClass, FalseClass
This matchers checks if the output string of a command includes string.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/aruba/matchers/string/output_string_eq.rb', line 20 RSpec::Matchers.define :output_string_eq do |expected| match do |actual| @expected = sanitize_text(expected.to_s) @actual = sanitize_text(actual.to_s) values_match? @expected, @actual end diffable description { "output string is eq: #{description_of expected}" } end |
#run_too_long ⇒ TrueClass, FalseClass
This matchers checks if
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/aruba/matchers/command/have_finished_in_time.rb', line 22 RSpec::Matchers.define :have_finished_in_time do match do |actual| @old_actual = actual @actual = @old_actual.commandline next false unless @old_actual.respond_to? :timed_out? @old_actual.stop @old_actual.timed_out? == false end end |