2016-08-06 12:03:25 -04:00
|
|
|
require "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
|
|
|
|
self.file_fixture_path = File.expand_path("../../file_fixtures", __FILE__)
|
|
|
|
|
|
|
|
test "#file_fixture returns Pathname to file fixture" do
|
|
|
|
path = file_fixture("sample.txt")
|
|
|
|
assert_kind_of Pathname, path
|
2016-07-01 09:29:54 -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
|
|
|
|
self.file_fixture_path = Pathname.new(File.expand_path("../../file_fixtures", __FILE__))
|
|
|
|
|
|
|
|
test "#file_fixture_path returns Pathname to file fixture" do
|
|
|
|
path = file_fixture("sample.txt")
|
|
|
|
assert_kind_of Pathname, path
|
2016-07-01 09:29:54 -04:00
|
|
|
assert_match %r{.*/test/file_fixtures/sample.txt$}, path.to_s
|
2015-01-23 09:45:34 -05:00
|
|
|
end
|
|
|
|
end
|