action_args 1.0.3 → 1.0.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.
data/README.md CHANGED
@@ -20,7 +20,7 @@ class HogeController < ApplicationController
20
20
  end
21
21
  ```
22
22
 
23
- Hitting "/hoge/fuga?piyo=foo" will call fuga('foo') and output 'foo'.
23
+ Hitting "/hoge/fuga?piyo=foo" will call `fuga('foo')` and output 'foo'.
24
24
  So, you do never need to touch the ugly `params` Hash in order to fetch the request parameters.
25
25
 
26
26
 
@@ -29,7 +29,7 @@ So, you do never need to touch the ugly `params` Hash in order to fetch the requ
29
29
  ActionArgs plays very nice with Rails 4 StrongParameters.
30
30
 
31
31
  In this `show` action, ActionArgs `require`s the `id` parameter.
32
- Hence, raises an error if the `id` value has not been specified, in the same way as usual Ruby methods do.
32
+ Hence, if the `id` value has not been specified in the request parameter, it raises an error in the same way as usual Ruby methods do.
33
33
 
34
34
  ```ruby
35
35
  class UsersController < ApplicationController
@@ -90,7 +90,7 @@ Thus, by hitting the scaffold generator command like this:
90
90
  % rails g scaffold user name age:integer email
91
91
  ```
92
92
 
93
- The following beautiful controller code will be generated:
93
+ The following elegant controller code will be generated:
94
94
 
95
95
  ```ruby
96
96
  # coding: utf-8
@@ -183,7 +183,7 @@ Of courese you still can use both Merbish style and plain old Rails style action
183
183
 
184
184
  ### Argument Naming Convention
185
185
 
