remarkable_rails 3.1.8 → 3.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/CHANGELOG +91 -88
  2. data/LICENSE +20 -20
  3. data/README +80 -80
  4. data/lib/remarkable_rails/action_controller/base.rb +29 -29
  5. data/lib/remarkable_rails/action_controller/macro_stubs.rb +459 -457
  6. data/lib/remarkable_rails/action_controller/matchers/assign_to_matcher.rb +92 -92
  7. data/lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb +41 -41
  8. data/lib/remarkable_rails/action_controller/matchers/redirect_to_matcher.rb +119 -119
  9. data/lib/remarkable_rails/action_controller/matchers/render_template_matcher.rb +146 -146
  10. data/lib/remarkable_rails/action_controller/matchers/respond_with_matcher.rb +126 -126
  11. data/lib/remarkable_rails/action_controller/matchers/route_matcher.rb +135 -109
  12. data/lib/remarkable_rails/action_controller/matchers/set_cookies_matcher.rb +49 -49
  13. data/lib/remarkable_rails/action_controller/matchers/set_session_matcher.rb +106 -106
  14. data/lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb +54 -54
  15. data/lib/remarkable_rails/action_controller.rb +22 -22
  16. data/lib/remarkable_rails/action_view/base.rb +7 -7
  17. data/lib/remarkable_rails/action_view.rb +18 -18
  18. data/lib/remarkable_rails/active_orm.rb +19 -19
  19. data/lib/remarkable_rails.rb +30 -30
  20. data/locale/en.yml +110 -110
  21. data/spec/action_controller/assign_to_matcher_spec.rb +142 -142
  22. data/spec/action_controller/filter_params_matcher_spec.rb +64 -64
  23. data/spec/action_controller/macro_stubs_spec.rb +234 -208
  24. data/spec/action_controller/redirect_to_matcher_spec.rb +102 -102
  25. data/spec/action_controller/render_template_matcher_spec.rb +251 -251
  26. data/spec/action_controller/respond_with_matcher_spec.rb +223 -223
  27. data/spec/action_controller/route_matcher_spec.rb +96 -79
  28. data/spec/action_controller/set_cookies_matcher_spec.rb +149 -149
  29. data/spec/action_controller/set_session_matcher_spec.rb +141 -141
  30. data/spec/action_controller/set_the_flash_matcher_spec.rb +93 -93
  31. data/spec/application/application.rb +15 -15
  32. data/spec/application/tasks_controller.rb +34 -34
  33. data/spec/functional_builder.rb +88 -88
  34. data/spec/rcov.opts +2 -2
  35. data/spec/remarkable_rails_spec.rb +5 -5
  36. data/spec/spec.opts +4 -4
  37. data/spec/spec_helper.rb +42 -42
  38. metadata +7 -7
