forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
109 lines (84 loc) · 3.04 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'manageiq-ui-classic'
ManageIQ::UI::Classic::Engine.load_tasks
begin
require 'rspec/core/rake_task'
APP_RAKEFILE = File.expand_path("../spec/manageiq/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'
rescue LoadError
end
if defined?(RSpec) && defined?(RSpec::Core::RakeTask)
namespace :spec do
desc "Setup environment for specs"
task :setup => ["app:test:initialize", "app:test:verify_no_db_access_loading_rails_environment", "app:test:setup_db"]
end
RSpec::Core::RakeTask.new(:spec => ["app:test:initialize", "app:evm:compile_sti_loader"]) do |t|
spec_dir = File.expand_path("spec", __dir__)
EvmTestHelper.init_rspec_task(t, ['--require', File.join(spec_dir, 'spec_helper')])
t.pattern = FileList[spec_dir + '/**/*_spec.rb'].exclude(spec_dir + '/manageiq/**/*_spec.rb')
end
end
# Only load the jasmine tasks if we are within this repo, otherwise, the bundle
# won't contain the jasmine gem (i.e., from manageiq)
if ENV["BUNDLE_GEMFILE"].nil? || ENV["BUNDLE_GEMFILE"] == File.expand_path("../Gemfile", __FILE__)
require 'jasmine'
load 'jasmine/tasks/jasmine.rake'
end
class StaticOrHaml
def initialize(dir = 'app/views/static')
@dir = dir
@rack_file = Rack::File.new(@dir)
end
def call(env)
path = Pathname.new(@dir).join(env["PATH_INFO"].sub(/^\/+/, ''))
return [404, {}, []] unless File.exist?(path)
return @rack_file.call(env) unless path.to_s.ends_with?('.haml')
raw = File.read(path)
scope = ActionView::Base.new
scope.controller = ActionController::Base.new
scope.view_paths << File.expand_path("../app/views", __FILE__)
compiled = Haml::Engine.new(raw).render(scope)
[200, {"Content-Type" => "text/html"}, [compiled]]
end
end
module Jasmine
class << self
alias old_initialize_config initialize_config
def initialize_config
old_initialize_config
# serve haml templates from app/views/static/ on /static/
@config.add_rack_path('/static', -> { StaticOrHaml.new })
# serve weback-compiled packs from public/packs/ on /packs/
@config.add_rack_path('/packs', -> { Rack::File.new(Rails.root.join('public', 'packs')) })
end
alias old_server_is_listening_on server_is_listening_on
def server_is_listening_on(_hostname, port)
# hack around Travis resolving localhost to IPv6 and failing
old_server_is_listening_on('127.0.0.1', port)
end
end
class Configuration
alias old_initialize initialize
def initialize
# hack around Travis resolving localhost to IPv6 and failing
@host = 'http://127.0.0.1'
old_initialize
end
end
end
namespace :spec do
namespace :javascript do
desc "Setup environment for javascript specs"
task :setup
end
desc "Run all javascript specs"
task :javascript => ["app:test:initialize", :environment, "jasmine:ci"]
namespace :compile do
desc "Does nothing, needed by Travis"
task :setup
end
desc "Try to compile assets"
task :compile => ["app:assets:precompile"]
end
task :default => :spec