| | 85 | |
|---|
| | 86 | uses_mocha 'framework paths' do |
|---|
| | 87 | class ConfigurationFrameworkPathsTests < Test::Unit::TestCase |
|---|
| | 88 | def setup |
|---|
| | 89 | @config = Rails::Configuration.new |
|---|
| | 90 | @config.frameworks.clear |
|---|
| | 91 | |
|---|
| | 92 | File.stubs(:directory?).returns(true) |
|---|
| | 93 | @config.stubs(:framework_root_path).returns('') |
|---|
| | 94 | end |
|---|
| | 95 | |
|---|
| | 96 | def test_minimal |
|---|
| | 97 | expected = %w( |
|---|
| | 98 | /railties |
|---|
| | 99 | /railties/lib |
|---|
| | 100 | /activesupport/lib |
|---|
| | 101 | ) |
|---|
| | 102 | assert_equal expected, @config.framework_paths |
|---|
| | 103 | end |
|---|
| | 104 | |
|---|
| | 105 | def test_actioncontroller_or_actionview_add_actionpack |
|---|
| | 106 | @config.frameworks << :action_controller |
|---|
| | 107 | assert_framework_path '/actionpack/lib' |
|---|
| | 108 | |
|---|
| | 109 | @config.frameworks = [:action_view] |
|---|
| | 110 | assert_framework_path '/actionpack/lib' |
|---|
| | 111 | end |
|---|
| | 112 | |
|---|
| | 113 | def test_paths_for_ar_ares_and_mailer |
|---|
| | 114 | [:active_record, :action_mailer, :active_resource, :action_web_service].each do |framework| |
|---|
| | 115 | @config.frameworks = [framework] |
|---|
| | 116 | assert_framework_path "/#{framework.to_s.gsub('_', '')}/lib" |
|---|
| | 117 | end |
|---|
| | 118 | end |
|---|
| | 119 | |
|---|
| | 120 | def test_unknown_framework_raises_error |
|---|
| | 121 | @config.frameworks << :action_foo |
|---|
| | 122 | initializer = Rails::Initializer.new @config |
|---|
| | 123 | initializer.expects(:require).raises(LoadError) |
|---|
| | 124 | |
|---|
| | 125 | assert_raise RuntimeError do |
|---|
| | 126 | initializer.send :require_frameworks |
|---|
| | 127 | end |
|---|
| | 128 | end |
|---|
| | 129 | |
|---|
| | 130 | protected |
|---|
| | 131 | |
|---|
| | 132 | def assert_framework_path(path) |
|---|
| | 133 | assert @config.framework_paths.include?(path), |
|---|
| | 134 | "<#{path.inspect}> not found among <#{@config.framework_paths.inspect}>" |
|---|
| | 135 | end |
|---|
| | 136 | end |
|---|
| | 137 | end |