gon 6.4.0 → 6.5.0

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -1
  3. data/README.md +1 -5
  4. data/lib/gon/base.rb +6 -3
  5. data/lib/gon/compatibility/old_rails.rb +2 -0
  6. data/lib/gon/env_finder.rb +2 -0
  7. data/lib/gon/escaper.rb +2 -0
  8. data/lib/gon/global.rb +2 -0
  9. data/lib/gon/helpers.rb +2 -0
  10. data/lib/gon/jbuilder/parser.rb +6 -4
  11. data/lib/gon/jbuilder.rb +3 -1
  12. data/lib/gon/json_dumper.rb +2 -0
  13. data/lib/gon/rabl.rb +3 -1
  14. data/lib/gon/request.rb +2 -0
  15. data/lib/gon/spec_helpers.rb +2 -0
  16. data/lib/gon/version.rb +3 -1
  17. data/lib/gon/watch.rb +2 -0
  18. data/lib/gon.rb +2 -0
  19. metadata +7 -38
  20. data/.github/FUNDING.yml +0 -1
  21. data/.gitignore +0 -7
  22. data/.travis.yml +0 -14
  23. data/Gemfile +0 -6
  24. data/Rakefile +0 -10
  25. data/doc/logo.png +0 -0
  26. data/doc/logo_small.png +0 -0
  27. data/doc/top_sample.png +0 -0
  28. data/gon.gemspec +0 -31
  29. data/spec/gon/basic_spec.rb +0 -304
  30. data/spec/gon/global_spec.rb +0 -146
  31. data/spec/gon/jbuilder_spec.rb +0 -75
  32. data/spec/gon/rabl_spec.rb +0 -90
  33. data/spec/gon/templates_spec.rb +0 -36
  34. data/spec/gon/thread_spec.rb +0 -39
  35. data/spec/gon/watch_spec.rb +0 -81
  36. data/spec/spec_helper.rb +0 -36
  37. data/spec/test_data/_sample_partial.json.jbuilder +0 -1
  38. data/spec/test_data/sample.json.jbuilder +0 -1
  39. data/spec/test_data/sample.rabl +0 -2
  40. data/spec/test_data/sample_rabl_rails.rabl +0 -2
  41. data/spec/test_data/sample_url_helpers.json.jbuilder +0 -1
  42. data/spec/test_data/sample_with_controller_method.json.jbuilder +0 -2
  43. data/spec/test_data/sample_with_helpers.json.jbuilder +0 -1
  44. data/spec/test_data/sample_with_helpers.rabl +0 -3
  45. data/spec/test_data/sample_with_helpers_rabl_rails.rabl +0 -3
  46. data/spec/test_data/sample_with_locals.json.jbuilder +0 -2
  47. data/spec/test_data/sample_with_partial.json.jbuilder +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bdd0446070acfd94f0e8ef48b57eb1bfdf82179dca4cdd7a6e230d43ee9551b
4
- data.tar.gz: 3dea439ff1cefa4edef65a9c39f2d0e505114140fcbf1a9effda085f04741e64
3
+ metadata.gz: 764e0fdc60fe7b018d593c4f10ac5da1b27c117b6c2f0bcd62eea6d04a91a571
4
+ data.tar.gz: 037f1aa29e3e2865c576dfd3dc70e4931b96ca59732d1067ef1c72bad53d8006
5
5
  SHA512:
6
- metadata.gz: af0597738e9196231399b4c15e77358bb4e3e90cbfe26fefae9da4d70ae5c20982c15c424e34b37ed58cd05cf8e867f6756cfa83f8621eda301df266ab5ff251
7
- data.tar.gz: 37a2e08e06f44c863bfce115e99c9628f798347b2db2579b491d38aa959b5e5ee076b9207ae02405e303b94c8952198becef9f2d24fce8f79bd7a0b5cf001339
6
+ metadata.gz: c1de2c9a8f8c3d571fe8d9eff0cf742e23b8f5be0ff133e59fbd3dc1157ec108c1cf4ea0a00b486e6f2be4e883cb5405af1857ba345002b4c647222698e5471f
7
+ data.tar.gz: ac19fa38ca794c863ede248e6a6a581f9417f5a59f5f4d836760280933c2f656a43e8048cd801f3fb1587c4d79bf86a7f00c21c711f264cd83d09aa05d9a3405
data/CHANGELOG.md CHANGED
@@ -230,7 +230,8 @@
230
230
  ### Changed
231
231
  - Don't really remember what was before this version
232
232
 
233
- [Unreleased]: https://github.com/gazay/gon/compare/v6.3.2...master
233
+ [Unreleased]: https://github.com/gazay/gon/compare/v6.4.0...master
234
+ [6.4.0]: https://github.com/gazay/gon/compare/v6.3.2...v6.4.0
234
235
  [6.3.2]: https://github.com/gazay/gon/compare/v6.3.1...v6.3.2
235
236
  [6.3.1]: https://github.com/gazay/gon/compare/v6.2.1...v6.3.1
236
237
  [6.2.1]: https://github.com/gazay/gon/compare/v6.2.0...v6.2.1
data/README.md CHANGED
@@ -1,11 +1,7 @@
1
1
  # Gon gem — get your Rails variables in your js
2
2
 
