blob: 87e0ad7bd736094a6d2635a06499368181fd89a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
require 'abstract_unit'
require 'rails/app_rails_loader'
class AppRailsLoaderTest < ActiveSupport::TestCase
test "is in a rails application if bin/rails exists and contains APP_PATH" do
File.stubs(:exists?).returns(true)
File.stubs(:read).with('bin/rails').returns('APP_PATH')
assert Rails::AppRailsLoader.in_rails_application_or_engine?
end
test "is not in a rails application if bin/rails exists but doesn't contain APP_PATH" do
File.stubs(:exists?).returns(true)
File.stubs(:read).with('bin/rails').returns('railties bin/rails')
assert !Rails::AppRailsLoader.in_rails_application_or_engine?
end
test "is in a rails application if parent directory has bin/rails containing APP_PATH" do
File.stubs(:exists?).with("/foo/bar/bin/rails").returns(false)
File.stubs(:exists?).with("/foo/bin/rails").returns(true)
File.stubs(:read).with('/foo/bin/rails').returns('APP_PATH')
assert Rails::AppRailsLoader.in_rails_application_or_engine_subdirectory?(Pathname.new("/foo/bar"))
end
test "is not in a rails application if at the root directory and doesn't have bin/rails" do
Pathname.any_instance.stubs(:root?).returns true
assert !Rails::AppRailsLoader.in_rails_application_or_engine?
end
test "is in a rails engine if parent directory has bin/rails containing ENGINE_PATH" do
File.stubs(:exists?).with("/foo/bar/bin/rails").returns(false)
File.stubs(:exists?).with("/foo/bin/rails").returns(true)
File.stubs(:read).with('/foo/bin/rails').returns('ENGINE_PATH')
assert Rails::AppRailsLoader.in_rails_application_or_engine_subdirectory?(Pathname.new("/foo/bar"))
end
test "is in a rails engine if bin/rails exists containing ENGINE_PATH" do
File.stubs(:exists?).returns(true)
File.stubs(:read).with('bin/rails').returns('ENGINE_PATH')
assert Rails::AppRailsLoader.in_rails_application_or_engine?
end
end
|