1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
require File.expand_path('../../test_file/rspec', __FILE__)
require File.expand_path('../../test_helper/rspec', __FILE__)
module Project
module RSpec
attr_accessor :rspec_version
def setup
super
test_file_generator.mixin TestFile::RSpec
test_helper_generator.mixin TestHelper::RSpec
end
def configure
super
gem_dependencies << gem_dependency(
:name => 'rspec',
:version => rspec_gem_version
)
add_to_test_requires(rspec_autorun_path)
add_file(rspec_options_filename, dot_rspec_content)
end
def test_runner_command
ruby_command('rake spec')
end
private
def rspec_gem_version
case rspec_version
when 2 then '~> 2.13'
when 1 then '~> 1.3'
when nil then raise ArgumentError, "rspec_version isn't set!"
else raise ArgumentError, "Invalid RSpec version '#{rspec_version}'"
end
end
def rspec_autorun_path
if rspec_version == 1
'spec/autorun'
else
'rspec/autorun'
end
end
def rspec_options_filename
if rspec_version == 1
'spec/spec.opts'
else
'.rspec'
end
end
def dot_rspec_content
lines = []
lines << '--color'
if rspec_version == 1
lines << '--format nested'
else
lines << '--format documentation'
end
if RR.debug?
lines << '--backtrace'
end
lines.join("\n")
end
end
end
|