js-asset_paths 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0af9d4ca2682c7ce9b68790787df93604c8913b1
4
- data.tar.gz: d05bc5297b8958b4ec731dc04ebdf16cc71d68ce
3
+ metadata.gz: d3c8c8ad421a0fd846b3adf40103130df0f7d4e5
4
+ data.tar.gz: fb8b888dbd741ce89d2dd1a38468da0e947f907c
5
5
  SHA512:
6
- metadata.gz: 8d2abb1a87914f7bd338fc20d9a989d9dc34b712923a55dea5270219c4e5a4a9d02ae2e2f4479232608616e7ccb7015f611beb7f623610d9f610eaf38cc31879
7
- data.tar.gz: 6de7508c1d7377be7383df0c8d5a779c8c28d3874b451e7987ae1e93ce7dc8def0b228cafe4723d844dcccbb5381e32a15d744b1949b718bc1d0c830e7100096
6
+ metadata.gz: 622731a9e97041a459ce39fe7585c81bda1b7451986d97541ceee34115ecc73063351581c6c585e35391f7dbae2a0b45ef2f92e8a9c07330a0820bec002c814d
7
+ data.tar.gz: 5b3154fbf5e5e370281082256f592c134973b14963192bf22beb6a98730617484459fc3f97992dac662d02454f0b94f3ae5a37a74b268199781438bf37be6c78
@@ -1,5 +1,7 @@
1
- require 'action_view/helpers/asset_url_helper'
2
-
3
1
  require 'js_asset_paths/version'
4
2
  require 'js_asset_paths/engine'
5
3
  require 'js_asset_paths/generator'
4
+
5
+ module JsAssetPaths
6
+ ASSET_METHODS = ActionView::Helpers::AssetUrlHelper.public_instance_methods.grep(/^((?!.*asset)[a-z]+)_path$/)
7
+ end
@@ -0,0 +1,39 @@
1
+ require 'execjs'
2
+ require_relative '../test_helper'
3
+
4
+ describe 'untrue values of config.assets.digest' do
5
+ before do
6
+ App.initialize! unless App.initialized?
7
+ end
8
+
9
+ it 'output has corresponding key and value pairs when digest is false' do
10
+ begin
11
+ Rails.application.config.assets.digest = false
12
+
13
+ JsAssetPaths::Generator.environment = Rails.application
14
+ @output = JsAssetPaths::Generator.generate!
15
+
16
+ map = ExecJS.eval(@output)
17
+
18
+ map.each do |key, value|
19
+ file = key.split('/').second
20
+ assert_equal file, value
21
+ end
22
+
23
+ ensure
24
+ Rails.application.config.assets.digest = true
25
+ end
26
+ end
27
+
28
+ it 'output has corresponding key and value pairs when digest is not boolean' do
29
+ begin
30
+ Rails.application.config.assets.digest = :foo
31
+
32
+ JsAssetPaths::Generator.environment = Rails.application
33
+
34
+ assert_raises(TypeError) { JsAssetPaths::Generator.generate! }
35
+ ensure
36
+ Rails.application.config.assets.digest = true
37
+ end
38
+ end
39
+ end
File without changes
@@ -25,14 +25,16 @@ describe JsAssetPaths::Generator do
25
25
  assert_kind_of Hash, ExecJS.eval(@output)
26
26
  end
27
27
 
28
- it 'output has corresponding key and value pairs' do
28
+ it 'output has corresponding key and value pairs when digest' do
29
+ assert App.config.assets.digest
30
+
29
31
  map = ExecJS.eval(@output)
30
32
 
31
33
  map.each do |key, value|
32
34
  file = key.split('/').second
33
35
  name, _, ext = file.rpartition('.')
34
36
 
