blob: 23cd2378c72663bc3bf0576365f3ce2002979742 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
require "isolation/abstract_unit"
module ApplicationTests
class RakeTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def setup
build_app
boot_rails
FileUtils.rm_rf("#{app_path}/config/environments")
end
def test_gems_tasks_are_loaded_first_than_application_ones
app_file "lib/tasks/app.rake", <<-RUBY
$task_loaded = Rake::Task.task_defined?("db:create:all")
RUBY
require "#{app_path}/config/environment"
::Rails.application.load_tasks
assert $task_loaded
end
def test_environment_is_required_in_rake_tasks
app_file "config/environment.rb", <<-RUBY
SuperMiddleware = Struct.new(:app)
AppTemplate::Application.configure do
config.middleware.use SuperMiddleware
end
AppTemplate::Application.initialize!
RUBY
assert_match "SuperMiddleware", Dir.chdir(app_path){ `rake middleware` }
end
def test_initializers_are_executed_in_rake_tasks
add_to_config <<-RUBY
initializer "do_something" do
puts "Doing something..."
end
rake_tasks do
task :do_nothing => :environment do
end
end
RUBY
output = Dir.chdir(app_path){ `rake do_nothing` }
assert_match "Doing something...", output
end
def test_code_statistics_sanity
assert_match "Code LOC: 5 Test LOC: 0 Code to Test Ratio: 1:0.0",
Dir.chdir(app_path){ `rake stats` }
end
def test_rake_routes_output_strips_anchors_from_http_verbs
app_file "config/routes.rb", <<-RUBY
AppTemplate::Application.routes.draw do
get '/cart', :to => 'cart#show'
end
RUBY
assert_match 'cart GET /cart(.:format)', Dir.chdir(app_path){ `rake routes` }
end
end
end
|