@@ -1,251 +1,251 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe 'render_template' do
4
- include FunctionalBuilder
5
-
6
- describe 'messages' do
7
- before(:each) do
8
- build_response { render :action => 'new' }
9
- @matcher = render_template('edit')
10
- end
11
-
12
- it 'should contain a description message' do
13
- @matcher.description.should == 'render template "edit"'
14
-
15
- @matcher.layout('application')
16
- @matcher.description.should == 'render template "edit" and with layout "application"'
17
-
18
- @matcher.layout(nil)
19
- @matcher.description.should == 'render template "edit" and with no layout'
20
-
21
- @matcher.content_type(Mime::XML).matches?(@controller)
22
- @matcher.description.should == 'render template "edit", with no layout, and with content type "application/xml"'
23
- end
24
-
25
- it 'should set rendered? message' do
26
- build_response
27
- @matcher.matches?(@controller)
28
- @matcher.failure_message.should == 'Expected template "edit" to be rendered, got no render'
29
- @matcher.negative_failure_message.should == 'Did not expect template "edit" to be rendered, got no render'
30
- end
31
-
32
- # Is not possible to check extensions on Rails 2.1
33
- unless RAILS_VERSION =~ /^2.1/
34
- it 'should set template_matches? message' do
35
- @matcher.matches?(@controller)
36
- @matcher.failure_message.should == 'Expected template "edit" to be rendered, got "examples/new.html.erb"'
37
- end
38
- end
39
-
40
- it 'should set layout_matches? message' do
41
- @matcher = render_template('new')
42
- @matcher.layout('users').matches?(@controller)
43
- @matcher.failure_message.should == 'Expected to render with layout "users", got nil'
44
- end
45
- end
46
-
47
- describe 'matcher' do
48
-
49
- [ :controller, :response ].each do |subject_name|
50
- describe "with #{subject_name} subject" do
51
-
52
- describe 'rendering a template' do
53
- before(:each) do
54
- build_response { render :action => :new }
55
- @subject = instance_variable_get("@#{subject_name}")
56
- end
57
-
58
- it { @subject.should render_template('new') }
59
- it { @subject.should render_template('new.html') }
60
- it { @subject.should render_template('new.html.erb') }
61
- it { @subject.should render_template('examples/new') }
62
- it { @subject.should render_template('examples/new.html') }
63
- it { @subject.should render_template('examples/new.html.erb') }
64
-
65
- it { @subject.should_not render_template('edit') }
66
- it { @subject.should_not render_template('projects/new') }
67
- it { @subject.should_not render_template('examples/edit') }
68
- end
69
-
70
- describe 'rendering a template with path' do
71
- before(:each) do
72
- build_response { render :template => 'projects/new' }
73
- @subject = instance_variable_get("@#{subject_name}")
74
- end
75
-
76
- it { @subject.should render_template('projects/new') }
77
- it { @subject.should render_template('projects/new.html') }
78
- it { @subject.should render_template('projects/new.html.erb') }
79
-
80
- it { @subject.should_not render_template('new') }
81
- it { @subject.should_not render_template('examples/new') }
82
- it { @subject.should_not render_template('projects/edit') }
83
- end
84
-
85
- describe 'rendering a template with extention xml.builder' do
86
- before(:each) do
87
- build_response { respond_to{ |format| format.xml } }
88
- @subject = instance_variable_get("@#{subject_name}")
89
- end
90
-
91
- it { @subject.should render_template('example') }
92
- it { @subject.should render_template('example.xml') }
93
- it { @subject.should render_template('example.xml.builder') }
94
- it { @subject.should render_template('examples/example') }
95
- it { @subject.should render_template('examples/example.xml') }
96
- it { @subject.should render_template('examples/example.xml.builder') }
97
-
98
- # Is not possible to check extensions on Rails 2.1
99
- unless RAILS_VERSION =~ /^2.1/
100
- it { @subject.should_not render_template('example.html') }
101
- it { @subject.should_not render_template('example.html.erb') }
102
- it { @subject.should_not render_template('example.html.builder') }
103
- it { @subject.should_not render_template('examples/example.html') }
104
- it { @subject.should_not render_template('examples/example.html') }
105
- it { @subject.should_not render_template('examples/example.html.erb') }
106
- end
107
- end
108
-
109
- describe 'rendering a partial' do
110
- before(:each) do
111
- build_response { render :partial => 'example' }
112
- @subject = instance_variable_get("@#{subject_name}")
113
- end
114
-
115
- it { @subject.should render_template('_example') }
116
- it { @subject.should render_template('_example.html') }
117
- it { @subject.should render_template('_example.html.erb') }
118
- it { @subject.should render_template('examples/_example') }
119
- it { @subject.should render_template('examples/_example.html') }
120
- it { @subject.should render_template('examples/_example.html.erb') }
121
-
122
- it { @subject.should_not render_template('example') }
123
- it { @subject.should_not render_template('example.html') }
124
- it { @subject.should_not render_template('example.html.erb') }
125
- it { @subject.should_not render_template('examples/example') }
126
- it { @subject.should_not render_template('examples/example.html') }
127
- it { @subject.should_not render_template('examples/example.html.erb') }
128
- end
129
-
130
- end
131
- end
132
-
133
- describe 'render_with_layout' do
134
- before(:each){ build_response { render :layout => 'examples' } }
135
-
136
- it { should render_with_layout('examples') }
137
- it { should_not render_with_layout('users') }
138
- it { should_not render_with_layout(nil) }
139
- it { should_not render_without_layout }
140
-
141
- it { should render_template.layout('examples') }
142
- it { should_not render_template.layout('users') }
143
- it { should_not render_template.layout(nil) }
144
- end
145
-
146
- describe 'render_without_layout' do
147
- before(:each){ build_response }
148
-
149
- it { should render_without_layout }
150
- it { should_not render_with_layout('examples') }
151
-
152
- it { should render_without_layout }
153
- it { should_not render_with_layout('examples') }
154
- end
155
- end
156
-
157
- describe 'macro' do
158
-
159
- describe 'rendering a template' do
160
- before(:each) { build_response { render :action => :new } }
161
-
162
- should_render_template 'new'
163
- should_render_template 'new.html'
164
- should_render_template 'new.html.erb'
165
- should_render_template 'examples/new'
166
- should_render_template 'examples/new.html'
167
- should_render_template 'examples/new.html.erb'
168
-
169
- should_not_render_template 'edit'
170
- should_not_render_template 'projects/new'
171
- should_not_render_template 'examples/edit'
172
- end
173
-
174
- describe 'rendering a template with path' do
175
- before(:each) { build_response { render :template => 'projects/new' } }
176
-
177
- should_render_template 'projects/new'
178
- should_render_template 'projects/new.html'
179
- should_render_template 'projects/new.html.erb'
180
-
181
- should_not_render_template 'new'
182
- should_not_render_template 'examples/new'
183
- should_not_render_template 'projects/edit'
184
- end
185
-
186
- describe 'rendering a template with extention xml.builder' do
187
- before(:each) { build_response { respond_to{ |format| format.xml } } }
188
-
189
- should_render_template 'example'
190
- should_render_template 'example.xml'
191
- should_render_template 'example.xml.builder'
192
- should_render_template 'examples/example'
193
- should_render_template 'examples/example.xml'
194
- should_render_template 'examples/example.xml.builder'
195
-
196
- # Is not possible to check extensions on Rails 2.1
197
- unless RAILS_VERSION =~ /^2.1/
198
- should_not_render_template 'example.html'
199
- should_not_render_template 'example.html.erb'
200
- should_not_render_template 'example.html.builder'
201
- should_not_render_template 'examples/example.html'
202
- should_not_render_template 'examples/example.html'
203
- should_not_render_template 'examples/example.html.erb'
204
- end
205
- end
206
-
207
- describe 'rendering a partial' do
208
- before(:each) { build_response { render :partial => 'example' } }
209
-
210
- should_render_template '_example'
211
- should_render_template '_example.html'
212
- should_render_template '_example.html.erb'
213
- should_render_template 'examples/_example'
214
- should_render_template 'examples/_example.html'
215
- should_render_template 'examples/_example.html.erb'
216
-
217
- should_not_render_template 'example'
218
- should_not_render_template 'example.html'
219
- should_not_render_template 'example.html.erb'
220
- should_not_render_template 'examples/example'
221
- should_not_render_template 'examples/example.html'
222
- should_not_render_template 'examples/example.html.erb'
223
- end
224
-
225
- describe 'render_with_layout' do
226
- before(:each){ build_response { render :layout => 'examples' } }
227
-
228
- should_render_with_layout 'examples'
229
- should_not_render_with_layout 'users'
230
- should_not_render_with_layout nil
231
-
232
- should_render_template :layout => 'examples'
233
- should_not_render_template :layout => 'users'
234
- should_not_render_template :layout => nil
235
- end
236
-
237
- describe 'render_without_layout' do
238
- before(:each){ build_response }
239
-
240
- should_render_without_layout
241
- should_not_render_with_layout 'examples'
242
-
243
- should_render_without_layout
244
- should_not_render_with_layout 'examples'
245
- end
246
- end
247
-
248
- generate_macro_stubs_specs_for(:render_template, 'new')
249
- generate_macro_stubs_specs_for(:render_with_layout, 'examples')
250
- generate_macro_stubs_specs_for(:render_without_layout)
251
- end
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe 'render_template' do
4
+ include FunctionalBuilder
5
+
6
+ describe 'messages' do
7
+ before(:each) do
8
+ build_response { render :action => 'new' }
9
+ @matcher = render_template('edit')
10
+ end
11
+
12
+ it 'should contain a description message' do
13
+ @matcher.description.should == 'render template "edit"'
14
+
15
+ @matcher.layout('application')
16
+ @matcher.description.should == 'render template "edit" and with layout "application"'
17
+
18
+ @matcher.layout(nil)
19
+ @matcher.description.should == 'render template "edit" and with no layout'
20
+
21
+ @matcher.content_type(Mime::XML).matches?(@controller)
22
+ @matcher.description.should == 'render template "edit", with no layout, and with content type "application/xml"'
23
+ end
24
+
25
+ it 'should set rendered? message' do
26
+ build_response
27
+ @matcher.matches?(@controller)
28
+ @matcher.failure_message.should == 'Expected template "edit" to be rendered, got no render'
29
+ @matcher.negative_failure_message.should == 'Did not expect template "edit" to be rendered, got no render'
30
+ end
31
+
32
+ # Is not possible to check extensions on Rails 2.1
33
+ unless RAILS_VERSION =~ /^2.1/
34
+ it 'should set template_matches? message' do
35
+ @matcher.matches?(@controller)
36
+ @matcher.failure_message.should == 'Expected template "edit" to be rendered, got "examples/new.html.erb"'
37
+ end
38
+ end
39
+
40
+ it 'should set layout_matches? message' do
41
+ @matcher = render_template('new')
42
+ @matcher.layout('users').matches?(@controller)
43
+ @matcher.failure_message.should == 'Expected to render with layout "users", got nil'
44
+ end
45
+ end
46
+
47
+ describe 'matcher' do
48
+
49
+ [ :controller, :response ].each do |subject_name|
50
+ describe "with #{subject_name} subject" do
51
+
52
+ describe 'rendering a template' do
53
+ before(:each) do
54
+ build_response { render :action => :new }
55
+ @subject = instance_variable_get("@#{subject_name}")
56
+ end
57
+
58
+ it { @subject.should render_template('new') }
59
+ it { @subject.should render_template('new.html') }
60
+ it { @subject.should render_template('new.html.erb') }
61
+ it { @subject.should render_template('examples/new') }
62
+ it { @subject.should render_template('examples/new.html') }
63
+ it { @subject.should render_template('examples/new.html.erb') }
64
+
65
+ it { @subject.should_not render_template('edit') }
66
+ it { @subject.should_not render_template('projects/new') }
67
+ it { @subject.should_not render_template('examples/edit') }
68
+ end
69
+
70
+ describe 'rendering a template with path' do
71
+ before(:each) do
72
+ build_response { render :template => 'projects/new' }
73
+ @subject = instance_variable_get("@#{subject_name}")
74
+ end
75
+
76
+ it { @subject.should render_template('projects/new') }
77
+ it { @subject.should render_template('projects/new.html') }
78
+ it { @subject.should render_template('projects/new.html.erb') }
79
+
80
+ it { @subject.should_not render_template('new') }
81
+ it { @subject.should_not render_template('examples/new') }
82
+ it { @subject.should_not render_template('projects/edit') }
83
+ end
84
+
85
+ describe 'rendering a template with extention xml.builder' do
86
+ before(:each) do
87
+ build_response { respond_to{ |format| format.xml } }
88
+ @subject = instance_variable_get("@#{subject_name}")
89
+ end
90
+
91
+ it { @subject.should render_template('example') }
92
+ it { @subject.should render_template('example.xml') }
93
+ it { @subject.should render_template('example.xml.builder') }
94
+ it { @subject.should render_template('examples/example') }
95
+ it { @subject.should render_template('examples/example.xml') }
96
+ it { @subject.should render_template('examples/example.xml.builder') }
97
+
98
+ # Is not possible to check extensions on Rails 2.1
99
+ unless RAILS_VERSION =~ /^2.1/
100
+ it { @subject.should_not render_template('example.html') }
101
+ it { @subject.should_not render_template('example.html.erb') }
102
+ it { @subject.should_not render_template('example.html.builder') }
103
+ it { @subject.should_not render_template('examples/example.html') }
104
+ it { @subject.should_not render_template('examples/example.html') }
105
+ it { @subject.should_not render_template('examples/example.html.erb') }
106
+ end
107
+ end
108
+
109
+ describe 'rendering a partial' do
110
+ before(:each) do
111
+ build_response { render :partial => 'example' }
112
+ @subject = instance_variable_get("@#{subject_name}")
113
+ end
114
+
115
+ it { @subject.should render_template('_example') }
116
+ it { @subject.should render_template('_example.html') }
117
+ it { @subject.should render_template('_example.html.erb') }
118
+ it { @subject.should render_template('examples/_example') }
119
+ it { @subject.should render_template('examples/_example.html') }
120
+ it { @subject.should render_template('examples/_example.html.erb') }
121
+
122
+ it { @subject.should_not render_template('example') }
123
+ it { @subject.should_not render_template('example.html') }
124
+ it { @subject.should_not render_template('example.html.erb') }
125
+ it { @subject.should_not render_template('examples/example') }
126
+ it { @subject.should_not render_template('examples/example.html') }
127
+ it { @subject.should_not render_template('examples/example.html.erb') }
128
+ end
129
+
130
+ end
131
+ end
132
+
133
+ describe 'render_with_layout' do
134
+ before(:each){ build_response { render :layout => 'examples' } }
135
+
136
+ it { should render_with_layout('examples') }
137
+ it { should_not render_with_layout('users') }
138
+ it { should_not render_with_layout(nil) }
139
+ it { should_not render_without_layout }
140
+
141
+ it { should render_template.layout('examples') }
142
+ it { should_not render_template.layout('users') }
143
+ it { should_not render_template.layout(nil) }
144
+ end
145
+
146
+ describe 'render_without_layout' do
147
+ before(:each){ build_response }
148
+
149
+ it { should render_without_layout }
150
+ it { should_not render_with_layout('examples') }
151
+
152
+ it { should render_without_layout }
153
+ it { should_not render_with_layout('examples') }
154
+ end
155
+ end
156
+
157
+ describe 'macro' do
158
+
159
+ describe 'rendering a template' do
160
+ before(:each) { build_response { render :action => :new } }
161
+
162
+ should_render_template 'new'
163
+ should_render_template 'new.html'
164
+ should_render_template 'new.html.erb'
165
+ should_render_template 'examples/new'
166
+ should_render_template 'examples/new.html'
167
+ should_render_template 'examples/new.html.erb'
168
+
169
+ should_not_render_template 'edit'
170
+ should_not_render_template 'projects/new'
171
+ should_not_render_template 'examples/edit'
172
+ end
173
+
174
+ describe 'rendering a template with path' do
175
+ before(:each) { build_response { render :template => 'projects/new' } }
176
+
177
+ should_render_template 'projects/new'
178
+ should_render_template 'projects/new.html'
179
+ should_render_template 'projects/new.html.erb'
180
+
181
+ should_not_render_template 'new'
182
+ should_not_render_template 'examples/new'
183
+ should_not_render_template 'projects/edit'
184
+ end
185
+
186
+ describe 'rendering a template with extention xml.builder' do
187
+ before(:each) { build_response { respond_to{ |format| format.xml } } }
188
+
189
+ should_render_template 'example'
190
+ should_render_template 'example.xml'
191
+ should_render_template 'example.xml.builder'
192
+ should_render_template 'examples/example'
193
+ should_render_template 'examples/example.xml'
194
+ should_render_template 'examples/example.xml.builder'
195
+
196
+ # Is not possible to check extensions on Rails 2.1
197
+ unless RAILS_VERSION =~ /^2.1/
198
+ should_not_render_template 'example.html'
199
+ should_not_render_template 'example.html.erb'
200
+ should_not_render_template 'example.html.builder'
201
+ should_not_render_template 'examples/example.html'
202
+ should_not_render_template 'examples/example.html'
203
+ should_not_render_template 'examples/example.html.erb'
204
+ end
205
+ end
206
+
207
+ describe 'rendering a partial' do
208
+ before(:each) { build_response { render :partial => 'example' } }
209
+
210
+ should_render_template '_example'
211
+ should_render_template '_example.html'
212
+ should_render_template '_example.html.erb'
213
+ should_render_template 'examples/_example'
214
+ should_render_template 'examples/_example.html'
215
+ should_render_template 'examples/_example.html.erb'
216
+
217
+ should_not_render_template 'example'
218
+ should_not_render_template 'example.html'
219
+ should_not_render_template 'example.html.erb'
220
+ should_not_render_template 'examples/example'
221
+ should_not_render_template 'examples/example.html'
222
+ should_not_render_template 'examples/example.html.erb'
223
+ end
224
+
225
+ describe 'render_with_layout' do
226
+ before(:each){ build_response { render :layout => 'examples' } }
227
+
228
+ should_render_with_layout 'examples'
229
+ should_not_render_with_layout 'users'
230
+ should_not_render_with_layout nil
231
+
232
+ should_render_template :layout => 'examples'
233
+ should_not_render_template :layout => 'users'
234
+ should_not_render_template :layout => nil
235
+ end
236
+
237
+ describe 'render_without_layout' do
238
+ before(:each){ build_response }
239
+
240
+ should_render_without_layout
241
+ should_not_render_with_layout 'examples'
242
+
243
+ should_render_without_layout
244
+ should_not_render_with_layout 'examples'
245
+ end
246
+ end
247
+
248
+ generate_macro_stubs_specs_for(:render_template, 'new')
249
+ generate_macro_stubs_specs_for(:render_with_layout, 'examples')
250
+ generate_macro_stubs_specs_for(:render_without_layout)
251
+ end