Module: LearnTest::JsStrategy
- Included in:
- Strategies::Mocha
- Defined in:
- lib/learn_test/js_strategy.rb
Instance Method Summary collapse
- #has_js_dependency?(dep) ⇒ Boolean
- #js_package ⇒ Object
- #missing_dependencies? ⇒ Boolean
- #modules_missing?(module_names) ⇒ Boolean
- #npm_install ⇒ Object
Instance Method Details
#has_js_dependency?(dep) ⇒ Boolean
7 8 9 |
# File 'lib/learn_test/js_strategy.rb', line 7 def has_js_dependency?(dep) [:dependencies, :devDependencies].any? { |key| js_package[key] && js_package[key][dep] } end |
#js_package ⇒ Object
3 4 5 |
# File 'lib/learn_test/js_strategy.rb', line 3 def js_package @js_package ||= File.exist?('package.json') ? Oj.load(File.read('package.json'), symbol_keys: true) : nil end |
#missing_dependencies? ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'lib/learn_test/js_strategy.rb', line 15 def missing_dependencies? return true if !File.exist?("node_modules") [:dependencies, :devDependencies, :peerDependencies].any? do |dep_group| modules = js_package[dep_group] || {} modules_missing?(modules.keys) end end |
#modules_missing?(module_names) ⇒ Boolean
11 12 13 |
# File 'lib/learn_test/js_strategy.rb', line 11 def modules_missing?(module_names) module_names.any? { |name| !File.exist?("node_modules/#{name}") } end |
#npm_install ⇒ Object
23 24 25 |
# File 'lib/learn_test/js_strategy.rb', line 23 def npm_install run_install('npm install', npm_install: true) if missing_dependencies? end |