3
- [![Join the chat at https://gitter.im/gazay/gon](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gazay/gon?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
-
5
3
  ![Gon. You should try this. If you look closer - you will see an elephant.](https://github.com/gazay/gon/raw/master/doc/logo_small.png)
6
4
 
7
- [![Build Status](https://travis-ci.org/gazay/gon.svg?branch=master)](https://travis-ci.org/gazay/gon) [![CodeClimate](https://codeclimate.com/github/gazay/gon/badges/gpa.svg)](https://codeclimate.com/github/gazay/gon)
8
-
9
5
  If you need to send some data to your js files and you don't want to do this with long way through views and parsing - use this force!
10
6
 
11
7
  Now you can easily renew data in your variables through ajax with [gon.watch](https://github.com/gazay/gon/wiki/Usage-gon-watch)!
@@ -224,7 +220,7 @@ usage gon.global.
224
220
 
225
221
  ## Speed up Gon
226
222
 
227
- You can use any [JSON Engine](https://github.com/intridea/multi_json#supported-json-engines) you want.
223
+ You can use any [JSON Engine](https://github.com/sferik/multi_json#supported-json-engines) you want.
228
224
  Gon uses `MultiJson` with autodetect mode, so all you need is just require your JSON library.
229
225
 
230
226
  ## Contributors
data/lib/gon/base.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'ostruct'
1
+ # frozen_string_literal: true
2
2
 
3
3
  class Gon
4
4
  module Base
@@ -16,6 +16,9 @@ class Gon
16
16
  nonce: nil
17
17
  }
18
18
 
19
+ Option = Struct.new(:cameled, *VALID_OPTION_DEFAULTS.keys)
20
+ private_constant :Option
21
+
19
22
  class << self
20
23
 
21
24
  def render_data(options = {})
@@ -31,7 +34,7 @@ class Gon
31
34
  private
32
35
 
33
36
  def define_options(options)
34
- _o = OpenStruct.new
37
+ _o = Option.new
35
38
 
36
39
  VALID_OPTION_DEFAULTS.each do |opt_name, default|
37
40
  _o.send("#{opt_name}=", options.fetch(opt_name, default))
@@ -43,7 +46,7 @@ class Gon
43
46
  end
44
47
 
45
48
  def formatted_data(_o)
46
- script = ''
49
+ script = +''
47
50
  before, after = render_wrap(_o)
48
51
  script << before
49
52
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'securerandom'
2
4
 
3
5
  class Gon
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module EnvFinder
3
5
  ENV_CONTROLLER_KEY = 'action_controller.instance'
data/lib/gon/escaper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module Escaper
3
5
  extend ActionView::Helpers::JavaScriptHelper
data/lib/gon/global.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  class Global < Gon
3
5
  class << self
data/lib/gon/helpers.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module ViewHelpers
3
5
  def include_gon(options = {})
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module Jbuilder
3
5
  class Parser
@@ -91,7 +93,7 @@ class Gon
91
93
  end
92
94
 
93
95
  def parse_path(path)
94
- return path if File.exists?(path)
96
+ return path if File.exist?(path)
95
97
  if (splitted = path.split('/')).blank?
96
98
  raise 'Something wrong with partial path in your jbuilder templates'
97
99
  elsif splitted.size == 1
@@ -108,9 +110,9 @@ class Gon
108
110
  end
109
111
 
110
112
  def path_with_ext(path)
111
- return path if File.exists?(path)
112
- return "#{path}.jbuilder" if File.exists?("#{path}.jbuilder")
113
- return "#{path}.json.jbuilder" if File.exists?("#{path}.json.jbuilder")
113
+ return path if File.exist?(path)
114
+ return "#{path}.jbuilder" if File.exist?("#{path}.jbuilder")
115
+ return "#{path}.json.jbuilder" if File.exist?("#{path}.json.jbuilder")
114
116
  end
115
117
 
116
118
  def find_partials(lines = [])
data/lib/gon/jbuilder.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module Jbuilder
3
5
  class << self
@@ -30,7 +32,7 @@ class Gon
30
32
 
31
33
  def parse_options_from(args)
32
34
  if old_api? args
33
- text = "[DEPRECATION] view_path argument is now optional. "
35
+ text = +"[DEPRECATION] view_path argument is now optional. "
34
36
  text << "If you need to specify it, "
35
37
  text << "please use gon.jbuilder(:template => 'path')"
36
38
  warn text
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module JsonDumper
3
5
  # Taken from ERB::Util
data/lib/gon/rabl.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'action_view'
2
4
 
3
5
  begin
@@ -63,7 +65,7 @@ class Gon
63
65
  def parse_options_from(args, global)
64
66
  if old_api? args
65
67
  unless global
66
- text = "[DEPRECATION] view_path argument is now optional. "
68
+ text = +"[DEPRECATION] view_path argument is now optional. "
67
69
  text << "If you need to specify it, "
68
70
  text << "please use gon.rabl(:template => 'path')"
69
71
  warn text
data/lib/gon/request.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  class Request
3
5
  attr_reader :env, :gon
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  module SpecHelper
3
5
  module Rails
data/lib/gon/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
- VERSION = '6.4.0'
4
+ VERSION = '6.5.0'
3
5
  end
data/lib/gon/watch.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Gon
2
4
  class Watch < Gon
3
5
  class << self
data/lib/gon.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'request_store'
2
4
  require 'action_view'
3
5
  require 'action_controller'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gon
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.4.0
4
+ version: 6.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gazay
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: actionpack
@@ -70,16 +69,16 @@ dependencies:
70
69
  name: rabl
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - '='
72
+ - - ">="
74
73
  - !ruby/object:Gem::Version
75
- version: 0.11.3
74
+ version: '0'
76
75
  type: :development
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
- - - '='
79
+ - - ">="
81
80
  - !ruby/object:Gem::Version
82
- version: 0.11.3
81
+ version: '0'
83
82
  - !ruby/object:Gem::Dependency
84
83
  name: rabl-rails
85
84
  requirement: !ruby/object:Gem::Requirement
@@ -186,19 +185,10 @@ executables: []
186
185
  extensions: []
187
186
  extra_rdoc_files: []
188
187
  files:
189
- - ".github/FUNDING.yml"
190
- - ".gitignore"
191
- - ".travis.yml"
192
188
  - CHANGELOG.md
193
- - Gemfile
194
189
  - LICENSE
195
190
  - README.md
196
- - Rakefile
197
191
  - coffee/watch.coffee
198
- - doc/logo.png
199
- - doc/logo_small.png
200
- - doc/top_sample.png
201
- - gon.gemspec
202
192
  - js/watch.js
203
193
  - lib/gon.rb
204
194
  - lib/gon/base.rb
@@ -215,30 +205,10 @@ files:
215
205
  - lib/gon/spec_helpers.rb
216
206
  - lib/gon/version.rb
217
207
  - lib/gon/watch.rb
218
- - spec/gon/basic_spec.rb
219
- - spec/gon/global_spec.rb
220
- - spec/gon/jbuilder_spec.rb
221
- - spec/gon/rabl_spec.rb
222
- - spec/gon/templates_spec.rb
223
- - spec/gon/thread_spec.rb
224
- - spec/gon/watch_spec.rb
225
- - spec/spec_helper.rb
226
- - spec/test_data/_sample_partial.json.jbuilder
227
- - spec/test_data/sample.json.jbuilder
228
- - spec/test_data/sample.rabl
229
- - spec/test_data/sample_rabl_rails.rabl
230
- - spec/test_data/sample_url_helpers.json.jbuilder
231
- - spec/test_data/sample_with_controller_method.json.jbuilder
232
- - spec/test_data/sample_with_helpers.json.jbuilder
233
- - spec/test_data/sample_with_helpers.rabl
234
- - spec/test_data/sample_with_helpers_rabl_rails.rabl
235
- - spec/test_data/sample_with_locals.json.jbuilder
236
- - spec/test_data/sample_with_partial.json.jbuilder
237
208
  homepage: https://github.com/gazay/gon
238
209
  licenses:
239
210
  - MIT
240
211
  metadata: {}
241
- post_install_message:
242
212
  rdoc_options: []
243
213
  require_paths:
244
214
  - lib
@@ -253,8 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
223
  - !ruby/object:Gem::Version
254
224
  version: '0'
255
225
  requirements: []
256
- rubygems_version: 3.1.2
257
- signing_key:
226
+ rubygems_version: 3.6.9
258
227
  specification_version: 4
259
228
  summary: Get your Rails variables in your JS
260
229
  test_files: []
data/.github/FUNDING.yml DELETED
@@ -1 +0,0 @@
1
- tidelift: "rubygems/gon"
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- tmp/*
6
- .rvmrc
7
- *.idea
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- env:
4
- - "RABL_GEM=rabl"
5
- - "RABL_GEM=rabl-rails"
6
-
7
- rvm:
8
- - 2.2.10
9
- - 2.3.8
10
- - 2.4.10
11
- - 2.5.8
12
- - 2.6.6
13
- - 2.7.1
14
- - ruby-head
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in gon.gemspec
4
- gem ENV['RABL_GEM'] || 'rabl'
5
-
6
- gemspec
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- desc 'Run all tests by default'
5
- task :default => :spec
6
-
7
- require 'rspec/core/rake_task'
8
- RSpec::Core::RakeTask.new do |t|
9
- t.rspec_opts = ["--color", '--format doc', '--require spec_helper']
10
- end
data/doc/logo.png DELETED
Binary file
data/doc/logo_small.png DELETED
Binary file
data/doc/top_sample.png DELETED
Binary file
data/gon.gemspec DELETED
@@ -1,31 +0,0 @@
1
- lib = File.expand_path('../lib', __FILE__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require 'gon/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'gon'
7
- s.version = Gon::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['gazay']
10
- s.licenses = ['MIT']
11
- s.email = ['alex.gaziev@gmail.com']
12
- s.homepage = 'https://github.com/gazay/gon'
13
- s.summary = %q{Get your Rails variables in your JS}
14
- s.description = %q{If you need to send some data to your js files and you don't want to do this with long way trough views and parsing - use this force!}
15
-
16
- s.files = `git ls-files`.split("\n")
17
- s.require_paths = ['lib']
18
- s.required_ruby_version = '>= 2.2.0'
19
- s.add_dependency 'actionpack', '>= 3.0.20'
20
- s.add_dependency 'i18n', '>= 0.7'
21
- s.add_dependency 'request_store', '>= 1.0'
22
- s.add_dependency 'multi_json'
23
- s.add_development_dependency 'rabl', '0.11.3'
24
- s.add_development_dependency 'rabl-rails'
25
- s.add_development_dependency 'rspec', '>= 3.0'
26
- s.add_development_dependency 'jbuilder'
27
- s.add_development_dependency 'railties', '>= 3.0.20'
28
- s.add_development_dependency 'rake'
29
- s.add_development_dependency 'pry'
30
- s.add_development_dependency 'pry-byebug'
31
- end
@@ -1,304 +0,0 @@
1
- describe Gon do
2
-
3
- before(:each) do
4
- Gon.clear
5
- end
6
-
7
- describe '#all_variables' do
8
-
9
- it 'returns all variables in hash' do
10
- Gon.a = 1
11
- Gon.b = 2
12
- Gon.c = Gon.a + Gon.b
13
- expect(Gon.c).to eq(3)
14
- expect(Gon.all_variables).to eq({ 'a' => 1, 'b' => 2, 'c' => 3 })
15
- end
16
-
17
- it 'supports all data types' do
18
- Gon.int = 1
19
- Gon.float = 1.1
20
- Gon.string = 'string'
21
- Gon.symbol = :symbol
22
- Gon.array = [1, 'string']
23
- Gon.hash_var = { :a => 1, :b => '2' }
24
- Gon.hash_w_array = { :a => [2, 3] }
25
- Gon.klass = Hash
26
- end
27
-
28
- it 'can be filled with dynamic named variables' do
29
- check = {}
30
- 3.times do |i|
31
- Gon.set_variable("variable#{i}", i)
32
- check["variable#{i}"] = i
33
- end
34
-
35
- expect(Gon.all_variables).to eq(check)
36
- end
37
-
38
- it 'can set and get variable with dynamic name' do
39
- var_name = "variable#{rand}"
40
-
41
- Gon.set_variable(var_name, 1)
42
- expect(Gon.get_variable(var_name)).to eq(1)
43
- end
44
-
45
- it 'can be support new push syntax' do
46
- Gon.push({ :int => 1, :string => 'string' })
47
- expect(Gon.all_variables).to eq({ 'int' => 1, 'string' => 'string' })
48
- end
49
-
50
- it 'push with wrong object' do
51
- expect {
52
- Gon.push(String.new('string object'))
53
- }.to raise_error('Object must have each_pair method')
54
- end
55
-
56
- describe "#merge_variable" do
57
- it 'deep merges the same key' do
58
- Gon.merge_variable(:foo, { bar: { tar: 12 }, car: 23 })
59
- Gon.merge_variable(:foo, { bar: { dar: 21 }, car: 12 })
60
- expect(Gon.get_variable(:foo)).to eq(bar: { tar: 12, dar: 21 }, car: 12)
61
- end
62
-
63
- it 'merges on push with a flag' do
64
- Gon.push(foo: { bar: 1 })
65
- Gon.push({ foo: { tar: 1 } }, :merge)
66
- expect(Gon.get_variable("foo")).to eq(bar: 1, tar: 1)
67
- end
68
-
69
- context 'overrides key' do
70
- specify "the previous value wasn't hash" do
71
- Gon.merge_variable(:foo, 2)
72
- Gon.merge_variable(:foo, { a: 1 })
73
- expect(Gon.get_variable(:foo)).to eq(a: 1)
74
- end
75
-
76
- specify "the new value isn't a hash" do
77
- Gon.merge_variable(:foo, { a: 1 })
78
- Gon.merge_variable(:foo, 2)
79
- expect(Gon.get_variable(:foo)).to eq(2)
80
- end
81
- end
82
- end
83
-
84
- end
85
-
86
- describe '#include_gon' do
87
-
88
- before(:each) do
89
- Gon::Request.
90
- instance_variable_set(:@request_id, request.object_id)
91
- expect(ActionView::Base.instance_methods).to include(:include_gon)
92
- @base = ActionView::Base.new
93
- @base.request = request
94
- end
95
-
96
- it 'outputs correct js with an integer' do
97
- Gon.int = 1
98
- expect(@base.include_gon).to eq(wrap_script(
99
- 'window.gon={};' +
100
- 'gon.int=1;'))
101
- end
102
-
103
- it 'outputs correct js with a string' do
104
- Gon.str = %q(a'b"c)
105
- expect(@base.include_gon).to eq(wrap_script(
106
- 'window.gon={};' +
107
- %q(gon.str="a'b\"c";))
108
- )
109
- end
110
-
111
- it 'outputs correct js with a script string' do
112
- Gon.str = %q(</script><script>alert('!')</script>)
113
- escaped_str = "\\u003c/script\\u003e\\u003cscript\\u003ealert('!')\\u003c/script\\u003e"
114
- expect(@base.include_gon).to eq(wrap_script(
115
- 'window.gon={};' +
116
- %Q(gon.str="#{escaped_str}";))
117
- )
118
- end
119
-
120
- it 'outputs correct js with an integer and type' do
121
- Gon.int = 1
122
- expect(@base.include_gon(type: true)).to eq('<script type="text/javascript">' +
123
- "\n//<![CDATA[\n" +
124
- 'window.gon={};' +
125
- 'gon.int=1;' +
126
- "\n//]]>\n" +
127
- '</script>')
128
- end
129
-
130
- it 'outputs correct js with an integer, camel-case and namespace' do
131
- Gon.int_cased = 1
132
- expect(@base.include_gon(camel_case: true, namespace: 'camel_cased')).to eq(
133
- wrap_script('window.camel_cased={};' +
134
- 'camel_cased.intCased=1;')
135
- )
136
- end
137
-
138
- it 'outputs correct js with camel_depth = :recursive' do
139
- Gon.test_hash = { test_depth_one: { test_depth_two: 1 } }
140
- expect(@base.include_gon(camel_case: true, camel_depth: :recursive)).to eq(
141
- wrap_script('window.gon={};' +
142
- 'gon.testHash={"testDepthOne":{"testDepthTwo":1}};')
143
- )
144
- end
145
-
146
- it 'outputs correct js with camel_depth = 2' do
147
- Gon.test_hash = { test_depth_one: { test_depth_two: 1 } }
148
- expect(@base.include_gon(camel_case: true, camel_depth: 2)).to eq(
149
- wrap_script('window.gon={};' +
150
- 'gon.testHash={"testDepthOne":{"test_depth_two":1}};')
151
- )
152
- end
153
-
154
- it 'outputs correct js for an array with camel_depth = :recursive' do
155
- Gon.test_hash = { test_depth_one: [{ test_depth_two: 1 }, { test_depth_two: 2 }] }
156
- expect(@base.include_gon(camel_case: true, camel_depth: :recursive)).to eq( \
157
- wrap_script('window.gon={};' +
158
- 'gon.testHash={"testDepthOne":[{"testDepthTwo":1},{"testDepthTwo":2}]};')
159
- )
160
- end
161
-
162
- it 'outputs correct key with camel_case option set alternately ' do
163
- Gon.test_hash = 1
164
- @base.include_gon(camel_case: true)
165
-
166
- expect(@base.include_gon(camel_case: false)).to eq(
167
- wrap_script('window.gon={};' +
168
- 'gon.test_hash=1;')
169
- )
170
- end
171
-
172
- it 'outputs correct js with an integer and without tag' do
173
- Gon.int = 1
174
- expect(@base.include_gon(need_tag: false)).to eq( \
175
- 'window.gon={};' +
176
- 'gon.int=1;'
177
- )
178
- end
179
-
180
- it 'outputs correct js without variables, without tag and gon init if before there was data' do
181
- Gon::Request.
182
- instance_variable_set(:@request_id, 123)
183
- Gon::Request.instance_variable_set(:@request_env, { 'gon' => { :a => 1 } })
184
- expect(@base.include_gon(need_tag: false, init: true)).to eq( \
185
- 'window.gon={};'
186
- )
187
- end
188
-
189
- it 'outputs correct js without variables, without tag and gon init' do
190
- expect(@base.include_gon(need_tag: false, init: true)).to eq( \
191
- 'window.gon={};'
192
- )
193
- end
194
-
195
- it 'outputs correct js without variables, without tag, gon init and an integer' do
196
- Gon.int = 1
197
- expect(@base.include_gon(need_tag: false, init: true)).to eq( \
198
- 'window.gon={};' +
199
- 'gon.int=1;'
200
- )
201
- end
202
-
203
- it 'outputs correct js without cdata, without type, gon init and an integer' do
204
- Gon.int = 1
205
- expect(@base.include_gon(cdata: false, type: false)).to eq(
206
- wrap_script(
207
- "\n" +
208
- 'window.gon={};' +
209
- 'gon.int=1;' +
210
- "\n", false)
211
- )
212
- end
213
-
214
- it 'outputs correct js with type text/javascript' do
215
- expect(@base.include_gon(need_type: true, init: true)).to eq(wrap_script('window.gon={};'))
216
- end
217
-
218
- it 'outputs correct js with namespace check' do
219
- expect(@base.include_gon(namespace_check: true)).to eq(wrap_script('window.gon=window.gon||{};'))
220
- end
221
-
222
- it 'outputs correct js without namespace check' do
223
- expect(@base.include_gon(namespace_check: false)).to eq(wrap_script('window.gon={};'))
224
- end
225
-
226
- context "without a current_gon instance" do
227
-
228
- before(:each) do
229
- RequestStore.store[:gon] = nil
230
- allow(Gon).to receive(:current_gon).and_return(nil)
231
- end
232
-
233
- it "does not raise an exception" do
234
- expect { @base.include_gon }.to_not raise_error
235
- end
236
-
237
- it 'outputs correct js' do
238
- expect(@base.include_gon).to eq("")
239
- end
240
-
241
- it 'outputs correct js with init' do
242
- expect(@base.include_gon(init: true)).to eq(wrap_script('window.gon={};'))
243
- end
244
-
245
- end
246
-
247
- end
248
-
249
- describe '#include_gon_amd' do
250
-
251
- before(:each) do
252
- Gon::Request.
253
- instance_variable_set(:@request_id, request.object_id)
254
- @base = ActionView::Base.new
255
- @base.request = request
256
- end
257
-
258
- it 'is included in ActionView::Base as a helper' do
259
- expect(ActionView::Base.instance_methods).to include(:include_gon_amd)
260
- end
261
-
262
- it 'outputs correct js without variables' do
263
- expect(@base.include_gon_amd).to eq( wrap_script( \
264
- 'define(\'gon\',[],function(){'+
265
- 'var gon={};return gon;'+
266
- '});')
267
- )
268
- end
269
-
270
- it 'outputs correct js with an integer' do
271
- Gon.int = 1
272
-
273
- expect(@base.include_gon_amd).to eq( wrap_script(
274
- 'define(\'gon\',[],function(){'+
275
- 'var gon={};gon[\'int\']=1;return gon;'+
276
- '});')
277
- )
278
- end
279
-
280
- it 'outputs correct module name when given a namespace' do
281
- expect(@base.include_gon_amd(namespace: 'data')).to eq(wrap_script(
282
- 'define(\'data\',[],function(){'+
283
- 'var gon={};return gon;'+
284
- '});')
285
- )
286
- end
287
- end
288
-
289
- it 'returns exception if try to set public method as variable' do
290
- expect { Gon.all_variables = 123 }.to raise_error(RuntimeError)
291
- expect { Gon.rabl = 123 }.to raise_error(RuntimeError)
292
- end
293
-
294
- describe '#check_for_rabl_and_jbuilder' do
295
-
296
- let(:controller) { ActionController::Base.new }
297
-
298
- it 'should be able to handle constants array (symbols)' do
299
- allow(Gon).to receive(:constants) { Gon.constants }
300
- expect { Gon.rabl :template => 'spec/test_data/sample.rabl', :controller => controller }.not_to raise_error
301
- expect { Gon.jbuilder :template => 'spec/test_data/sample.json.jbuilder', :controller => controller }.not_to raise_error
302
- end
303
- end
304
- end
@@ -1,146 +0,0 @@
1
- describe Gon::Global do
2
-
3
- before(:each) do
4
- Gon::Global.clear
5
- Gon::Request.instance_variable_set(:@request_env, nil)
6
- end
7
-
8
- describe '#all_variables' do
9
-
10
- it 'returns all variables in hash' do
11
- Gon.global.a = 1
12
- Gon.global.b = 2
13
- Gon.global.c = Gon.global.a + Gon.global.b
14
- expect(Gon.global.c).to eq(3)
15
- expect(Gon.global.all_variables).to eq({ 'a' => 1, 'b' => 2, 'c' => 3 })
16
- end
17
-
18
- it 'supports all data types' do
19
- Gon.global.int = 1
20
- Gon.global.float = 1.1
21
- Gon.global.string = 'string'
22
- Gon.global.symbol = :symbol
23
- Gon.global.array = [1, 'string']
24
- Gon.global.hash_var = { :a => 1, :b => '2' }
25
- Gon.global.hash_w_array = { :a => [2, 3] }
26
- Gon.global.klass = Hash
27
- end
28
-
29
- end
30
-
31
- describe '#include_gon' do
32
-
33
- before(:each) do
34
- Gon.clear
35
- expect(ActionView::Base.instance_methods).to include(:include_gon)
36
- @base = ActionView::Base.new
37
- @base.request = request
38
- end
39
-
40
- it 'outputs correct js with an integer' do
41
- Gon.global.int = 1
42
- expect(@base.include_gon).to eq("<script>" +
43
- "\n//<![CDATA[\n" +
44
- "window.gon={};" +
45
- "gon.global={\"int\":1};" +
46
- "\n//]]>\n" +
47
- "</script>")
48
- end
49
-
50
- it 'outputs correct js with an integer and integer in Gon' do
51
- Gon.int = 1
52
- Gon.global.int = 1
53
- expect(@base.include_gon).to eq("<script>" +
54
- "\n//<![CDATA[\n" +
55
- "window.gon={};" +
56
- "gon.global={\"int\":1};" +
57
- "gon.int=1;" +
58
- "\n//]]>\n" +
59
- "</script>")
60
- end
61
-
62
- it 'outputs correct js with a string' do
63
- Gon.global.str = %q(a'b"c)
64
- expect(@base.include_gon).to eq("<script>" +
65
- "\n//<![CDATA[\n" +
66
- "window.gon={};" +
67
- "gon.global={\"str\":\"a'b\\\"c\"};" +
68
- "\n//]]>\n" +
69
- "</script>")
70
- end
71
-
72
- it 'outputs correct js with a script string' do
73
- Gon.global.str = %q(</script><script>alert('!')</script>)
74
- escaped_str = "\\u003c/script\\u003e\\u003cscript\\u003ealert('!')\\u003c/script\\u003e"
75
- expect(@base.include_gon).to eq("<script>" +
76
- "\n//<![CDATA[\n" +
77
- "window.gon={};" +
78
- "gon.global={\"str\":\"#{escaped_str}\"};" +
79
- "\n//]]>\n" +
80
- "</script>")
81
- end
82
-
83
- it 'outputs correct js with a unicode line separator' do
84
- Gon.global.str = "\u2028"
85
- expect(@base.include_gon).to eq("<script>" +
86
- "\n//<![CDATA[\n" +
87
- "window.gon={};" +
88
- "gon.global={\"str\":\"&#x2028;\"};" +
89
- "\n//]]>\n" +
90
- "</script>")
91
- end
92
-
93
- it 'outputs locally overridden value' do
94
- Gon.str = 'local value'
95
- Gon.global.str = 'global value'
96
- expect(@base.include_gon(global_root: '')).to eq("<script>" +
97
- "\n//<![CDATA[\n" +
98
- "window.gon={};" +
99
- "gon.str=\"local value\";" +
100
- "\n//]]>\n" +
101
- "</script>")
102
- end
103
-
104
- it "includes the tag attributes in the script tag" do
105
- Gon.global.int = 1
106
- expect(@base.include_gon(nonce: 'test')).to eq("<script nonce=\"test\">" +
107
- "\n//<![CDATA[\n" +
108
- "window.gon={};" +
109
- "gon.global={\"int\":1};" +
110
- "\n//]]>\n" +
111
- "</script>")
112
- end
113
-
114
- end
115
-
116
- it 'returns exception if try to set public method as variable' do
117
- expect { Gon.global.all_variables = 123 }.to raise_error(RuntimeError)
118
- expect { Gon.global.rabl = 123 }.to raise_error(RuntimeError)
119
- end
120
-
121
- context 'with jbuilder and rabl' do
122
-
123
- before :each do
124
- controller.instance_variable_set('@objects', objects)
125
- end
126
-
127
- let(:controller) { ActionController::Base.new }
128
- let(:objects) { [1, 2] }
129
-
130
- it 'works fine with rabl' do
131
- Gon.global.rabl :template => 'spec/test_data/sample.rabl', :controller => controller
132
- expect(Gon.global.objects.length).to eq(2)
133
- end
134
-
135
- it 'works fine with jbuilder' do
136
- Gon.global.jbuilder :template => 'spec/test_data/sample.json.jbuilder', :controller => controller
137
- expect(Gon.global.objects.length).to eq(2)
138
- end
139
-
140
- it 'should throw exception, if use rabl or jbuilder without :template' do
141
- expect { Gon.global.rabl }.to raise_error(RuntimeError)
142
- expect { Gon.global.jbuilder }.to raise_error(RuntimeError)
143
- end
144
-
145
- end
146
- end
@@ -1,75 +0,0 @@
1
- describe Gon do
2
-
3
- describe '.jbuilder' do
4
- context 'render jbuilder templates' do
5
-
6
- before do
7
- Gon.clear
8
- controller.instance_variable_set('@objects', objects)
9
- end
10
-
11
- let(:controller) { ActionController::Base.new }
12
- let(:objects) { [1, 2] }
13
-
14
- it 'render json from jbuilder template' do
15
- Gon.jbuilder :template => 'spec/test_data/sample.json.jbuilder', :controller => controller
16
- expect(Gon.objects.length).to eq(2)
17
- end
18
-
19
- it 'render json from jbuilder template with locals' do
20
- Gon.jbuilder :template => 'spec/test_data/sample_with_locals.json.jbuilder',
21
- :controller => controller,
22
- :locals => { :some_local => 1234, :some_complex_local => OpenStruct.new(:id => 1234) }
23
- expect(Gon.some_local).to eq(1234)
24
- expect(Gon.some_complex_local_id).to eq(1234)
25
- end
26
-
27
- it 'render json from jbuilder template with locals' do
28
- Gon.jbuilder :template => 'spec/test_data/sample_with_helpers.json.jbuilder', :controller => controller
29
- expect(Gon.date).to eq('about 6 hours')
30
- end
31
-
32
- it 'render json from jbuilder template with controller methods' do
33
- class << controller
34
- def private_controller_method
35
- 'gon test helper works'
36
- end
37
- helper_method :private_controller_method
38
- private :private_controller_method
39
- end
40
-
41
- Gon.jbuilder :template => 'spec/test_data/sample_with_controller_method.json.jbuilder', :controller => controller
42
- expect(Gon.data_from_method).to eq('gon test helper works')
43
- end
44
-
45
- it 'render json from jbuilder template with a partial' do
46
- controller.view_paths << 'spec/test_data'
47
- Gon.jbuilder :template => 'spec/test_data/sample_with_partial.json.jbuilder', :controller => controller
48
- expect(Gon.objects.length).to eq(2)
49
- end
50
-
51
- context 'within Rails' do
52
- before do
53
- module ::Rails
54
- end
55
-
56
- allow(Rails).to receive_message_chain("application.routes.url_helpers.instance_methods") { [:user_path] }
57
- controller.instance_variable_set('@user_id', 1)
58
- end
59
-
60
- after do
61
- Object.send(:remove_const, :Rails)
62
- end
63
-
64
- it 'includes url_helpers' do
65
- expect(controller).to receive(:user_path) { |id| "/users/#{id}" }
66
- Gon.jbuilder :template => 'spec/test_data/sample_url_helpers.json.jbuilder', :controller => controller
67
- expect(Gon.url).to eq '/users/1'
68
- end
69
- end
70
-
71
- end
72
-
73
- end
74
-
75
- end
@@ -1,90 +0,0 @@
1
- describe Gon do
2
- describe '.rabl' do
3
-
4
- before :each do
5
- Gon.clear
6
- controller.instance_variable_set('@objects', objects)
7
- end
8
-
9
- let(:controller) { ActionController::Base.new }
10
- let(:objects) { [1, 2] }
11
-
12
- context 'render template with deprecation' do
13
- it 'still works' do
14
- Gon.rabl 'spec/test_data/sample.rabl', :controller => controller
15
- expect(Gon.objects.length).to eq(2)
16
- end
17
- end
18
-
19
- context 'option locals' do
20
- it 'works without locals object properly' do
21
- Gon.rabl(
22
- :template => 'spec/test_data/sample.rabl',
23
- :controller => controller
24
- )
25
- expect(Gon.objects.map { |it| it['object']['inspect'] }).to eq(%w(1 2))
26
- end
27
-
28
- it 'works with different locals object' do
29
- Gon.rabl(
30
- :template => 'spec/test_data/sample.rabl',
31
- :controller => controller,
32
- :locals => { :objects => [3, 4] }
33
- )
34
- expect(Gon.objects.map { |it| it['object']['inspect'] }).to eq(%w(3 4))
35
- end
36
- end
37
-
38
- it 'works if rabl is included' do
39
- Gon.rabl :template => 'spec/test_data/sample.rabl', :controller => controller
40
- expect(Gon.objects.length).to eq(2)
41
- end
42
-
43
- it 'works with ActionView::Helpers' do
44
- Gon.rabl :template => 'spec/test_data/sample_with_helpers.rabl', :controller => controller
45
- expect(Gon.objects.first['object']['time_ago']).to eq('about 6 hours')
46
- end
47
-
48
- it 'raise exception if rabl is not included' do
49
- Gon.send :remove_const, 'Rabl'
50
- expect { Gon.rabl :template => 'spec/test_data/sample.rabl', :controller => controller }.to raise_error(NameError)
51
- load 'rabl.rb'
52
- load 'gon/rabl.rb'
53
- end
54
-
55
- context '.template_path' do
56
- context 'template is specified' do
57
-
58
- it 'add the extension if not included in the template name' do
59
- expect(Gon::EnvFinder.send(:template_path, { :template => 'spec/test_data/sample' }, 'rabl')).to eql('spec/test_data/sample.rabl')
60
- end
61
-
62
- it 'return the specified template' do
63
- expect(Gon::EnvFinder.send(:template_path, { :template => 'spec/test_data/sample.rabl' }, 'rabl')).to eql('spec/test_data/sample.rabl')
64
- end
65
-
66
- end
67
-
68
- context 'template is not specified' do
69
-
70
- before do
71
- Gon.clear
72
- controller.instance_variable_set('@objects', objects)
73
- controller.action_name = 'show'
74
- end
75
-
76
- let(:controller) { ActionController::Base.new }
77
- let(:objects) { [1, 2] }
78
-
79
- context 'the action doesn as a template at a different format' do
80
- it 'return the same template as the action with rabl extension' do
81
- expect(Gon::EnvFinder.send(:template_path, { :controller => controller }, 'rabl')).to eql('app/views/action_controller/base/show.json.rabl')
82
- end
83
- end
84
-
85
- end
86
- end
87
-
88
- end
89
-
90
- end
@@ -1,36 +0,0 @@
1
- describe Gon do
2
-
3
- describe '.template_path' do
4
- context 'template is specified' do
5
-
6
- it 'add the extension if not included in the template name' do
7
- expect(Gon::EnvFinder.send(:template_path, { :template => 'spec/test_data/sample' }, 'jbuilder')).to eql('spec/test_data/sample.jbuilder')
8
- end
9
-
10
- it 'return the specified template' do
11
- expect(Gon::EnvFinder.send(:template_path, { :template => 'spec/test_data/sample.jbuilder' }, 'jbuilder')).to eql('spec/test_data/sample.jbuilder')
12
- end
13
-
14
- end
15
-
16
- context 'template is not specified' do
17
-
18
- before do
19
- Gon.clear
20
- controller.instance_variable_set('@objects', objects)
21
- controller.action_name = 'show'
22
- end
23
-
24
- let(:controller) { ActionController::Base.new }
25
- let(:objects) { [1, 2] }
26
-
27
- context 'the action doesn as a template at a different format' do
28
- it 'return the same template as the action with rabl extension' do
29
- expect(Gon::EnvFinder.send(:template_path, { :controller => controller }, 'jbuilder')).to eql('app/views/action_controller/base/show.json.jbuilder')
30
- end
31
- end
32
-
33
- end
34
- end
35
-
36
- end
@@ -1,39 +0,0 @@
1
- class GonTestWorker
2
- include Gon::ControllerHelpers
3
-
4
- def request
5
- @request ||= ActionDispatch::TestRequest.create
6
- end
7
-
8
- def env
9
- request.env
10
- end
11
-
12
- def execute
13
- gon.clear
14
- gon.a ||= 1
15
- gon.a += 1
16
- end
17
-
18
- def value
19
- gon.a
20
- end
21
- end
22
-
23
- describe 'threading behaviour' do
24
- before do
25
- allow(Gon).to receive(:current_gon).and_call_original
26
- end
27
-
28
- it 'is threadsafe' do
29
- threads = []
30
- 10.times do
31
- threads << Thread.new do
32
- gtw = GonTestWorker.new
33
- gtw.execute
34
- expect(gtw.value).to eq 2
35
- end
36
- end
37
- threads.each(&:join)
38
- end
39
- end
@@ -1,81 +0,0 @@
1
- describe Gon::Watch do
2
-
3
- let(:controller) { ActionController::Base.new }
4
- let(:request) { ActionDispatch::Request.new({}) }
5
-
6
- before :each do
7
- controller.request = request
8
- controller.params = {}
9
- env = {}
10
- env['ORIGINAL_FULLPATH'] = '/foo'
11
- env['REQUEST_METHOD'] = 'GET'
12
-
13
- Gon::Watch.clear
14
- Gon.send(:current_gon).instance_variable_set(:@env, env)
15
- Gon.send(:current_gon).env['action_controller.instance'] = controller
16
- Gon.clear
17
- end
18
-
19
- it 'should add variables to Gon#all_variables hash' do
20
- Gon.a = 1
21
- Gon.watch.b = 2
22
- expect(Gon.all_variables).to eq({ 'a' => 1, 'b' => 2 })
23
- end
24
-
25
- describe '#all_variables' do
26
-
27
- it 'should generate array with current request url, method type and variable names' do
28
- Gon.watch.a = 1
29
- expect(Gon.watch.all_variables).to eq({ 'a' => { 'url' => '/foo', 'method' => 'GET', 'name' => 'a' } })
30
- end
31
-
32
- end
33
-
34
- describe '#render' do
35
-
36
- it 'should render function with variables in gon namespace' do
37
- Gon.watch.a = 1
38
- expect(Gon.watch.render).to match(/gon\.watch\s=/)
39
- expect(Gon.watch.render).to match(/gon\.watchedVariables/)
40
- end
41
-
42
- end
43
-
44
- describe 'Render concrete variable' do
45
- before do
46
- env = Gon.send(:current_gon).env
47
- env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
48
-
49
- allow(controller).to receive_messages(request: ActionDispatch::Request.new(env))
50
- Gon.send(:current_gon).env['action_controller.instance'] = controller
51
- end
52
-
53
- context 'when request variable is json safe content' do
54
- before do
55
- allow(controller).to receive_messages(params: {
56
- gon_return_variable: true,
57
- gon_watched_variable: 'safety'})
58
- end
59
-
60
- it 'should return value of variable if called right request' do
61
- expect(controller).to receive(:render).with(json: '12345')
62
- Gon.watch.safety = 12345
63
- end
64
- end
65
-
66
- context 'when request variable is json unsafe content' do
67
- let(:expected) { %Q{"\\u003cscript\\u003e'\\"\\u003c/script\\u003e&#x2028;Dangerous"} }
68
-
69
- before do
70
- allow(controller).to receive_messages(params: {
71
- gon_return_variable: true,
72
- gon_watched_variable: 'danger'})
73
- end
74
-
75
- it 'should return value of variable if called right request' do
76
- expect(controller).to receive(:render).with(json: expected)
77
- Gon.watch.danger = %Q{<script>'"</script>\u2028Dangerous}
78
- end
79
- end
80
- end
81
- end
data/spec/spec_helper.rb DELETED
@@ -1,36 +0,0 @@
1
- require 'rails/railtie'
2
- # We don't require rails for specs, but jbuilder works only in rails.
3
- # And it checks version of rails. I've decided to configure jbuilder for rails v4
4
- module Rails
5
- module VERSION
6
- MAJOR = 4
7
- end
8
-
9
- def self.version
10
- '4.2.0'
11
- end
12
- end
13
-
14
- require 'gon'
15
-
16
- require 'jbuilder'
17
-
18
- RSpec.configure do |config|
19
- config.before(:each) do
20
- RequestStore.store[:gon] = Gon::Request.new({})
21
- @request = RequestStore.store[:gon]
22
- allow(Gon).to receive(:current_gon).and_return(@request)
23
- end
24
- end
25
-
26
- def request
27
- @request ||= double 'request', :env => {}
28
- end
29
-
30
- def wrap_script(content, cdata=true)
31
- script = "<script>"
32
- script << "\n//<![CDATA[\n" if cdata
33
- script << content
34
- script << "\n//]]>\n" if cdata
35
- script << '</script>'
36
- end
@@ -1 +0,0 @@
1
- json.objects objects
@@ -1 +0,0 @@
1
- json.objects @objects
@@ -1,2 +0,0 @@
1
- collection @objects => 'objects'
2
- attributes :inspect
@@ -1,2 +0,0 @@
1
- collection :@objects => 'objects'
2
- attributes :inspect
@@ -1 +0,0 @@
1
- json.url user_path(@user_id)
@@ -1,2 +0,0 @@
1
- json.objects @objects
2
- json.data_from_method private_controller_method
@@ -1 +0,0 @@
1
- json.date distance_of_time_in_words(20000)
@@ -1,3 +0,0 @@
1
- collection @objects => 'objects'
2
- attributes :id
3
- node(:time_ago) { |_| distance_of_time_in_words(20000) }
@@ -1,3 +0,0 @@
1
- collection :@objects => 'objects'
2
- attributes :inspect
3
- node(:time_ago) { distance_of_time_in_words(20000) }
@@ -1,2 +0,0 @@
1
- json.some_local some_local
2
- json.some_complex_local_id some_complex_local.id
@@ -1 +0,0 @@
1
- json.partial! 'spec/test_data/_sample_partial.json.jbuilder', :objects => @objects