jbuilder 2.6.0 → 2.6.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d949cb2167336c8e5b026626493bb07843dab242
4
- data.tar.gz: 1c0a6e23cb4441794732665e5fa2ef73a63eae0d
3
+ metadata.gz: e35bd234795a5d5f23c73a30d259ca195e42f6e5
4
+ data.tar.gz: 3e884978c900ea0ef14aa7e68e611246b2b74814
5
5
  SHA512:
6
- metadata.gz: bd78d3b8d0fa94ead3c7a77c7769593f2202ec46d18f3a2d3ba875f35a72040bd0e519bfd6e67b60fea465fbef8ffaf8966d964e02538eb8479c52011a5c24a1
7
- data.tar.gz: dc257849862f9619da61c740ab9596026b1e2d9cdf0b3b8aa7eee7ab23eef1912fc00ec49eb6c6a3cd888161104929ff851ddbabb1358d655dc947003f6222cc
6
+ metadata.gz: de29407995773a316901cee9012d9f363366ac02ecd4faeb98ab58099536dc5377d53e3c07242f24f17e039111a7f45842ecb5cfc37be67af5852e4ce7c471de
7
+ data.tar.gz: 9bc528a7c2f5fe784567d0d62012a51b3e398debf13a72e68496f7345be69f0f62c401b6dfa07e1a38773a4d4d952b768e63b83c32fa24e64041fe62b6dd3778
data/.travis.yml CHANGED
@@ -9,6 +9,7 @@ rvm:
9
9
  - 2.1
10
10
  - 2.2.5
11
11
  - 2.3.1
12
+ - 2.4.0
12
13
  - ruby-head
13
14
  - jruby-19mode
14
15
  - rbx
@@ -21,6 +22,7 @@ gemfile:
21
22
  - gemfiles/rails_4_1.gemfile
22
23
  - gemfiles/rails_4_2.gemfile
23
24
  - gemfiles/rails_5_0.gemfile
25
+ - gemfiles/rails_5_1.gemfile
24
26
 
25
27
  matrix:
26
28
  allow_failures:
@@ -31,14 +33,34 @@ matrix:
31
33
  exclude:
32
34
  - rvm: 1.9
33
35
  gemfile: gemfiles/rails_5_0.gemfile
36
+ - rvm: 1.9
37
+ gemfile: gemfiles/rails_5_1.gemfile
34
38
  - rvm: 2.0
35
39
  gemfile: gemfiles/rails_5_0.gemfile
40
+ - rvm: 2.0
41
+ gemfile: gemfiles/rails_5_1.gemfile
36
42
  - rvm: 2.1
37
43
  gemfile: gemfiles/rails_5_0.gemfile
44
+ - rvm: 2.1
45
+ gemfile: gemfiles/rails_5_1.gemfile
38
46
  - rvm: jruby-19mode
39
47
  gemfile: gemfiles/rails_5_0.gemfile
48
+ - rvm: jruby-19mode
49
+ gemfile: gemfiles/rails_5_1.gemfile
40
50
  - rvm: rbx
41
51
  gemfile: gemfiles/rails_5_0.gemfile
52
+ - rvm: rbx
53
+ gemfile: gemfiles/rails_5_1.gemfile
54
+ - rvm: 2.4.0
55
+ gemfile: gemfiles/rails_3_0.gemfile
56
+ - rvm: 2.4.0
57
+ gemfile: gemfiles/rails_3_1.gemfile
58
+ - rvm: 2.4.0
59
+ gemfile: gemfiles/rails_3_2.gemfile
60
+ - rvm: 2.4.0
61
+ gemfile: gemfiles/rails_4_0.gemfile
62
+ - rvm: 2.4.0
63
+ gemfile: gemfiles/rails_4_1.gemfile
42
64
 
43
65
  notifications:
44
66
  email: false
data/Appraisals CHANGED
@@ -42,3 +42,9 @@ appraise "rails-5-0" do
42
42
  gem "actionpack", "~> 5.0.0"