35
- assert_match /#{name}-[0-9,a-z]{64}.#{ext}/, value
37
+ assert_match (/#{name}-[0-9,a-z]{64}.#{ext}/), value
36
38
  end
37
39
  end
38
40
  end
@@ -0,0 +1,8 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe JsAssetPaths do
4
+ it 'ASSET_METHOD constant has the correct values' do
5
+ assert_equal %i(audio_path font_path image_path javascript_path stylesheet_path video_path),
6
+ JsAssetPaths::ASSET_METHODS.sort
7
+ end
8
+ end
@@ -0,0 +1,45 @@
1
+ require 'execjs'
2
+ require_relative '../test_helper'
3
+
4
+ describe 'generated javascript' do
5
+ before do
6
+ App.initialize! unless App.initialized?
7
+ JsAssetPaths::Generator.environment = Rails.application
8
+
9
+ js_file_contents = ERB.new(File.read('app/assets/javascripts/js-asset_paths.js.erb')).result(binding)
10
+ @js_context = ExecJS.compile(js_file_contents)
11
+ end
12
+
13
+ it 'PathHelper is an object' do
14
+ assert_equal 'object', @js_context.eval('typeof PathHelper')
15
+ end
16
+
17
+ it 'PathHelper.assetPath is a function' do
18
+ assert_equal 'function', @js_context.eval('typeof PathHelper.assetPath')
19
+ end
20
+
21
+ it 'PathHelper.fontPath is a function' do
22
+ assert_equal 'function', @js_context.eval('typeof PathHelper.fontPath')
23
+ end
24
+
25
+ it 'PathHelper.imagePath is a function' do
26
+ assert_equal 'function', @js_context.eval('typeof PathHelper.imagePath')
27
+ end
28
+
29
+ it 'PathHelper.javascriptPath is a function' do
30
+ assert_equal 'function', @js_context.eval('typeof PathHelper.javascriptPath')
31
+ end
32
+
33
+ it 'PathHelper.stylesheetPath is a function' do
34
+ assert_equal 'function', @js_context.eval('typeof PathHelper.stylesheetPath')
35
+ end
36
+
37
+ it 'PathHelper.videoPath is a function' do
38
+ assert_equal 'function', @js_context.eval('typeof PathHelper.videoPath')
39
+ end
40
+
41
+ it 'has the correct number of public functions' do
42
+ assert_equal JsAssetPaths::ASSET_METHODS.length + 1,
43
+ @js_context.eval('Object.keys(PathHelper).length')
44
+ end
45
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js-asset_paths
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sonny Michaud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-20 00:00:00.000000000 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -114,7 +114,21 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
- description: Access paths to compiled assets from in javascript.
117
+ - !ruby/object:Gem::Dependency
118
+ name: codeclimate-test-reporter
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '1'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '1'
131
+ description:
118
132
  email:
119
133
  - michaud.sonny@gmail.com
120
134
  executables: []
@@ -123,9 +137,11 @@ extra_rdoc_files: []
123
137
  files:
124
138
  - lib/js-asset_paths.rb
125
139
  - lib/js_asset_paths.rb
126
- - test/integration/bundler_gem_require_test.rb
127
- - test/lib/engine_test.rb
128
- - test/lib/generator_test.rb
140
+ - test/unit/digest_values_test.rb
141
+ - test/unit/engine_test.rb
142
+ - test/unit/generator_test.rb
143
+ - test/unit/js_asset_paths_test.rb
144
+ - test/unit/output_test.rb
129
145
  homepage: https://github.com/sonnym/js-asset_paths
130
146
  licenses:
131
147
  - MIT
@@ -151,6 +167,8 @@ signing_key:
151
167
  specification_version: 4
152
168
  summary: Access paths to compiled assets from in javascript.
153
169
  test_files:
154
- - test/integration/bundler_gem_require_test.rb
155
- - test/lib/engine_test.rb
156
- - test/lib/generator_test.rb
170
+ - test/unit/engine_test.rb
171
+ - test/unit/generator_test.rb
172
+ - test/unit/digest_values_test.rb
173
+ - test/unit/js_asset_paths_test.rb
174
+ - test/unit/output_test.rb
@@ -1,7 +0,0 @@
1
- require_relative '../test_helper'
2
-
3
- describe 'bundler gem' do
4
- it 'successfully runs a simple inline bundler script' do
5
- assert `test/support/bundlescript`
6
- end
7
- end