Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 120 lines (103 sloc) 4.25 kb
4e43779 @ihoka initial import
ihoka authored
1 # I think this is the one that should be moved to the extension Rakefile template
2
3 # In rails 1.2, plugins aren't available in the path until they're loaded.
4 # Check to see if the rspec plugin is installed first and require
5 # it if it is. If not, use the gem version.
6
7 # Determine where the RSpec plugin is by loading the boot
8 unless defined? RADIANT_ROOT
9 ENV["RAILS_ENV"] = "test"
10 case
11 when ENV["RADIANT_ENV_FILE"]
12 require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
13 when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
14 require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
15 else
16 require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
17 end
18 end
19
20 require 'rake'
21 require 'rake/rdoctask'
22 require 'rake/testtask'
23
24 rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
25 $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
26 require 'spec/rake/spectask'
27 # require 'spec/translator'
28
29 # Cleanup the RADIANT_ROOT constant so specs will load the environment
30 Object.send(:remove_const, :RADIANT_ROOT)
31
32 extension_root = File.expand_path(File.dirname(__FILE__))
33
34 task :default => :spec
35 task :stats => "spec:statsetup"
36
37 desc "Run all specs in spec directory"
38 Spec::Rake::SpecTask.new(:spec) do |t|
39 t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
40 t.spec_files = FileList['spec/**/*_spec.rb']
41 end
42
43 namespace :spec do
44 desc "Run all specs in spec directory with RCov"
45 Spec::Rake::SpecTask.new(:rcov) do |t|
46 t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
47 t.spec_files = FileList['spec/**/*_spec.rb']
48 t.rcov = true
49 t.rcov_opts = ['--exclude', 'spec', '--rails']
50 end
51
52 desc "Print Specdoc for all specs"
53 Spec::Rake::SpecTask.new(:doc) do |t|
54 t.spec_opts = ["--format", "specdoc", "--dry-run"]
55 t.spec_files = FileList['spec/**/*_spec.rb']
56 end
57
58 [:models, :controllers, :views, :helpers].each do |sub|
59 desc "Run the specs under spec/#{sub}"
60 Spec::Rake::SpecTask.new(sub) do |t|
61 t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
62 t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
63 end
64 end
65
66 # Hopefully no one has written their extensions in pre-0.9 style
67 # desc "Translate specs from pre-0.9 to 0.9 style"
68 # task :translate do
69 # translator = ::Spec::Translator.new
70 # dir = RAILS_ROOT + '/spec'
71 # translator.translate(dir, dir)
72 # end
73
74 # Setup specs for stats
75 task :statsetup do
76 require 'code_statistics'
77 ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
78 ::STATS_DIRECTORIES << %w(View\ specs spec/views)
79 ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
80 ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
81 ::CodeStatistics::TEST_TYPES << "Model specs"
82 ::CodeStatistics::TEST_TYPES << "View specs"
83 ::CodeStatistics::TEST_TYPES << "Controller specs"
84 ::CodeStatistics::TEST_TYPES << "Helper specs"
85 ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
86 end
87
88 namespace :db do
89 namespace :fixtures do
90 desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
91 task :load => :environment do
92 require 'active_record/fixtures'
93 ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
94 (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
95 Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
96 end
97 end
98 end
99 end
100 end
101
102 desc 'Generate documentation for the paginate extension.'
103 Rake::RDocTask.new(:rdoc) do |rdoc|
104 rdoc.rdoc_dir = 'rdoc'
105 rdoc.title = 'PaginateExtension'
106 rdoc.options << '--line-numbers' << '--inline-source'
107 rdoc.rdoc_files.include('README')
108 rdoc.rdoc_files.include('lib/**/*.rb')
109 end
110
111 # For extensions that are in transition
112 desc 'Test the paginate extension.'
113 Rake::TestTask.new(:test) do |t|
114 t.libs << 'lib'
115 t.pattern = 'test/**/*_test.rb'
116 t.verbose = true
117 end
118
119 # Load any custom rakefiles for extension
120 Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
Something went wrong with that request. Please try again.