jbuilder_rspec_generator 1.4 → 1.5

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
  SHA256:
3
- metadata.gz: 67e103e34bfc0a8ef9d83f095e125f5460244d00501cc25f74056b513079673e
4
- data.tar.gz: 8f3287fb66ed746ae6cbd4cddbcf9c065454b0440250ab734011a033913b0555
3
+ metadata.gz: fca0d9fdcdee7a324a2783bfbdf52082d8721414c6f540bf467143658d2c1726
4
+ data.tar.gz: 8308572944df8297353661ed23b1ec95feea14c1c3fd97b7cb18b8193595c517
5
5
  SHA512:
6
- metadata.gz: 3533db5c8cd37ec36da99dc4bce3866400db108dc553bfaf973f722c0e5e8a351816667f60d282cf49ab5453a06c586f634e6c9a72ec71dab21d74143ef26980
7
- data.tar.gz: adf9e1d467a8a664a9b781d0577d227ca8c0e2e65b3c022c98f571fc0299e0eabfb950e87b88d8f25c07bd8a5665f7d752262184bc1b243409d32574b3fc2ae6
6
+ metadata.gz: 30a6281a929fce2d8c0e955546ee889f462b39faa574538eddea11320ff5943d1d085df947196d332b221b6a54e9c2f90181d8255e170e6b53fff1198e1a2349
7
+ data.tar.gz: 52ae8bdefc2b5a674f3c309d2b9f9ca152d6fd3e318ad8d90ef66b2c58cc888ab712668262fa53563212659b7e80bf2e8fc049467fc202053c0a12178166347e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4
1
+ 1.5
@@ -2,16 +2,16 @@
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.4 ruby lib
5
+ # stub: jbuilder_rspec_generator 1.5 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "jbuilder_rspec_generator".freeze
9
- s.version = "1.4"
9
+ s.version = "1.5"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Dmitri Koulikoff".freeze]
14
- s.date = "2019-05-22"
14
+ s.date = "2020-04-30"
15
15
  s.description = "Generates RSpecs for jbuilder templates".freeze
16
16
  s.email = "dima@koulikoff.ru".freeze
17
17
  s.extra_rdoc_files = [
@@ -6,21 +6,25 @@ require 'spec_helper'
6
6
 
7
7
  <% open_attributes = attributes.reject(&:password_digest?) -%>
8
8
  <% links = open_attributes.select{|a| [:belongs_to, :references].include? a.type} -%>
9
+
9
10
  describe "<%= ns_table_name %>/index.json.jbuilder", type: :view do
11
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_bot -%>
12
+ <% factory = true -%>
13
+ let(:<%= ns_file_name %>) { create :<%= ns_file_name %> }
14
+
15
+ <% end -%>
10
16
  before(:each) do
11
17
  <% if Rails.application.config.generators.options[:rails][:cancan] -%>
12
18
  allow(controller).to receive(:can?).and_return(true)
13
19
  <% end -%>
14
- <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_bot -%>
15
- @<%= ns_file_name %> = create(:<%= ns_file_name %>)
16
- <% else -%>
20
+ <% unless factory -%>
17
21
  @<%= ns_file_name %> = <%= class_name %>.create(<%= open_attributes.empty? ? ')' : '' %>
18
22
  <% open_attributes.each_with_index do |attribute, attribute_index| -%>
19
23
  <%= attribute.name %>: <%= value_for(attribute) %><%= attribute_index == open_attributes.length - 1 ? '' : ','%>
20
24
  <% end -%>
21
25
  )
22
26
  <% end -%>
23
- assign :<%= table_name %>, [@<%= ns_file_name %>, @<%= ns_file_name %>]
27
+ assign :<%= table_name %>, [<% unless factory -%>@<% end -%><%= ns_file_name %>, <% unless factory -%>@<% end -%><%= ns_file_name %>]
24
28
  render
25
29
  end
26
30
 
@@ -53,12 +57,12 @@ describe "<%= ns_table_name %>/index.json.jbuilder", type: :view do
53
57
  expect(hash.first).to eq(hash = hash.last)
54
58
  expect(hash.keys.sort).to eq attributes.sort
55
59
  <% if links.present? -%>
56
- expected = @<%= ns_file_name %>.attributes.slice *(attributes - complex)
60
+ expected = <% unless factory -%>@<% end -%><%= ns_file_name %>.attributes.slice *(attributes - complex)
57
61
  <% else -%>
58
- expected = @<%= ns_file_name %>.attributes.slice *attributes
62
+ expected = <% unless factory -%>@<% end -%><%= ns_file_name %>.attributes.slice *attributes
59
63
  <% end -%>
60
64
  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] %>)
65
+ expected['url'] = <%= "api_" if options[:with_api] %><%= "#{options[:api_version]}_" if options[:with_api] and options[:api_version].present? %><%= ns_file_name %>_url(<% unless factory -%>@<% end -%><%= ns_file_name %><%= ", format: 'json'" unless options[:with_api] %>)
62
66
  <% if links.present? -%>
