remarkable_rails 3.0.1 → 3.0.2

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 (31) hide show
  1. data/CHANGELOG +44 -44
  2. data/LICENSE +1 -1
  3. data/README +83 -83
  4. data/lib/remarkable_rails/action_controller/base.rb +24 -24
  5. data/lib/remarkable_rails/action_controller/macro_stubs.rb +493 -493
  6. data/lib/remarkable_rails/action_controller/matchers/assign_to_matcher.rb +72 -72
  7. data/lib/remarkable_rails/action_controller/matchers/filter_params_matcher.rb +21 -21
  8. data/lib/remarkable_rails/action_controller/matchers/redirect_to_matcher.rb +112 -112
  9. data/lib/remarkable_rails/action_controller/matchers/render_template_matcher.rb +140 -140
  10. data/lib/remarkable_rails/action_controller/matchers/respond_with_matcher.rb +118 -118
  11. data/lib/remarkable_rails/action_controller/matchers/route_matcher.rb +51 -51
  12. data/lib/remarkable_rails/action_controller/matchers/set_session_matcher.rb +103 -103
  13. data/lib/remarkable_rails/action_controller/matchers/set_the_flash_matcher.rb +50 -50
  14. data/lib/remarkable_rails/action_view/base.rb +1 -1
  15. data/lib/remarkable_rails/action_view.rb +16 -16
  16. data/lib/remarkable_rails/active_orm.rb +2 -2
  17. data/locale/en.yml +74 -74
  18. data/spec/action_controller/assign_to_matcher_spec.rb +68 -68
  19. data/spec/action_controller/filter_params_matcher_spec.rb +42 -42
  20. data/spec/action_controller/macro_stubs_spec.rb +17 -17
  21. data/spec/action_controller/redirect_to_matcher_spec.rb +60 -60
  22. data/spec/action_controller/render_template_matcher_spec.rb +227 -227
  23. data/spec/action_controller/respond_with_matcher_spec.rb +189 -189
  24. data/spec/action_controller/route_matcher_spec.rb +75 -75
  25. data/spec/action_controller/set_session_matcher_spec.rb +43 -43
  26. data/spec/action_controller/set_the_flash_matcher_spec.rb +1 -1
  27. data/spec/application/application.rb +14 -14
  28. data/spec/application/tasks_controller.rb +34 -34
  29. data/spec/functional_builder.rb +93 -93
  30. data/spec/spec_helper.rb +44 -44
  31. metadata +4 -4
@@ -4,34 +4,34 @@ describe 'respond_with' do
4
4
  include FunctionalBuilder
5
5
 
6
6
  describe 'messages' do
7
- before(:each) do
7
+ before(:each) do
8
8
  build_response
9
9
  @matcher = respond_with(:error)
10
10
  end
11
11
 
12
- it 'should contain a description message' do
12
+ it 'should contain a description message' do
13
13
  respond_with(404).description.should == 'respond with 404'
14
- respond_with(:error).description.should == 'respond with error'
15
- respond_with(500..599).description.should == 'respond with 500..599'
16
-
17
- @matcher.body(/anything/)
18
- @matcher.description.should == 'respond with error and with body /anything/'
19
-
20
- @matcher.content_type(Mime::XML).matches?(@controller)
14
+ respond_with(:error).description.should == 'respond with error'
15
+ respond_with(500..599).description.should == 'respond with 500..599'
16
+
17
+ @matcher.body(/anything/)
18
+ @matcher.description.should == 'respond with error and with body /anything/'
19
+
20
+ @matcher.content_type(Mime::XML).matches?(@controller)
21
21
  @matcher.description.should == 'respond with error, with body /anything/, and with content type "application/xml"'
22
22
  end
23
23
 
24
24
  it 'should set status_matches? message' do
25
25
  @matcher.matches?(@controller)
26
26
  @matcher.failure_message.should == 'Expected to respond with :error, got 200'
27
- end
28
-
27
+ end
28
+
29
29
  it 'should set content_type_matches? message' do
30
30
  @matcher = respond_with(:success)
31
31
  @matcher.body(/anything/).matches?(@controller)
32
32
  @matcher.failure_message.should == 'Expected to respond with body equals to /anything/, got " "'
