Fixed RSpec so only the plugin is loaded. #1135
This commit is contained in:
1
Rakefile
Normal file
1
Rakefile
Normal file
@@ -0,0 +1 @@
|
||||
Dir[File.expand_path(File.dirname(__FILE__)) + "/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
|
||||
51
lib/tasks/rspec.rake
Normal file
51
lib/tasks/rspec.rake
Normal file
@@ -0,0 +1,51 @@
|
||||
# Modifided from the RSpec on Rails plugins
|
||||
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/../../../')
|
||||
PLUGIN_ROOT = File.expand_path(File.dirname(__FILE__) + '/../../')
|
||||
|
||||
|
||||
# In rails 1.2, plugins aren't available in the path until they're loaded.
|
||||
# Check to see if the rspec plugin is installed first and require
|
||||
# it if it is. If not, use the gem version.
|
||||
rspec_base = File.expand_path(File.dirname(__FILE__) + '/../rspec/lib')
|
||||
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
||||
require 'spec/rake/spectask'
|
||||
require 'spec/translator'
|
||||
|
||||
spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
||||
task :noop do
|
||||
end
|
||||
|
||||
task :default => :spec
|
||||
task :stats => "spec:statsetup"
|
||||
|
||||
desc "Run all specs in spec directory (excluding plugin specs)"
|
||||
Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
|
||||
t.spec_opts = ['--options', "\"#{PLUGIN_ROOT}/spec/spec.opts\""]
|
||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
||||
|
||||
namespace :spec do
|
||||
desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
||||
Spec::Rake::SpecTask.new(:rcov) do |t|
|
||||
t.spec_opts = ['--options', "\"#{PLUGIN_ROOT}/spec/spec.opts\""]
|
||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||
t.rcov = true
|
||||
t.rcov_opts = lambda do
|
||||
IO.readlines("#{PLUGIN_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
||||
end
|
||||
end
|
||||
|
||||
desc "Print Specdoc for all specs (excluding plugin specs)"
|
||||
Spec::Rake::SpecTask.new(:doc) do |t|
|
||||
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
||||
|
||||
[:models, :controllers, :views, :helpers, :lib].each do |sub|
|
||||
desc "Run the specs under spec/#{sub}"
|
||||
Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
|
||||
t.spec_opts = ['--options', "\"#{PLUGIN_ROOT}/spec/spec.opts\""]
|
||||
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,3 +1,5 @@
|
||||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
describe Class do
|
||||
it "should be a class of Class" do
|
||||
Class.class.should eql(Class)
|
||||
|
||||
7
spec/spec.opts
Normal file
7
spec/spec.opts
Normal file
@@ -0,0 +1,7 @@
|
||||
--colour
|
||||
--format
|
||||
progress
|
||||
--loadby
|
||||
mtime
|
||||
--reverse
|
||||
--backtrace
|
||||
39
spec/spec_helper.rb
Normal file
39
spec/spec_helper.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
||||
# from the project root directory.
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
|
||||
require 'spec'
|
||||
require 'spec/rails'
|
||||
|
||||
Spec::Runner.configure do |config|
|
||||
# If you're not using ActiveRecord you should remove these
|
||||
# lines, delete config/database.yml and disable :active_record
|
||||
# in your config/boot.rb
|
||||
config.use_transactional_fixtures = true
|
||||
config.use_instantiated_fixtures = false
|
||||
config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
||||
|
||||
# == Fixtures
|
||||
#
|
||||
# You can declare fixtures for each example_group like this:
|
||||
# describe "...." do
|
||||
# fixtures :table_a, :table_b
|
||||
#
|
||||
# Alternatively, if you prefer to declare them only once, you can
|
||||
# do so right here. Just uncomment the next line and replace the fixture
|
||||
# names with your fixtures.
|
||||
#
|
||||
# config.global_fixtures = :table_a, :table_b
|
||||
#
|
||||
# If you declare global fixtures, be aware that they will be declared
|
||||
# for all of your examples, even those that don't use them.
|
||||
#
|
||||
# == Mock Framework
|
||||
#
|
||||
# RSpec uses it's own mocking framework by default. If you prefer to
|
||||
# use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
end
|
||||
Reference in New Issue
Block a user