Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package rubygem-js-routes for
openSUSE:Factory checked in at 2022-08-09 15:26:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-js-routes (Old)
and /work/SRC/openSUSE:Factory/.rubygem-js-routes.new.1521 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-js-routes"
Tue Aug 9 15:26:36 2022 rev:27 rq:993490 version:2.2.4
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-js-routes/rubygem-js-routes.changes
2022-04-30 22:52:36.880230490 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-js-routes.new.1521/rubygem-js-routes.changes
2022-08-09 15:26:47.681358143 +0200
@@ -1,0 +2,12 @@
+Thu Aug 4 13:16:15 UTC 2022 - Stephan Kulow <[email protected]>
+
+updated to version 2.2.4
+ see installed CHANGELOG.md
+
+ ## v2.2.5
+
+ * Fix middleware generator
[#300](https://github.com/railsware/js-routes/issues/300)
+ * Support `params` special parameter
+
+
+-------------------------------------------------------------------
Old:
----
js-routes-2.2.3.gem
New:
----
js-routes-2.2.4.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-js-routes.spec ++++++
--- /var/tmp/diff_new_pack.CQ1piG/_old 2022-08-09 15:26:48.213359662 +0200
+++ /var/tmp/diff_new_pack.CQ1piG/_new 2022-08-09 15:26:48.217359674 +0200
@@ -24,7 +24,7 @@
#
Name: rubygem-js-routes
-Version: 2.2.3
+Version: 2.2.4
Release: 0
%define mod_name js-routes
%define mod_full_name %{mod_name}-%{version}
++++++ js-routes-2.2.3.gem -> js-routes-2.2.4.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md 2022-03-07 13:07:43.000000000 +0100
+++ new/CHANGELOG.md 2022-05-18 17:51:51.000000000 +0200
@@ -1,5 +1,10 @@
## master
+## v2.2.5
+
+* Fix middleware generator
[#300](https://github.com/railsware/js-routes/issues/300)
+* Support `params` special parameter
+
## v2.2.4
* Fix rails engine loading if sprockets is not in Gemfile. Fixes
[#294](https://github.com/railsware/js-routes/issues/294)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Readme.md new/Readme.md
--- old/Readme.md 2022-03-07 13:07:43.000000000 +0100
+++ new/Readme.md 2022-05-18 17:51:51.000000000 +0200
@@ -62,7 +62,7 @@
alert(Routes.post_path(1))
```
-Upgrade `rake assets:precompile` to update js-routes files:
+Upgrade `rake assets:precompile` to update js-routes files in `Rakefile`:
``` ruby
namespace :assets do
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/js_routes/generators/middleware.rb
new/lib/js_routes/generators/middleware.rb
--- old/lib/js_routes/generators/middleware.rb 2022-03-07 13:07:43.000000000
+0100
+++ new/lib/js_routes/generators/middleware.rb 2022-05-18 17:51:51.000000000
+0200
@@ -52,7 +52,7 @@
{},
{module_type: 'DTS'}
].map do |config|
- File.join('/', JsRoutes.new(config).configuration.output_file) + "\n"
+ File.join('/', JsRoutes::Configuration.new(config).output_file) + "\n"
end.join
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/js_routes/instance.rb
new/lib/js_routes/instance.rb
--- old/lib/js_routes/instance.rb 2022-03-07 13:07:43.000000000 +0100
+++ new/lib/js_routes/instance.rb 2022-05-18 17:51:51.000000000 +0200
@@ -2,7 +2,7 @@
require "js_routes/route"
module JsRoutes
- class Instance
+ class Instance # :nodoc:
attr_reader :configuration
#
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/js_routes/middleware.rb
new/lib/js_routes/middleware.rb
--- old/lib/js_routes/middleware.rb 2022-03-07 13:07:43.000000000 +0100
+++ new/lib/js_routes/middleware.rb 2022-05-18 17:51:51.000000000 +0200
@@ -21,12 +21,16 @@
def update_js_routes
new_mtime = routes_mtime
unless new_mtime == @mtime
- JsRoutes.generate!
- JsRoutes.definitions!
+ regenerate
@mtime = new_mtime
end
end
+ def regenerate
+ JsRoutes.generate!
+ JsRoutes.definitions!
+ end
+
def routes_mtime
File.mtime(@routes_file)
rescue Errno::ENOENT
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/js_routes/version.rb new/lib/js_routes/version.rb
--- old/lib/js_routes/version.rb 2022-03-07 13:07:43.000000000 +0100
+++ new/lib/js_routes/version.rb 2022-05-18 17:51:51.000000000 +0200
@@ -1,3 +1,3 @@
module JsRoutes
- VERSION = "2.2.3"
+ VERSION = "2.2.4"
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/routes.d.ts new/lib/routes.d.ts
--- old/lib/routes.d.ts 2022-03-07 13:07:43.000000000 +0100
+++ new/lib/routes.d.ts 2022-05-18 17:51:51.000000000 +0200
@@ -53,6 +53,7 @@
port: string | number;
anchor: string;
trailing_slash: boolean;
+ params: RouteParameters;
}>;
declare type RouteOptions = KeywordUrlOptions & RouteParameters;
declare type PartsTable = Record<string, {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/routes.js new/lib/routes.js
--- old/lib/routes.js 2022-03-07 13:07:43.000000000 +0100
+++ new/lib/routes.js 2022-05-18 17:51:51.000000000 +0200
@@ -222,12 +222,23 @@
...options,
};
const keyword_parameters = {};
- const query_parameters = {};
+ let query_parameters = {};
for (const key in options) {
if (!hasProp(options, key))
continue;
const value = options[key];
- if (this.is_reserved_option(key)) {
+ if (key === "params") {
+ if (this.is_object(value)) {
+ query_parameters = {
+ ...query_parameters,
+ ...value,
+ };
+ }
+ else {
+ throw new Error("params value should always be an
object");
+ }
+ }
+ else if (this.is_reserved_option(key)) {
keyword_parameters[key] = value;
}
else {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/routes.ts new/lib/routes.ts
--- old/lib/routes.ts 2022-03-07 13:07:43.000000000 +0100
+++ new/lib/routes.ts 2022-05-18 17:51:51.000000000 +0200
@@ -70,6 +70,7 @@
port: string | number;
anchor: string;
trailing_slash: boolean;
+ params: RouteParameters;
}>;
type RouteOptions = KeywordUrlOptions & RouteParameters;
@@ -365,11 +366,20 @@
};
const keyword_parameters: KeywordUrlOptions = {};
- const query_parameters: RouteParameters = {};
+ let query_parameters: RouteParameters = {};
for (const key in options) {
if (!hasProp(options, key)) continue;
const value = options[key];
- if (this.is_reserved_option(key)) {
+ if (key === "params") {
+ if (this.is_object(value)) {
+ query_parameters = {
+ ...query_parameters,
+ ...(value as RouteParameters),
+ };
+ } else {
+ throw new Error("params value should always be an object");
+ }
+ } else if (this.is_reserved_option(key)) {
keyword_parameters[key] = value as any;
} else {
if (
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2022-03-07 13:07:43.000000000 +0100
+++ new/metadata 2022-05-18 17:51:51.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: js-routes
version: !ruby/object:Gem::Version
- version: 2.2.3
+ version: 2.2.4
platform: ruby
authors:
- Bogdan Gusiev
autorequire:
bindir: bin
cert_chain: []
-date: 2022-03-07 00:00:00.000000000 Z
+date: 2022-05-18 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: railties
@@ -200,6 +200,7 @@
- spec/js_routes/module_types/umd_spec.rb
- spec/js_routes/options_spec.rb
- spec/js_routes/rails_routes_compatibility_spec.rb
+- spec/js_routes/route_specification_spec.rb
- spec/js_routes/zzz_last_post_rails_init_spec.rb
- spec/spec_helper.rb
- spec/support/routes.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/default_serializer_spec.rb
new/spec/js_routes/default_serializer_spec.rb
--- old/spec/js_routes/default_serializer_spec.rb 2022-03-07
13:07:43.000000000 +0100
+++ new/spec/js_routes/default_serializer_spec.rb 2022-05-18
17:51:51.000000000 +0200
@@ -7,25 +7,25 @@
end
it "should provide this method" do
- expect(evaljs("Routes.serialize({a: 1, b: [2,3], c: {d: 4, e: 5}, f:
''})")).to eq(
+ expectjs("Routes.serialize({a: 1, b: [2,3], c: {d: 4, e: 5}, f: ''})").to
eq(
"a=1&b%5B%5D=2&b%5B%5D=3&c%5Bd%5D=4&c%5Be%5D=5&f="
)
end
it "should provide this method" do
- expect(evaljs("Routes.serialize({a: 1, b: [2,3], c: {d: 4, e: 5}, f:
''})")).to eq(
+ expectjs("Routes.serialize({a: 1, b: [2,3], c: {d: 4, e: 5}, f: ''})").to
eq(
"a=1&b%5B%5D=2&b%5B%5D=3&c%5Bd%5D=4&c%5Be%5D=5&f="
)
end
it "works with JS suckiness" do
- expect(evaljs(
+ expectjs(
[
"const query = Object.create(null);",
"query.a = 1;",
"query.b = 2;",
"Routes.serialize(query);",
].join("\n")
- )).to eq("a=1&b=2")
+ ).to eq("a=1&b=2")
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/module_types/amd_spec.rb
new/spec/js_routes/module_types/amd_spec.rb
--- old/spec/js_routes/module_types/amd_spec.rb 2022-03-07 13:07:43.000000000
+0100
+++ new/spec/js_routes/module_types/amd_spec.rb 2022-05-18 17:51:51.000000000
+0200
@@ -29,7 +29,7 @@
end
it "should working from require" do
- expect(evaljs("require(['js-routes'], function(r){ return
r.inboxes_path(); })")).to eq(test_routes.inboxes_path())
+ expectjs("require(['js-routes'], function(r){ return r.inboxes_path();
})").to eq(test_routes.inboxes_path())
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/module_types/cjs_spec.rb
new/spec/js_routes/module_types/cjs_spec.rb
--- old/spec/js_routes/module_types/cjs_spec.rb 2022-03-07 13:07:43.000000000
+0100
+++ new/spec/js_routes/module_types/cjs_spec.rb 2022-05-18 17:51:51.000000000
+0200
@@ -10,6 +10,6 @@
end
it "should define module exports" do
- expect(evaljs("module.exports.inboxes_path()")).to
eq(test_routes.inboxes_path())
+ expectjs("module.exports.inboxes_path()").to eq(test_routes.inboxes_path())
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/module_types/dts/routes.spec.d.ts
new/spec/js_routes/module_types/dts/routes.spec.d.ts
--- old/spec/js_routes/module_types/dts/routes.spec.d.ts 2022-03-07
13:07:43.000000000 +0100
+++ new/spec/js_routes/module_types/dts/routes.spec.d.ts 2022-05-18
17:51:51.000000000 +0200
@@ -53,6 +53,7 @@
port: string | number;
anchor: string;
trailing_slash: boolean;
+ params: RouteParameters;
}>;
declare type RouteOptions = KeywordUrlOptions & RouteParameters;
declare type PartsTable = Record<string, {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/module_types/esm_spec.rb
new/spec/js_routes/module_types/esm_spec.rb
--- old/spec/js_routes/module_types/esm_spec.rb 2022-03-07 13:07:43.000000000
+0100
+++ new/spec/js_routes/module_types/esm_spec.rb 2022-05-18 17:51:51.000000000
+0200
@@ -13,7 +13,7 @@
end
it "defines route helpers" do
- expect(evaljs("inboxes_path()")).to eq(test_routes.inboxes_path())
+ expectjs("inboxes_path()").to eq(test_routes.inboxes_path())
end
it "exports route helpers" do
@@ -33,7 +33,7 @@
end
it "defines utility methods" do
- expect(evaljs("serialize({a: 1, b: 2})")).to eq({a: 1, b: 2}.to_param)
+ expectjs("serialize({a: 1, b: 2})").to eq({a: 1, b: 2}.to_param)
end
describe "compiled javascript asset" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/module_types/nil_spec.rb
new/spec/js_routes/module_types/nil_spec.rb
--- old/spec/js_routes/module_types/nil_spec.rb 2022-03-07 13:07:43.000000000
+0100
+++ new/spec/js_routes/module_types/nil_spec.rb 2022-05-18 17:51:51.000000000
+0200
@@ -36,7 +36,7 @@
end
it "should be possible" do
- expect(evaljs("r.inboxes_path()")).to eq(test_routes.inboxes_path())
+ expectjs("r.inboxes_path()").to eq(test_routes.inboxes_path())
end
end
@@ -50,8 +50,8 @@
evaljs(generated_js)
end
it "should use this namespace for routing" do
- expect(evaljs("window.Routes")).to be_nil
- expect(evaljs("window.PHM.inboxes_path")).not_to be_nil
+ expectjs("window.Routes").to be_nil
+ expectjs("window.PHM.inboxes_path").not_to be_nil
end
describe "is nested" do
@@ -60,7 +60,7 @@
let(:_options) { {namespace: "PHM.Routes"} }
it "should use this namespace for routing" do
- expect(evaljs("PHM.Routes.inboxes_path")).not_to be_nil
+ expectjs("PHM.Routes.inboxes_path").not_to be_nil
end
end
@@ -68,7 +68,7 @@
let(:_options) { {namespace: "PHM.Routes"} }
it "should initialize namespace" do
- expect(evaljs("window.PHM.Routes.inboxes_path")).not_to be_nil
+ expectjs("window.PHM.Routes.inboxes_path").not_to be_nil
end
end
@@ -77,8 +77,8 @@
let(:_options) { {namespace: "PHM.Routes"} }
it "should not overwrite existing parts" do
- expect(evaljs("window.PHM.Utils")).not_to be_nil
- expect(evaljs("window.PHM.Routes.inboxes_path")).not_to be_nil
+ expectjs("window.PHM.Utils").not_to be_nil
+ expectjs("window.PHM.Routes.inboxes_path").not_to be_nil
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/options_spec.rb
new/spec/js_routes/options_spec.rb
--- old/spec/js_routes/options_spec.rb 2022-03-07 13:07:43.000000000 +0100
+++ new/spec/js_routes/options_spec.rb 2022-05-18 17:51:51.000000000 +0200
@@ -37,7 +37,7 @@
it "should set configurable serializer" do
# expect the nonsense serializer above to have appened foo=bar
# to the end of the path
- expect(evaljs(%q(Routes.inboxes_path()))).to eql("/inboxes?foo=bar")
+ expectjs(%q(Routes.inboxes_path())).to eql("/inboxes?foo=bar")
end
end
@@ -57,7 +57,7 @@
it "uses JS serializer" do
evaljs("Routes.configure({serializer: function (object, prefix) {
return 'bar=baz'; }})")
- expect(evaljs(%q(Routes.inboxes_path({a: 1})))).to
eql("/inboxes?bar=baz")
+ expectjs(%q(Routes.inboxes_path({a: 1}))).to eql("/inboxes?bar=baz")
end
end
end
@@ -67,18 +67,18 @@
let(:_options) { {:exclude => /^admin_/} }
it "should exclude specified routes from file" do
- expect(evaljs("Routes.admin_users_path")).to be_nil
+ expectjs("Routes.admin_users_path").to be_nil
end
it "should not exclude routes not under specified pattern" do
- expect(evaljs("Routes.inboxes_path()")).not_to be_nil
+ expectjs("Routes.inboxes_path()").not_to be_nil
end
context "for rails engine" do
let(:_options) { {:exclude => /^blog_app_posts/} }
it "should exclude specified engine route" do
- expect(evaljs("Routes.blog_app_posts_path")).to be_nil
+ expectjs("Routes.blog_app_posts_path").to be_nil
end
end
end
@@ -88,22 +88,22 @@
let(:_options) { {:include => /^admin_/} }
it "should exclude specified routes from file" do
- expect(evaljs("Routes.admin_users_path()")).not_to be_nil
+ expectjs("Routes.admin_users_path()").not_to be_nil
end
it "should not exclude routes not under specified pattern" do
- expect(evaljs("Routes.inboxes_path")).to be_nil
+ expectjs("Routes.inboxes_path").to be_nil
end
context "with camel_case option" do
let(:_options) { {include: /^admin_/, camel_case: true} }
it "should exclude specified routes from file" do
- expect(evaljs("Routes.adminUsersPath()")).not_to be_nil
+ expectjs("Routes.adminUsersPath()").not_to be_nil
end
it "should not exclude routes not under specified pattern" do
- expect(evaljs("Routes.inboxesPath")).to be_nil
+ expectjs("Routes.inboxesPath").to be_nil
end
end
@@ -111,7 +111,7 @@
let(:_options) { {:include => /^blog_app_posts/} }
it "should include specified engine route" do
- expect(evaljs("Routes.blog_app_posts_path()")).not_to be_nil
+ expectjs("Routes.blog_app_posts_path()").not_to be_nil
end
end
end
@@ -121,13 +121,13 @@
let(:_options) { {:prefix => "/myprefix/" } }
it "should render routing with prefix" do
- expect(evaljs("Routes.inbox_path(1)")).to
eq("/myprefix#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox_path(1)").to
eq("/myprefix#{test_routes.inbox_path(1)}")
end
it "should render routing with prefix set in JavaScript" do
evaljs("Routes.configure({prefix: '/newprefix/'})")
- expect(evaljs("Routes.config().prefix")).to eq("/newprefix/")
- expect(evaljs("Routes.inbox_path(1)")).to
eq("/newprefix#{test_routes.inbox_path(1)}")
+ expectjs("Routes.config().prefix").to eq("/newprefix/")
+ expectjs("Routes.inbox_path(1)").to
eq("/newprefix#{test_routes.inbox_path(1)}")
end
end
@@ -137,7 +137,7 @@
let(:_options) { {:prefix => "http://localhost:3000" } }
it "should render routing with prefix" do
- expect(evaljs("Routes.inbox_path(1)")).to eq(_options[:prefix] +
test_routes.inbox_path(1))
+ expectjs("Routes.inbox_path(1)").to eq(_options[:prefix] +
test_routes.inbox_path(1))
end
end
@@ -146,12 +146,12 @@
let(:_options) { {:prefix => "/myprefix" } }
it "should render routing with prefix" do
- expect(evaljs("Routes.inbox_path(1)")).to
eq("/myprefix#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox_path(1)").to
eq("/myprefix#{test_routes.inbox_path(1)}")
end
it "should render routing with prefix set in JavaScript" do
evaljs("Routes.configure({prefix: '/newprefix/'})")
- expect(evaljs("Routes.inbox_path(1)")).to
eq("/newprefix#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox_path(1)").to
eq("/newprefix#{test_routes.inbox_path(1)}")
end
end
@@ -162,30 +162,30 @@
if Rails.version >= "5"
it "should render routing with default_format" do
- expect(evaljs("Routes.inbox_path(1)")).to eq(test_routes.inbox_path(1))
+ expectjs("Routes.inbox_path(1)").to eq(test_routes.inbox_path(1))
end
it "should render routing with default_format and zero object" do
- expect(evaljs("Routes.inbox_path(0)")).to eq(test_routes.inbox_path(0))
+ expectjs("Routes.inbox_path(0)").to eq(test_routes.inbox_path(0))
end
end
it "should override default_format when spefified implicitly" do
- expect(evaljs("Routes.inbox_path(1, {format: 'xml'})")).to
eq(test_routes.inbox_path(1, :format => "xml"))
+ expectjs("Routes.inbox_path(1, {format: 'xml'})").to
eq(test_routes.inbox_path(1, :format => "xml"))
end
it "should override nullify implicitly when specified implicitly" do
- expect(evaljs("Routes.inbox_path(1, {format: null})")).to
eq(test_routes.inbox_path(1, format: nil))
+ expectjs("Routes.inbox_path(1, {format: null})").to
eq(test_routes.inbox_path(1, format: nil))
end
it "shouldn't require the format" do
- expect(evaljs("Routes.json_only_path()")).to
eq(test_routes.json_only_path)
+ expectjs("Routes.json_only_path()").to eq(test_routes.json_only_path)
end
end
it "shouldn't include the format when {:format => false} is specified" do
- expect(evaljs("Routes.no_format_path()")).to
eq(test_routes.no_format_path())
- expect(evaljs("Routes.no_format_path({format: 'json'})")).to
eq(test_routes.no_format_path(format: 'json'))
+ expectjs("Routes.no_format_path()").to eq(test_routes.no_format_path())
+ expectjs("Routes.no_format_path({format: 'json'})").to
eq(test_routes.no_format_path(format: 'json'))
end
describe "default_url_options" do
@@ -193,21 +193,21 @@
context "provided by the default_url_options" do
let(:_options) { { :default_url_options => { :optional_id => "12",
:format => "json" } } }
it "should use this options to fill optional parameters" do
- expect(evaljs("Routes.things_path()")).to
eq(test_routes.things_path(12))
+ expectjs("Routes.things_path()").to eq(test_routes.things_path(12))
end
end
context "provided inline by the method parameters" do
let(:options) { { :default_url_options => { :optional_id => "12" } } }
it "should overwrite the default_url_options" do
- expect(evaljs("Routes.things_path({ optional_id: 34 })")).to
eq(test_routes.things_path(optional_id: 34))
+ expectjs("Routes.things_path({ optional_id: 34 })").to
eq(test_routes.things_path(optional_id: 34))
end
end
context "not provided" do
let(:_options) { { :default_url_options => { :format => "json" } } }
it "breaks" do
- expect(evaljs("Routes.foo_all_path()")).to
eq(test_routes.foo_all_path)
+ expectjs("Routes.foo_all_path()").to eq(test_routes.foo_all_path)
end
end
end
@@ -215,19 +215,19 @@
context "with required route parts" do
let(:_options) { { :default_url_options => { :inbox_id => "12" } } }
it "should use this options to fill optional parameters" do
- expect(evaljs("Routes.inbox_messages_path()")).to
eq(test_routes.inbox_messages_path)
+ expectjs("Routes.inbox_messages_path()").to
eq(test_routes.inbox_messages_path)
end
end
context "with optional and required route parts" do
let(:_options) { {:default_url_options => { :optional_id => "12" } } }
it "should use this options to fill the optional parameters" do
- expect(evaljs("Routes.thing_path(1)")).to eq test_routes.thing_path(1,
{ optional_id: "12" })
+ expectjs("Routes.thing_path(1)").to eq test_routes.thing_path(1, {
optional_id: "12" })
end
context "when passing options that do not have defaults" do
it "should use this options to fill the optional parameters" do
- expect(evaljs("Routes.thing_path(1, { format: 'json' })")).to eq
test_routes.thing_path(1, { optional_id: "12", format: "json" } ) #
test_routes.thing_path needs optional_id here to generate the correct route.
Not sure why.
+ expectjs("Routes.thing_path(1, { format: 'json' })").to eq
test_routes.thing_path(1, { optional_id: "12", format: "json" } ) #
test_routes.thing_path needs optional_id here to generate the correct route.
Not sure why.
end
end
end
@@ -236,7 +236,7 @@
let(:_options) { { :default_url_options => { :format => "json" } } }
it "uses JS defined value" do
evaljs("Routes.configure({default_url_options: {format: 'xml'}})")
- expect(evaljs("Routes.inboxes_path()")).to
eq(test_routes.inboxes_path(format: 'xml'))
+ expectjs("Routes.inboxes_path()").to
eq(test_routes.inboxes_path(format: 'xml'))
end
end
end
@@ -245,33 +245,33 @@
context "with default option" do
let(:_options) { Hash.new }
it "should working in params" do
- expect(evaljs("Routes.inbox_path(1, {trailing_slash: true})")).to
eq(test_routes.inbox_path(1, :trailing_slash => true))
+ expectjs("Routes.inbox_path(1, {trailing_slash: true})").to
eq(test_routes.inbox_path(1, :trailing_slash => true))
end
it "should working with additional params" do
- expect(evaljs("Routes.inbox_path(1, {trailing_slash: true, test:
'params'})")).to eq(test_routes.inbox_path(1, :trailing_slash => true, :test =>
'params'))
+ expectjs("Routes.inbox_path(1, {trailing_slash: true, test:
'params'})").to eq(test_routes.inbox_path(1, :trailing_slash => true, :test =>
'params'))
end
end
context "with default_url_options option" do
let(:_options) { {:default_url_options => {:trailing_slash => true}} }
it "should working" do
- expect(evaljs("Routes.inbox_path(1, {test: 'params'})")).to
eq(test_routes.inbox_path(1, :trailing_slash => true, :test => 'params'))
+ expectjs("Routes.inbox_path(1, {test: 'params'})").to
eq(test_routes.inbox_path(1, :trailing_slash => true, :test => 'params'))
end
it "should remove it by params" do
- expect(evaljs("Routes.inbox_path(1, {trailing_slash: false})")).to
eq(test_routes.inbox_path(1, trailing_slash: false))
+ expectjs("Routes.inbox_path(1, {trailing_slash: false})").to
eq(test_routes.inbox_path(1, trailing_slash: false))
end
end
context "with disabled default_url_options option" do
let(:_options) { {:default_url_options => {:trailing_slash => false}} }
it "should not use trailing_slash" do
- expect(evaljs("Routes.inbox_path(1, {test: 'params'})")).to
eq(test_routes.inbox_path(1, :test => 'params'))
+ expectjs("Routes.inbox_path(1, {test: 'params'})").to
eq(test_routes.inbox_path(1, :test => 'params'))
end
it "should use it by params" do
- expect(evaljs("Routes.inbox_path(1, {trailing_slash: true})")).to
eq(test_routes.inbox_path(1, :trailing_slash => true))
+ expectjs("Routes.inbox_path(1, {trailing_slash: true})").to
eq(test_routes.inbox_path(1, :trailing_slash => true))
end
end
end
@@ -280,18 +280,18 @@
context "with default option" do
let(:_options) { Hash.new }
it "should use snake case routes" do
- expect(evaljs("Routes.inbox_path(1)")).to eq(test_routes.inbox_path(1))
- expect(evaljs("Routes.inboxPath")).to be_nil
+ expectjs("Routes.inbox_path(1)").to eq(test_routes.inbox_path(1))
+ expectjs("Routes.inboxPath").to be_nil
end
end
context "with true" do
let(:_options) { { :camel_case => true } }
it "should generate camel case routes" do
- expect(evaljs("Routes.inbox_path")).to be_nil
- expect(evaljs("Routes.inboxPath")).not_to be_nil
- expect(evaljs("Routes.inboxPath(1)")).to eq(test_routes.inbox_path(1))
- expect(evaljs("Routes.inboxMessagesPath(10)")).to
eq(test_routes.inbox_messages_path(:inbox_id => 10))
+ expectjs("Routes.inbox_path").to be_nil
+ expectjs("Routes.inboxPath").not_to be_nil
+ expectjs("Routes.inboxPath(1)").to eq(test_routes.inbox_path(1))
+ expectjs("Routes.inboxMessagesPath(10)").to
eq(test_routes.inbox_messages_path(:inbox_id => 10))
end
end
end
@@ -300,8 +300,8 @@
context "with default option" do
let(:_options) { Hash.new }
it "should generate only path links" do
- expect(evaljs("Routes.inbox_path(1)")).to eq(test_routes.inbox_path(1))
- expect(evaljs("Routes.inbox_url")).to be_nil
+ expectjs("Routes.inbox_path(1)").to eq(test_routes.inbox_path(1))
+ expectjs("Routes.inbox_url").to be_nil
end
end
@@ -310,19 +310,19 @@
let(:_options) { { :url_links => true, :default_url_options => {:host
=> "example.com"} } }
it "uses the specified host, defaults protocol to http, defaults port
to 80 (leaving it blank)" do
- expect(evaljs("Routes.inbox_url(1)")).to
eq("http://example.com#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox_url(1)").to
eq("http://example.com#{test_routes.inbox_path(1)}")
end
it "does not override protocol when specified in route" do
- expect(evaljs("Routes.new_session_url()")).to
eq("https://example.com#{test_routes.new_session_path}")
+ expectjs("Routes.new_session_url()").to
eq("https://example.com#{test_routes.new_session_path}")
end
it "does not override host when specified in route" do
- expect(evaljs("Routes.sso_url()")).to eq(test_routes.sso_url)
+ expectjs("Routes.sso_url()").to eq(test_routes.sso_url)
end
it "does not override port when specified in route" do
- expect(evaljs("Routes.portals_url()")).to
eq("http://example.com:8080#{test_routes.portals_path}")
+ expectjs("Routes.portals_url()").to
eq("http://example.com:8080#{test_routes.portals_path}")
end
end
@@ -330,19 +330,19 @@
let(:_options) { { :url_links => true, :default_url_options => {:host
=> "example.com", :protocol => "ftp"} } }
it "uses the specified protocol and host, defaults port to 80 (leaving
it blank)" do
- expect(evaljs("Routes.inbox_url(1)")).to
eq("ftp://example.com#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox_url(1)").to
eq("ftp://example.com#{test_routes.inbox_path(1)}")
end
it "does not override protocol when specified in route" do
- expect(evaljs("Routes.new_session_url()")).to
eq("https://example.com#{test_routes.new_session_path}")
+ expectjs("Routes.new_session_url()").to
eq("https://example.com#{test_routes.new_session_path}")
end
it "does not override host when host is specified in route" do
- expect(evaljs("Routes.sso_url()")).to
eq("ftp://sso.example.com#{test_routes.sso_path}")
+ expectjs("Routes.sso_url()").to
eq("ftp://sso.example.com#{test_routes.sso_path}")
end
it "does not override port when specified in route" do
- expect(evaljs("Routes.portals_url()")).to
eq("ftp://example.com:8080#{test_routes.portals_path}")
+ expectjs("Routes.portals_url()").to
eq("ftp://example.com:8080#{test_routes.portals_path}")
end
end
@@ -350,40 +350,40 @@
let(:_options) { { :url_links => true, :default_url_options => {:host
=> "example.com", :port => 3000} } }
it "uses the specified host and port, defaults protocol to http" do
- expect(evaljs("Routes.inbox_url(1)")).to
eq("http://example.com:3000#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox_url(1)").to
eq("http://example.com:3000#{test_routes.inbox_path(1)}")
end
it "does not override protocol when specified in route" do
- expect(evaljs("Routes.new_session_url()")).to
eq("https://example.com:3000#{test_routes.new_session_path}")
+ expectjs("Routes.new_session_url()").to
eq("https://example.com:3000#{test_routes.new_session_path}")
end
it "does not override host, protocol, or port when host is specified
in route" do
- expect(evaljs("Routes.sso_url()")).to
eq("http://sso.example.com:3000" + test_routes.sso_path)
+ expectjs("Routes.sso_url()").to eq("http://sso.example.com:3000" +
test_routes.sso_path)
end
it "does not override parts when specified in route" do
- expect(evaljs("Routes.secret_root_url()")).to
eq(test_routes.secret_root_url)
+ expectjs("Routes.secret_root_url()").to
eq(test_routes.secret_root_url)
end
end
context "with camel_case option" do
let(:_options) { { :camel_case => true, :url_links => true,
:default_url_options => {:host => "example.com"} } }
it "should generate path and url links" do
- expect(evaljs("Routes.inboxUrl(1)")).to
eq("http://example.com#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inboxUrl(1)").to
eq("http://example.com#{test_routes.inbox_path(1)}")
end
end
context "with prefix option" do
let(:_options) { { :prefix => "/api", :url_links => true,
:default_url_options => {:host => 'example.com'} } }
it "should generate path and url links" do
- expect(evaljs("Routes.inbox_url(1)")).to
eq("http://example.com/api#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox_url(1)").to
eq("http://example.com/api#{test_routes.inbox_path(1)}")
end
end
context "with compact option" do
let(:_options) { { :compact => true, :url_links => true,
:default_url_options => {:host => 'example.com'} } }
it "does not affect url helpers" do
- expect(evaljs("Routes.inbox_url(1)")).to
eq("http://example.com#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox_url(1)").to
eq("http://example.com#{test_routes.inbox_path(1)}")
end
end
end
@@ -415,31 +415,31 @@
let(:_options) { { :url_links => true } }
it "uses the current host" do
- expect(evaljs("Routes.inbox_path")).not_to be_nil
- expect(evaljs("Routes.inbox_url")).not_to be_nil
- expect(evaljs("Routes.inbox_url(1)")).to
eq("http://current.example.com#{test_routes.inbox_path(1)}")
- expect(evaljs("Routes.inbox_url(1, { test_key: \"test_val\" })")).to
eq("http://current.example.com#{test_routes.inbox_path(1, :test_key =>
"test_val")}")
- expect(evaljs("Routes.new_session_url()")).to
eq("https://current.example.com#{test_routes.new_session_path}")
+ expectjs("Routes.inbox_path").not_to be_nil
+ expectjs("Routes.inbox_url").not_to be_nil
+ expectjs("Routes.inbox_url(1)").to
eq("http://current.example.com#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox_url(1, { test_key: \"test_val\" })").to
eq("http://current.example.com#{test_routes.inbox_path(1, :test_key =>
"test_val")}")
+ expectjs("Routes.new_session_url()").to
eq("https://current.example.com#{test_routes.new_session_path}")
end
it "doesn't use current when specified in the route" do
- expect(evaljs("Routes.sso_url()")).to eq(test_routes.sso_url)
+ expectjs("Routes.sso_url()").to eq(test_routes.sso_url)
end
it "uses host option as an argument" do
- expect(evaljs("Routes.secret_root_url({host: 'another.com'})")).to
eq(test_routes.secret_root_url(host: 'another.com'))
+ expectjs("Routes.secret_root_url({host: 'another.com'})").to
eq(test_routes.secret_root_url(host: 'another.com'))
end
it "uses port option as an argument" do
- expect(evaljs("Routes.secret_root_url({host: 'localhost', port:
8080})")).to eq(test_routes.secret_root_url(host: 'localhost', port: 8080))
+ expectjs("Routes.secret_root_url({host: 'localhost', port:
8080})").to eq(test_routes.secret_root_url(host: 'localhost', port: 8080))
end
it "uses protocol option as an argument" do
- expect(evaljs("Routes.secret_root_url({host: 'localhost', protocol:
'https'})")).to eq(test_routes.secret_root_url(protocol: 'https', host:
'localhost'))
+ expectjs("Routes.secret_root_url({host: 'localhost', protocol:
'https'})").to eq(test_routes.secret_root_url(protocol: 'https', host:
'localhost'))
end
it "uses subdomain option as an argument" do
- expect(evaljs("Routes.secret_root_url({subdomain: 'custom'})")).to
eq(test_routes.secret_root_url(subdomain: 'custom'))
+ expectjs("Routes.secret_root_url({subdomain: 'custom'})").to
eq(test_routes.secret_root_url(subdomain: 'custom'))
end
end
end
@@ -449,8 +449,8 @@
let(:_options) { { url_links: true } }
it 'generates path' do
- expect(evaljs("Routes.inbox_url(1)")).to eq test_routes.inbox_path(1)
- expect(evaljs("Routes.new_session_url()")).to eq
test_routes.new_session_path
+ expectjs("Routes.inbox_url(1)").to eq test_routes.inbox_path(1)
+ expectjs("Routes.new_session_url()").to eq
test_routes.new_session_path
end
end
end
@@ -459,9 +459,9 @@
describe "when the compact mode is enabled" do
let(:_options) { { :compact => true } }
it "removes _path suffix from path helpers" do
- expect(evaljs("Routes.inbox_path")).to be_nil
- expect(evaljs("Routes.inboxes()")).to eq(test_routes.inboxes_path())
- expect(evaljs("Routes.inbox(2)")).to eq(test_routes.inbox_path(2))
+ expectjs("Routes.inbox_path").to be_nil
+ expectjs("Routes.inboxes()").to eq(test_routes.inboxes_path())
+ expectjs("Routes.inbox(2)").to eq(test_routes.inbox_path(2))
end
context "with url_links option" do
@@ -473,8 +473,8 @@
let(:_options) { { :compact => true, :url_links => true,
default_url_options: {host: 'localhost'} } }
it "should not strip urls" do
- expect(evaljs("Routes.inbox(1)")).to eq(test_routes.inbox_path(1))
- expect(evaljs("Routes.inbox_url(1)")).to
eq("http://localhost#{test_routes.inbox_path(1)}")
+ expectjs("Routes.inbox(1)").to eq(test_routes.inbox_path(1))
+ expectjs("Routes.inbox_url(1)").to
eq("http://localhost#{test_routes.inbox_path(1)}")
end
end
end
@@ -483,9 +483,9 @@
let(:_options) { { special_options_key: :__options__ } }
it "can be redefined" do
expect {
- expect(evaljs("Routes.inbox_message_path({inbox_id: 1, id: 2,
_options: true})")).to eq("")
+ expectjs("Routes.inbox_message_path({inbox_id: 1, id: 2, _options:
true})").to eq("")
}.to raise_error(js_error_class)
- expect(evaljs("Routes.inbox_message_path({inbox_id: 1, id: 2,
__options__: true})")).to eq(test_routes.inbox_message_path(inbox_id: 1, id: 2))
+ expectjs("Routes.inbox_message_path({inbox_id: 1, id: 2, __options__:
true})").to eq(test_routes.inbox_message_path(inbox_id: 1, id: 2))
end
end
@@ -493,7 +493,7 @@
let(:_options) { {:application => BlogEngine::Engine} }
it "should include specified engine route" do
- expect(evaljs("Routes.posts_path()")).not_to be_nil
+ expectjs("Routes.posts_path()").not_to be_nil
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/rails_routes_compatibility_spec.rb
new/spec/js_routes/rails_routes_compatibility_spec.rb
--- old/spec/js_routes/rails_routes_compatibility_spec.rb 2022-03-07
13:07:43.000000000 +0100
+++ new/spec/js_routes/rails_routes_compatibility_spec.rb 2022-05-18
17:51:51.000000000 +0200
@@ -10,11 +10,11 @@
end
it "should generate collection routing" do
- expect(evaljs("Routes.inboxes_path()")).to eq(test_routes.inboxes_path())
+ expectjs("Routes.inboxes_path()").to eq(test_routes.inboxes_path())
end
it "should generate member routing" do
- expect(evaljs("Routes.inbox_path(1)")).to eq(test_routes.inbox_path(1))
+ expectjs("Routes.inbox_path(1)").to eq(test_routes.inbox_path(1))
end
it "should raise error if required argument is not passed",
:aggregate_failures do
@@ -27,8 +27,8 @@
expect { evaljs("Routes.book_title_path()") }
.to raise_error(/Route missing required keys: title/)
- expect( evaljs("try {Routes.thing_path()} catch (e) { e.name }") ).to
eq('ParametersMissing')
- expect( evaljs("try {Routes.thing_path()} catch (e) { e.keys }") ).to
eq(['id'])
+ expectjs("try {Routes.thing_path()} catch (e) { e.name }") .to
eq('ParametersMissing')
+ expectjs("try {Routes.thing_path()} catch (e) { e.keys }") .to eq(['id'])
end
it "should produce error stacktraces including function names" do
@@ -45,129 +45,145 @@
end
it "should support 0 as a member parameter" do
- expect(evaljs("Routes.inbox_path(0)")).to eq(test_routes.inbox_path(0))
+ expectjs("Routes.inbox_path(0)").to eq(test_routes.inbox_path(0))
end
it "should generate nested routing with one parameter" do
- expect(evaljs("Routes.inbox_messages_path(1)")).to
eq(test_routes.inbox_messages_path(1))
+ expectjs("Routes.inbox_messages_path(1)").to
eq(test_routes.inbox_messages_path(1))
end
it "should generate nested routing" do
- expect(evaljs("Routes.inbox_message_path(1,2)")).to
eq(test_routes.inbox_message_path(1, 2))
+ expectjs("Routes.inbox_message_path(1,2)").to
eq(test_routes.inbox_message_path(1, 2))
end
it "should generate routing with format" do
- expect(evaljs("Routes.inbox_path(1, {format: 'json'})")).to
eq(test_routes.inbox_path(1, :format => "json"))
+ expectjs("Routes.inbox_path(1, {format: 'json'})").to
eq(test_routes.inbox_path(1, :format => "json"))
end
it "should support routes with reserved javascript words as parameters" do
- expect(evaljs("Routes.object_path(1, 2)")).to
eq(test_routes.object_path(1,2))
+ expectjs("Routes.object_path(1, 2)").to eq(test_routes.object_path(1,2))
end
it "should support routes with trailing_slash" do
- expect(evaljs("Routes.inbox_path(1, {trailing_slash: true})")).to
eq(test_routes.inbox_path(1, trailing_slash: true))
+ expectjs("Routes.inbox_path(1, {trailing_slash: true})").to
eq(test_routes.inbox_path(1, trailing_slash: true))
end
it "should support url anchor given as parameter" do
- expect(evaljs("Routes.inbox_path(1, {anchor: 'hello'})")).to
eq(test_routes.inbox_path(1, :anchor => "hello"))
+ expectjs("Routes.inbox_path(1, {anchor: 'hello'})").to
eq(test_routes.inbox_path(1, :anchor => "hello"))
end
it "should support url anchor and get parameters" do
- expect(evaljs("Routes.inbox_path(1, {expanded: true, anchor:
'hello'})")).to eq(test_routes.inbox_path(1, :expanded => true, :anchor =>
"hello"))
+ expectjs("Routes.inbox_path(1, {expanded: true, anchor: 'hello'})").to
eq(test_routes.inbox_path(1, :expanded => true, :anchor => "hello"))
end
it "should support required parameters given as options hash" do
- expect(evaljs("Routes.search_path({q: 'hello'})")).to
eq(test_routes.search_path(:q => 'hello'))
+ expectjs("Routes.search_path({q: 'hello'})").to
eq(test_routes.search_path(:q => 'hello'))
end
it "should use irregular ActiveSupport pluralizations" do
- expect(evaljs("Routes.budgies_path()")).to eq(test_routes.budgies_path)
- expect(evaljs("Routes.budgie_path(1)")).to eq(test_routes.budgie_path(1))
- expect(evaljs("Routes.budgy_path")).to eq(nil)
- expect(evaljs("Routes.budgie_descendents_path(1)")).to
eq(test_routes.budgie_descendents_path(1))
+ expectjs("Routes.budgies_path()").to eq(test_routes.budgies_path)
+ expectjs("Routes.budgie_path(1)").to eq(test_routes.budgie_path(1))
+ expectjs("Routes.budgy_path").to eq(nil)
+ expectjs("Routes.budgie_descendents_path(1)").to
eq(test_routes.budgie_descendents_path(1))
end
it "should support route with parameters containing symbols that need
URI-encoding", :aggregate_failures do
- expect(evaljs("Routes.inbox_path('#hello')")).to
eq(test_routes.inbox_path('#hello'))
- expect(evaljs("Routes.inbox_path('some param')")).to
eq(test_routes.inbox_path('some param'))
- expect(evaljs("Routes.inbox_path('some param with more & more encode
symbols')")).to eq(test_routes.inbox_path('some param with more & more encode
symbols'))
+ expectjs("Routes.inbox_path('#hello')").to
eq(test_routes.inbox_path('#hello'))
+ expectjs("Routes.inbox_path('some param')").to
eq(test_routes.inbox_path('some param'))
+ expectjs("Routes.inbox_path('some param with more & more encode
symbols')").to eq(test_routes.inbox_path('some param with more & more encode
symbols'))
end
it "should support route with parameters containing symbols not need
URI-encoding", :aggregate_failures do
- expect(evaljs("Routes.inbox_path(':some_id')")).to
eq(test_routes.inbox_path(':some_id'))
- expect(evaljs("Routes.inbox_path('.+')")).to
eq(test_routes.inbox_path('.+'))
+ expectjs("Routes.inbox_path(':some_id')").to
eq(test_routes.inbox_path(':some_id'))
+ expectjs("Routes.inbox_path('.+')").to eq(test_routes.inbox_path('.+'))
end
describe "when route has defaults" do
it "should support route default format" do
- expect(evaljs("Routes.api_purchases_path()")).to
eq(test_routes.api_purchases_path)
+ expectjs("Routes.api_purchases_path()").to
eq(test_routes.api_purchases_path)
end
it 'should support route default subdomain' do
- expect(evaljs("Routes.backend_root_path()")).to
eq(test_routes.backend_root_path)
+ expectjs("Routes.backend_root_path()").to
eq(test_routes.backend_root_path)
end
it "should support default format override" do
- expect(evaljs("Routes.api_purchases_path({format: 'xml'})")).to
eq(test_routes.api_purchases_path(format: 'xml'))
+ expectjs("Routes.api_purchases_path({format: 'xml'})").to
eq(test_routes.api_purchases_path(format: 'xml'))
end
it "should support default format override by passing it in args" do
- expect(evaljs("Routes.api_purchases_path('xml')")).to
eq(test_routes.api_purchases_path('xml'))
+ expectjs("Routes.api_purchases_path('xml')").to
eq(test_routes.api_purchases_path('xml'))
end
it "doesn't apply defaults to path" do
- expect(evaljs("Routes.with_defaults_path()")).to
eq(test_routes.with_defaults_path)
- expect(evaljs("Routes.with_defaults_path({format: 'json'})")).to
eq(test_routes.with_defaults_path(format: 'json'))
+ expectjs("Routes.with_defaults_path()").to
eq(test_routes.with_defaults_path)
+ expectjs("Routes.with_defaults_path({format: 'json'})").to
eq(test_routes.with_defaults_path(format: 'json'))
end
end
context "with rails engines" do
it "should support simple route" do
- expect(evaljs("Routes.blog_app_posts_path()")).to
eq(blog_routes.posts_path())
+ expectjs("Routes.blog_app_posts_path()").to eq(blog_routes.posts_path())
end
it "should support root route" do
- expect(evaljs("Routes.blog_app_path()")).to
eq(test_routes.blog_app_path())
+ expectjs("Routes.blog_app_path()").to eq(test_routes.blog_app_path())
end
it "should support route with parameters" do
- expect(evaljs("Routes.blog_app_post_path(1)")).to
eq(blog_routes.post_path(1))
+ expectjs("Routes.blog_app_post_path(1)").to eq(blog_routes.post_path(1))
end
it "should support root path" do
- expect(evaljs("Routes.blog_app_root_path()")).to
eq(blog_routes.root_path)
+ expectjs("Routes.blog_app_root_path()").to eq(blog_routes.root_path)
end
it "should support single route mapping" do
- expect(evaljs("Routes.support_path({page: 3})")).to
eq(test_routes.support_path(:page => 3))
+ expectjs("Routes.support_path({page: 3})").to
eq(test_routes.support_path(:page => 3))
end
it 'works' do
- expect(evaljs("Routes.planner_manage_path({locale: 'ua'})")).to
eq(planner_routes.manage_path(locale: 'ua'))
- expect(evaljs("Routes.planner_manage_path()")).to
eq(planner_routes.manage_path)
+ expectjs("Routes.planner_manage_path({locale: 'ua'})").to
eq(planner_routes.manage_path(locale: 'ua'))
+ expectjs("Routes.planner_manage_path()").to
eq(planner_routes.manage_path)
end
end
it "shouldn't require the format" do
- expect(evaljs("Routes.json_only_path({format: 'json'})")).to
eq(test_routes.json_only_path(:format => 'json'))
+ expectjs("Routes.json_only_path({format: 'json'})").to
eq(test_routes.json_only_path(:format => 'json'))
end
it "should serialize object with empty string value" do
- expect(evaljs("Routes.inboxes_path({a: '', b: 1})")).to
eq(test_routes.inboxes_path(:a => '', :b => 1))
+ expectjs("Routes.inboxes_path({a: '', b: 1})").to
eq(test_routes.inboxes_path(:a => '', :b => 1))
end
it "should support utf-8 route" do
- expect(evaljs("Routes.hello_path()")).to eq(test_routes.hello_path)
+ expectjs("Routes.hello_path()").to eq(test_routes.hello_path)
end
it "should support root_path" do
- expect(evaljs("Routes.root_path()")).to eq(test_routes.root_path)
+ expectjs("Routes.root_path()").to eq(test_routes.root_path)
+ end
+
+ describe "params parameter" do
+ it "works" do
+ expectjs("Routes.inboxes_path({params: {key: 'value'}})").to
eq(test_routes.inboxes_path(params: {key: 'value'}))
+ end
+
+ it "allows keyword key as a query parameter" do
+ expectjs("Routes.inboxes_path({params: {anchor: 'a', params: 'p'}})").to
eq(test_routes.inboxes_path(params: {anchor: 'a', params: 'p'}))
+ end
+
+ it "throws when value is not an object" do
+ expect {
+ evaljs("Routes.inboxes_path({params: 1})")
+ }.to raise_error(js_error_class)
+ end
end
describe "get parameters" do
it "should support simple get parameters" do
- expect(evaljs("Routes.inbox_path(1, {format: 'json', lang: 'ua', q:
'hello'})")).to eq(test_routes.inbox_path(1, :lang => "ua", :q => "hello",
:format => "json"))
+ expectjs("Routes.inbox_path(1, {format: 'json', lang: 'ua', q:
'hello'})").to eq(test_routes.inbox_path(1, :lang => "ua", :q => "hello",
:format => "json"))
end
it "should support array get parameters" do
- expect(evaljs("Routes.inbox_path(1, {hello: ['world', 'mars']})")).to
eq(test_routes.inbox_path(1, :hello => [:world, :mars]))
+ expectjs("Routes.inbox_path(1, {hello: ['world', 'mars']})").to
eq(test_routes.inbox_path(1, :hello => [:world, :mars]))
end
context "object without prototype" do
@@ -177,94 +193,94 @@
end
it "should still work correctly" do
- expect(evaljs("Routes.inbox_path(inbox, params)")).to eq(
+ expectjs("Routes.inbox_path(inbox, params)").to eq(
test_routes.inbox_path(1, q: "hello")
)
end
end
it "should support nested get parameters" do
- expect(evaljs("Routes.inbox_path(1, {format: 'json', env: 'test',
search: { category_ids: [2,5], q: 'hello'}})")).to eq(
+ expectjs("Routes.inbox_path(1, {format: 'json', env: 'test', search: {
category_ids: [2,5], q: 'hello'}})").to eq(
test_routes.inbox_path(1, :env => 'test', :search => {:category_ids =>
[2,5], :q => "hello"}, :format => "json")
)
end
it "should support null and undefined parameters" do
- expect(evaljs("Routes.inboxes_path({uri: null, key: undefined})")).to
eq(test_routes.inboxes_path(:uri => nil, :key => nil))
+ expectjs("Routes.inboxes_path({uri: null, key: undefined})").to
eq(test_routes.inboxes_path(:uri => nil, :key => nil))
end
it "should escape get parameters" do
- expect(evaljs("Routes.inboxes_path({uri: 'http://example.com'})")).to
eq(test_routes.inboxes_path(:uri => 'http://example.com'))
+ expectjs("Routes.inboxes_path({uri: 'http://example.com'})").to
eq(test_routes.inboxes_path(:uri => 'http://example.com'))
end
it "should support nested object null parameters" do
- expect(evaljs("Routes.inboxes_path({hello: {world: null}})")).to
eq(test_routes.inboxes_path(:hello => {:world => nil}))
+ expectjs("Routes.inboxes_path({hello: {world: null}})").to
eq(test_routes.inboxes_path(:hello => {:world => nil}))
end
end
context "routes globbing" do
it "should be supported as parameters" do
- expect(evaljs("Routes.book_path('thrillers', 1)")).to
eq(test_routes.book_path('thrillers', 1))
+ expectjs("Routes.book_path('thrillers', 1)").to
eq(test_routes.book_path('thrillers', 1))
end
it "should support routes globbing as array" do
- expect(evaljs("Routes.book_path(['thrillers'], 1)")).to
eq(test_routes.book_path(['thrillers'], 1))
+ expectjs("Routes.book_path(['thrillers'], 1)").to
eq(test_routes.book_path(['thrillers'], 1))
end
it "should support routes globbing as array" do
- expect(evaljs("Routes.book_path([1, 2, 3], 1)")).to
eq(test_routes.book_path([1, 2, 3], 1))
+ expectjs("Routes.book_path([1, 2, 3], 1)").to
eq(test_routes.book_path([1, 2, 3], 1))
end
it "should support routes globbing with slash" do
- expect(evaljs("Routes.book_path('a_test/b_test/c_test', 1)")).to
eq(test_routes.book_path('a_test/b_test/c_test', 1))
+ expectjs("Routes.book_path('a_test/b_test/c_test', 1)").to
eq(test_routes.book_path('a_test/b_test/c_test', 1))
end
it "should support routes globbing as hash" do
- expect(evaljs("Routes.book_path('a%b', 1)")).to
eq(test_routes.book_path('a%b', 1))
+ expectjs("Routes.book_path('a%b', 1)").to
eq(test_routes.book_path('a%b', 1))
end
it "should support routes globbing as array with optional params" do
- expect(evaljs("Routes.book_path([1, 2, 3, 5], 1, {c: '1'})")).to
eq(test_routes.book_path([1, 2, 3, 5], 1, { :c => "1" }))
+ expectjs("Routes.book_path([1, 2, 3, 5], 1, {c: '1'})").to
eq(test_routes.book_path([1, 2, 3, 5], 1, { :c => "1" }))
end
it "should support routes globbing in book_title route as array" do
- expect(evaljs("Routes.book_title_path('john', ['thrillers',
'comedian'])")).to eq(test_routes.book_title_path('john', ['thrillers',
'comedian']))
+ expectjs("Routes.book_title_path('john', ['thrillers', 'comedian'])").to
eq(test_routes.book_title_path('john', ['thrillers', 'comedian']))
end
it "should support routes globbing in book_title route as array with
optional params" do
- expect(evaljs("Routes.book_title_path('john', ['thrillers', 'comedian'],
{some_key: 'some_value'})")).to eq(test_routes.book_title_path('john',
['thrillers', 'comedian'], {:some_key => 'some_value'}))
+ expectjs("Routes.book_title_path('john', ['thrillers', 'comedian'],
{some_key: 'some_value'})").to eq(test_routes.book_title_path('john',
['thrillers', 'comedian'], {:some_key => 'some_value'}))
end
end
context "using optional path fragments" do
context "including not optional parts" do
it "should include everything that is not optional" do
- expect(evaljs("Routes.foo_path()")).to eq(test_routes.foo_path)
+ expectjs("Routes.foo_path()").to eq(test_routes.foo_path)
end
end
context "but not including them" do
it "should not include the optional parts" do
- expect(evaljs("Routes.things_path()")).to eq(test_routes.things_path)
- expect(evaljs("Routes.things_path({ q: 'hello' })")).to
eq(test_routes.things_path(q: 'hello'))
+ expectjs("Routes.things_path()").to eq(test_routes.things_path)
+ expectjs("Routes.things_path({ q: 'hello' })").to
eq(test_routes.things_path(q: 'hello'))
end
it "treats false as absent optional part" do
pending("https://github.com/rails/rails/issues/42280")
- expect(evaljs("Routes.things_path(false)")).to
eq(test_routes.things_path(false))
+ expectjs("Routes.things_path(false)").to
eq(test_routes.things_path(false))
end
it "treats false as absent optional part when default is specified" do
- expect(evaljs("Routes.campaigns_path(false)")).to
eq(test_routes.campaigns_path(false))
+ expectjs("Routes.campaigns_path(false)").to
eq(test_routes.campaigns_path(false))
end
it "should not require the optional parts as arguments" do
- expect(evaljs("Routes.thing_path(null, 5)")).to
eq(test_routes.thing_path(nil, 5))
+ expectjs("Routes.thing_path(null, 5)").to
eq(test_routes.thing_path(nil, 5))
end
it "should treat undefined as non-given optional part" do
- expect(evaljs("Routes.thing_path(5, {optional_id: undefined})")).to
eq(test_routes.thing_path(5, :optional_id => nil))
+ expectjs("Routes.thing_path(5, {optional_id: undefined})").to
eq(test_routes.thing_path(5, :optional_id => nil))
end
it "should raise error when passing non-full list of arguments and some
query params" do
@@ -273,15 +289,15 @@
end
it "should treat null as non-given optional part" do
- expect(evaljs("Routes.thing_path(5, {optional_id: null})")).to
eq(test_routes.thing_path(5, :optional_id => nil))
+ expectjs("Routes.thing_path(5, {optional_id: null})").to
eq(test_routes.thing_path(5, :optional_id => nil))
end
it "should work when passing required params in options" do
- expect(evaljs("Routes.thing_deep_path({second_required: 1,
third_required: 2})")).to eq(test_routes.thing_deep_path(second_required: 1,
third_required: 2))
+ expectjs("Routes.thing_deep_path({second_required: 1, third_required:
2})").to eq(test_routes.thing_deep_path(second_required: 1, third_required: 2))
end
it "should skip leading and trailing optional parts" do
- expect(evaljs("Routes.thing_deep_path(1, 2)")).to
eq(test_routes.thing_deep_path(1, 2))
+ expectjs("Routes.thing_deep_path(1, 2)").to
eq(test_routes.thing_deep_path(1, 2))
end
end
@@ -291,30 +307,30 @@
end
it "should include the optional parts" do
- expect(evaljs("Routes.things_path({optional_id: 5})")).to
eq(test_routes.things_path(:optional_id => 5))
- expect(evaljs("Routes.things_path(5)")).to
eq(test_routes.things_path(5))
- expect(evaljs("Routes.thing_deep_path(1, { third_required: 3,
second_required: 2 })")).to eq(test_routes.thing_deep_path(1, third_required:
3, second_required: 2))
- expect(evaljs("Routes.thing_deep_path(1, { third_required: 3,
second_required: 2, forth_optional: 4 })")).to
eq(test_routes.thing_deep_path(1, third_required: 3, second_required: 2,
forth_optional: 4))
- expect(evaljs("Routes.thing_deep_path(2, { third_required: 3,
first_optional: 1 })")).to eq(test_routes.thing_deep_path(2, third_required: 3,
first_optional: 1))
- expect(evaljs("Routes.thing_deep_path(3, { first_optional: 1,
second_required: 2 })")).to eq(test_routes.thing_deep_path(3, first_optional:
1, second_required: 2))
- expect(evaljs("Routes.thing_deep_path(3, { first_optional: 1,
second_required: 2, forth_optional: 4 })")).to
eq(test_routes.thing_deep_path(3, first_optional: 1, second_required: 2,
forth_optional: 4))
- expect(evaljs("Routes.thing_deep_path(4, { first_optional: 1,
second_required: 2, third_required: 3 })")).to
eq(test_routes.thing_deep_path(4, first_optional: 1, second_required: 2,
third_required: 3))
- expect(evaljs("Routes.thing_deep_path(2, 3)")).to
eq(test_routes.thing_deep_path(2, 3))
- expect(evaljs("Routes.thing_deep_path(1, 2, { third_required: 3
})")).to eq(test_routes.thing_deep_path(1, 2, third_required: 3))
- expect(evaljs("Routes.thing_deep_path(1,2, {third_required: 3, q:
'bogdan'})")).to eq(test_routes.thing_deep_path(1,2, {third_required: 3, q:
'bogdan'}))
- expect(evaljs("Routes.thing_deep_path(1, 2, { forth_optional: 4,
third_required: 3 })")).to eq(test_routes.thing_deep_path(1, 2, forth_optional:
4, third_required: 3))
- expect(evaljs("Routes.thing_deep_path(1, 3, { second_required: 2
})")).to eq(test_routes.thing_deep_path(1, 3, second_required: 2))
- expect(evaljs("Routes.thing_deep_path(1, 4, { second_required: 2,
third_required: 3 })")).to eq(test_routes.thing_deep_path(1, 4,
second_required: 2, third_required: 3))
- expect(evaljs("Routes.thing_deep_path(2, 3, { first_optional: 1
})")).to eq(test_routes.thing_deep_path(2, 3, first_optional: 1))
- expect(evaljs("Routes.thing_deep_path(2, 3, { first_optional: 1,
forth_optional: 4 })")).to eq(test_routes.thing_deep_path(2, 3, first_optional:
1, forth_optional: 4))
- expect(evaljs("Routes.thing_deep_path(2, 4, { first_optional: 1,
third_required: 3 })")).to eq(test_routes.thing_deep_path(2, 4, first_optional:
1, third_required: 3))
- expect(evaljs("Routes.thing_deep_path(3, 4, { first_optional: 1,
second_required: 2 })")).to eq(test_routes.thing_deep_path(3, 4,
first_optional: 1, second_required: 2))
- expect(evaljs("Routes.thing_deep_path(1, 2, 3)")).to
eq(test_routes.thing_deep_path(1, 2, 3))
- expect(evaljs("Routes.thing_deep_path(1, 2, 3, { forth_optional: 4
})")).to eq(test_routes.thing_deep_path(1, 2, 3, forth_optional: 4))
- expect(evaljs("Routes.thing_deep_path(1, 2, 4, { third_required: 3
})")).to eq(test_routes.thing_deep_path(1, 2, 4, third_required: 3))
- expect(evaljs("Routes.thing_deep_path(1, 3, 4, { second_required: 2
})")).to eq(test_routes.thing_deep_path(1, 3, 4, second_required: 2))
- expect(evaljs("Routes.thing_deep_path(2, 3, 4, { first_optional: 1
})")).to eq(test_routes.thing_deep_path(2, 3, 4, first_optional: 1))
- expect(evaljs("Routes.thing_deep_path(1, 2, 3, 4)")).to
eq(test_routes.thing_deep_path(1, 2, 3, 4))
+ expectjs("Routes.things_path({optional_id: 5})").to
eq(test_routes.things_path(:optional_id => 5))
+ expectjs("Routes.things_path(5)").to eq(test_routes.things_path(5))
+ expectjs("Routes.thing_deep_path(1, { third_required: 3,
second_required: 2 })").to eq(test_routes.thing_deep_path(1, third_required: 3,
second_required: 2))
+ expectjs("Routes.thing_deep_path(1, { third_required: 3,
second_required: 2, forth_optional: 4 })").to eq(test_routes.thing_deep_path(1,
third_required: 3, second_required: 2, forth_optional: 4))
+ expectjs("Routes.thing_deep_path(2, { third_required: 3,
first_optional: 1 })").to eq(test_routes.thing_deep_path(2, third_required: 3,
first_optional: 1))
+ expectjs("Routes.thing_deep_path(3, { first_optional: 1,
second_required: 2 })").to eq(test_routes.thing_deep_path(3, first_optional: 1,
second_required: 2))
+ expectjs("Routes.thing_deep_path(3, { first_optional: 1,
second_required: 2, forth_optional: 4 })").to eq(test_routes.thing_deep_path(3,
first_optional: 1, second_required: 2, forth_optional: 4))
+ expectjs("Routes.thing_deep_path(4, { first_optional: 1,
second_required: 2, third_required: 3 })").to eq(test_routes.thing_deep_path(4,
first_optional: 1, second_required: 2, third_required: 3))
+ expectjs("Routes.thing_deep_path(2, 3)").to
eq(test_routes.thing_deep_path(2, 3))
+ expectjs("Routes.thing_deep_path(1, 2, { third_required: 3 })").to
eq(test_routes.thing_deep_path(1, 2, third_required: 3))
+ expectjs("Routes.thing_deep_path(1,2, {third_required: 3, q:
'bogdan'})").to eq(test_routes.thing_deep_path(1,2, {third_required: 3, q:
'bogdan'}))
+ expectjs("Routes.thing_deep_path(1, 2, { forth_optional: 4,
third_required: 3 })").to eq(test_routes.thing_deep_path(1, 2, forth_optional:
4, third_required: 3))
+ expectjs("Routes.thing_deep_path(1, 3, { second_required: 2 })").to
eq(test_routes.thing_deep_path(1, 3, second_required: 2))
+ expectjs("Routes.thing_deep_path(1, 4, { second_required: 2,
third_required: 3 })").to eq(test_routes.thing_deep_path(1, 4, second_required:
2, third_required: 3))
+ expectjs("Routes.thing_deep_path(2, 3, { first_optional: 1 })").to
eq(test_routes.thing_deep_path(2, 3, first_optional: 1))
+ expectjs("Routes.thing_deep_path(2, 3, { first_optional: 1,
forth_optional: 4 })").to eq(test_routes.thing_deep_path(2, 3, first_optional:
1, forth_optional: 4))
+ expectjs("Routes.thing_deep_path(2, 4, { first_optional: 1,
third_required: 3 })").to eq(test_routes.thing_deep_path(2, 4, first_optional:
1, third_required: 3))
+ expectjs("Routes.thing_deep_path(3, 4, { first_optional: 1,
second_required: 2 })").to eq(test_routes.thing_deep_path(3, 4, first_optional:
1, second_required: 2))
+ expectjs("Routes.thing_deep_path(1, 2, 3)").to
eq(test_routes.thing_deep_path(1, 2, 3))
+ expectjs("Routes.thing_deep_path(1, 2, 3, { forth_optional: 4 })").to
eq(test_routes.thing_deep_path(1, 2, 3, forth_optional: 4))
+ expectjs("Routes.thing_deep_path(1, 2, 4, { third_required: 3 })").to
eq(test_routes.thing_deep_path(1, 2, 4, third_required: 3))
+ expectjs("Routes.thing_deep_path(1, 3, 4, { second_required: 2 })").to
eq(test_routes.thing_deep_path(1, 3, 4, second_required: 2))
+ expectjs("Routes.thing_deep_path(2, 3, 4, { first_optional: 1 })").to
eq(test_routes.thing_deep_path(2, 3, 4, first_optional: 1))
+ expectjs("Routes.thing_deep_path(1, 2, 3, 4)").to
eq(test_routes.thing_deep_path(1, 2, 3, 4))
end
@@ -322,7 +338,7 @@
if Rails.version <= "5.0.0"
# this type of routing is deprecated
it "should include everything that is not optional" do
- expect(evaljs("Routes.classic_path({controller: 'classic', action:
'edit'})")).to eq(test_routes.classic_path(controller: :classic, action: :edit))
+ expectjs("Routes.classic_path({controller: 'classic', action:
'edit'})").to eq(test_routes.classic_path(controller: :classic, action: :edit))
end
end
end
@@ -361,7 +377,7 @@
evaljs("Array.prototype.indexOf = null")
end
it "should still work correctly" do
- expect(evaljs("Routes.inboxes_path()")).to eq(test_routes.inboxes_path())
+ expectjs("Routes.inboxes_path()").to eq(test_routes.inboxes_path())
end
end
@@ -382,98 +398,69 @@
}.to raise_error(js_error_class)
end
it "should support 0 as a to_param option" do
- expect(evaljs("Routes.inbox_path({to_param: 0})")).to
eq(test_routes.inbox_path(Struct.new(:to_param).new('0')))
+ expectjs("Routes.inbox_path({to_param: 0})").to
eq(test_routes.inbox_path(Struct.new(:to_param).new('0')))
end
it "should check for options special key" do
- expect(evaljs("Routes.inbox_path({id: 7, q: 'hello', _options:
true})")).to eq(test_routes.inbox_path(id: 7, q: 'hello'))
+ expectjs("Routes.inbox_path({id: 7, q: 'hello', _options: true})").to
eq(test_routes.inbox_path(id: 7, q: 'hello'))
expect {
evaljs("Routes.inbox_path({to_param: 7, _options: true})")
}.to raise_error(js_error_class)
- expect(evaljs("Routes.inbox_message_path(5, {id: 7, q: 'hello',
_options: true})")).to eq(test_routes.inbox_message_path(5, id: 7, q: 'hello'))
+ expectjs("Routes.inbox_message_path(5, {id: 7, q: 'hello', _options:
true})").to eq(test_routes.inbox_message_path(5, id: 7, q: 'hello'))
end
it "should support 0 as an id option" do
- expect(evaljs("Routes.inbox_path({id: 0})")).to
eq(test_routes.inbox_path(0))
+ expectjs("Routes.inbox_path({id: 0})").to eq(test_routes.inbox_path(0))
end
it "should use id property of the object in path" do
- expect(evaljs("Routes.inbox_path({id: 1})")).to
eq(test_routes.inbox_path(1))
+ expectjs("Routes.inbox_path({id: 1})").to eq(test_routes.inbox_path(1))
end
it "should prefer to_param property over id property" do
- expect(evaljs("Routes.inbox_path({id: 1, to_param: 'my'})")).to
eq(test_routes.inbox_path(inbox))
+ expectjs("Routes.inbox_path({id: 1, to_param: 'my'})").to
eq(test_routes.inbox_path(inbox))
end
it "should call to_param if it is a function" do
- expect(evaljs("Routes.inbox_path({id: 1, to_param: function(){ return
'my';}})")).to eq(test_routes.inbox_path(inbox))
+ expectjs("Routes.inbox_path({id: 1, to_param: function(){ return
'my';}})").to eq(test_routes.inbox_path(inbox))
end
it "should call id if it is a function" do
- expect(evaljs("Routes.inbox_path({id: function() { return 1;}})")).to
eq(test_routes.inbox_path(1))
+ expectjs("Routes.inbox_path({id: function() { return 1;}})").to
eq(test_routes.inbox_path(1))
end
it "should support options argument" do
- expect(evaljs(
+ expectjs(
"Routes.inbox_message_path({id:1, to_param: 'my'}, {id:2}, {custom:
true, format: 'json'})"
- )).to eq(test_routes.inbox_message_path(inbox, 2, :custom => true,
:format => "json"))
+ ).to eq(test_routes.inbox_message_path(inbox, 2, :custom => true,
:format => "json"))
end
it "supports camel case property name" do
- expect(evaljs("Routes.inbox_path({id: 1, toParam: 'my'})")).to
eq(test_routes.inbox_path(inbox))
+ expectjs("Routes.inbox_path({id: 1, toParam: 'my'})").to
eq(test_routes.inbox_path(inbox))
end
it "supports camel case method name" do
- expect(evaljs("Routes.inbox_path({id: 1, toParam: function(){ return
'my';}})")).to eq(test_routes.inbox_path(inbox))
+ expectjs("Routes.inbox_path({id: 1, toParam: function(){ return
'my';}})").to eq(test_routes.inbox_path(inbox))
end
context "when globbing" do
it "should prefer to_param property over id property" do
- expect(evaljs("Routes.book_path({id: 1, to_param: 'my'}, 1)")).to
eq(test_routes.book_path(inbox, 1))
+ expectjs("Routes.book_path({id: 1, to_param: 'my'}, 1)").to
eq(test_routes.book_path(inbox, 1))
end
it "should call to_param if it is a function" do
- expect(evaljs("Routes.book_path({id: 1, to_param: function(){ return
'my';}}, 1)")).to eq(test_routes.book_path(inbox, 1))
+ expectjs("Routes.book_path({id: 1, to_param: function(){ return
'my';}}, 1)").to eq(test_routes.book_path(inbox, 1))
end
it "should call id if it is a function" do
- expect(evaljs("Routes.book_path({id: function() { return
'technical';}}, 1)")).to eq(test_routes.book_path('technical', 1))
+ expectjs("Routes.book_path({id: function() { return 'technical';}},
1)").to eq(test_routes.book_path('technical', 1))
end
it "should support options argument" do
- expect(evaljs(
+ expectjs(
"Routes.book_path({id:1, to_param: 'my'}, {id:2}, {custom: true,
format: 'json'})"
- )).to eq(test_routes.book_path(inbox, 2, :custom => true, :format =>
"json"))
+ ).to eq(test_routes.book_path(inbox, 2, :custom => true, :format =>
"json"))
end
end
-
- end
-
- context "when specs" do
- it "should show inbox spec" do
- expect(evaljs("Routes.inbox_path.toString()")).to
eq('/inboxes/:id(.:format)')
- end
-
- it "should show inbox spec convert to string" do
- expect(evaljs("'' + Routes.inbox_path")).to eq('/inboxes/:id(.:format)')
- end
-
- it "should show inbox message spec" do
- expect(evaljs("Routes.inbox_message_path.toString()")).to
eq('/inboxes/:inbox_id/messages/:id(.:format)')
- end
-
- it "should show inbox message spec convert to string" do
- expect(evaljs("'' + Routes.inbox_message_path")).to
eq('/inboxes/:inbox_id/messages/:id(.:format)')
- end
- end
-
- describe "requiredParams" do
- it "should show inbox spec" do
- expect(evaljs("Routes.inbox_path.requiredParams()").to_a).to eq(["id"])
- end
-
- it "should show inbox message spec" do
- expect(evaljs("Routes.inbox_message_path.requiredParams()").to_a).to
eq(["inbox_id", "id"])
- end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/js_routes/route_specification_spec.rb
new/spec/js_routes/route_specification_spec.rb
--- old/spec/js_routes/route_specification_spec.rb 1970-01-01
01:00:00.000000000 +0100
+++ new/spec/js_routes/route_specification_spec.rb 2022-05-18
17:51:51.000000000 +0200
@@ -0,0 +1,40 @@
+
+require "spec_helper"
+
+describe JsRoutes, "compatibility with Rails" do
+
+ let(:generated_js) do
+ JsRoutes.generate({module_type: nil, namespace: 'Routes'})
+ end
+ before(:each) do
+ evaljs(generated_js)
+ end
+
+ context "when specs" do
+ it "should show inbox spec" do
+ expectjs("Routes.inbox_path.toString()").to eq('/inboxes/:id(.:format)')
+ end
+
+ it "should show inbox spec convert to string" do
+ expectjs("'' + Routes.inbox_path").to eq('/inboxes/:id(.:format)')
+ end
+
+ it "should show inbox message spec" do
+ expectjs("Routes.inbox_message_path.toString()").to
eq('/inboxes/:inbox_id/messages/:id(.:format)')
+ end
+
+ it "should show inbox message spec convert to string" do
+ expectjs("'' + Routes.inbox_message_path").to
eq('/inboxes/:inbox_id/messages/:id(.:format)')
+ end
+ end
+
+ describe "requiredParams" do
+ it "should show inbox spec" do
+ expect(evaljs("Routes.inbox_path.requiredParams()").to_a).to eq(["id"])
+ end
+
+ it "should show inbox message spec" do
+ expect(evaljs("Routes.inbox_message_path.requiredParams()").to_a).to
eq(["inbox_id", "id"])
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb
--- old/spec/spec_helper.rb 2022-03-07 13:07:43.000000000 +0100
+++ new/spec/spec_helper.rb 2022-05-18 17:51:51.000000000 +0200
@@ -70,6 +70,10 @@
evaljs("console.log(#{string})")
end
+def expectjs(string)
+ expect(evaljs(string))
+end
+
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular "budgie", "budgies"
end