33
- end
34
-
33
+ end
34
+
35
35
  it 'should set content_type_matches? message' do
36
36
  @matcher = respond_with(:success)
37
37
  @matcher.content_type(Mime::XML).matches?(@controller)
@@ -39,185 +39,185 @@ describe 'respond_with' do
39
39
  end
40
40
  end
41
41
 
42
- describe 'matcher' do
43
-
44
- describe 'on success' do
45
- before(:each){ build_response }
46
-
47
- it { should respond_with(200) }
48
- it { should respond_with(:ok) }
49
- it { should respond_with(:success) }
50
- it { should respond_with(200..299) }
51
-
52
- it { should respond_with(200, :content_type => Mime::HTML) }
53
- it { should respond_with(:ok, :content_type => Mime::HTML) }
54
- it { should respond_with(:success, :content_type => Mime::HTML) }
55
- it { should respond_with(200..299, :content_type => Mime::HTML) }
56
-
57
- it { should_not respond_with(404) }
58
- it { should_not respond_with(:not_found) }
59
- it { should_not respond_with(300..400) }
60
- end
61
-
62
- describe 'on missing' do
63
- before(:each){ build_response { render :text => "404 Not Found", :status => 404 } }
64
-
65
- it { should respond_with(404) }
66
- it { should respond_with(:not_found) }
67
- it { should respond_with(:missing) }
68
- it { should respond_with(400..405) }
69
-
70
- it { should_not respond_with(302) }
71
- it { should_not respond_with(:found) }
72
- it { should_not respond_with(:redirect) }
73
- it { should_not respond_with(300..305) }
74
- end
75
-
76
- describe 'respond_with_body' do
77
- before(:each) { build_response { respond_to{ |format| format.xml { render :xml => [].to_xml } } } }
78
-
79
- it { should respond_with_body(%{<?xml version="1.0" encoding="UTF-8"?>\n<nil-classes type="array"/>\n}) }
80
- it { should respond_with_body(/xml/) }
81
- it { should_not respond_with_body('html') }
82
- it { should_not respond_with_body(/html/) }
83
- end
84
-
85
- describe 'on redirect' do
86
- before(:each){ build_response { redirect_to project_tasks_url(1) } }
87
-
88
- it { should respond_with(302) }
89
- it { should respond_with(:found) }
90
- it { should respond_with(:redirect) }
91
- it { should respond_with(300..305) }
92
-
93
- it { should_not respond_with(200) }
94
- it { should_not respond_with(:ok) }
95
- it { should_not respond_with(:success) }
96
- it { should_not respond_with(200..299) }
97
- end
98
-
99
- describe 'respond_with_content_type' do
100
- describe 'and Mime::HTML' do
101
- before(:each){ build_response { render :action => :new } }
102
-
103
- it { should respond_with_content_type(:html) }
104
- it { should respond_with_content_type(/html/) }
105
- it { should respond_with_content_type(Mime::HTML) }
106
- it { should respond_with_content_type('text/html') }
107
-
108
- it { should_not respond_with_content_type(:xml) }
109
- it { should_not respond_with_content_type(/xml/) }
110
- it { should_not respond_with_content_type(Mime::XML) }
111
- it { should_not respond_with_content_type('application/xml') }
112
- end
113
-
114
- describe 'and Mime::XML' do
115
- before(:each) { build_response { respond_to{ |format| format.xml } } }
116
-
117
- it { should respond_with_content_type(:xml) }
118
- it { should respond_with_content_type(/xml/) }
119
- it { should respond_with_content_type(Mime::XML) }
120
- it { should respond_with_content_type('application/xml') }
121
-
122
- it { should_not respond_with_content_type(:html) }
123
- it { should_not respond_with_content_type(/html/) }
124
- it { should_not respond_with_content_type(Mime::HTML) }
125
- it { should_not respond_with_content_type('text/html') }
126
- end
127
- end
42
+ describe 'matcher' do
43
+
44
+ describe 'on success' do
45
+ before(:each){ build_response }
46
+
47
+ it { should respond_with(200) }
48
+ it { should respond_with(:ok) }
49
+ it { should respond_with(:success) }
50
+ it { should respond_with(200..299) }
51
+
52
+ it { should respond_with(200, :content_type => Mime::HTML) }
53
+ it { should respond_with(:ok, :content_type => Mime::HTML) }
54
+ it { should respond_with(:success, :content_type => Mime::HTML) }
55
+ it { should respond_with(200..299, :content_type => Mime::HTML) }
56
+
57
+ it { should_not respond_with(404) }
58
+ it { should_not respond_with(:not_found) }
59
+ it { should_not respond_with(300..400) }
60
+ end
61
+
62
+ describe 'on missing' do
63
+ before(:each){ build_response { render :text => "404 Not Found", :status => 404 } }
64
+
65
+ it { should respond_with(404) }
66
+ it { should respond_with(:not_found) }
67
+ it { should respond_with(:missing) }
68
+ it { should respond_with(400..405) }
69
+
70
+ it { should_not respond_with(302) }
71
+ it { should_not respond_with(:found) }
72
+ it { should_not respond_with(:redirect) }
73
+ it { should_not respond_with(300..305) }
74
+ end
75
+
76
+ describe 'respond_with_body' do
77
+ before(:each) { build_response { respond_to{ |format| format.xml { render :xml => [].to_xml } } } }
78
+
79
+ it { should respond_with_body(%{<?xml version="1.0" encoding="UTF-8"?>\n<nil-classes type="array"/>\n}) }
80
+ it { should respond_with_body(/xml/) }
81
+ it { should_not respond_with_body('html') }
82
+ it { should_not respond_with_body(/html/) }
83
+ end
84
+
85
+ describe 'on redirect' do
86
+ before(:each){ build_response { redirect_to project_tasks_url(1) } }
87
+
88
+ it { should respond_with(302) }
89
+ it { should respond_with(:found) }
90
+ it { should respond_with(:redirect) }
91
+ it { should respond_with(300..305) }
92
+
93
+ it { should_not respond_with(200) }
94
+ it { should_not respond_with(:ok) }
95
+ it { should_not respond_with(:success) }
96
+ it { should_not respond_with(200..299) }
97
+ end
98
+
99
+ describe 'respond_with_content_type' do
100
+ describe 'and Mime::HTML' do
101
+ before(:each){ build_response { render :action => :new } }
102
+
103
+ it { should respond_with_content_type(:html) }
104
+ it { should respond_with_content_type(/html/) }
105
+ it { should respond_with_content_type(Mime::HTML) }
106
+ it { should respond_with_content_type('text/html') }
107
+
108
+ it { should_not respond_with_content_type(:xml) }
109
+ it { should_not respond_with_content_type(/xml/) }
110
+ it { should_not respond_with_content_type(Mime::XML) }
111
+ it { should_not respond_with_content_type('application/xml') }
112
+ end
113
+
114
+ describe 'and Mime::XML' do
115
+ before(:each) { build_response { respond_to{ |format| format.xml } } }
116
+
117
+ it { should respond_with_content_type(:xml) }
118
+ it { should respond_with_content_type(/xml/) }
119
+ it { should respond_with_content_type(Mime::XML) }
120
+ it { should respond_with_content_type('application/xml') }
121
+
122
+ it { should_not respond_with_content_type(:html) }
123
+ it { should_not respond_with_content_type(/html/) }
124
+ it { should_not respond_with_content_type(Mime::HTML) }
125
+ it { should_not respond_with_content_type('text/html') }
126
+ end
127
+ end
128
128
 
