subelsky_power_tools 1.2.5 → 1.2.6

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/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ v1.2.6
2
+ ======
3
+ * Controller shared behavior can now test Rails controllers that use nested
4
+ routes
5
+
1
6
  v1.2.3
2
7
  =====
3
8
  * Fix PageLoadAssertions typo!
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- subelsky_power_tools (1.2.5)
4
+ subelsky_power_tools (1.2.6)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -1,15 +1,22 @@
1
1
  # https://www.relishapp.com/rspec/rspec-core/v/2-10/docs/example-groups/shared-examples
2
2
  shared_examples "a protected plural controller" do |skip_actions|
3
+ # if you specify a "request options" method in your test, we use that when making requests.
4
+ # useful for testing nested controllers, e.g. if you were testing a comments controller
5
+ # that used nested routes like /:post_id/comments, you could do this:
6
+ #
7
+ # let(:request_options) { { post_id: 5 } }
8
+ let(:protected_plural_controller_options) { defined?(request_options) ? request_options : {} }
9
+
3
10
  describe "new", :if => described_class.instance_methods.include?(:new) && not(Array(skip_actions).include?(:new)) do
4
11
  it "requires signin" do
5
- get :new
12
+ get :new, protected_plural_controller_options
6
13
  response.should redirect_to signin_redirect
7
14
  end
8
15
  end
9
16
 
10
17
  describe "edit", :if => described_class.instance_methods.include?(:edit) && not(Array(skip_actions).include?(:edit)) do
11
18
  def simple_get(obj_id = 1)
12
- get :edit, { id: obj_id }
19
+ get :edit, protected_plural_controller_options.merge(id: obj_id)
13
20
  end
14
21
 
15
22
  it "requires signin" do
@@ -26,7 +33,7 @@ shared_examples "a protected plural controller" do |skip_actions|
26
33
 
27
34
  describe "show", :if => described_class.instance_methods.include?(:show) && not(Array(skip_actions).include?(:show)) do
28
35
  def simple_get(obj_id = 1)
29
- get :show, { id: obj_id }
36
+ get :show, protected_plural_controller_options.merge(id: obj_id)
30
37
  end
31
38
 
32
39
  it "requires signin" do
@@ -50,14 +57,14 @@ shared_examples "a protected plural controller" do |skip_actions|
50
57
 
51
58
  describe "create", :if => described_class.instance_methods.include?(:create) && not(Array(skip_actions).include?(:create)) do
52
59
  it "requires signin" do
53
- post :create
60
+ post :create, protected_plural_controller_options
54
61
  response.should redirect_to signin_redirect
55
62
  end
56
63
  end
57
64
 
58
65
  describe "update", :if => described_class.instance_methods.include?(:update) && not(Array(skip_actions).include?(:update)) do
59
66
  def simple_put(obj_id = 1,params = {})
60
- put :update, params.merge(id: obj_id)
67
+ put :update, params.merge(id: obj_id).merge(protected_plural_controller_options)
61
68
  end
62
69
 
63
70
  it "requires signin" do
@@ -79,7 +86,7 @@ shared_examples "a protected plural controller" do |skip_actions|
79
86
 
80
87
  describe "delete", :if => described_class.instance_methods.include?(:destroy) && not(Array(skip_actions).include?(:destroy)) do
81
88
  def simple_delete(obj_id = 1)
82
- delete :destroy, id: obj_id
89
+ delete :destroy, protected_plural_controller_options.merge(id: obj_id)
83
90
  end
84
91
 
85
92
  it "requires signin" do
@@ -97,44 +104,45 @@ shared_examples "a protected plural controller" do |skip_actions|
97
104
  end
98
105
 
99
106
  shared_examples "a protected singular controller" do |skip_actions|
107
+ let(:protected_singular_controller_options) { defined?(request_options) ? request_options : {} }
100
108
  describe "new", :if => described_class.instance_methods.include?(:new) && not(Array(skip_actions).include?(:new)) do
101
109
  it "requires signin" do
102
- get :new
110
+ get :new, protected_singular_controller_options
103
111
  response.should redirect_to signin_redirect
104
112
  end
105
113
  end
106
114
 
107
115
  describe "edit", :if => described_class.instance_methods.include?(:edit) && not(Array(skip_actions).include?(:edit)) do
108
116
  it "requires signin" do
109
- get :edit
117
+ get :edit, protected_singular_controller_options
110
118
  response.should redirect_to signin_redirect
111
119
  end
112
120
  end
113
121
 
114
122
  describe "show", :if => described_class.instance_methods.include?(:show) && not(Array(skip_actions).include?(:show)) do
115
123
  it "requires signin" do
116
- get :show
124
+ get :show, protected_singular_controller_options
117
125
  response.should redirect_to signin_redirect
118
126
  end
119
127
  end
120
128
 
121
129
  describe "create", :if => described_class.instance_methods.include?(:create) && not(Array(skip_actions).include?(:create)) do
122
130
  it "requires signin" do
123
- post :create
131
+ post :create, protected_singular_controller_options
124
132
  response.should redirect_to signin_redirect
125
133
  end
126
134
  end
127
135
 
128
136
  describe "update", :if => described_class.instance_methods.include?(:update) && not(Array(skip_actions).include?(:update)) do
129
137
  it "requires signin" do
130
- put :update
138
+ put :update, protected_singular_controller_options
131
139
  response.should redirect_to signin_redirect
132
140
  end
133
141
  end
134
142
 
135
143
  describe "delete", :if => described_class.instance_methods.include?(:destroy) && not(Array(skip_actions).include?(:destroy)) do
136
144
  it "requires signin" do
137
- delete :destroy
145
+ delete :destroy, protected_singular_controller_options
138
146
  response.should redirect_to signin_redirect
139
147
  end
140
148
  end
@@ -1,3 +1,3 @@
1
1
  module SubelskyPowerTools
2
- VERSION = "1.2.5"
2
+ VERSION = "1.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subelsky_power_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
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-05-19 00:00:00.000000000 Z
12
+ date: 2012-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 1.8.22
85
+ rubygems_version: 1.8.23
86
86
  signing_key:
87
87
  specification_version: 3
88
88
  summary: This is a collection of Ruby extensions and utilities I've been carting around