forked from pat/thinking-sphinx
/
testing.rb
78 lines (67 loc) · 2.19 KB
/
testing.rb
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
70
71
72
73
74
75
76
77
78
require 'rubygems'
require 'spec/rake/spectask'
require 'cucumber/rake/task'
desc "Run the specs under spec"
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts << "-c"
end
desc "Run all feature-set configurations"
task :features do |t|
puts "rake features:mysql"
system "rake features:mysql"
puts "rake features:postgresql"
system "rake features:postgresql"
end
namespace :features do
def add_task(name, description)
Cucumber::Rake::Task.new(name, description) do |t|
t.cucumber_opts = "--format pretty"
t.profile = name
end
end
add_task :mysql, "Run feature-set against MySQL"
add_task :postgresql, "Run feature-set against PostgreSQL"
end
desc "Generate RCov reports"
Spec::Rake::SpecTask.new(:rcov) do |t|
t.libs << 'lib'
t.spec_files = FileList['spec/**/*_spec.rb']
t.rcov = true
t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems', '--exclude', 'riddle']
end
namespace :rcov do
def add_task(name, description)
Cucumber::Rake::Task.new(name, description) do |t|
t.cucumber_opts = "--format pretty"
t.profile = name
t.rcov = true
t.rcov_opts = [
'--exclude', 'spec',
'--exclude', 'gems',
'--exclude', 'riddle',
'--exclude', 'features'
]
end
end
add_task :mysql, "Run feature-set against MySQL with rcov"
add_task :postgresql, "Run feature-set against PostgreSQL with rcov"
end
desc "Build cucumber.yml file"
task :cucumber_defaults do
default_requires = %w(
--require features/support/env.rb
--require features/support/db/mysql.rb
--require features/support/db/active_record.rb
--require features/support/post_database.rb
).join(" ")
step_definitions = FileList["features/step_definitions/**.rb"].collect { |path|
"--require #{path}"
}.join(" ")
features = FileList["features/*.feature"].join(" ")
File.open('cucumber.yml', 'w') { |f|
f.write "default: \"#{default_requires} #{step_definitions}\"\n\n"
f.write "mysql: \"#{default_requires} #{step_definitions} #{features}\"\n\n"
f.write "postgresql: \"#{default_requires.gsub(/mysql/, 'postgresql')} #{step_definitions} #{features}\""
}
end