129
129
  end
130
130
 
131
131
  describe 'macro' do
132
-
133
- describe 'on success' do
134
- before(:each){ build_response }
135
-
136
- should_respond_with 200
137
- should_respond_with :ok
138
- should_respond_with :success
139
- should_respond_with 200..299
140
-
141
- should_respond_with 200, :content_type => Mime::HTML
142
- should_respond_with :ok, :content_type => Mime::HTML
143
- should_respond_with :success, :content_type => Mime::HTML
144
- should_respond_with 200..299, :content_type => Mime::HTML
145
-
146
- should_not_respond_with 404
147
- should_not_respond_with :not_found
148
- should_not_respond_with 300..400
149
- end
150
-
151
- describe 'on missing' do
152
- before(:each){ build_response { render :text => "404 Not Found", :status => 404 } }
153
-
154
- should_respond_with 404
155
- should_respond_with :not_found
156
- should_respond_with :missing
157
- should_respond_with 400..405
158
-
159
- should_not_respond_with 302
160
- should_not_respond_with :found
161
- should_not_respond_with :redirect
162
- should_not_respond_with 300..305
163
- end
164
-
165
- describe 'on redirect' do
166
- before(:each){ build_response { redirect_to project_tasks_url(1) } }
167
-
168
- should_respond_with 302
169
- should_respond_with :found
170
- should_respond_with :redirect
171
- should_respond_with 300..305
172
-
173
- should_not_respond_with 200
174
- should_not_respond_with :ok
175
- should_not_respond_with :success
176
- should_not_respond_with 200..299
177
- end
178
-
179
- describe 'respond_with_body' do
180
- before(:each) { build_response { respond_to{ |format| format.xml { render :xml => [].to_xml } } } }
181
-
182
- should_respond_with_body %{<?xml version="1.0" encoding="UTF-8"?>\n<nil-classes type="array"/>\n}
183
- should_respond_with_body /xml/
184
- should_not_respond_with_body 'html'
185
- should_not_respond_with_body /html/
186
- end
187
-
188
- describe 'respond_with_content_type' do
189
- describe 'and Mime::HTML' do
190
- before(:each){ build_response { render :action => :new } }
191
-
192
- should_respond_with_content_type :html
193
- should_respond_with_content_type /html/
194
- should_respond_with_content_type Mime::HTML
195
- should_respond_with_content_type 'text/html'
196
-
197
- should_not_respond_with_content_type :xml
198
- should_not_respond_with_content_type /xml/
199
- should_not_respond_with_content_type Mime::XML
200
- should_not_respond_with_content_type 'application/xml'
201
- end
202
-
203
- describe 'and Mime::XML' do
204
- before(:each) { build_response { respond_to{ |format| format.xml } } }
205
-
206
- should_respond_with_content_type :xml
207
- should_respond_with_content_type /xml/
208
- should_respond_with_content_type Mime::XML
209
- should_respond_with_content_type 'application/xml'
210
-
211
- should_not_respond_with_content_type :html
212
- should_not_respond_with_content_type /html/
213
- should_not_respond_with_content_type Mime::HTML
214
- should_not_respond_with_content_type 'text/html'
215
- end
216
- end
217
-
218
- end
219
-
220
- generate_macro_stubs_specs_for(:respond_with, 200)
221
- generate_macro_stubs_specs_for(:respond_with_body, /xml/)
132
+
133
+ describe 'on success' do
134
+ before(:each){ build_response }
135
+
136
+ should_respond_with 200
137
+ should_respond_with :ok
138
+ should_respond_with :success
139
+ should_respond_with 200..299
140
+
141
+ should_respond_with 200, :content_type => Mime::HTML
142
+ should_respond_with :ok, :content_type => Mime::HTML
143
+ should_respond_with :success, :content_type => Mime::HTML
144
+ should_respond_with 200..299, :content_type => Mime::HTML
145
+
146
+ should_not_respond_with 404
147
+ should_not_respond_with :not_found
148
+ should_not_respond_with 300..400
149
+ end
150
+
151
+ describe 'on missing' do
152
+ before(:each){ build_response { render :text => "404 Not Found", :status => 404 } }
153
+
154
+ should_respond_with 404
155
+ should_respond_with :not_found
156
+ should_respond_with :missing
157
+ should_respond_with 400..405
158
+
159
+ should_not_respond_with 302
160
+ should_not_respond_with :found
161
+ should_not_respond_with :redirect
162
+ should_not_respond_with 300..305
163
+ end
164
+
165
+ describe 'on redirect' do
166
+ before(:each){ build_response { redirect_to project_tasks_url(1) } }
167
+
168
+ should_respond_with 302
169
+ should_respond_with :found
170
+ should_respond_with :redirect
171
+ should_respond_with 300..305
172
+
173
+ should_not_respond_with 200
174
+ should_not_respond_with :ok
175
+ should_not_respond_with :success
176
+ should_not_respond_with 200..299
177
+ end
178
+
179
+ describe 'respond_with_body' do
180
+ before(:each) { build_response { respond_to{ |format| format.xml { render :xml => [].to_xml } } } }
181
+
182
+ should_respond_with_body %{<?xml version="1.0" encoding="UTF-8"?>\n<nil-classes type="array"/>\n}
183
+ should_respond_with_body /xml/
184
+ should_not_respond_with_body 'html'
185
+ should_not_respond_with_body /html/
186
+ end
187
+
188
+ describe 'respond_with_content_type' do
189
+ describe 'and Mime::HTML' do
190
+ before(:each){ build_response { render :action => :new } }
191
+
192
+ should_respond_with_content_type :html
193
+ should_respond_with_content_type /html/
194
+ should_respond_with_content_type Mime::HTML
195
+ should_respond_with_content_type 'text/html'
196
+
197
+ should_not_respond_with_content_type :xml
198
+ should_not_respond_with_content_type /xml/
199
+ should_not_respond_with_content_type Mime::XML
200
+ should_not_respond_with_content_type 'application/xml'
201
+ end
202
+
203
+ describe 'and Mime::XML' do
204
+ before(:each) { build_response { respond_to{ |format| format.xml } } }
205
+
206
+ should_respond_with_content_type :xml
207
+ should_respond_with_content_type /xml/
208
+ should_respond_with_content_type Mime::XML
209
+ should_respond_with_content_type 'application/xml'
210
+
211
+ should_not_respond_with_content_type :html
212
+ should_not_respond_with_content_type /html/
213
+ should_not_respond_with_content_type Mime::HTML
214
+ should_not_respond_with_content_type 'text/html'
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ generate_macro_stubs_specs_for(:respond_with, 200)
221
+ generate_macro_stubs_specs_for(:respond_with_body, /xml/)
222
222
  generate_macro_stubs_specs_for(:respond_with_content_type, Mime::HTML)
