From d9b2fdbea63730281964d71f968c0cb0aaf8e5ad Mon Sep 17 00:00:00 2001 From: Markus Reiter <me@reitermark.us> Date: Thu, 23 Feb 2017 06:06:55 +0100 Subject: [PATCH] Convert `brew log` test to spec. --- Library/Homebrew/test/cmd/log_spec.rb | 41 +++++++++++++++++++++++ Library/Homebrew/test/log_formula_test.rb | 27 --------------- Library/Homebrew/test/log_test.rb | 13 ------- 3 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 Library/Homebrew/test/cmd/log_spec.rb delete mode 100644 Library/Homebrew/test/log_formula_test.rb delete mode 100644 Library/Homebrew/test/log_test.rb diff --git a/Library/Homebrew/test/cmd/log_spec.rb b/Library/Homebrew/test/cmd/log_spec.rb new file mode 100644 index 0000000000..bdbca89121 --- /dev/null +++ b/Library/Homebrew/test/cmd/log_spec.rb @@ -0,0 +1,41 @@ +describe "brew log", :integration_test do + it "shows the Git log for the Homebrew repository when no argument is given" do + HOMEBREW_REPOSITORY.cd do + shutup do + system "git", "init" + system "git", "commit", "--allow-empty", "-m", "This is a test commit" + end + end + + expect { brew "log" } + .to output(/This is a test commit/).to_stdout + .and not_to_output.to_stderr + .and be_a_success + end + + it "shows the Git log for a given Formula" do + setup_test_formula "testball" + + core_tap = CoreTap.new + core_tap.path.cd do + shutup do + system "git", "init" + system "git", "add", "--all" + system "git", "commit", "-m", "This is a test commit for Testball" + end + end + + core_tap_url = "file://#{core_tap.path}" + shallow_tap = Tap.fetch("homebrew", "shallow") + shutup do + system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path + end + + expect { brew "log", "#{shallow_tap}/testball" } + .to output(/This is a test commit for Testball/).to_stdout + .and output(/Warning: The git repository is a shallow clone/).to_stderr + .and be_a_success + + expect(shallow_tap.path/".git/shallow").to exist, "A shallow clone should have been created." + end +end diff --git a/Library/Homebrew/test/log_formula_test.rb b/Library/Homebrew/test/log_formula_test.rb deleted file mode 100644 index bb6a1f6619..0000000000 --- a/Library/Homebrew/test/log_formula_test.rb +++ /dev/null @@ -1,27 +0,0 @@ -require "testing_env" - -class IntegrationCommandTestLogFormula < IntegrationCommandTestCase - def test_log_formula - core_tap = CoreTap.new - setup_test_formula "testball" - - core_tap.path.cd do - shutup do - system "git", "init" - system "git", "add", "--all" - system "git", "commit", "-m", "This is a test commit for Testball" - end - end - - core_tap_url = "file://#{core_tap.path}" - shallow_tap = Tap.fetch("homebrew", "shallow") - shutup do - system "git", "clone", "--depth=1", core_tap_url, shallow_tap.path - end - - assert_match "This is a test commit for Testball", - cmd("log", "#{shallow_tap}/testball") - assert_predicate shallow_tap.path/".git/shallow", :exist?, - "A shallow clone should have been created." - end -end diff --git a/Library/Homebrew/test/log_test.rb b/Library/Homebrew/test/log_test.rb deleted file mode 100644 index b2e150ccd5..0000000000 --- a/Library/Homebrew/test/log_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "testing_env" - -class IntegrationCommandTestLog < IntegrationCommandTestCase - def test_log - FileUtils.cd HOMEBREW_REPOSITORY do - shutup do - system "git", "init" - system "git", "commit", "--allow-empty", "-m", "This is a test commit" - end - end - assert_match "This is a test commit", cmd("log") - end -end -- GitLab