jbuilder_rspec_generator 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/jbuilder_rspec_generator.gemspec +2 -2
- data/lib/generators/rails/jbuilder/jbuilder_generator.rb +5 -0
- data/lib/generators/rails/jbuilder/templates/partial.json.jbuilder +1 -1
- data/lib/generators/rspec/jbuilder_generator.rb +5 -0
- data/lib/generators/rspec/templates/index_spec.rb +2 -2
- data/lib/generators/rspec/templates/show_spec.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86e3a0f61821fd59aaf0e3e2a2a9aaf6b99d299c
|
4
|
+
data.tar.gz: 3cc3094fa98a757800f54311b085618228bbdf02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42232c3559c2823fb972a5a166346f7ee14c28e8339994ecae6a332498c42a2eef1459bd67476ca02fe336bd9f8795367c40ff478a4c4f2c919f21294dc704bd
|
7
|
+
data.tar.gz: 0a61ad63b40c9983fa083e1469ff0149d2645ad243ac07e92275bf7a0664071d0ce1554329b478eee1ec91328af17c545694b8fdeb31e1850705460a21b0154a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.1
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: jbuilder_rspec_generator 1.3.
|
5
|
+
# stub: jbuilder_rspec_generator 1.3.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "jbuilder_rspec_generator"
|
9
|
-
s.version = "1.3.
|
9
|
+
s.version = "1.3.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -3,6 +3,11 @@ require 'generators/rails/jbuilder_generator'
|
|
3
3
|
module Rails
|
4
4
|
module Generators
|
5
5
|
class JbuilderGenerator < NamedBase # :nodoc:
|
6
|
+
class_option :with_api, type: :boolean,
|
7
|
+
desc: "Generates also API controller in 'app/contorllers/api'"
|
8
|
+
class_option :api_version, type: :string,
|
9
|
+
desc: "Adds specified path as version to 'app/contorllers/api'"
|
10
|
+
|
6
11
|
source_paths.unshift File.expand_path('../templates', __FILE__)
|
7
12
|
|
8
13
|
hook_for :test_framework
|
@@ -1,2 +1,2 @@
|
|
1
1
|
json.extract! <%= singular_table_name %>, <%= attributes_list_with_timestamps %>
|
2
|
-
json.url <%= "
|
2
|
+
json.url <%= "api_" if options[:with_api] %><%= "#{options[:api_version]}_" if options[:with_api] and options[:api_version].present? %><%= singular_table_name %>_url(<%= singular_table_name %><%= ", format: 'json'" unless options[:with_api] %>)
|
@@ -6,6 +6,11 @@ module Rspec
|
|
6
6
|
class JbuilderGenerator < Base
|
7
7
|
include ::Rails::Generators::ResourceHelpers
|
8
8
|
|
9
|
+
class_option :with_api, type: :boolean,
|
10
|
+
desc: "Generates also API controller in 'app/contorllers/api'"
|
11
|
+
class_option :api_version, type: :string,
|
12
|
+
desc: "Adds specified path as version to 'app/contorllers/api'"
|
13
|
+
|
9
14
|
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
10
15
|
|
11
16
|
def generate_view_specs
|
@@ -58,7 +58,7 @@ describe "<%= ns_table_name %>/index.json.jbuilder", type: :view do
|
|
58
58
|
expected = @<%= ns_file_name %>.attributes.slice *attributes
|
59
59
|
<% end -%>
|
60
60
|
expected = MultiJson.load MultiJson.dump expected
|
61
|
-
expected['url'] = <%= ns_file_name %>_url(@<%= ns_file_name
|
61
|
+
expected['url'] = <%= "api_" if options[:with_api] %><%= "#{options[:api_version]}_" if options[:with_api] and options[:api_version].present? %><%= ns_file_name %>_url(@<%= ns_file_name %><%= ", format: 'json'" unless options[:with_api] %>)
|
62
62
|
<% if links.present? -%>
|
63
63
|
expect(hash.except! *complex).to eq expected
|
64
64
|
<% else -%>
|
@@ -73,7 +73,7 @@ describe "<%= ns_table_name %>/index.json.jbuilder", type: :view do
|
|
73
73
|
expect(hash.keys.sort).to eq <%= attribute.name %>_attributes.sort
|
74
74
|
expected = @<%= ns_file_name %>.<%= attribute.name %>.attributes.slice *<%= attribute.name %>_attributes
|
75
75
|
expected = MultiJson.load MultiJson.dump expected
|
76
|
-
expected['url'] = <%= attribute.name %>_url(@<%= ns_file_name %>.<%= attribute.name
|
76
|
+
expected['url'] = <%= "api_" if options[:with_api] %><%= "#{options[:api_version]}_" if options[:with_api] and options[:api_version].present? %><%= attribute.name %>_url(@<%= ns_file_name %>.<%= attribute.name %><%= ", format: 'json'" unless options[:with_api] %>)
|
77
77
|
expect(hash).to eq expected
|
78
78
|
end
|
79
79
|
<% end -%>
|
@@ -32,6 +32,7 @@ describe "<%= ns_table_name %>/show.json.jbuilder", type: :view do
|
|
32
32
|
<% end -%>
|
33
33
|
created_at
|
34
34
|
updated_at
|
35
|
+
url
|
35
36
|
]
|
36
37
|
<% if links.present? -%>
|
37
38
|
complex = %w[
|
@@ -57,6 +58,7 @@ describe "<%= ns_table_name %>/show.json.jbuilder", type: :view do
|
|
57
58
|
expected = @<%= ns_file_name %>.attributes.slice *attributes
|
58
59
|
<% end -%>
|
59
60
|
expected = MultiJson.load MultiJson.dump expected
|
61
|
+
expected['url'] = <%= "api_" if options[:with_api] %><%= "#{options[:api_version]}_" if options[:with_api] and options[:api_version].present? %><%= ns_file_name %>_url(@<%= ns_file_name %><%= ", format: 'json'" unless options[:with_api] %>)
|
60
62
|
<% if links.present? -%>
|
61
63
|
expect(hash.except! *complex).to eq expected
|
62
64
|
<% else -%>
|
@@ -71,7 +73,7 @@ describe "<%= ns_table_name %>/show.json.jbuilder", type: :view do
|
|
71
73
|
expect(hash.keys.sort).to eq <%= attribute.name %>_attributes.sort
|
72
74
|
expected = @<%= ns_file_name %>.<%= attribute.name %>.attributes.slice *<%= attribute.name %>_attributes
|
73
75
|
expected = MultiJson.load MultiJson.dump expected
|
74
|
-
expected['url'] = <%= attribute.name %>_url(@<%= ns_file_name %>.<%= attribute.name
|
76
|
+
expected['url'] = <%= "api_" if options[:with_api] %><%= "#{options[:api_version]}_" if options[:with_api] and options[:api_version].present? %><%= attribute.name %>_url(@<%= ns_file_name %>.<%= attribute.name %><%= ", format: 'json'" unless options[:with_api] %>)
|
75
77
|
expect(hash).to eq expected
|
76
78
|
end
|
77
79
|
<% end -%>
|