-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
75 lines (62 loc) · 2.47 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
# frozen_string_literal: true
require "bundler/setup"
require "rspec/core/rake_task"
class ExtensionIntegrator
class << self
def init_submodule!
`git submodule init`
`git submodule update`
end
def clear_specs!
base_dir = File.join(Dir.pwd, "spec")
Dir.foreach(base_dir) do |file|
next if %w[. .. stubs].include?(file)
file_name = File.join(base_dir, file)
if File.directory?(file_name)
FileUtils.rm_rf(file_name)
else
File.delete(file_name)
end
end
end
def copy_spec_stubs!
FileUtils.cp_r("spec/stubs/spec_helper_integration.rb", "spec/spec_helper_integration.rb")
FileUtils.cp_r("spec/stubs/spec_helper_integration.rb", "spec/spec_helper.rb")
FileUtils.cp_r("spec/stubs/models/user.rb", "spec/dummy/app/models/user.rb")
FileUtils.cp_r("spec/stubs/config/initializers/db.rb", "spec/dummy/config/initializers/db.rb")
FileUtils.cp_r("spec/stubs/config/application.rb", "spec/dummy/config/application.rb")
FileUtils.cp_r("spec/stubs/support/sequel.rb", "spec/support/orm/sequel.rb")
FileUtils.rm("spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb", force: true)
FileUtils.rm("spec/dummy/config/initializers/new_framework_defaults.rb", force: true)
FileUtils.rm("spec/models/doorkeeper/base_record_spec.rb", force: true)
FileUtils.rm("spec/lib/orm/active_record/stale_records_cleaner_spec.rb", force: true)
# Remove generators specs because we are using our own
FileUtils.rm(Dir.glob("spec/generators/*.rb"))
end
end
end
desc "Update Git submodules."
task :update_submodules do
ExtensionIntegrator.init_submodule! if Dir["doorkeeper/*"].empty?
`git submodule foreach git pull origin master`
end
task :copy_and_run_doorkeeper_specs do
# Clear specs directory
ExtensionIntegrator.clear_specs!
# Init Doorkeeper submodule if it doesn't exists
ExtensionIntegrator.init_submodule! if Dir["doorkeeper/*"].empty?
# Copy native Doorkeeper specs
`cp -r #{Gem.win_platform? ? "" : "-n"} doorkeeper/spec .`
# Replace ORM-dependent files (configs, models, etc)
ExtensionIntegrator.copy_spec_stubs!
# Run specs
`bundle exec rspec`
end
desc "Default: run specs."
task default: :spec
desc "Clone doorkeeper specs, prepare it for Sequel and run"
task spec: :copy_and_run_doorkeeper_specs
RSpec::Core::RakeTask.new(:spec) do |config|
config.verbose = false
end
Bundler::GemHelper.install_tasks