2017-07-09 08:06:36 -04:00
|
|
|
# frozen_string_literal: true
|
2017-07-10 09:39:13 -04:00
|
|
|
|
2018-09-29 20:50:43 -04:00
|
|
|
require_relative "../abstract_unit"
|
2015-01-23 09:45:34 -05:00
|
|
|
|
2016-08-06 12:03:25 -04:00
|
|
|
require "pathname"
|
2016-07-04 08:08:27 -04:00
|
|
|
|
2015-01-23 09:45:34 -05:00
|
|
|
class FileFixturesTest < ActiveSupport::TestCase
|
2017-05-15 10:17:28 -04:00
|
|
|
self.file_fixture_path = File.expand_path("../file_fixtures", __dir__)
|
2015-01-23 09:45:34 -05:00
|
|
|
|
|
|
|
test "#file_fixture returns Pathname to file fixture" do
|
|
|
|
path = file_fixture("sample.txt")
|
|
|
|
assert_kind_of Pathname, path
|
2017-05-06 15:08:58 -04:00
|
|
|
assert_match %r{.*/test/file_fixtures/sample\.txt$}, path.to_s
|
2015-01-23 09:45:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "raises an exception when the fixture file does not exist" do
|
|
|
|
e = assert_raises(ArgumentError) do
|
|
|
|
file_fixture("nope")
|
|
|
|
end
|
|
|
|
assert_match(/^the directory '[^']+test\/file_fixtures' does not contain a file named 'nope'$/, e.message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class FileFixturesPathnameDirectoryTest < ActiveSupport::TestCase
|
2017-05-15 10:17:28 -04:00
|
|
|
self.file_fixture_path = Pathname.new(File.expand_path("../file_fixtures", __dir__))
|
2015-01-23 09:45:34 -05:00
|
|
|
|
|
|
|
test "#file_fixture_path returns Pathname to file fixture" do
|
|
|
|
path = file_fixture("sample.txt")
|
|
|
|
assert_kind_of Pathname, path
|
2017-05-06 15:08:58 -04:00
|
|
|
assert_match %r{.*/test/file_fixtures/sample\.txt$}, path.to_s
|
2015-01-23 09:45:34 -05:00
|
|
|
end
|
|
|
|
end
|