mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-06 05:04:35 +08:00
adds spec/features loader [fixes SCI-1998]
This commit is contained in:
parent
ccab688728
commit
c6d585bc57
5 changed files with 51 additions and 0 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -62,3 +62,7 @@ coverage
|
||||||
/node_modules
|
/node_modules
|
||||||
.DS_Store
|
.DS_Store
|
||||||
app/javascript/src/componentLoader/components/*
|
app/javascript/src/componentLoader/components/*
|
||||||
|
|
||||||
|
# ignore addon features
|
||||||
|
features/addons/*
|
||||||
|
!features/addons/.gitkeep
|
||||||
|
|
45
config/initializers/load_addons_specs.rb
Normal file
45
config/initializers/load_addons_specs.rb
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
require 'singleton'
|
||||||
|
|
||||||
|
class AddonsSpecLoader
|
||||||
|
include Singleton
|
||||||
|
include AddonsHelper
|
||||||
|
|
||||||
|
# rspec will recognise symlinks in the second run
|
||||||
|
def mount
|
||||||
|
FileUtils.rm_f Dir.glob("#{Dir.pwd}/spec/addons/*")
|
||||||
|
available_addons.each do |addon|
|
||||||
|
specs_path = "addons/#{addon}/spec"
|
||||||
|
next unless Dir.exist? specs_path
|
||||||
|
File.symlink("#{Dir.pwd}/#{specs_path}",
|
||||||
|
"#{Dir.pwd}/spec/addons/#{addon}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# cucumber can't respolve path with symlinks so we copy files from addons
|
||||||
|
def copy_to_features
|
||||||
|
FileUtils.rm_f Dir.glob("#{Dir.pwd}/features/addons/*")
|
||||||
|
available_addons.each do |addon|
|
||||||
|
feature_path = "addons/#{addon}/features"
|
||||||
|
FileUtils.copy_entry("#{Dir.pwd}/#{feature_path}",
|
||||||
|
"#{Dir.pwd}/features/addons/#{addon}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def available_addons
|
||||||
|
list_all_addons.map { |addon| addon.to_s.split('::').last.underscore }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if ENV['RAILS_ENV'].in? %w(test development)
|
||||||
|
begin
|
||||||
|
puts '[sciNote] Generating symlinks for addons!'
|
||||||
|
puts '[sciNote] Copying features from addons!'
|
||||||
|
AddonsSpecLoader.instance.mount
|
||||||
|
AddonsSpecLoader.instance.copy_to_features
|
||||||
|
rescue
|
||||||
|
puts '[sciNote] Unable to load specs from addons!'
|
||||||
|
puts '[sciNote] Your system does not support symlink!'
|
||||||
|
end
|
||||||
|
end
|
0
features/addons/.gitkeep
Normal file
0
features/addons/.gitkeep
Normal file
1
features/addons/organization_management
Symbolic link
1
features/addons/organization_management
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/usr/src/app/addons/organization_management/features
|
1
spec/addons/organization_management
Symbolic link
1
spec/addons/organization_management
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/usr/src/app/addons/organization_management/spec
|
Loading…
Add table
Reference in a new issue