Skip to content
This repository has been archived by the owner on Dec 23, 2020. It is now read-only.

Commit

Permalink
Move common assertions to the test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
nickjj committed Aug 17, 2014
1 parent bba1050 commit 4587a74
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
19 changes: 0 additions & 19 deletions test/integration/cli_test.rb
Expand Up @@ -88,25 +88,6 @@ def assert_nuked(options = {})
system "rm -rf #{TEST_PATH}"
end

def assert_count(input, regex, expected)
assert input.scan(regex).size == expected,
"Found #{input.scan(regex).size} matches for '#{regex}' but " + \
"expected #{expected}"
end

def assert_in_file(file_path, match_regex)
file_contents = `cat #{file_path}`
assert_match(/#{match_regex}/, file_contents)
end

def assert_path(file_or_dir)
assert File.exist?(file_or_dir), "Expected path '#{file_or_dir}' to exist"
end

def refute_path(file_or_dir)
refute File.exist?(file_or_dir), "Expected path '#{file_or_dir}' to exist"
end

def capture_orats(command)
out, err = capture_subprocess_io do
orats "#{command} #{@target_path}", flags: @extra_flags
Expand Down
21 changes: 21 additions & 0 deletions test/test_helper.rb
Expand Up @@ -42,6 +42,27 @@ def orats(command, options = {})
system "#{prepend_command} #{BINARY_PATH} #{command} #{options[:flags]}"
end

def assert_count(input, regex, expected)
assert input.scan(regex).size == expected,
"Found #{input.scan(regex).size} matches for '#{regex}' but " + \
"expected #{expected}"
end

def assert_in_file(file_path, match_regex)
file_contents = `cat #{file_path}`
assert_match(/#{match_regex}/, file_contents)
end

def assert_path(file_or_dir)
assert File.exist?(file_or_dir),
"Expected path '#{file_or_dir}' to exist"
end

def refute_path(file_or_dir)
refute File.exist?(file_or_dir),
"Expected path '#{file_or_dir}' to exist"
end

private

def answer(options)
Expand Down

0 comments on commit 4587a74

Please sign in to comment.