63
67
  expect(hash.except! *complex).to eq expected
64
68
  <% else -%>
@@ -71,9 +75,9 @@ describe "<%= ns_table_name %>/index.json.jbuilder", type: :view do
71
75
  hash = MultiJson.load(rendered).last
72
76
  hash = hash['<%= attribute.name %>']
73
77
  expect(hash.keys.sort).to eq <%= attribute.name %>_attributes.sort
74
- expected = @<%= ns_file_name %>.<%= attribute.name %>.attributes.slice *<%= attribute.name %>_attributes
78
+ expected = <% unless factory -%>@<% end -%><%= ns_file_name %>.<%= attribute.name %>.attributes.slice *<%= attribute.name %>_attributes
75
79
  expected = MultiJson.load MultiJson.dump expected
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] %>)
80
+ expected['url'] = <%= "api_" if options[:with_api] %><%= "#{options[:api_version]}_" if options[:with_api] and options[:api_version].present? %><%= attribute.name %>_url(<% unless factory -%>@<% end -%><%= ns_file_name %>.<%= attribute.name %><%= ", format: 'json'" unless options[:with_api] %>)
77
81
  expect(hash).to eq expected
78
82
  end
79
83
  <% end -%>
@@ -6,13 +6,19 @@ require 'spec_helper'
6
6
 
7
7
  <% open_attributes = attributes.reject(&:password_digest?) -%>
8
8
  <% links = open_attributes.select{|a| [:belongs_to, :references].include? a.type} -%>
9
+
9
10
  describe "<%= ns_table_name %>/show.json.jbuilder", type: :view do
11
+ <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_bot -%>
12
+ <% factory = true -%>
13
+ let(:<%= ns_file_name %>) { create :<%= ns_file_name %> }
14
+
15
+ <% end -%>
10
16
  before(:each) do
11
17
  <% if Rails.application.config.generators.options[:rails][:cancan] -%>
12
18
  allow(controller).to receive(:can?).and_return(true)
13
19
  <% end -%>
14
- <% if Rails.application.config.generators.options[:rails][:fixture_replacement] == :factory_bot -%>
15
- @<%= ns_file_name %> = assign(:<%= ns_file_name %>, create(:<%= ns_file_name %>))
20
+ <% if factory -%>
21
+ assign :<%= ns_file_name %>, <%= ns_file_name %>
16
22
  <% else -%>
17
23
  @<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create(<%= open_attributes.empty? ? '))' : '' %>
18
24
  <% open_attributes.each_with_index do |attribute, attribute_index| -%>
@@ -53,12 +59,12 @@ describe "<%= ns_table_name %>/show.json.jbuilder", type: :view do
53
59
  hash = MultiJson.load rendered
54
60
  expect(hash.keys.sort).to eq attributes.sort
55
61
  <% if links.present? -%>
56
- expected = @<%= ns_file_name %>.attributes.slice *(attributes - complex)
62
+ expected = <% unless factory -%>@<% end -%><%= ns_file_name %>.attributes.slice *(attributes - complex)
57
63
  <% else -%>
58
- expected = @<%= ns_file_name %>.attributes.slice *attributes
64
+ expected = <% unless factory -%>@<% end -%><%= ns_file_name %>.attributes.slice *attributes
59
65
  <% end -%>
60
66
  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] %>)
67
+ expected['url'] = <%= "api_" if options[:with_api] %><%= "#{options[:api_version]}_" if options[:with_api] and options[:api_version].present? %><%= ns_file_name %>_url(<% unless factory -%>@<% end -%><%= ns_file_name %><%= ", format: 'json'" unless options[:with_api] %>)
62
68
  <% if links.present? -%>
63
69
  expect(hash.except! *complex).to eq expected
64
70
  <% else -%>
@@ -71,9 +77,9 @@ describe "<%= ns_table_name %>/show.json.jbuilder", type: :view do
71
77
  hash = MultiJson.load(rendered)
72
78
  hash = hash['<%= attribute.name %>']
73
79
  expect(hash.keys.sort).to eq <%= attribute.name %>_attributes.sort
74
- expected = @<%= ns_file_name %>.<%= attribute.name %>.attributes.slice *<%= attribute.name %>_attributes
80
+ expected = <% unless factory -%>@<% end -%><%= ns_file_name %>.<%= attribute.name %>.attributes.slice *<%= attribute.name %>_attributes
75
81
  expected = MultiJson.load MultiJson.dump expected
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] %>)
82
+ expected['url'] = <%= "api_" if options[:with_api] %><%= "#{options[:api_version]}_" if options[:with_api] and options[:api_version].present? %><%= attribute.name %>_url(<% unless factory -%>@<% end -%><%= ns_file_name %>.<%= attribute.name %><%= ", format: 'json'" unless options[:with_api] %>)
77
83
  expect(hash).to eq expected
78
84
  end
79
85
  <% end -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder_rspec_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.4'
4
+ version: '1.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitri Koulikoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json