Module: JasmineRails
- Defined in:
- lib/jasmine_rails/save_fixture.rb,
lib/jasmine-rails.rb,
lib/jasmine_rails/engine.rb,
lib/jasmine_rails/runner.rb,
lib/jasmine_rails/version.rb,
lib/jasmine_rails/offline_asset_paths.rb,
app/helpers/jasmine_rails/spec_runner_helper.rb,
lib/generators/jasmine_rails/install_generator.rb,
app/controllers/jasmine_rails/application_controller.rb,
app/controllers/jasmine_rails/spec_runner_controller.rb,
lib/generators/jasmine_rails/jasmine_rails_generator.rb
Overview
Rails Asset Patch extension used to write assets out an offline asset directory for future use example:
ActionView::AssetPaths.send :include, JasmineRails::OfflineAssetPaths
Defined Under Namespace
Modules: Generators, OfflineAssetPaths, Runner, SaveFixture, SpecRunnerHelper Classes: ApplicationController, Engine, SpecRunnerController
Constant Summary collapse
- DEFAULT_TMP_DIR =
'tmp/jasmine'
- CONSOLE_REPORTERS =
{'console' => ['jasmine-console-shims.js', 'jasmine-console-reporter.js']}
- VERSION =
"0.14.6"
Class Method Summary collapse
-
.css_files ⇒ Object
return a list of any additional CSS files to be included into the jasmine testsuite.
-
.each_spec_dir(&block) ⇒ Object
iterate over all directories used as part of the testsuite (including subdirectories).
-
.force_ssl ⇒ Object
force ssl when loading the test runner.
- .include_dir ⇒ Object
- .phantom_options ⇒ Array<String>
-
.reload_jasmine_config ⇒ Object
clear out cached jasmine config file it would be nice to automatically flush when the jasmine.yml file changes instead of having this programatic API.
- .reporter_files(types_string) ⇒ Object
-
.route_path ⇒ Object
return the relative path to access the spec runner for the host Rails application ex: /jasmine.
- .spec_dir ⇒ Object
-
.spec_files ⇒ Object
returns list of all files to be included into the jasmine testsuite includes: * application src_files * spec helpers * spec_files.
- .tmp_dir ⇒ Object
-
.use_phantom_gem? ⇒ Boolean
use the phantom command from the phantom gem.
Class Method Details
.css_files ⇒ Object
return a list of any additional CSS files to be included into the jasmine testsuite
70 71 72 73 74 75 76 77 |
# File 'lib/jasmine-rails.rb', line 70 def css_files files = [] files += filter_files css_dir, jasmine_config['css_files'] spec_dir.each do |dir| files += filter_files dir, jasmine_config['css_files'] end files end |
.each_spec_dir(&block) ⇒ Object
iterate over all directories used as part of the testsuite (including subdirectories)
80 81 82 83 84 85 86 |
# File 'lib/jasmine-rails.rb', line 80 def each_spec_dir(&block) spec_dir.each do |dir| each_dir dir.to_s, &block end each_dir src_dir.to_s, &block each_dir css_dir.to_s, &block end |
.force_ssl ⇒ Object
force ssl when loading the test runner. Set to true if your app forces SSL
96 97 98 |
# File 'lib/jasmine-rails.rb', line 96 def force_ssl jasmine_config['force_ssl'] || false end |
.include_dir ⇒ Object
29 30 31 32 |
# File 'lib/jasmine-rails.rb', line 29 def include_dir paths = jasmine_config['include_dir'] [paths].flatten.compact.collect { |path| Rails.root.join(path) } end |
.phantom_options ⇒ Array<String>
106 107 108 |
# File 'lib/jasmine-rails.rb', line 106 def jasmine_config['phantom_options'].to_s.split(/\s+/).map(&:strip) end |
.reload_jasmine_config ⇒ Object
clear out cached jasmine config file it would be nice to automatically flush when the jasmine.yml file changes instead of having this programatic API
91 92 93 |
# File 'lib/jasmine-rails.rb', line 91 def reload_jasmine_config @config = nil end |
.reporter_files(types_string) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/jasmine-rails.rb', line 39 def reporter_files(types_string) types = types_string.to_s.split(',') reporters = jasmine_config['reporters'] || {} reporters = reporters.merge(JasmineRails::CONSOLE_REPORTERS) reporters.values_at(*types).compact.flatten end |
.route_path ⇒ Object
return the relative path to access the spec runner for the host Rails application ex: /jasmine
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jasmine-rails.rb', line 11 def route_path route = Rails.application.routes.named_routes[:jasmine_rails] raise 'JasmineRails::Engine has not been mounted. Try adding `mount JasmineRails::Engine => "/specs" if defined?(JasmineRails)` to routes.rb' unless route path = route.path # Rails 3.1 support -- TODO: safe to delete for 3.2? if path.is_a?(String) path else path.spec.to_s end end |
.spec_dir ⇒ Object
24 25 26 27 |
# File 'lib/jasmine-rails.rb', line 24 def spec_dir paths = jasmine_config['spec_dir'] || 'spec/javascripts' [paths].flatten.map { |path| Dir.glob path }.flatten.collect { |path| Rails.root.join(path) } end |
.spec_files ⇒ Object
returns list of all files to be included into the jasmine testsuite includes:
-
application src_files
-
spec helpers
-
spec_files
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/jasmine-rails.rb', line 53 def spec_files files = [] files += filter_files src_dir, jasmine_config['src_files'] spec_dir.each do |dir| files += filter_files dir, jasmine_config['helpers'] files += filter_files dir, jasmine_config['spec_files'] end # Sprockets 4 wants "logical paths" not to include file extensions if defined?(Sprockets) && Sprockets::VERSION.to_f >= 4 files = files.map { |f| f.chomp(File.extname f) } end files end |
.tmp_dir ⇒ Object
34 35 36 37 |
# File 'lib/jasmine-rails.rb', line 34 def tmp_dir path = jasmine_config['tmp_dir'] || JasmineRails::DEFAULT_TMP_DIR Rails.root.join(path) end |
.use_phantom_gem? ⇒ Boolean
use the phantom command from the phantom gem. Set to false if you want to manage your own phantom executable
101 102 103 |
# File 'lib/jasmine-rails.rb', line 101 def use_phantom_gem? jasmine_config['use_phantom_gem'].nil? || jasmine_config['use_phantom_gem'] == true end |