186
- Each action method parameter name corresponds to `params` key name. For example, the following beautifully written nested show action works perfectly (this might not be a very good example of effective querying, but that's another story).
186
+ Each action method parameter name corresponds to `params` key name. For example, the following beautifully written nested `show` action works perfectly (this might not be a very good example of effective querying, but that's another story).
187
187
 
188
188
  ```ruby
189
189
  Rails.application.routes.draw do
@@ -1,3 +1,3 @@
1
1
  module ActionArgs
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
data/lib/action_args.rb CHANGED
@@ -1,8 +1,8 @@
1
- require 'action_args/abstract_controller'
2
1
  begin
3
2
  require 'strong_parameters'
4
3
  rescue LoadError
5
4
  end
5
+ require 'action_args/abstract_controller'
6
6
 
7
7
  module ActionArgs
8
8
  class Railtie < ::Rails::Railtie
@@ -5,21 +5,17 @@ describe <%= controller_class_name %>Controller do
5
5
  # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
6
6
  # update the return value of this method accordingly.
7
7
  def valid_attributes
8
- {}
9
- end
10
-
11
- before do
12
- @controller = <%= controller_class_name %>Controller.new
8
+ <%= formatted_hash(example_valid_attributes) %>
13
9
  end
14
10
 
15
11
  <% unless options[:singleton] -%>
16
12
  describe 'GET index' do
17
13
  before do
18
14
  @<%= file_name %> = <%= class_name %>.create! valid_attributes
19
- @controller.index
15
+ controller.index
20
16
  end
21
17
  describe 'assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>' do
22
- subject { @controller.instance_variable_get('@<%= table_name %>') }
18
+ subject { controller.instance_variable_get('@<%= table_name %>') }
23
19
  it { should eq([@<%= file_name %>]) }
24
20
  end
25
21
  end
@@ -28,20 +24,20 @@ describe <%= controller_class_name %>Controller do
28
24
  describe 'GET show' do
29
25
  before do
30
26
  @<%= file_name %> = <%= class_name %>.create! valid_attributes
31
- @controller.show(@<%= file_name %>.to_param)
27
+ controller.show(@<%= file_name %>.to_param)
32
28
  end
33
29
  describe 'assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>' do
34
- subject { @controller.instance_variable_get('@<%= ns_file_name %>') }
30
+ subject { controller.instance_variable_get('@<%= ns_file_name %>') }
35
31
  it { should eq(@<%= file_name %>) }
36
32
  end
37
33
  end
38
34
 
39
35
  describe 'GET new' do
40
36
  before do
41
- @controller.new
37
+ controller.new
42
38
  end
43
39
  describe 'assigns a new <%= ns_file_name %> as @<%= ns_file_name %>' do
44
- subject { @controller.instance_variable_get('@<%= ns_file_name %>') }
40
+ subject { controller.instance_variable_get('@<%= ns_file_name %>') }
45
41
  it { should be_a_new(<%= class_name %>) }
46
42
  end
47
43
  end
@@ -49,10 +45,10 @@ describe <%= controller_class_name %>Controller do
49
45
  describe 'GET edit' do
50
46
  before do
51
47
  @<%= file_name %> = <%= class_name %>.create! valid_attributes
52
- @controller.edit(@<%= file_name %>.to_param)
48
+ controller.edit(@<%= file_name %>.to_param)
53
49
  end
54
50
  describe 'assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>' do
55
- subject { @controller.instance_variable_get('@<%= ns_file_name %>') }
51
+ subject { controller.instance_variable_get('@<%= ns_file_name %>') }
56
52
  it { should eq(@<%= file_name %>) }
57
53
  end
58
54
  end
@@ -60,19 +56,19 @@ describe <%= controller_class_name %>Controller do
60
56
  describe 'POST create' do
61
57
  context 'with valid params' do
62
58
  before do
63
- @controller.should_receive(:redirect_to) {|u| u.should eq(<%= class_name %>.last) }
59
+ controller.should_receive(:redirect_to) {|u| u.should eq(<%= class_name %>.last) }
64
60
  end
65
61
  describe 'creates a new <%= class_name %>' do
66
62
  it { expect {
67
- @controller.create(valid_attributes)
63
+ controller.create(valid_attributes)
68
64
  }.to change(<%= class_name %>, :count).by(1) }
69
65
  end
70
66
 
71
67
  describe 'assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %> and redirects to the created <%= ns_file_name %>' do
72
68
  before do
73
- @controller.create(valid_attributes)
69
+ controller.create(valid_attributes)
74
70
  end
75
- subject { @controller.instance_variable_get('@<%= ns_file_name %>') }
71
+ subject { controller.instance_variable_get('@<%= ns_file_name %>') }
76
72
  it { should be_a(<%= class_name %>) }
77
73
  it { should be_persisted }
78
74
  end
@@ -82,10 +78,10 @@ describe <%= controller_class_name %>Controller do
82
78
  describe "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>, and re-renders the 'new' template" do
83
79
  before do
84
80
  <%= class_name %>.any_instance.stub(:save) { false }
85
- @controller.should_receive(:render).with(:action => 'new')
86
- @controller.create({})
81
+ controller.should_receive(:render).with(:action => 'new')
82
+ controller.create(<%= formatted_hash(example_invalid_attributes) %>)
87
83
  end
88
- subject { @controller.instance_variable_get('@<%= ns_file_name %>') }
84
+ subject { controller.instance_variable_get('@<%= ns_file_name %>') }
89
85
  it { should be_a_new(<%= class_name %>) }
90
86
  end
91
87
  end
@@ -96,10 +92,10 @@ describe <%= controller_class_name %>Controller do
96
92
  describe 'updates the requested <%= ns_file_name %>, assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>, and redirects to the <%= ns_file_name %>' do
97
93
  before do
98
94
  @<%= file_name %> = <%= class_name %>.create! valid_attributes
99
- @controller.should_receive(:redirect_to).with(@<%= file_name %>, anything)
100
- @controller.update(@<%= file_name %>.to_param, valid_attributes)
95
+ controller.should_receive(:redirect_to).with(@<%= file_name %>, anything)
96
+ controller.update(@<%= file_name %>.to_param, valid_attributes)
101
97
  end
102
- subject { @controller.instance_variable_get('@<%= ns_file_name %>') }
98
+ subject { controller.instance_variable_get('@<%= ns_file_name %>') }
103
99
  it { should eq(@<%= file_name %>) }
104
100
  end
105
101
  end
@@ -110,10 +106,10 @@ describe <%= controller_class_name %>Controller do
110
106
  @<%= file_name %> = <%= class_name %>.create! valid_attributes
111
107
  # Trigger the behavior that occurs when invalid params are submitted
112
108
  <%= class_name %>.any_instance.stub(:save) { false }
113
- @controller.should_receive(:render).with(:action => 'edit')
114
- @controller.update(@<%= file_name %>.to_param, {})
109
+ controller.should_receive(:render).with(:action => 'edit')
110
+ controller.update(@<%= file_name %>.to_param, <%= formatted_hash(example_invalid_attributes) %>)
115
111
  end
116
- subject { @controller.instance_variable_get('@<%= ns_file_name %>') }
112
+ subject { controller.instance_variable_get('@<%= ns_file_name %>') }
117
113
  it { should eq(@<%= file_name %>) }
118
114
  end
119
115
  end
@@ -122,12 +118,12 @@ describe <%= controller_class_name %>Controller do
122
118
  describe 'DELETE destroy' do
123
119
  before do
124
120
  @<%= file_name %> = <%= class_name %>.create! valid_attributes
125
- @controller.stub(:<%= index_helper %>_url) { '/<%= index_helper %>' }
126
- @controller.should_receive(:redirect_to).with('/<%= index_helper %>')
121
+ controller.stub(:<%= index_helper %>_url) { '/<%= index_helper %>' }
122
+ controller.should_receive(:redirect_to).with('/<%= index_helper %>')
127
123
  end
128
124
  it 'destroys the requested <%= ns_file_name %>, and redirects to the <%= table_name %> list' do
129
125
  expect {
130
- @controller.destroy(@<%= file_name %>.to_param)
126
+ controller.destroy(@<%= file_name %>.to_param)
131
127
  }.to change(<%= class_name %>, :count).by(-1)
132
128
  end
133
129
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_args
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-30 00:00:00.000000000 Z
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Rails plugin gem that supports Merbish style controller action arguments.
15
15
  email: