rspec-rails 1.1.12 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +7 -0
- data/History.txt +55 -0
- data/License.txt +1 -1
- data/Manifest.txt +53 -48
- data/README.txt +5 -4
- data/Rakefile +9 -2
- data/TODO.txt +1 -0
- data/Upgrade.markdown +103 -0
- data/generators/rspec/rspec_generator.rb +1 -0
- data/generators/rspec/templates/rspec.rake +134 -111
- data/generators/rspec/templates/script/autospec +1 -0
- data/generators/rspec/templates/script/spec +21 -4
- data/generators/rspec/templates/script/spec_server +34 -107
- data/generators/rspec/templates/spec_helper.rb +1 -1
- data/generators/rspec_controller/rspec_controller_generator.rb +1 -5
- data/generators/rspec_scaffold/rspec_scaffold_generator.rb +13 -17
- data/generators/rspec_scaffold/templates/controller_spec.rb +27 -29
- data/generators/rspec_scaffold/templates/edit_erb_spec.rb +2 -2
- data/generators/rspec_scaffold/templates/helper_spec.rb +1 -1
- data/generators/rspec_scaffold/templates/index_erb_spec.rb +2 -2
- data/generators/rspec_scaffold/templates/new_erb_spec.rb +2 -2
- data/generators/rspec_scaffold/templates/routing_spec.rb +24 -20
- data/generators/rspec_scaffold/templates/show_erb_spec.rb +2 -2
- data/lib/spec/rails.rb +10 -9
- data/lib/spec/rails/example.rb +2 -2
- data/lib/spec/rails/example/assigns_hash_proxy.rb +1 -2
- data/lib/spec/rails/example/controller_example_group.rb +117 -123
- data/lib/spec/rails/example/functional_example_group.rb +7 -22
- data/lib/spec/rails/example/helper_example_group.rb +15 -33
- data/lib/spec/rails/example/model_example_group.rb +1 -1
- data/lib/spec/rails/example/render_observer.rb +0 -26
- data/lib/spec/rails/example/routing_example_group.rb +13 -0
- data/lib/spec/rails/example/routing_helpers.rb +68 -0
- data/lib/spec/rails/example/view_example_group.rb +50 -47
- data/lib/spec/rails/extensions.rb +2 -1
- data/lib/spec/rails/extensions/action_controller/rescue.rb +25 -8
- data/lib/spec/rails/extensions/action_controller/test_case.rb +16 -0
- data/lib/spec/rails/extensions/action_controller/test_response.rb +4 -3
- data/lib/spec/rails/extensions/action_view/base.rb +9 -9
- data/lib/spec/rails/extensions/active_record/base.rb +39 -23
- data/lib/spec/rails/extensions/active_support/test_case.rb +7 -0
- data/lib/spec/rails/extensions/spec/matchers/have.rb +8 -6
- data/lib/spec/rails/extensions/spec/runner/configuration.rb +12 -44
- data/lib/spec/rails/matchers/ar_be_valid.rb +8 -5
- data/lib/spec/rails/matchers/assert_select.rb +36 -21
- data/lib/spec/rails/matchers/have_text.rb +3 -3
- data/lib/spec/rails/matchers/include_text.rb +4 -4
- data/lib/spec/rails/matchers/redirect_to.rb +30 -19
- data/lib/spec/rails/matchers/render_template.rb +7 -3
- data/lib/spec/rails/mocks.rb +1 -1
- data/lib/spec/rails/spec_server.rb +97 -0
- data/lib/spec/rails/story_adapter.rb +4 -4
- data/lib/spec/rails/version.rb +2 -2
- data/spec/resources/controllers/controller_spec_controller.rb +14 -6
- data/spec/resources/controllers/example.txt +1 -0
- data/spec/resources/controllers/redirect_spec_controller.rb +4 -0
- data/spec/resources/controllers/render_spec_controller.rb +1 -1
- data/spec/resources/controllers/rjs_spec_controller.rb +1 -1
- data/spec/resources/helpers/explicit_helper.rb +1 -1
- data/spec/resources/views/controller_spec/{_partial.rhtml → _partial.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_setting_flash_after_session_reset.rhtml → action_setting_flash_after_session_reset.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_setting_flash_before_session_reset.rhtml → action_setting_flash_before_session_reset.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_setting_the_assigns_hash.rhtml → action_setting_the_assigns_hash.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_with_errors_in_template.rhtml → action_with_errors_in_template.html.erb} +0 -0
- data/spec/resources/views/controller_spec/{action_with_template.rhtml → action_with_template.html.erb} +0 -0
- data/spec/resources/views/layouts/{application.rhtml → application.html.erb} +0 -0
- data/spec/resources/views/layouts/{simple.rhtml → simple.html.erb} +0 -0
- data/spec/resources/views/render_spec/{_a_partial.rhtml → _a_partial.html.erb} +0 -0
- data/spec/resources/views/render_spec/{action_with_alternate_layout.rhtml → action_with_alternate_layout.html.erb} +0 -0
- data/spec/resources/views/rjs_spec/{_replacement_partial.rhtml → _replacement_partial.html.erb} +0 -0
- data/spec/resources/views/rjs_spec/{hide_div.rjs → hide_div.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{hide_page_element.rjs → hide_page_element.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{insert_html.rjs → insert_html.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{replace.rjs → replace.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{replace_html.rjs → replace_html.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{replace_html_with_partial.rjs → replace_html_with_partial.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{visual_effect.rjs → visual_effect.js.rjs} +0 -0
- data/spec/resources/views/rjs_spec/{visual_toggle_effect.rjs → visual_toggle_effect.js.rjs} +0 -0
- data/spec/resources/views/tag_spec/{no_tags.rhtml → no_tags.html.erb} +0 -0
- data/spec/resources/views/tag_spec/{single_div_with_no_attributes.rhtml → single_div_with_no_attributes.html.erb} +0 -0
- data/spec/resources/views/tag_spec/{single_div_with_one_attribute.rhtml → single_div_with_one_attribute.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_partial.rhtml → _partial.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_partial_used_twice.rhtml → _partial_used_twice.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_partial_with_local_variable.rhtml → _partial_with_local_variable.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_partial_with_sub_partial.rhtml → _partial_with_sub_partial.html.erb} +0 -0
- data/spec/resources/views/view_spec/{_spacer.rhtml → _spacer.html.erb} +0 -0
- data/spec/resources/views/view_spec/{accessor.rhtml → accessor.html.erb} +0 -0
- data/spec/resources/views/view_spec/{block_helper.rhtml → block_helper.html.erb} +0 -0
- data/spec/resources/views/view_spec/{entry_form.rhtml → entry_form.html.erb} +0 -0
- data/spec/resources/views/view_spec/{explicit_helper.rhtml → explicit_helper.html.erb} +0 -0
- data/spec/resources/views/view_spec/foo/{show.rhtml → show.html.erb} +0 -0
- data/spec/resources/views/view_spec/{implicit_helper.rhtml → implicit_helper.html.erb} +0 -0
- data/spec/resources/views/view_spec/{multiple_helpers.rhtml → multiple_helpers.html.erb} +0 -0
- data/spec/resources/views/view_spec/{should_not_receive.rhtml → should_not_receive.html.erb} +0 -0
- data/spec/resources/views/view_spec/{template_with_partial.rhtml → template_with_partial.html.erb} +0 -0
- data/spec/resources/views/view_spec/{template_with_partial_using_collection.rhtml → template_with_partial_using_collection.html.erb} +0 -0
- data/spec/resources/views/view_spec/{template_with_partial_with_array.rhtml → template_with_partial_with_array.html.erb} +0 -0
- data/spec/spec/rails/example/assigns_hash_proxy_spec.rb +18 -5
- data/spec/spec/rails/example/configuration_spec.rb +15 -29
- data/spec/spec/rails/example/{controller_spec_spec.rb → controller_example_group_spec.rb} +40 -96
- data/spec/spec/rails/example/cookies_proxy_spec.rb +32 -36
- data/spec/spec/rails/example/error_handling_spec.rb +90 -0
- data/spec/spec/rails/example/example_group_factory_spec.rb +5 -5
- data/spec/spec/rails/example/{helper_spec_spec.rb → helper_example_group_spec.rb} +45 -13
- data/spec/spec/rails/example/{model_spec_spec.rb → model_example_group_spec.rb} +3 -1
- data/spec/spec/rails/example/routing_example_group_spec.rb +9 -0
- data/spec/spec/rails/example/shared_routing_example_group_examples.rb +45 -0
- data/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb +1 -1
- data/spec/spec/rails/example/{view_spec_spec.rb → view_example_group_spec.rb} +44 -17
- data/spec/spec/rails/matchers/ar_be_valid_spec.rb +10 -0
- data/spec/spec/rails/matchers/assert_select_spec.rb +59 -60
- data/spec/spec/rails/matchers/have_text_spec.rb +12 -4
- data/spec/spec/rails/matchers/include_text_spec.rb +11 -13
- data/spec/spec/rails/matchers/redirect_to_spec.rb +224 -189
- data/spec/spec/rails/matchers/render_template_spec.rb +169 -158
- data/spec/spec/rails/spec_server_spec.rb +18 -7
- data/spec/spec_helper.rb +21 -9
- metadata +68 -53
- data/lib/spec/rails/example/rails_example_group.rb +0 -28
- data/lib/spec/rails/extensions/action_controller/base.rb +0 -14
- data/rspec-rails.gemspec +0 -36
- data/spec/resources/views/render_spec/some_action.rjs +0 -1
- data/spec/spec/rails/example/shared_behaviour_spec.rb +0 -16
- data/spec/spec/rails/extensions/action_controller_rescue_action_spec.rb +0 -57
@@ -24,21 +24,21 @@ module Spec
|
|
24
24
|
example_group.superclass.should == Spec::Rails::Example::ModelExampleGroup
|
25
25
|
end
|
26
26
|
|
27
|
-
it "should return
|
27
|
+
it "should return an ActiveSupport::TestCase when given :spec_path => '/blah/spec/foo/' (anything other than controllers, views and helpers)" do
|
28
28
|
example_group = Spec::Example::ExampleGroupFactory.create_example_group(
|
29
29
|
"name", :spec_path => '/blah/spec/foo/blah.rb'
|
30
30
|
) {}
|
31
|
-
example_group.superclass.should ==
|
31
|
+
example_group.superclass.should == ActiveSupport::TestCase
|
32
32
|
end
|
33
33
|
|
34
|
-
it "should return
|
34
|
+
it "should return an ActiveSupport::TestCase when given :spec_path => '\\blah\\spec\\foo\\' (windows format) (anything other than controllers, views and helpers)" do
|
35
35
|
example_group = Spec::Example::ExampleGroupFactory.create_example_group(
|
36
36
|
"name", :spec_path => '\\blah\\spec\\foo\\blah.rb'
|
37
37
|
) {}
|
38
|
-
example_group.superclass.should ==
|
38
|
+
example_group.superclass.should == ActiveSupport::TestCase
|
39
39
|
end
|
40
40
|
|
41
|
-
it "should return a ViewExampleGroup when given :type => :
|
41
|
+
it "should return a ViewExampleGroup when given :type => :view" do
|
42
42
|
example_group = Spec::Example::ExampleGroupFactory.create_example_group(
|
43
43
|
"name", :type => :view
|
44
44
|
) {}
|
@@ -16,6 +16,8 @@ module Spec
|
|
16
16
|
describe HelperExampleGroup, :type => :helper do
|
17
17
|
helper_name :explicit
|
18
18
|
|
19
|
+
accesses_configured_helper_methods
|
20
|
+
|
19
21
|
it "DEPRECATED should have direct access to methods defined in helpers" do
|
20
22
|
method_in_explicit_helper.should =~ /text from a method/
|
21
23
|
end
|
@@ -112,8 +114,6 @@ module Spec
|
|
112
114
|
ActionView::Helpers::TextHelper,
|
113
115
|
ActionView::Helpers::UrlHelper
|
114
116
|
]
|
115
|
-
helpers << ActionView::Helpers::PaginationHelper rescue nil #removed for 2.0
|
116
|
-
helpers << ActionView::Helpers::JavaScriptMacrosHelper rescue nil #removed for 2.0
|
117
117
|
helpers.each do |helper_module|
|
118
118
|
it "should include #{helper_module}" do
|
119
119
|
self.class.ancestors.should include(helper_module)
|
@@ -144,21 +144,25 @@ module Spec
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
147
|
+
describe HelperExampleGroup, "using a helper that uses output_buffer inside helper", :type => :helper do
|
148
|
+
helper_name :explicit
|
149
|
+
|
150
|
+
before(:each) do
|
151
|
+
if Rails::VERSION::STRING <= "2.1"
|
152
|
+
pending("need to get this new feature working against pre 2.2 versions of rails")
|
153
153
|
end
|
154
|
+
end
|
154
155
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
156
|
+
it "should not raise an error" do
|
157
|
+
lambda { method_using_output_buffer }.should_not raise_error
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should put the output in the output_buffer" do
|
161
|
+
method_using_output_buffer
|
162
|
+
output_buffer.should == "the_text_from_concat"
|
159
163
|
end
|
160
164
|
end
|
161
|
-
|
165
|
+
|
162
166
|
describe HelperExampleGroup, "using a helper that tries to access @template", :type => :helper do
|
163
167
|
helper_name :explicit
|
164
168
|
|
@@ -170,6 +174,7 @@ module Spec
|
|
170
174
|
method_using_template.should have_text(/#some_id/)
|
171
175
|
end
|
172
176
|
end
|
177
|
+
|
173
178
|
end
|
174
179
|
end
|
175
180
|
end
|
@@ -199,3 +204,30 @@ module Spec
|
|
199
204
|
end
|
200
205
|
end
|
201
206
|
end
|
207
|
+
|
208
|
+
module Bug719
|
209
|
+
# see http://rspec.lighthouseapp.com/projects/5645/tickets/719
|
210
|
+
# FIXME - helper and example provided in ticket. The example did
|
211
|
+
# fail initially, so running it now shows that the bug is fixed,
|
212
|
+
# but this doesn't serve as a good internal example.
|
213
|
+
module ImagesHelper
|
214
|
+
def hide_images_button
|
215
|
+
content_tag :div, :class => :hide_images_button do
|
216
|
+
button_to_function "Hide Images", :id => :hide_images_button do |page|
|
217
|
+
page[:more_images_button].toggle
|
218
|
+
page[:image_browser].toggle
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe ImagesHelper, :type => :helper do
|
225
|
+
it "should render a hide_images_button" do
|
226
|
+
helper.hide_images_button.should have_tag('div[class=?]','hide_images_button') do
|
227
|
+
with_tag('input[id=?][type=?][value=?][onclick^=?]',
|
228
|
+
'hide_images_button', 'button', 'Hide Images',
|
229
|
+
"$("more_images_button").toggle();\n$("image_browser").toggle();;")
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
@@ -4,7 +4,9 @@ module Spec
|
|
4
4
|
module Rails
|
5
5
|
module Example
|
6
6
|
describe ModelExampleGroup do
|
7
|
-
|
7
|
+
accesses_configured_helper_methods
|
8
|
+
|
9
|
+
it "clears its name from the description" do
|
8
10
|
group = describe("foo", :type => :model) do
|
9
11
|
$nested_group = describe("bar") do
|
10
12
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
require 'controller_spec_controller'
|
3
|
+
require File.join(File.dirname(__FILE__), "/shared_routing_example_group_examples.rb")
|
4
|
+
|
5
|
+
describe "Routing Examples", :type => :routing do
|
6
|
+
|
7
|
+
include RoutingExampleGroupSpec
|
8
|
+
|
9
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
share_as :RoutingExampleGroupSpec do
|
2
|
+
|
3
|
+
class CustomRouteSpecController < ActionController::Base; end
|
4
|
+
class RspecOnRailsSpecsController < ActionController::Base; end
|
5
|
+
|
6
|
+
it "support custom routes" do
|
7
|
+
route_for(:controller => "custom_route_spec", :action => "custom_route").
|
8
|
+
should == "/custom_route"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "support existing routes" do
|
12
|
+
route_for(:controller => "controller_spec", :action => "some_action").
|
13
|
+
should == "/controller_spec/some_action"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "support existing routes with additional parameters" do
|
17
|
+
route_for(:controller => "controller_spec", :action => "some_action", :param => '1').
|
18
|
+
should == "/controller_spec/some_action?param=1"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "recognize routes with methods besides :get" do
|
22
|
+
route_for(:controller => "rspec_on_rails_specs", :action => "update", :id => "37").
|
23
|
+
should == {:path => "/rspec_on_rails_specs/37", :method => :put}
|
24
|
+
end
|
25
|
+
|
26
|
+
it "generate params for custom routes" do
|
27
|
+
params_from(:get, '/custom_route').
|
28
|
+
should == {:controller => "custom_route_spec", :action => "custom_route"}
|
29
|
+
end
|
30
|
+
|
31
|
+
it "generate params for existing routes" do
|
32
|
+
params_from(:get, '/controller_spec/some_action').
|
33
|
+
should == {:controller => "controller_spec", :action => "some_action"}
|
34
|
+
end
|
35
|
+
|
36
|
+
it "generate params for an existing route with a query parameter" do
|
37
|
+
params_from(:get, '/controller_spec/some_action?param=1').
|
38
|
+
should == {:controller => "controller_spec", :action => "some_action", :param => '1'}
|
39
|
+
end
|
40
|
+
|
41
|
+
it "generate params for an existing route with multiple query parameters" do
|
42
|
+
params_from(:get, '/controller_spec/some_action?param1=1¶m2=2').
|
43
|
+
should == {:controller => "controller_spec", :action => "some_action", :param1 => '1', :param2 => '2' }
|
44
|
+
end
|
45
|
+
end
|
@@ -4,6 +4,8 @@ describe "A template with an implicit helper", :type => :view do
|
|
4
4
|
before(:each) do
|
5
5
|
render "view_spec/implicit_helper"
|
6
6
|
end
|
7
|
+
|
8
|
+
accesses_configured_helper_methods
|
7
9
|
|
8
10
|
it "should include the helper" do
|
9
11
|
response.should have_tag('div', :content => "This is text from a method in the ViewSpecHelper")
|
@@ -95,7 +97,7 @@ describe "A template that includes a partial", :type => :view do
|
|
95
97
|
template.verify_rendered
|
96
98
|
rescue Spec::Mocks::MockExpectationError => e
|
97
99
|
ensure
|
98
|
-
e.backtrace.find{|line| line =~ /
|
100
|
+
e.backtrace.find{|line| line =~ /#{__FILE__}\:#{__LINE__ - 6}/}.should_not be_nil
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
@@ -112,7 +114,7 @@ describe "A template that includes a partial", :type => :view do
|
|
112
114
|
template.verify_rendered
|
113
115
|
rescue Spec::Mocks::MockExpectationError => e
|
114
116
|
ensure
|
115
|
-
e.backtrace.find{|line| line =~ /
|
117
|
+
e.backtrace.find{|line| line =~ /#{__FILE__}\:#{__LINE__ - 6}/}.should_not be_nil
|
116
118
|
end
|
117
119
|
end
|
118
120
|
|
@@ -149,18 +151,16 @@ describe "A view that includes a partial using :collection and :spacer_template"
|
|
149
151
|
|
150
152
|
end
|
151
153
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
end
|
154
|
+
describe "A view that includes a partial using an array as partial_path", :type => :view do
|
155
|
+
before(:each) do
|
156
|
+
renderable_object = Object.new
|
157
|
+
renderable_object.stub!(:name).and_return("Renderable Object")
|
158
|
+
assigns[:array] = [renderable_object]
|
159
|
+
end
|
159
160
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
161
|
+
it "should render the array passed through to render_partial without modification" do
|
162
|
+
render "view_spec/template_with_partial_with_array"
|
163
|
+
response.body.should match(/^Renderable Object$/)
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
@@ -179,6 +179,18 @@ describe "A view", :type => :view do
|
|
179
179
|
render "view_spec/accessor"
|
180
180
|
end
|
181
181
|
|
182
|
+
it "should use the template as the implicit subject" do
|
183
|
+
subject.should == template
|
184
|
+
end
|
185
|
+
|
186
|
+
describe "with a specified subject" do
|
187
|
+
subject { 'specified' }
|
188
|
+
|
189
|
+
it "should use the specified subject" do
|
190
|
+
subject.should == 'specified'
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
182
194
|
it "should have access to session data" do
|
183
195
|
response.should have_tag("div#session", "session")
|
184
196
|
end
|
@@ -242,13 +254,22 @@ describe "render :inline => ...", :type => :view do
|
|
242
254
|
end
|
243
255
|
end
|
244
256
|
|
245
|
-
describe "render 'view_spec/foo/show
|
257
|
+
describe "render 'view_spec/foo/show'", :type => :view do
|
246
258
|
it "should derive action name using the first part of the template name" do
|
247
|
-
render 'view_spec/foo/show
|
259
|
+
render 'view_spec/foo/show'
|
248
260
|
request.path_parameters[:action].should == 'show'
|
249
261
|
end
|
250
262
|
end
|
251
263
|
|
264
|
+
describe "view_spec/foo/show", :type => :view do
|
265
|
+
context "rendered with no args" do
|
266
|
+
it "renders just fine" do
|
267
|
+
render
|
268
|
+
request.path_parameters[:action].should == 'show'
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
252
273
|
describe "setting path parameters", :type => :view do
|
253
274
|
describe "(controller)" do
|
254
275
|
it "should supercede the default path parameters" do
|
@@ -270,6 +291,12 @@ describe "setting path parameters", :type => :view do
|
|
270
291
|
end
|
271
292
|
end
|
272
293
|
|
294
|
+
describe "route helpers", :type => :view do
|
295
|
+
it "should be available before render is called" do
|
296
|
+
custom_route_path.should == '/custom_route'
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
273
300
|
module Spec
|
274
301
|
module Rails
|
275
302
|
module Example
|
@@ -285,10 +312,10 @@ module Spec
|
|
285
312
|
|
286
313
|
it "should clear ActionView::Base.base_view_path on teardown" do
|
287
314
|
group = describe("base_view_path_cleared flag", :type => :view) {}
|
288
|
-
example = group.
|
315
|
+
example = group.new("example",{}) {}
|
289
316
|
|
290
317
|
ActionView::Base.should_receive(:base_view_path=).with(nil)
|
291
|
-
|
318
|
+
example.run_after_each
|
292
319
|
end
|
293
320
|
end
|
294
321
|
end
|
@@ -13,6 +13,16 @@ describe "be_valid" do
|
|
13
13
|
CanBeValid.new(false).should_not be_valid
|
14
14
|
end
|
15
15
|
|
16
|
+
describe CanBeValid do
|
17
|
+
subject { CanBeValid.new(true) }
|
18
|
+
it { subject.should be_valid }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe CanBeValid do
|
22
|
+
subject { CanBeValid.new(false) }
|
23
|
+
it { subject.should_not be_valid }
|
24
|
+
end
|
25
|
+
|
16
26
|
class CanHaveErrors
|
17
27
|
def initialize(errors)
|
18
28
|
@valid = !errors
|
@@ -12,11 +12,6 @@ class AssertSelectController < ActionController::Base
|
|
12
12
|
@content = content
|
13
13
|
end
|
14
14
|
|
15
|
-
#NOTE - this is commented because response is implemented in lib/spec/rails/context/controller
|
16
|
-
# def response(&block)
|
17
|
-
# @update = block
|
18
|
-
# end
|
19
|
-
#
|
20
15
|
def html()
|
21
16
|
render :text=>@content, :layout=>false, :content_type=>Mime::HTML
|
22
17
|
@content = nil
|
@@ -212,8 +207,8 @@ describe "should have_tag", :type => :controller do
|
|
212
207
|
response.should have_tag("form[action=test]") { |form|
|
213
208
|
with_tag("input[type=text][name=email]")
|
214
209
|
}
|
215
|
-
response.should have_tag("form[action=
|
216
|
-
with_tag("input[type=text][name=
|
210
|
+
response.should have_tag("form[action=other]") { |form|
|
211
|
+
with_tag("input[type=text][name=other_input]")
|
217
212
|
}
|
218
213
|
|
219
214
|
lambda {
|
@@ -484,8 +479,7 @@ describe "have_rjs behaviour_type", :type => :controller do
|
|
484
479
|
with_tag("#1")
|
485
480
|
with_tag("#2")
|
486
481
|
with_tag("#3")
|
487
|
-
|
488
|
-
# with_tag("#5")
|
482
|
+
with_tag("#4")
|
489
483
|
end
|
490
484
|
end
|
491
485
|
|
@@ -678,56 +672,6 @@ describe "send_email behaviour_type", :type => :controller do
|
|
678
672
|
|
679
673
|
end
|
680
674
|
|
681
|
-
# describe "An rjs call to :visual_effect, a 'should have_rjs' spec with",
|
682
|
-
# :type => :view do
|
683
|
-
#
|
684
|
-
# before do
|
685
|
-
# render 'rjs_spec/visual_effect'
|
686
|
-
# end
|
687
|
-
#
|
688
|
-
# it "should pass with the correct element name" do
|
689
|
-
# response.should have_rjs(:effect, :fade, 'mydiv')
|
690
|
-
# end
|
691
|
-
#
|
692
|
-
# it "should fail the wrong element name" do
|
693
|
-
# lambda {
|
694
|
-
# response.should have_rjs(:effect, :fade, 'wrongname')
|
695
|
-
# }.should raise_error(SpecFailed)
|
696
|
-
# end
|
697
|
-
#
|
698
|
-
# it "should fail with the correct element but the wrong command" do
|
699
|
-
# lambda {
|
700
|
-
# response.should have_rjs(:effect, :puff, 'mydiv')
|
701
|
-
# }.should raise_error(SpecFailed)
|
702
|
-
# end
|
703
|
-
#
|
704
|
-
# end
|
705
|
-
#
|
706
|
-
# describe "An rjs call to :visual_effect for a toggle, a 'should have_rjs' spec with",
|
707
|
-
# :type => :view do
|
708
|
-
#
|
709
|
-
# before do
|
710
|
-
# render 'rjs_spec/visual_toggle_effect'
|
711
|
-
# end
|
712
|
-
#
|
713
|
-
# it "should pass with the correct element name" do
|
714
|
-
# response.should have_rjs(:effect, :toggle_blind, 'mydiv')
|
715
|
-
# end
|
716
|
-
#
|
717
|
-
# it "should fail with the wrong element name" do
|
718
|
-
# lambda {
|
719
|
-
# response.should have_rjs(:effect, :toggle_blind, 'wrongname')
|
720
|
-
# }.should raise_error(SpecFailed)
|
721
|
-
# end
|
722
|
-
#
|
723
|
-
# it "should fail the correct element but the wrong command" do
|
724
|
-
# lambda {
|
725
|
-
# response.should have_rjs(:effect, :puff, 'mydiv')
|
726
|
-
# }.should raise_error(SpecFailed)
|
727
|
-
# end
|
728
|
-
#
|
729
|
-
# end
|
730
|
-
|
731
675
|
describe "string.should have_tag", :type => :helper do
|
732
676
|
include AssertSelectSpecHelpers
|
733
677
|
|
@@ -745,6 +689,10 @@ describe "string.should have_tag", :type => :helper do
|
|
745
689
|
"<div><p>a paragraph</p></div>".should have_tag("p", "a paragraph")
|
746
690
|
end
|
747
691
|
|
692
|
+
it "should find nested element in one line" do
|
693
|
+
"<div><p>a paragraph</p></div>".should have_tag("div p","a paragraph")
|
694
|
+
end
|
695
|
+
|
748
696
|
it "should find nested element" do
|
749
697
|
"<div><p>a paragraph</p></div>".should have_tag("div") do
|
750
698
|
with_tag("p", "a paragraph")
|
@@ -786,6 +734,7 @@ describe "have_tag", :type => :controller do
|
|
786
734
|
end
|
787
735
|
|
788
736
|
describe 'selecting in HTML that contains a mock with null_object' do
|
737
|
+
include ActionController::Assertions::SelectorAssertions
|
789
738
|
module HTML
|
790
739
|
class Document
|
791
740
|
def initialize_with_strict_error_checking(text, strict=false, xml=false)
|
@@ -807,4 +756,54 @@ describe 'selecting in HTML that contains a mock with null_object' do
|
|
807
756
|
html = "<b>#{mock.colour}</b>"
|
808
757
|
lambda {html.should have_tag('b')}.should_not raise_error
|
809
758
|
end
|
810
|
-
end
|
759
|
+
end
|
760
|
+
|
761
|
+
# describe "An rjs call to :visual_effect, a 'should have_rjs' spec with",
|
762
|
+
# :type => :view do
|
763
|
+
#
|
764
|
+
# before do
|
765
|
+
# render 'rjs_spec/visual_effect'
|
766
|
+
# end
|
767
|
+
#
|
768
|
+
# it "should pass with the correct element name" do
|
769
|
+
# response.should have_rjs(:effect, :fade, 'mydiv')
|
770
|
+
# end
|
771
|
+
#
|
772
|
+
# it "should fail the wrong element name" do
|
773
|
+
# lambda {
|
774
|
+
# response.should have_rjs(:effect, :fade, 'wrongname')
|
775
|
+
# }.should raise_error(SpecFailed)
|
776
|
+
# end
|
777
|
+
#
|
778
|
+
# it "should fail with the correct element but the wrong command" do
|
779
|
+
# lambda {
|
780
|
+
# response.should have_rjs(:effect, :puff, 'mydiv')
|
781
|
+
# }.should raise_error(SpecFailed)
|
782
|
+
# end
|
783
|
+
#
|
784
|
+
# end
|
785
|
+
#
|
786
|
+
# describe "An rjs call to :visual_effect for a toggle, a 'should have_rjs' spec with",
|
787
|
+
# :type => :view do
|
788
|
+
#
|
789
|
+
# before do
|
790
|
+
# render 'rjs_spec/visual_toggle_effect'
|
791
|
+
# end
|
792
|
+
#
|
793
|
+
# it "should pass with the correct element name" do
|
794
|
+
# response.should have_rjs(:effect, :toggle_blind, 'mydiv')
|
795
|
+
# end
|
796
|
+
#
|
797
|
+
# it "should fail with the wrong element name" do
|
798
|
+
# lambda {
|
799
|
+
# response.should have_rjs(:effect, :toggle_blind, 'wrongname')
|
800
|
+
# }.should raise_error(SpecFailed)
|
801
|
+
# end
|
802
|
+
#
|
803
|
+
# it "should fail the correct element but the wrong command" do
|
804
|
+
# lambda {
|
805
|
+
# response.should have_rjs(:effect, :puff, 'mydiv')
|
806
|
+
# }.should raise_error(SpecFailed)
|
807
|
+
# end
|
808
|
+
#
|
809
|
+
# end
|