Move rspec rake stuff into loaderror begin-rescue so that we can deploy with --without test
This commit is contained in:
parent
847a66735a
commit
8af6fab0a4
1 changed files with 47 additions and 48 deletions
|
|
@ -5,46 +5,22 @@
|
||||||
begin
|
begin
|
||||||
require 'rspec/core'
|
require 'rspec/core'
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
rescue MissingSourceFile
|
|
||||||
module RSpec
|
|
||||||
module Core
|
|
||||||
class RakeTask
|
|
||||||
def initialize(name)
|
|
||||||
task name do
|
|
||||||
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
|
|
||||||
|
|
||||||
# ... otherwise, do this:
|
spec_prereq = Rails.root.join('config', 'database.yml').exist? ? "db:test:prepare" : :noop
|
||||||
raise <<-MSG
|
task :noop do
|
||||||
|
|
||||||
#{"*" * 80}
|
|
||||||
* You are trying to run an rspec rake task defined in
|
|
||||||
* #{__FILE__},
|
|
||||||
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
|
||||||
#{"*" * 80}
|
|
||||||
MSG
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
spec_prereq = Rails.root.join('config', 'database.yml').exist? ? "db:test:prepare" : :noop
|
task :stats => "spec:statsetup"
|
||||||
task :noop do
|
|
||||||
end
|
|
||||||
|
|
||||||
task :stats => "spec:statsetup"
|
desc "Run all specs in spec directory (excluding plugin specs)"
|
||||||
|
RSpec::Core::RakeTask.new(:spec => spec_prereq)
|
||||||
|
|
||||||
desc "Run all specs in spec directory (excluding plugin specs)"
|
desc "Run the specs with rcov"
|
||||||
RSpec::Core::RakeTask.new(:spec => spec_prereq)
|
Rspec::Core::RakeTask.new(:rcov => spec_prereq) do |t|
|
||||||
|
|
||||||
desc "Run the specs with rcov"
|
|
||||||
Rspec::Core::RakeTask.new(:rcov => spec_prereq) do |t|
|
|
||||||
t.rcov = true
|
t.rcov = true
|
||||||
t.rcov_opts = ['-Ispec', '--exclude', 'spec', '--exclude', 'gems']
|
t.rcov_opts = ['-Ispec', '--exclude', 'spec', '--exclude', 'gems']
|
||||||
end
|
end
|
||||||
namespace :"spec --color" do
|
namespace :"spec --color" do
|
||||||
[:requests, :models, :controllers, :views, :helpers, :mailers, :lib].each do |sub|
|
[:requests, :models, :controllers, :views, :helpers, :mailers, :lib].each do |sub|
|
||||||
desc "Run the code examples in spec/#{sub}"
|
desc "Run the code examples in spec/#{sub}"
|
||||||
RSpec::Core::RakeTask.new(sub => spec_prereq) do |t|
|
RSpec::Core::RakeTask.new(sub => spec_prereq) do |t|
|
||||||
|
|
@ -72,5 +48,28 @@ namespace :"spec --color" do
|
||||||
::CodeStatistics::TEST_TYPES << "Request specs" if File.exist?('spec/requests')
|
::CodeStatistics::TEST_TYPES << "Request specs" if File.exist?('spec/requests')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
rescue MissingSourceFile
|
||||||
|
module RSpec
|
||||||
|
module Core
|
||||||
|
class RakeTask
|
||||||
|
def initialize(name)
|
||||||
|
task name do
|
||||||
|
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
||||||
|
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
|
||||||
|
|
||||||
|
# ... otherwise, do this:
|
||||||
|
raise <<-MSG
|
||||||
|
|
||||||
|
#{"*" * 80}
|
||||||
|
* You are trying to run an rspec rake task defined in
|
||||||
|
* #{__FILE__},
|
||||||
|
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
||||||
|
#{"*" * 80}
|
||||||
|
MSG
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue