This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
forked from anlek/mongify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
87 lines (74 loc) · 2.14 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require 'bundler'
Bundler::GemHelper.install_tasks
require 'cucumber/rake/task'
require 'rspec/core/rake_task'
task :cleanup_rcov_files do
rm_rf 'coverage.data'
end
desc 'clobber generated files'
task :clobber do
rm_rf "pkg"
rm_rf "tmp"
rm "Gemfile.lock" if File.exist?("Gemfile.lock")
end
if RUBY_VERSION.to_f == 1.8
namespace :rcov do
Cucumber::Rake::Task.new(:cucumber) do |t|
t.rcov = true
t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
t.rcov_opts << %[-o "coverage"]
end
RSpec::Core::RakeTask.new(:rspec) do |t|
t.rcov = true
t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/,features\/}
end
desc "Run both specs and features to generate aggregated coverage"
task :all do |t|
rm "coverage.data" if File.exist?("coverage.data")
Rake::Task["rcov:cucumber"].invoke
Rake::Task["rcov:rspec"].invoke
end
end
end
desc "Run rspec test"
task :test do
Rake::Task["test:rspec"].invoke
if RUBY_VERSION.to_f < 1.9
Rake::Task["rcov:cucumber"].invoke
else
Rake::Task["test:cucumber"].invoke
end
end
namespace :test do
RSpec::Core::RakeTask.new(:rspec)
Cucumber::Rake::Task.new(:cucumber)
namespace :mysql do
desc "Setup a mysql database based on the spec/support/database.yml settings"
task :setup do
require './spec/support/config_reader'
require 'active_record'
::CONNECTION_CONFIG = ConfigReader.new('spec/support/database.yml')
ActiveRecord::Base.establish_connection(CONNECTION_CONFIG.mysql)
conn = ActiveRecord::Base.connection
conn.create_table(:users, :force => true) do |t|
t.string :first_name, :last_name
t.timestamps
end
conn.create_table(:posts, :force => true) do |t|
t.string :title
t.integer :owner_id
t.text :body
t.datetime :published_at
t.timestamps
end
conn.create_table(:comments, :force => true) do |t|
t.text :body
t.integer :post_id
t.integer :user_id
t.timestamps
end
puts "Finished"
end
end
end
task :default => ['test']