43
43
  gem "activemodel", "~> 5.0.0"
44
44
  end
45
+
46
+ appraise "rails-5-1" do
47
+ gem "railties", ">= 5.1.0", "< 5.2"
48
+ gem "actionpack", ">= 5.1.0", "< 5.2"
49
+ gem "activemodel", ">= 5.1.0", "< 5.2"
50
+ end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ 2.6.4
4
+ -----
5
+
6
+ * Drop the pessimistic upper-bound restriction on Active Support and MultiJSON to prevent future gemfile resolution deadlocks *DHH*
7
+
8
+ 2.6.3
9
+ -----
10
+
11
+ * Support Rails 5.1
12
+
13
+ 2.6.2
14
+ -----
15
+
16
+ * Fix thor warnings
17
+
18
+ 2.6.1
19
+ -----
20
+
21
+ * [Optimize root caches with cache_root!](https://github.com/rails/jbuilder/pull/370)
22
+
3
23
  2.6.0
4
24
  -----
5
25
 
data/CONTRIBUTING.md CHANGED
@@ -39,7 +39,8 @@ Ensure that you can build the project and run tests.
39
39
 
40
40
  ```
41
41
  bundle install
42
- bundle exec rake test
42
+ appraisal install
43
+ appraisal rake test
43
44
  ```
44
45
 
45
46
  #### Write Tests
@@ -52,7 +53,7 @@ We definitely appreciate pull requests that highlight or reproduce a problem, ev
52
53
 
53
54
  Implement your feature or bug fix.
54
55
 
55
- Make sure that `bundle exec rake test` completes without errors.
56
+ Make sure that `appraisal rake test` completes without errors.
56
57
 
57
58
  #### Write Documentation
58
59
 
@@ -82,7 +83,7 @@ git push origin my-feature-branch
82
83
 
83
84
  #### Make a Pull Request
84
85
 
85
- Go to https://github.com/contributor/jbuilder and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
86
+ Visit your forked repo and click the 'New pull request' button. Select your feature branch, fill out the form, and click the 'Create pull request' button. Pull requests are usually reviewed within a few days.
86
87
 
87
88
  #### Rebase
88
89
 
@@ -100,7 +101,7 @@ Go back to your pull request after a few minutes and see whether it passed muste
100
101
 
101
102
  #### Be Patient
102
103
 
103
- It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
104
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang in there!
104
105
 
105
106
  #### Thank You
106
107
 
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2016 David Heinemeier Hansson, 37signals
1
+ Copyright (c) 2011-2017 David Heinemeier Hansson, 37signals
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Jbuilder
2
2
 
3
3
  Jbuilder gives you a simple DSL for declaring JSON structures that beats
4
- massaging giant hash structures. This is particularly helpful when the
4
+ manipulating giant hash structures. This is particularly helpful when the
5
5
  generation process is fraught with conditionals and loops. Here's a simple
6
6
  example:
7
7
 
@@ -124,7 +124,7 @@ company.to_builder.target!
124
124
  ```
125
125
 
126
126
  You can either use Jbuilder stand-alone or directly as an ActionView template
127
- language. When required in Rails, you can create views ala show.json.jbuilder
127
+ language. When required in Rails, you can create views a la show.json.jbuilder
128
128
  (the json is already yielded):
129
129
 
130
130
  ``` ruby
@@ -9,5 +9,6 @@ gem "pry"
9
9
  gem "railties", "~> 4.2.0"
10
10
  gem "actionpack", "~> 4.2.0"
11
11
  gem "activemodel", "~> 4.2.0"
12
+ gem "nokogiri", "< 1.7" if RUBY_VERSION < "2.1"
12
13
 
13
14
  gemspec :path => "../"
@@ -6,8 +6,8 @@ gem "rake"
6
6
  gem "mocha", :require => false
7
7
  gem "appraisal"
8
8
  gem "pry"
9
- gem "railties", ">= 5.0.0.beta2", "< 5.1"
10
- gem "actionpack", ">= 5.0.0.beta2", "< 5.1"
11
- gem "activemodel", ">= 5.0.0.beta2", "< 5.1"
9
+ gem "railties", "~> 5.0.0"
10
+ gem "actionpack", "~> 5.0.0"
11
+ gem "activemodel", "~> 5.0.0"
12
12
 
13
13
  gemspec :path => "../"
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "mocha", :require => false
7
+ gem "appraisal"
8
+ gem "pry"
9
+ gem "railties", ">= 5.1.0", "< 5.2"
10
+ gem "actionpack", ">= 5.1.0", "< 5.2"
11
+ gem "activemodel", ">= 5.1.0", "< 5.2"
12
+
13
+ gemspec :path => "../"
data/jbuilder.gemspec CHANGED
@@ -1,16 +1,16 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jbuilder'
3
- s.version = '2.6.0'
4
- s.authors = ['David Heinemeier Hansson', 'Pavel Pravosud']
5
- s.email = ['david@37signals.com', 'pavel@pravosud.com']
3
+ s.version = '2.6.4'
4
+ s.authors = ['David Heinemeier Hansson']
5
+ s.email = ['david@37signals.com']
6
6
  s.summary = 'Create JSON structures via a Builder-style DSL'
7
7
  s.homepage = 'https://github.com/rails/jbuilder'
8
8
  s.license = 'MIT'
9
9
 
10
10
  s.required_ruby_version = '>= 1.9.3'
11
11
 
12
- s.add_dependency 'activesupport', '>= 3.0.0', '< 5.1'
13
- s.add_dependency 'multi_json', '~> 1.2'
12
+ s.add_dependency 'activesupport', '>= 3.0.0'
13
+ s.add_dependency 'multi_json', '>= 1.2'
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- test/*`.split("\n")
@@ -6,7 +6,7 @@ module Rails
6
6
  class ScaffoldControllerGenerator
7
7
  source_paths << File.expand_path('../templates', __FILE__)
8
8
 
9
- hook_for :jbuilder, default: true
9
+ hook_for :jbuilder, type: :boolean, default: true
10
10
  end
11
11
  end
12
12
  end
@@ -1 +1 @@
1
- json.array! @<%= plural_table_name %>, partial: '<%= plural_table_name %>/<%= singular_table_name %>', as: :<%= singular_table_name %>
1
+ json.array! @<%= plural_table_name %>, partial: '<%= plural_table_name %>/<%= singular_table_name %>', as: :<%= singular_table_name %>
@@ -1,2 +1,2 @@
1
1
  json.extract! <%= singular_table_name %>, <%= attributes_list_with_timestamps %>
2
- json.url <%= singular_table_name %>_url(<%= singular_table_name %>, format: :json)
2
+ json.url <%= singular_table_name %>_url(<%= singular_table_name %>, format: :json)
@@ -1 +1 @@
1
- json.partial! "<%= plural_table_name %>/<%= singular_table_name %>", <%= singular_table_name %>: @<%= singular_table_name %>
1
+ json.partial! "<%= plural_table_name %>/<%= singular_table_name %>", <%= singular_table_name %>: @<%= singular_table_name %>
@@ -14,4 +14,11 @@ class Jbuilder
14
14
  new(message)
15
15
  end
16
16
  end
17
+
18
+ class MergeError < ::StandardError
19
+ def self.build(current_value, updates)
20
+ message = "Can't merge #{updates.inspect} into #{current_value.inspect}"
21
+ new(message)
22
+ end
23
+ end
17
24
  end
@@ -11,6 +11,7 @@ class JbuilderTemplate < Jbuilder
11
11
 
12
12
  def initialize(context, *args)
13
13
  @context = context
14
+ @cached_root = nil
14
15
  super(*args)
15
16
  end
16
17
 
@@ -42,6 +43,27 @@ class JbuilderTemplate < Jbuilder
42
43
  end
43
44
  end
44
45
 
46
+ # Caches the json structure at the root using a string rather than the hash structure. This is considerably
47
+ # faster, but the drawback is that it only works, as the name hints, at the root. So you cannot
48
+ # use this approach to cache deeper inside the hierarchy, like in partials or such. Continue to use #cache! there.
49
+ #
50
+ # Example:
51
+ #
52
+ # json.cache_root! @person do
53
+ # json.extract! @person, :name, :age
54
+ # end
55
+ #
56
+ # # json.extra 'This will not work either, the root must be exclusive'
57
+ def cache_root!(key=nil, options={})
58
+ if @context.controller.perform_caching
59
+ raise "cache_root! can't be used after JSON structures have been defined" if @attributes.present?
60
+
61
+ @cached_root = _cache_fragment_for([ :root, key ], options) { yield; target! }
62
+ else
63
+ yield
64
+ end
65
+ end
66
+
45
67
  # Conditionally caches the json depending in the condition given as first parameter. Has the same
46
68
  # signature as the `cache` helper method in `ActionView::Helpers::CacheHelper` and so can be used in
47
69
  # the same way.
@@ -55,6 +77,10 @@ class JbuilderTemplate < Jbuilder
55
77
  condition ? cache!(*args, &::Proc.new) : yield
56
78
  end
57
79
 
80
+ def target!
81
+ @cached_root || super
82
+ end
83
+
58
84
  def array!(collection = [], *args)
59
85
  options = args.first
60
86
 
@@ -11,8 +11,8 @@ class Jbuilder
11
11
  args.each do |name|
12
12
  @format[name] = []
13
13
  end
14
- options.each do |name, paramaters|
15
- @format[name] = paramaters
14
+ options.each do |name, parameters|
15
+ @format[name] = parameters
16
16
  end
17
17
  end
18
18
 
data/lib/jbuilder.rb CHANGED
@@ -270,14 +270,14 @@ class Jbuilder
270
270
  def _merge_values(current_value, updates)
271
271
  if _blank?(updates)
272
272
  current_value
273
- elsif _blank?(current_value) || updates.nil?
273
+ elsif _blank?(current_value) || updates.nil? || current_value.empty? && ::Array === updates
274
274
  updates
275
- elsif ::Array === updates
276
- ::Array === current_value ? current_value + updates : updates
277
- elsif ::Hash === current_value
275
+ elsif ::Array === current_value && ::Array === updates
276
+ current_value + updates
277
+ elsif ::Hash === current_value && ::Hash === updates
278
278
  current_value.merge(updates)
279
279
  else
280
- raise "Can't merge #{updates.inspect} with #{current_value.inspect}"
280
+ raise MergeError.build(current_value, updates)
281
281
  end
282
282
  end
283
283
 
@@ -21,16 +21,16 @@ class JbuilderGeneratorTest < Rails::Generators::TestCase
21
21
  run_generator
22
22
 
23
23
  assert_file 'app/views/posts/index.json.jbuilder' do |content|
24
- assert_match /json.array! @posts, partial: 'posts\/post', as: :post/, content
24
+ assert_match %r{json.array! @posts, partial: 'posts/post', as: :post}, content
25
25
  end
26
26
 
27
27
  assert_file 'app/views/posts/show.json.jbuilder' do |content|
28
- assert_match /json.partial! \"posts\/post\", post: @post/, content
28
+ assert_match %r{json.partial! \"posts/post\", post: @post}, content
29
29
  end
30
30
 
31
31
  assert_file 'app/views/posts/_post.json.jbuilder' do |content|
32
- assert_match /json\.extract! post, :id, :title, :body/, content
33
- assert_match /json\.url post_url\(post, format: :json\)/, content
32
+ assert_match %r{json\.extract! post, :id, :title, :body}, content
33
+ assert_match %r{json\.url post_url\(post, format: :json\)}, content
34
34
  end
35
35
 
36
36
 
@@ -307,18 +307,6 @@ class JbuilderTemplateTest < ActionView::TestCase
307
307
  assert_equal %w[a b c], result
308
308
  end
309
309
 
310
- test "fragment caching works with previous version of cache digests" do
311
- undef_context_methods :cache_fragment_name
312
-
313
- @context.expects :fragment_name_with_digest
314
-
315
- jbuild <<-JBUILDER
316
- json.cache! "cachekey" do
317
- json.name "Cache"
318
- end
319
- JBUILDER
320
- end
321
-
322
310
  test "fragment caching works with current cache digests" do
323
311
  undef_context_methods :fragment_name_with_digest
324
312
 
@@ -386,6 +374,35 @@ class JbuilderTemplateTest < ActionView::TestCase
386
374
  JBUILDER
387
375
  end
388
376
 
377
+ test "caching root structure" do
378
+ undef_context_methods :fragment_name_with_digest, :cache_fragment_name
379
+
380
+ cache_miss_result = jbuild <<-JBUILDER
381
+ json.cache_root! "cachekey" do
382
+ json.name "Miss"
383
+ end
384
+ JBUILDER
385
+
386
+ cache_hit_result = jbuild <<-JBUILDER
387
+ json.cache_root! "cachekey" do
388
+ json.name "Hit"
389
+ end
390
+ JBUILDER
391
+
392
+ assert_equal cache_miss_result, cache_hit_result
393
+ end
394
+
395
+ test "failing to cache root after attributes have been defined" do
396
+ assert_raises ActionView::Template::Error, "cache_root! can't be used after JSON structures have been defined" do
397
+ jbuild <<-JBUILDER
398
+ json.name "Kaboom"
399
+ json.cache_root! "cachekey" do
400
+ json.name "Miss"
401
+ end
402
+ JBUILDER
403
+ end
404
+ end
405
+
389
406
  test "does not perform caching when controller.perform_caching is false" do
390
407
  controller.perform_caching = false
391
408
 
@@ -686,4 +686,31 @@ class JbuilderTest < ActiveSupport::TestCase
686
686
  end
687
687
  end
688
688
  end
689
+
690
+ test "throws MergeError when trying to merge array with non-empty hash" do
691
+ assert_raise Jbuilder::MergeError do
692
+ jbuild do |json|
693
+ json.name "Daniel"
694
+ json.merge! []
695
+ end
696
+ end
697
+ end
698
+
699
+ test "throws MergeError when trying to merge hash with array" do
700
+ assert_raise Jbuilder::MergeError do
701
+ jbuild do |json|
702
+ json.array!
703
+ json.merge!({})
704
+ end
705
+ end
706
+ end
707
+
708
+ test "throws MergeError when trying to merge invalid objects" do
709
+ assert_raise Jbuilder::MergeError do
710
+ jbuild do |json|
711
+ json.name "Daniel"
712
+ json.merge! "Nope"
713
+ end
714
+ end
715
+ end
689
716
  end
@@ -15,7 +15,7 @@ if Rails::VERSION::MAJOR > 4
15
15
 
16
16
  assert_file 'app/controllers/posts_controller.rb' do |content|
17
17
  assert_instance_method :index, content do |m|
18
- assert_match /@posts = Post\.all/, m
18
+ assert_match %r{@posts = Post\.all}, m
19
19
  end
20
20
 
21
21
  assert_instance_method :show, content do |m|
@@ -23,23 +23,23 @@ if Rails::VERSION::MAJOR > 4
23
23
  end
24
24
 
25
25
  assert_instance_method :create, content do |m|
26
- assert_match /@post = Post\.new\(post_params\)/, m
27
- assert_match /@post\.save/, m
28
- assert_match /render :show, status: :created, location: @post/, m
29
- assert_match /render json: @post\.errors, status: :unprocessable_entity/, m
26
+ assert_match %r{@post = Post\.new\(post_params\)}, m
27
+ assert_match %r{@post\.save}, m
28
+ assert_match %r{render :show, status: :created, location: @post}, m
29
+ assert_match %r{render json: @post\.errors, status: :unprocessable_entity}, m
30
30
  end
31
31
 
32
32
  assert_instance_method :update, content do |m|
33
- assert_match /render :show, status: :ok, location: @post/, m
34
- assert_match /render json: @post.errors, status: :unprocessable_entity/, m
33
+ assert_match %r{render :show, status: :ok, location: @post}, m
34
+ assert_match %r{render json: @post.errors, status: :unprocessable_entity}, m
35
35
  end
36
36
 
37
37
  assert_instance_method :destroy, content do |m|
38
- assert_match /@post\.destroy/, m
38
+ assert_match %r{@post\.destroy}, m
39
39
  end
40
40
 
41
- assert_match(/def post_params/, content)
42
- assert_match(/params\.require\(:post\)\.permit\(:title, :body\)/, content)
41
+ assert_match %r{def post_params}, content
42
+ assert_match %r{params\.require\(:post\)\.permit\(:title, :body\)}, content
43
43
  end
44
44
  end
45
45
 
@@ -47,8 +47,8 @@ if Rails::VERSION::MAJOR > 4
47
47
  run_generator %w(Post --api)
48
48
 
49
49
  assert_file 'app/controllers/posts_controller.rb' do |content|
50
- assert_match(/def post_params/, content)
51
- assert_match(/params\.fetch\(:post, {}\)/, content)
50
+ assert_match %r{def post_params}, content
51
+ assert_match %r{params\.fetch\(:post, \{\}\)}, content
52
52
  end
53
53
  end
54
54
  end
@@ -13,7 +13,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
13
13
 
14
14
  assert_file 'app/controllers/posts_controller.rb' do |content|
15
15
  assert_instance_method :index, content do |m|
16
- assert_match /@posts = Post\.all/, m
16
+ assert_match %r{@posts = Post\.all}, m
17
17
  end
18
18
 
19
19
  assert_instance_method :show, content do |m|
@@ -21,7 +21,7 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
21
21
  end
22
22
 
23
23
  assert_instance_method :new, content do |m|
24
- assert_match /@post = Post\.new/, m
24
+ assert_match %r{@post = Post\.new}, m
25
25
  end
26
26
 
27
27
  assert_instance_method :edit, content do |m|
@@ -29,29 +29,29 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
29
29
  end
30
30
 
31
31
  assert_instance_method :create, content do |m|
32
- assert_match /@post = Post\.new\(post_params\)/, m
33
- assert_match /@post\.save/, m
34
- assert_match /format\.html \{ redirect_to @post, notice: 'Post was successfully created\.' \}/, m
35
- assert_match /format\.json \{ render :show, status: :created, location: @post \}/, m
36
- assert_match /format\.html \{ render :new \}/, m
37
- assert_match /format\.json \{ render json: @post\.errors, status: :unprocessable_entity \}/, m
32
+ assert_match %r{@post = Post\.new\(post_params\)}, m
33
+ assert_match %r{@post\.save}, m
34
+ assert_match %r{format\.html \{ redirect_to @post, notice: 'Post was successfully created\.' \}}, m
35
+ assert_match %r{format\.json \{ render :show, status: :created, location: @post \}}, m
36
+ assert_match %r{format\.html \{ render :new \}}, m
37
+ assert_match %r{format\.json \{ render json: @post\.errors, status: :unprocessable_entity \}}, m
38
38
  end
39
39
 
40
40
  assert_instance_method :update, content do |m|
41
- assert_match /format\.html \{ redirect_to @post, notice: 'Post was successfully updated\.' \}/, m
42
- assert_match /format\.json \{ render :show, status: :ok, location: @post \}/, m
43
- assert_match /format\.html \{ render :edit \}/, m
44
- assert_match /format\.json \{ render json: @post.errors, status: :unprocessable_entity \}/, m
41
+ assert_match %r{format\.html \{ redirect_to @post, notice: 'Post was successfully updated\.' \}}, m
42
+ assert_match %r{format\.json \{ render :show, status: :ok, location: @post \}}, m
43
+ assert_match %r{format\.html \{ render :edit \}}, m
44
+ assert_match %r{format\.json \{ render json: @post.errors, status: :unprocessable_entity \}}, m
45
45
  end
46
46
 
47
47
  assert_instance_method :destroy, content do |m|
48
- assert_match /@post\.destroy/, m
49
- assert_match /format\.html \{ redirect_to posts_url, notice: 'Post was successfully destroyed\.' \}/, m
50
- assert_match /format\.json \{ head :no_content \}/, m
48
+ assert_match %r{@post\.destroy}, m
49
+ assert_match %r{format\.html \{ redirect_to posts_url, notice: 'Post was successfully destroyed\.' \}}, m
50
+ assert_match %r{format\.json \{ head :no_content \}}, m
51
51
  end
52
52
 
53
- assert_match(/def post_params/, content)
54
- assert_match(/params\.require\(:post\)\.permit\(:title, :body\)/, content)
53
+ assert_match %r{def post_params}, content
54
+ assert_match %r{params\.require\(:post\)\.permit\(:title, :body\)}, content
55
55
  end
56
56
  end
57
57
 
@@ -59,8 +59,8 @@ class ScaffoldControllerGeneratorTest < Rails::Generators::TestCase
59
59
  run_generator %w(Post)
60
60
 
61
61
  assert_file 'app/controllers/posts_controller.rb' do |content|
62
- assert_match(/def post_params/, content)
63
- assert_match(/params\.fetch\(:post, {}\)/, content)
62
+ assert_match %r{def post_params}, content
63
+ assert_match %r{params\.fetch\(:post, \{\}\)}, content
64
64
  end
65
65
  end
66
66
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- - Pavel Pravosud
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2016-07-20 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
@@ -18,9 +17,6 @@ dependencies:
18
17
  - - ">="
19
18
  - !ruby/object:Gem::Version
20
19
  version: 3.0.0
21
- - - "<"
22
- - !ruby/object:Gem::Version
23
- version: '5.1'
24
20
  type: :runtime
25
21
  prerelease: false
26
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -28,27 +24,23 @@ dependencies:
28
24
  - - ">="
29
25
  - !ruby/object:Gem::Version
30
26
  version: 3.0.0
31
- - - "<"
32
- - !ruby/object:Gem::Version
33
- version: '5.1'
34
27
  - !ruby/object:Gem::Dependency
35
28
  name: multi_json
36
29
  requirement: !ruby/object:Gem::Requirement
37
30
  requirements:
38
- - - "~>"
31
+ - - ">="
39
32
  - !ruby/object:Gem::Version
40
33
  version: '1.2'
41
34
  type: :runtime
42
35
  prerelease: false
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
37
  requirements:
45
- - - "~>"
38
+ - - ">="
46
39
  - !ruby/object:Gem::Version
47
40
  version: '1.2'
48
41
  description:
49
42
  email:
50
43
  - david@37signals.com
51
- - pavel@pravosud.com
52
44
  executables: []
53
45
  extensions: []
54
46
  extra_rdoc_files: []
@@ -69,6 +61,7 @@ files:
69
61
  - gemfiles/rails_4_1.gemfile
70
62
  - gemfiles/rails_4_2.gemfile
71
63
  - gemfiles/rails_5_0.gemfile
64
+ - gemfiles/rails_5_1.gemfile
72
65
  - jbuilder.gemspec
73
66
  - lib/generators/rails/jbuilder_generator.rb
74
67
  - lib/generators/rails/scaffold_controller_generator.rb
@@ -112,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
105
  version: '0'
113
106
  requirements: []
114
107
  rubyforge_project:
115
- rubygems_version: 2.6.4
108
+ rubygems_version: 2.6.8
116
109
  signing_key:
117
110
  specification_version: 4
118
111
  summary: Create JSON structures via a Builder-style DSL