Skip to content
Newer
Older
100644 122 lines (103 sloc) 4.14 KB
a0f6df9 @davec 0.8.0 compatibility
davec authored May 26, 2009
1 # I think this is the one that should be moved to the extension Rakefile templat
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
4b68bb6 gittin polls for radiant
nuex authored Jan 24, 2009
20 require 'rake'
21 require 'rake/testtask'
22 require 'rake/rdoctask'
23
a0f6df9 @davec 0.8.0 compatibility
davec authored May 27, 2009
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'
4b68bb6 gittin polls for radiant
nuex authored Jan 24, 2009
28
a0f6df9 @davec 0.8.0 compatibility
davec authored May 27, 2009
29
30 # Cleanup the RADIANT_ROOT constant so specs will load the environment
31 Object.send(:remove_const, :RADIANT_ROOT)
32
33 extension_root = File.expand_path(File.dirname(__FILE__))
34
35 task :default => :spec
36 task :stats => "spec:statsetup"
37
38 desc "Run all specs in spec directory"
39 Spec::Rake::SpecTask.new(:spec) do |t|
40 t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
41 t.spec_files = FileList['spec/**/*_spec.rb']
42 end
43
44 namespace :spec do
45 desc "Run all specs in spec directory with RCov"
46 Spec::Rake::SpecTask.new(:rcov) do |t|
47 t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
48 t.spec_files = FileList['spec/**/*_spec.rb']
49 t.rcov = true
50 t.rcov_opts = ['--exclude', 'spec', '--rails']
51 end
52
53 desc "Print Specdoc for all specs"
54 Spec::Rake::SpecTask.new(:doc) do |t|
55 t.spec_opts = ["--format", "specdoc", "--dry-run"]
56 t.spec_files = FileList['spec/**/*_spec.rb']
57 end
58
59 [:models, :controllers, :views, :helpers].each do |sub|
60 desc "Run the specs under spec/#{sub}"
61 Spec::Rake::SpecTask.new(sub) do |t|
62 t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
63 t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
64 end
65 end
66
67 # Hopefully no one has written their extensions in pre-0.9 style
68 # desc "Translate specs from pre-0.9 to 0.9 style"
69 # task :translate do
70 # translator = ::Spec::Translator.new
71 # dir = RAILS_ROOT + '/spec'
72 # translator.translate(dir, dir)
73 # end
74
75 # Setup specs for stats
76 task :statsetup do
77 require 'code_statistics'
78 ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
79 ::STATS_DIRECTORIES << %w(View\ specs spec/views)
80 ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
81 ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
82 ::CodeStatistics::TEST_TYPES << "Model specs"
83 ::CodeStatistics::TEST_TYPES << "View specs"
84 ::CodeStatistics::TEST_TYPES << "Controller specs"
85 ::CodeStatistics::TEST_TYPES << "Helper specs"
86 ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
87 end
88
89 namespace :db do
90 namespace :fixtures do
91 desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
92 task :load => :environment do
93 require 'active_record/fixtures'
94 ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
95 (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
96 Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
97 end
98 end
99 end
100 end
4b68bb6 gittin polls for radiant
nuex authored Jan 24, 2009
101 end
102
103 desc 'Generate documentation for the polls extension.'
104 Rake::RDocTask.new(:rdoc) do |rdoc|
105 rdoc.rdoc_dir = 'rdoc'
106 rdoc.title = 'PollsExtension'
107 rdoc.options << '--line-numbers' << '--inline-source'
108 rdoc.rdoc_files.include('README')
109 rdoc.rdoc_files.include('lib/**/*.rb')
110 end
111
a0f6df9 @davec 0.8.0 compatibility
davec authored May 27, 2009
112 # For extensions that are in transition
113 desc 'Test the polls extension.'
114 Rake::TestTask.new(:test) do |t|
115 t.libs << 'lib'
116 t.pattern = 'test/**/*_test.rb'
117 t.verbose = true
118 end
119
4b68bb6 gittin polls for radiant
nuex authored Jan 24, 2009
120 # Load any custom rakefiles for extension
a0f6df9 @davec 0.8.0 compatibility
davec authored May 27, 2009
121 Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
Something went wrong with that request. Please try again.