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