js-routes 0.9.8 → 0.9.9

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: b27e547dc710d8afdc60c2196335c9bfafa2e279
4
- data.tar.gz: 6dd7e82d07ba8f7326637e9ff37e6db477eea728
3
+ metadata.gz: 11383682f9433b305670ebe17feb5ac27ccb7626
4
+ data.tar.gz: 422793010efafcc0e4a205c0e3d04f5bdcfdf533
5
5
  SHA512:
6
- metadata.gz: a886ba634317aba0a1319ea2ba180c5428772d35a7011a03a1b26215d127151fd6253a5935bd685670eab3cb6844d5eef9d1c110d0be2a3d482f14f18bdab9b5
7
- data.tar.gz: 8624616cd6b8abf666e0a6b1e6e0669bf79f83453e3c2d268de308e75d18aa75a106aa3ba7b371686274b87fa867567c73021f018fe5c5ad3eefcb43f19bac28
6
+ metadata.gz: e75c78237118f839aedad8697e13c4f4364eec313c9ab6c84993f12bdfd98a08e8aae1914aa17f0318cd0130c9a763c3d145795a74b15df4ea55fd9fe6875c65
7
+ data.tar.gz: badb9598727f1b815a5b3ca7b4e746b723c6321de85e0233ee647d13052d929cc3a7663615d89e77a2e75df22417545872ad1c30b68315170a901f219a7310e8
@@ -0,0 +1,14 @@
1
+ ## master
2
+
3
+ ## v0.9.8
4
+
5
+ * Support AMD/Require.js [#111](https://github.com/railsware/js-routes/pull/111)
6
+ * Support trailing slash [#106](https://github.com/railsware/js-routes/pull/106)
7
+
8
+ ## v0.9.7
9
+
10
+ * Depend on railties [#97](https://github.com/railsware/js-routes/pull/97)
11
+ * Fix typeof error for IE [#95](https://github.com/railsware/js-routes/pull/95)
12
+ * Fix testing on ruby-head [#92](https://github.com/railsware/js-routes/pull/92)
13
+ * Correct thread safety issue in js-routes generation [#90](https://github.com/railsware/js-routes/pull/90)
14
+ * Use the `of` operator to detect for `to_param` and `id` in objects [#87](https://github.com/railsware/js-routes/pull/87)
@@ -9,7 +9,6 @@ Gem::Specification.new do |s|
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bogdan Gusiev"]
12
- s.date = %q{2013-02-13}
13
12
  s.description = %q{Generates javascript file that defines all Rails named routes as javascript helpers}
14
13
  s.email = %q{agresso@gmail.com}
15
14
  s.extra_rdoc_files = [
@@ -24,7 +23,7 @@ Gem::Specification.new do |s|
24
23
 
25
24
  s.add_runtime_dependency(%q<railties>, [">= 3.2"])
26
25
  s.add_runtime_dependency(%q<sprockets-rails>)
27
- s.add_development_dependency(%q<rspec>, [">= 2.14.0"])
26
+ s.add_development_dependency(%q<rspec>, [">= 3.0.0"])
28
27
  s.add_development_dependency(%q<bundler>, [">= 1.1.0"])
29
28
  s.add_development_dependency(%q<guard>, [">= 0"])
30
29
  s.add_development_dependency(%q<guard-coffeescript>, [">= 0"])
@@ -1,2 +1 @@
1
1
  require 'js_routes'
2
- require 'js_routes/engine'
@@ -1,4 +1,5 @@
1
1
  require 'uri'
2
+ require 'js_routes/engine' if defined?(Rails)
2
3
  require 'js_routes/version'
3
4
 
4
5
  class JsRoutes
@@ -145,7 +146,7 @@ class JsRoutes
145
146
 
146
147
  def any_match?(route, parent_route, matchers)
147
148
  matchers = Array(matchers)
148
- matchers.any? {|regex| [parent_route.try(:name), route.name].compact.join('') =~ regex}
149
+ matchers.any? {|regex| [parent_route.try(:name), route.name].compact.join('_') =~ regex}
149
150
  end
150
151
 
151
152
  def build_js(route, parent_route)
@@ -1,5 +1,5 @@
1
1
  class JsRoutes
2
- class Engine < Rails::Engine
2
+ class Engine < ::Rails::Engine
3
3
  JS_ROUTES_ASSET = 'js-routes'
4
4
 
5
5
  initializer 'js-routes.dependent_on_routes', after: "sprockets.environment" do
@@ -1,3 +1,3 @@
1
1
  class JsRoutes
2
- VERSION = "0.9.8"
2
+ VERSION = "0.9.9"
3
3
  end
@@ -10,13 +10,13 @@ describe JsRoutes do
10
10
  describe "generated js" do
11
11
  subject { JsRoutes.generate }
12
12
  it "should have correct function without arguments signature" do
13
- should include("inboxes_path: function(options)")
13
+ is_expected.to include("inboxes_path: function(options)")
14
14
  end
15
15
  it "should have correct function with arguments signature" do
16
- should include("inbox_message_path: function(_inbox_id, _id, options)")
16
+ is_expected.to include("inbox_message_path: function(_inbox_id, _id, options)")
17
17
  end
18
18
  it "should have correct function signature with unordered hash" do
19
- should include("inbox_message_attachment_path: function(_inbox_id, _message_id, _id, options)")
19
+ is_expected.to include("inbox_message_attachment_path: function(_inbox_id, _message_id, _id, options)")
20
20
  end
21
21
 
22
22
  it "routes should be sorted in alphabetical order" do
@@ -26,31 +26,32 @@ describe JsRoutes do
26
26
 
27
27
  describe ".generate!" do
28
28
 
29
- let(:name) { "#{File.dirname(__FILE__)}/../routes.js" }
29
+ let(:name) { "#{File.dirname(__FILE__)}/../routes.js" }
30
30
 
31
31
  before(:each) do
32
32
  FileUtils.rm_f(name)
33
33
  JsRoutes.generate!({:file => name})
34
34
  end
35
35
 
36
+ after(:all) do
37
+ FileUtils.rm_f("#{File.dirname(__FILE__)}/../routes.js") # let(:name) is not available here
38
+ end
39
+
36
40
  it "should not generate file before initialization" do
37
41
  # This method is alread fixed in Rails master
38
42
  # But in 3.2 stable we need to hack it like this
39
43
  if Rails.application.instance_variable_get("@initialized")
40
44
  pending
41
45
  end
42
- expect(File.exists?(name)).to be_false
46
+ expect(File.exists?(name)).to be_falsey
43
47
  end
44
48
 
45
- after(:all) do
46
- FileUtils.rm_f(name)
47
- end
48
49
  end
49
50
 
50
51
  describe "compiled javascript asset" do
51
52
  subject { ERB.new(File.read("app/assets/javascripts/js-routes.js.erb")).result(binding) }
52
53
  it "should have js routes code" do
53
- should include("inbox_message_path: function(_inbox_id, _id, options)")
54
+ is_expected.to include("inbox_message_path: function(_inbox_id, _id, options)")
54
55
  end
55
56
  end
56
57
  end
@@ -24,7 +24,16 @@ describe JsRoutes, "options" do
24
24
  it "should not exclude routes not under specified pattern" do
25
25
  expect(evaljs("Routes.inboxes_path()")).not_to be_nil
26
26
  end
27
+
28
+ context "for rails engine" do
29
+ let(:_options) { {:exclude => /^blog_app_posts/} }
30
+
31
+ it "should exclude specified engine route" do
32
+ expect(evaljs("Routes.blog_app_posts_path")).to be_nil
33
+ end
34
+ end
27
35
  end
36
+
28
37
  context "when include is specified" do
29
38
 
30
39
  let(:_options) { {:include => /^admin_/} }
@@ -36,6 +45,14 @@ describe JsRoutes, "options" do
36
45
  it "should not exclude routes not under specified pattern" do
37
46
  expect(evaljs("Routes.inboxes_path")).to be_nil
38
47
  end
48
+
49
+ context "for rails engine" do
50
+ let(:_options) { {:include => /^blog_app_posts/} }
51
+
52
+ it "should include specified engine route" do
53
+ expect(evaljs("Routes.blog_app_posts_path()")).not_to be_nil
54
+ end
55
+ end
39
56
  end
40
57
 
41
58
  context "when prefix with trailing slash is specified" do
@@ -20,7 +20,7 @@ describe "after Rails initialization" do
20
20
  end
21
21
 
22
22
  it "should generate routes file" do
23
- expect(File.exists?(NAME)).to be_true
23
+ expect(File.exists?(NAME)).to be_truthy
24
24
  end
25
25
 
26
26
  context "JsRoutes::Engine" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: js-routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-02-13 00:00:00.000000000 Z
11
+ date: 2014-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.14.0
47
+ version: 3.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.14.0
54
+ version: 3.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -135,6 +135,7 @@ files:
135
135
  - ".rspec"
136
136
  - ".travis.yml"
137
137
  - Appraisals
138
+ - CHANGELOG.md
138
139
  - Gemfile
139
140
  - Guardfile
140
141
  - LICENSE.txt