Sha256: 79d37bb23e060a73a8ba7eb8810fce40d87e3a037d394c305de966373b74941e

Contents?: true

Size: 1.34 KB

Versions: 19

Compression:

Stored size: 1.34 KB

Contents

require "test_helper"

class TestVerifyCommand < Test::Unit::TestCase
  def setup
    @io = StringIO.new
    @command = Juicer::Command::Verify.new(Logger.new(@io))
    @path = Dir.pwd
    @juicer = Juicer.home
  end

  def teardown
    Dir.chdir(@path)
    Juicer.home = @juicer
  end

  context "executing command" do
    should "fail with no files" do
      assert_raise ArgumentError do
        @command.execute []
      end
    end

    should "fail if installer is not found" do
      Juicer.home = path("somewhere")
      Dir.chdir("lib")
      command = Juicer::Command::Verify.new(Logger.new(@io))

      assert_raise FileNotFoundError do
        command.execute path("a.js")
      end
    end

    should "verify several files" do
      files = %w[file1.js file2.js file3.js]
      ok = "OK!\njslint: No problems"

      Juicer::Command::Verify.any_instance.expects(:files).with(files).returns(files)
      Juicer::JsLint.any_instance.expects(:check).with(files[0]).returns(Juicer::JsLint::Report.new)
      Juicer::JsLint.any_instance.expects(:check).with(files[1]).returns(Juicer::JsLint::Report.new(["Oops"]))
      Juicer::JsLint.any_instance.expects(:check).with(files[2]).returns(Juicer::JsLint::Report.new)
      
      @command.execute(files)
     
      assert_match(/OK!/, @io.string)
      assert_match(/Problems detected/, @io.string)
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
juicer-1.0.13 test/unit/juicer/command/verify_test.rb
psyho_juicer-1.0.11 test/unit/juicer/command/verify_test.rb
juicer-1.0.12 test/unit/juicer/command/verify_test.rb
juicer-1.0.11 test/unit/juicer/command/verify_test.rb
juicer-1.0.10 test/unit/juicer/command/verify_test.rb
psyho_juicer-1.0.9 test/unit/juicer/command/verify_test.rb
juicer-1.0.9 test/unit/juicer/command/verify_test.rb
juicer-1.0.8 test/unit/juicer/command/verify_test.rb
juicer-1.0.7 test/unit/juicer/command/verify_test.rb
psyho_juicer-1.0.7 test/unit/juicer/command/verify_test.rb
juicer-1.0.6 test/unit/juicer/command/verify_test.rb
juicer-1.0.5 test/unit/juicer/command/verify_test.rb
juicer-1.0.4 test/unit/juicer/command/verify_test.rb
juicer-1.0.3 test/unit/juicer/command/verify_test.rb
juicer-1.0.2 test/unit/juicer/command/verify_test.rb
juicer-1.0.1 test/unit/juicer/command/verify_test.rb
psyho_juicer-1.0.0 test/unit/juicer/command/verify_test.rb
juicer-1.0.0 test/unit/juicer/command/verify_test.rb
ktheory-juicer-1.0.0.ktheory1 test/unit/juicer/command/verify_test.rb