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
|
||||
require 'rspec/core'
|
||||
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:
|
||||
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
|
||||
spec_prereq = Rails.root.join('config', 'database.yml').exist? ? "db:test:prepare" : :noop
|
||||
task :noop do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
spec_prereq = Rails.root.join('config', 'database.yml').exist? ? "db:test:prepare" : :noop
|
||||
task :noop do
|
||||
end
|
||||
task :stats => "spec:statsetup"
|
||||
|
||||
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)"
|
||||
RSpec::Core::RakeTask.new(:spec => spec_prereq)
|
||||
|
||||
desc "Run the specs with rcov"
|
||||
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_opts = ['-Ispec', '--exclude', 'spec', '--exclude', 'gems']
|
||||
end
|
||||
namespace :"spec --color" do
|
||||
end
|
||||
namespace :"spec --color" do
|
||||
[:requests, :models, :controllers, :views, :helpers, :mailers, :lib].each do |sub|
|
||||
desc "Run the code examples in spec/#{sub}"
|
||||
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')
|
||||
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