223
223
  end
@@ -1,75 +1,75 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe 'route_matcher' do
4
- include FunctionalBuilder
5
-
6
- describe 'messages' do
7
- before(:each) do
8
- @matcher = route(:get, '/projects', :controller => 'boo', :action => 'index')
9
- end
10
-
11
- it 'should contain a description message' do
12
- @matcher.description.should match(/route GET "\/projects" to\/from/)
13
- end
14
-
15
- it 'should set map_to_path? message' do
16
- @matcher.matches?(nil)
17
- @matcher.failure_message.should match(/Expected to map/)
18
- end
19
-
20
- it 'should set map_to_path? message' do
21
- @matcher.stub!(:map_to_path?).and_return(true)
22
- @matcher.matches?(nil)
23
- @matcher.failure_message.should match(/Expected to generate params/)
24
- end
25
- end
26
-
27
- describe 'matchers' do
28
- it { should route(:get, '/projects', :controller => :projects, :action => :index) }
29
- it { should route(:delete, '/projects/1', :controller => :projects, :action => :destroy, :id => 1) }
30
- it { should route(:get, '/projects/new', :controller => :projects, :action => :new) }
31
-
32
- # explicitly specify :controller
33
- it { should route(:post, '/projects', :controller => :projects, :action => :create) }
34
-
35
- # non-string parameter
36
- it { should route(:get, '/projects/1', :controller => :projects, :action => :show, :id => 1) }
37
-
38
- # string-parameter
39
- it { should route(:put, '/projects/1', :controller => :projects, :action => :update, :id => "1") }
40
-
41
- # failing case
42
- it { should_not route(:get, '/projects', :controller => :projects, :action => :show) }
43
- end
44
-
45
- describe 'macros' do
46
- should_route :get, '/projects', :controller => :projects, :action => :index
47
- should_route :delete, '/projects/1', :controller => :projects, :action => :destroy, :id => 1
48
- should_route :get, '/projects/new', :controller => :projects, :action => :new
49
-
50
- # explicitly specify :controller
51
- should_route :post, '/projects', :controller => :projects, :action => :create
52
-
53
- # non-string parameter
54
- should_route :get, '/projects/1', :controller => :projects, :action => :show, :id => 1
55
-
56
- # string-parameter
57
- should_route :put, '/projects/1', :controller => :projects, :action => :update, :id => "1"
58
-
59
- # failing case
60
- should_not_route :get, '/projects', :controller => :projects, :action => :show
61
- end
62
-
63
- describe TasksController, :type => :routing do
64
- controller_name 'tasks'
65
-
66
- # Test the nested routes with implicit controller
67
- should_route :get, '/projects/5/tasks', :action => :index, :project_id => 5
68
- should_route :post, '/projects/5/tasks', :action => :create, :project_id => 5
69
- should_route :get, '/projects/5/tasks/1', :action => :show, :id => 1, :project_id => 5
70
- should_route :delete, '/projects/5/tasks/1', :action => :destroy, :id => 1, :project_id => 5
71
- should_route :get, '/projects/5/tasks/new', :action => :new, :project_id => 5
72
- should_route :put, '/projects/5/tasks/1', :action => :update, :id => 1, :project_id => 5
73
- end
74
-
75
- end
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe 'route_matcher' do
4
+ include FunctionalBuilder
5
+
6
+ describe 'messages' do
7
+ before(:each) do
8
+ @matcher = route(:get, '/projects', :controller => 'boo', :action => 'index')
9
+ end
10
+
11
+ it 'should contain a description message' do
12
+ @matcher.description.should match(/route GET "\/projects" to\/from/)
13
+ end
14
+
15
+ it 'should set map_to_path? message' do
16
+ @matcher.matches?(nil)
17
+ @matcher.failure_message.should match(/Expected to map/)
18
+ end
19
+
20
+ it 'should set map_to_path? message' do
21
+ @matcher.stub!(:map_to_path?).and_return(true)
22
+ @matcher.matches?(nil)
23
+ @matcher.failure_message.should match(/Expected to generate params/)
24
+ end
25
+ end
26
+
27
+ describe 'matchers' do
28
+ it { should route(:get, '/projects', :controller => :projects, :action => :index) }
29
+ it { should route(:delete, '/projects/1', :controller => :projects, :action => :destroy, :id => 1) }
30
+ it { should route(:get, '/projects/new', :controller => :projects, :action => :new) }
31
+
32
+ # explicitly specify :controller
33
+ it { should route(:post, '/projects', :controller => :projects, :action => :create) }
34
+
35
+ # non-string parameter
36
+ it { should route(:get, '/projects/1', :controller => :projects, :action => :show, :id => 1) }
37
+
38
+ # string-parameter
39
+ it { should route(:put, '/projects/1', :controller => :projects, :action => :update, :id => "1") }
40
+
41
+ # failing case
42
+ it { should_not route(:get, '/projects', :controller => :projects, :action => :show) }
43
+ end
44
+
45
+ describe 'macros' do
46
+ should_route :get, '/projects', :controller => :projects, :action => :index
47
+ should_route :delete, '/projects/1', :controller => :projects, :action => :destroy, :id => 1
48
+ should_route :get, '/projects/new', :controller => :projects, :action => :new
49
+
50
+ # explicitly specify :controller
51
+ should_route :post, '/projects', :controller => :projects, :action => :create
52
+
53
+ # non-string parameter
54
+ should_route :get, '/projects/1', :controller => :projects, :action => :show, :id => 1
55
+
56
+ # string-parameter
57
+ should_route :put, '/projects/1', :controller => :projects, :action => :update, :id => "1"
58
+
59
+ # failing case
60
+ should_not_route :get, '/projects', :controller => :projects, :action => :show
61
+ end
62
+
63
+ describe TasksController, :type => :routing do
64
+ controller_name 'tasks'
65
+
66
+ # Test the nested routes with implicit controller
67
+ should_route :get, '/projects/5/tasks', :action => :index, :project_id => 5
68
+ should_route :post, '/projects/5/tasks', :action => :create, :project_id => 5
69
+ should_route :get, '/projects/5/tasks/1', :action => :show, :id => 1, :project_id => 5
70
+ should_route :delete, '/projects/5/tasks/1', :action => :destroy, :id => 1, :project_id => 5
71
+ should_route :get, '/projects/5/tasks/new', :action => :new, :project_id => 5
72
+ should_route :put, '/projects/5/tasks/1', :action => :update, :id => 1, :project_id => 5
73
+ end
74
+
75
+ end