aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-08-14 09:44:54 +0100
committerGitHub2016-08-14 09:44:54 +0100
commitfcb0b33f16277ff15be73f6747169e7c88135c85 (patch)
treef74da13dd39638e6cae4b077141ae7aece72a358 /Library
parentc008797ffebde5fdcc92ecb9dba5564240683783 (diff)
parent91b67bd41d3a6fa04d5dd438b667d9bcb7e414e9 (diff)
downloadbrew-fcb0b33f16277ff15be73f6747169e7c88135c85.tar.bz2
Merge pull request #682 from eirinikos/extend-cmd-audit-tests
tests: refactor FormulaTextTests in test_cmd_audit, add assertion to test_simple_valid_formula
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_cmd_audit.rb53
1 files changed, 23 insertions, 30 deletions
diff --git a/Library/Homebrew/test/test_cmd_audit.rb b/Library/Homebrew/test/test_cmd_audit.rb
index f9056d0da..f3899e2d3 100644
--- a/Library/Homebrew/test/test_cmd_audit.rb
+++ b/Library/Homebrew/test/test_cmd_audit.rb
@@ -13,53 +13,46 @@ class FormulaTextTests < Homebrew::TestCase
FileUtils.rm_rf @dir
end
- def formula_text(name, text)
+ def formula_text(name, body = nil, options = {})
path = Pathname.new "#{@dir}/#{name}.rb"
- path.open("w") { |f| f.write text }
+ path.open("w") do |f|
+ f.write <<-EOS.undent
+ class #{Formulary.class_s(name)} < Formula
+ #{body}
+ end
+ #{options[:patch]}
+ EOS
+ end
FormulaText.new path
end
def test_simple_valid_formula
- ft = formula_text "valid", <<-EOS.undent
- class Valid < Formula
- url "http://www.example.com/valid-1.0.tar.gz"
- end
- EOS
+ ft = formula_text "valid", 'url "http://www.example.com/valid-1.0.tar.gz"'
- refute ft.has_DATA?, "The formula doesn't have DATA"
- refute ft.has_END?, "The formula doesn't have __END__"
- assert ft.has_trailing_newline?, "The formula have a trailing newline"
+ refute ft.has_DATA?, "The formula should not have DATA"
+ refute ft.has_END?, "The formula should not have __END__"
+ assert ft.has_trailing_newline?, "The formula should have a trailing newline"
- assert ft =~ /\burl\b/, "The formula match 'url'"
- assert_nil ft.line_number(/desc/), "The formula doesn't match 'desc'"
+ assert ft =~ /\burl\b/, "The formula should match 'url'"
+ assert_nil ft.line_number(/desc/), "The formula should not match 'desc'"
assert_equal 2, ft.line_number(/\burl\b/)
+ assert ft.include?("Valid"), "The formula should include \"Valid\""
end
def test_trailing_newline
- ft = formula_text "newline", "class Newline < Formula; end"
- refute ft.has_trailing_newline?, "The formula doesn't have a trailing newline"
+ ft = formula_text "newline"
+ assert ft.has_trailing_newline?, "The formula must have a trailing newline"
end
def test_has_data
- ft = formula_text "data", <<-EOS.undent
- class Data < Formula
- patch :DATA
- end
- EOS
-
- assert ft.has_DATA?, "The formula has DATA"
+ ft = formula_text "data", "patch :DATA"
+ assert ft.has_DATA?, "The formula must have DATA"
end
def test_has_end
- ft = formula_text "end", <<-EOS.undent
- class End < Formula
- end
- __END__
- a patch here
- EOS
-
- assert ft.has_END?, "The formula has __END__"
- assert_equal "class End < Formula\nend", ft.without_patch
+ ft = formula_text "end", "", :patch => "__END__\na patch here"
+ assert ft.has_END?, "The formula must have __END__"
+ assert_equal "class End < Formula\n \nend", ft.without_patch
end
end