forked from makandra/spreewald
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
executable file
·54 lines (45 loc) · 1.68 KB
/
Rakefile
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
#!/usr/bin/env rake
require "bundler/gem_tasks"
desc 'Default: Run all tests.'
task :default => 'tests:run' # now you can run the tests by just typing "rake" into your console
desc 'Update the "Steps" section of the README'
task :update_readme do
require 'support/documentation_generator'
readme = File.read('README.md')
start_of_steps_section = readme =~ /^## Steps/
length_of_steps_section = (readme[(start_of_steps_section+1)..-1] =~ /^##[^#]/) || readme.size - start_of_steps_section
readme[start_of_steps_section, length_of_steps_section] = "## Steps\n\n" + DocumentationGenerator::StepDefinitionsDirectory.new('lib/spreewald').format
File.open('README.md', 'w') { |f| f.write(readme) }
end
namespace :tests do
desc "Run tests on all test apps"
task :run do # to run the tests type "rake tests:run" into your console
success = true
for_each_directory_of('tests/**/Rakefile') do |directory|
Bundler.with_clean_env do
env = "SPEC=../../#{ENV['SPEC']} " if ENV['SPEC']
success &= system("cd #{directory} && #{env} bundle exec rake features")
end
end
fail "Tests failed" unless success
end
desc "Bundle all test apps"
task :bundle do
for_each_directory_of('tests/**/Gemfile') do |directory|
Bundler.with_clean_env do
system("cd #{directory} && bundle install")
end
end
end
desc 'Shortcut for creating a database'
task :create_database do
system("mysql -uroot -p -e 'create database spreewald_test;'")
end
end
def for_each_directory_of(path, &block)
Dir[path].sort.each do |rakefile|
directory = File.dirname(rakefile)
puts '', "\033[44m#{directory}\033[0m", ''
block.call(directory)
end
end