Sha256: 558c834dcc62848139921ea75cf36b6b9a48dda0b653e48ad563c762af23fc04

Contents?: true

Size: 1.82 KB

Versions: 6

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

require "assert"
require "assert/assertions"

require "assert/utils"

module Assert::Assertions
  class AssertFileExistsTests < Assert::Context
    include Assert::Test::TestHelpers

    desc "`assert_file_exists`"
    subject do
      args = args1
      Factory.test do
        assert_file_exists(__FILE__) # pass
        assert_file_exists(*args)    # fail
      end
    end

    let(:desc1){ "assert file exists fail desc" }
    let(:args1){ ["/a/path/to/some/file/that/no/exists", desc1] }
    let(:config1){ subject.config }

    should "produce results as expected" do
      subject.run(&test_run_callback)

      assert_that(test_run_result_count).equals(2)
      assert_that(test_run_result_count(:pass)).equals(1)
      assert_that(test_run_result_count(:fail)).equals(1)

      exp =
        "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to exist."
      assert_that(test_run_results(:fail).first.message).equals(exp)
    end
  end

  class AssertNotFileExistsTests < Assert::Context
    include Assert::Test::TestHelpers

    desc "`assert_not_file_exists`"
    subject do
      args = args1
      Factory.test do
        assert_not_file_exists("/file/path") # pass
        assert_not_file_exists(*args)        # fail
      end
    end

    let(:desc1){ "assert not file exists fail desc" }
    let(:args1){ [__FILE__, desc1] }
    let(:config1){ subject.config }

    should "produce results as expected" do
      subject.run(&test_run_callback)

      assert_that(test_run_result_count).equals(2)
      assert_that(test_run_result_count(:pass)).equals(1)
      assert_that(test_run_result_count(:fail)).equals(1)

      exp =
        "#{args1[1]}\nExpected #{Assert::U.show(args1[0], config1)} to "\
        "not exist."
      assert_that(test_run_results(:fail).first.message).equals(exp)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
assert-2.19.8 test/unit/assertions/assert_file_exists_tests.rb
assert-2.19.7 test/unit/assertions/assert_file_exists_tests.rb
assert-2.19.6 test/unit/assertions/assert_file_exists_tests.rb
assert-2.19.5 test/unit/assertions/assert_file_exists_tests.rb
assert-2.19.4 test/unit/assertions/assert_file_exists_tests.rb
assert-2.19.3 test/unit/assertions/assert_file_exists_tests.rb