rspec-rails 1.3.4 → 2.0.0.a2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (202) hide show
  1. data/.gitignore +1 -7
  2. data/README.markdown +58 -0
  3. data/Rakefile +51 -9
  4. data/example_app_template.rb +33 -0
  5. data/lib/generators/rspec.rb +25 -0
  6. data/lib/generators/rspec/controller/controller_generator.rb +26 -0
  7. data/lib/generators/rspec/controller/templates/controller_spec.rb +15 -0
  8. data/lib/generators/rspec/controller/templates/view_spec.rb +12 -0
  9. data/lib/generators/rspec/helper/helper_generator.rb +11 -0
  10. data/lib/generators/rspec/helper/templates/helper_spec.rb +14 -0
  11. data/lib/generators/rspec/install/install_generator.rb +29 -0
  12. data/lib/generators/rspec/install/templates/lib/tasks/rspec.rake +119 -0
  13. data/lib/generators/rspec/install/templates/script/rspec.tt +4 -0
  14. data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/rcov.opts +0 -0
  15. data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/spec.opts +0 -0
  16. data/{generators/rspec/templates → lib/generators/rspec/install/templates/spec}/spec_helper.rb +14 -12
  17. data/lib/generators/rspec/integration/integration_generator.rb +12 -0
  18. data/{generators/integration_spec/templates/integration_spec.rb → lib/generators/rspec/integration/templates/request_spec.rb} +0 -0
  19. data/lib/generators/rspec/mailer/mailer_generator.rb +21 -0
  20. data/lib/generators/rspec/mailer/templates/fixture +3 -0
  21. data/lib/generators/rspec/mailer/templates/mailer_spec.rb +14 -0
  22. data/lib/generators/rspec/model/model_generator.rb +22 -0
  23. data/lib/generators/rspec/model/templates/fixtures.yml +19 -0
  24. data/{generators/rspec_model → lib/generators/rspec/model}/templates/model_spec.rb +1 -1
  25. data/lib/generators/rspec/observer/observer_generator.rb +12 -0
  26. data/lib/generators/rspec/observer/templates/observer_spec.rb +5 -0
  27. data/lib/generators/rspec/plugin/plugin_generator.rb +11 -0
  28. data/lib/generators/rspec/plugin/templates/%file_name%_spec.rb.tt +5 -0
  29. data/lib/generators/rspec/plugin/templates/test_helper.rb +5 -0
  30. data/lib/generators/rspec/scaffold/scaffold_generator.rb +112 -0
  31. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +127 -0
  32. data/{generators/rspec_scaffold/templates/edit_erb_spec.rb → lib/generators/rspec/scaffold/templates/edit_spec.rb} +3 -3
  33. data/{generators/rspec_scaffold/templates/index_erb_spec.rb → lib/generators/rspec/scaffold/templates/index_spec.rb} +4 -4
  34. data/{generators/rspec_scaffold/templates/new_erb_spec.rb → lib/generators/rspec/scaffold/templates/new_spec.rb} +3 -3
  35. data/{generators/rspec_scaffold → lib/generators/rspec/scaffold}/templates/routing_spec.rb +4 -0
  36. data/{generators/rspec_scaffold/templates/show_erb_spec.rb → lib/generators/rspec/scaffold/templates/show_spec.rb} +4 -4
  37. data/lib/rspec/rails.rb +2 -0
  38. data/lib/rspec/rails/example.rb +2 -0
  39. data/lib/rspec/rails/example/controller_example_group.rb +31 -0
  40. data/lib/rspec/rails/example/request_example_group.rb +26 -0
  41. data/lib/rspec/rails/matchers.rb +14 -0
  42. data/lib/rspec/rails/transactional_database_support.rb +38 -0
  43. data/lib/rspec/rails/version.rb +16 -0
  44. data/rspec-rails.gemspec +78 -18
  45. metadata +97 -321
  46. data/.document +0 -7
  47. data/Contribute.rdoc +0 -4
  48. data/Gemfile +0 -4
  49. data/Gemfile.lock +0 -27
  50. data/History.rdoc +0 -321
  51. data/License.txt +0 -33
  52. data/Manifest.txt +0 -165
  53. data/README.rdoc +0 -48
  54. data/TODO.txt +0 -17
  55. data/Upgrade.rdoc +0 -148
  56. data/generators/integration_spec/integration_spec_generator.rb +0 -10
  57. data/generators/rspec/CHANGES +0 -1
  58. data/generators/rspec/rspec_generator.rb +0 -72
  59. data/generators/rspec/templates/previous_failures.txt +0 -0
  60. data/generators/rspec/templates/rspec.rake +0 -144
  61. data/generators/rspec/templates/script/autospec +0 -6
  62. data/generators/rspec/templates/script/spec +0 -10
  63. data/generators/rspec_controller/USAGE +0 -33
  64. data/generators/rspec_controller/rspec_controller_generator.rb +0 -47
  65. data/generators/rspec_controller/templates/controller_spec.rb +0 -25
  66. data/generators/rspec_controller/templates/helper_spec.rb +0 -11
  67. data/generators/rspec_controller/templates/view_spec.rb +0 -12
  68. data/generators/rspec_default_values.rb +0 -28
  69. data/generators/rspec_model/USAGE +0 -18
  70. data/generators/rspec_model/rspec_model_generator.rb +0 -35
  71. data/generators/rspec_scaffold/rspec_scaffold_generator.rb +0 -154
  72. data/generators/rspec_scaffold/templates/controller_spec.rb +0 -131
  73. data/generators/rspec_scaffold/templates/helper_spec.rb +0 -11
  74. data/init.rb +0 -9
  75. data/lib/autotest/discover.rb +0 -5
  76. data/lib/autotest/rails_rspec.rb +0 -76
  77. data/lib/spec/rails.rb +0 -26
  78. data/lib/spec/rails/example.rb +0 -48
  79. data/lib/spec/rails/example/assigns_hash_proxy.rb +0 -39
  80. data/lib/spec/rails/example/controller_example_group.rb +0 -285
  81. data/lib/spec/rails/example/cookies_proxy.rb +0 -29
  82. data/lib/spec/rails/example/functional_example_group.rb +0 -106
  83. data/lib/spec/rails/example/helper_example_group.rb +0 -153
  84. data/lib/spec/rails/example/integration_example_group.rb +0 -16
  85. data/lib/spec/rails/example/model_example_group.rb +0 -15
  86. data/lib/spec/rails/example/render_observer.rb +0 -80
  87. data/lib/spec/rails/example/routing_example_group.rb +0 -16
  88. data/lib/spec/rails/example/routing_helpers.rb +0 -66
  89. data/lib/spec/rails/example/view_example_group.rb +0 -203
  90. data/lib/spec/rails/extensions.rb +0 -11
  91. data/lib/spec/rails/extensions/action_controller/rescue.rb +0 -42
  92. data/lib/spec/rails/extensions/action_controller/test_case.rb +0 -16
  93. data/lib/spec/rails/extensions/action_controller/test_response.rb +0 -21
  94. data/lib/spec/rails/extensions/action_view/base.rb +0 -35
  95. data/lib/spec/rails/extensions/active_record/base.rb +0 -45
  96. data/lib/spec/rails/extensions/active_support/test_case.rb +0 -7
  97. data/lib/spec/rails/extensions/spec/matchers/have.rb +0 -23
  98. data/lib/spec/rails/extensions/spec/runner/configuration.rb +0 -45
  99. data/lib/spec/rails/interop/testcase.rb +0 -14
  100. data/lib/spec/rails/matchers.rb +0 -32
  101. data/lib/spec/rails/matchers/ar_be_valid.rb +0 -27
  102. data/lib/spec/rails/matchers/assert_select.rb +0 -180
  103. data/lib/spec/rails/matchers/change.rb +0 -13
  104. data/lib/spec/rails/matchers/have_text.rb +0 -57
  105. data/lib/spec/rails/matchers/include_text.rb +0 -54
  106. data/lib/spec/rails/matchers/redirect_to.rb +0 -126
  107. data/lib/spec/rails/matchers/render_template.rb +0 -129
  108. data/lib/spec/rails/matchers/route_to.rb +0 -149
  109. data/lib/spec/rails/mocks.rb +0 -140
  110. data/lib/spec/rails/version.rb +0 -16
  111. data/spec/autotest/mappings_spec.rb +0 -86
  112. data/spec/rails_suite.rb +0 -7
  113. data/spec/resources/controllers/action_view_base_spec_controller.rb +0 -2
  114. data/spec/resources/controllers/application.rb +0 -9
  115. data/spec/resources/controllers/controller_spec_controller.rb +0 -127
  116. data/spec/resources/controllers/example.txt +0 -1
  117. data/spec/resources/controllers/redirect_spec_controller.rb +0 -70
  118. data/spec/resources/controllers/render_spec_controller.rb +0 -34
  119. data/spec/resources/controllers/rjs_spec_controller.rb +0 -58
  120. data/spec/resources/helpers/addition_helper.rb +0 -5
  121. data/spec/resources/helpers/explicit_helper.rb +0 -46
  122. data/spec/resources/helpers/more_explicit_helper.rb +0 -5
  123. data/spec/resources/helpers/plugin_application_helper.rb +0 -6
  124. data/spec/resources/helpers/view_spec_helper.rb +0 -13
  125. data/spec/resources/models/animal.rb +0 -4
  126. data/spec/resources/models/person.rb +0 -18
  127. data/spec/resources/models/thing.rb +0 -3
  128. data/spec/resources/views/controller_spec/_partial.html.erb +0 -0
  129. data/spec/resources/views/controller_spec/action_setting_flash_after_session_reset.html.erb +0 -1
  130. data/spec/resources/views/controller_spec/action_setting_flash_before_session_reset.html.erb +0 -1
  131. data/spec/resources/views/controller_spec/action_setting_the_assigns_hash.html.erb +0 -0
  132. data/spec/resources/views/controller_spec/action_with_errors_in_template.html.erb +0 -1
  133. data/spec/resources/views/controller_spec/action_with_template.html.erb +0 -1
  134. data/spec/resources/views/controller_spec/non_existent_action_with_existent_template.html.erb +0 -1
  135. data/spec/resources/views/layouts/application.html.erb +0 -0
  136. data/spec/resources/views/layouts/simple.html.erb +0 -0
  137. data/spec/resources/views/objects/_object.html.erb +0 -1
  138. data/spec/resources/views/render_spec/_a_partial.html.erb +0 -0
  139. data/spec/resources/views/render_spec/action_with_alternate_layout.html.erb +0 -0
  140. data/spec/resources/views/render_spec/some_action.html.erb +0 -0
  141. data/spec/resources/views/render_spec/some_action.js.rjs +0 -1
  142. data/spec/resources/views/rjs_spec/_replacement_partial.html.erb +0 -1
  143. data/spec/resources/views/rjs_spec/hide_div.js.rjs +0 -1
  144. data/spec/resources/views/rjs_spec/hide_page_element.js.rjs +0 -1
  145. data/spec/resources/views/rjs_spec/insert_html.js.rjs +0 -1
  146. data/spec/resources/views/rjs_spec/replace.js.rjs +0 -1
  147. data/spec/resources/views/rjs_spec/replace_html.js.rjs +0 -1
  148. data/spec/resources/views/rjs_spec/replace_html_with_partial.js.rjs +0 -1
  149. data/spec/resources/views/rjs_spec/visual_effect.js.rjs +0 -1
  150. data/spec/resources/views/rjs_spec/visual_toggle_effect.js.rjs +0 -1
  151. data/spec/resources/views/tag_spec/no_tags.html.erb +0 -1
  152. data/spec/resources/views/tag_spec/single_div_with_no_attributes.html.erb +0 -1
  153. data/spec/resources/views/tag_spec/single_div_with_one_attribute.html.erb +0 -1
  154. data/spec/resources/views/view_spec/_partial.html.erb +0 -2
  155. data/spec/resources/views/view_spec/_partial_used_twice.html.erb +0 -0
  156. data/spec/resources/views/view_spec/_partial_with_local_variable.html.erb +0 -1
  157. data/spec/resources/views/view_spec/_partial_with_sub_partial.html.erb +0 -1
  158. data/spec/resources/views/view_spec/_spacer.html.erb +0 -1
  159. data/spec/resources/views/view_spec/accessor.html.erb +0 -6
  160. data/spec/resources/views/view_spec/block_helper.html.erb +0 -3
  161. data/spec/resources/views/view_spec/entry_form.html.erb +0 -2
  162. data/spec/resources/views/view_spec/explicit_helper.html.erb +0 -2
  163. data/spec/resources/views/view_spec/foo/show.html.erb +0 -1
  164. data/spec/resources/views/view_spec/implicit_helper.html.erb +0 -2
  165. data/spec/resources/views/view_spec/multiple_helpers.html.erb +0 -3
  166. data/spec/resources/views/view_spec/path_params.html.erb +0 -1
  167. data/spec/resources/views/view_spec/should_not_receive.html.erb +0 -3
  168. data/spec/resources/views/view_spec/template_with_partial.html.erb +0 -5
  169. data/spec/resources/views/view_spec/template_with_partial_using_collection.html.erb +0 -3
  170. data/spec/resources/views/view_spec/template_with_partial_with_array.html.erb +0 -1
  171. data/spec/resources/views/view_spec/view_helpers.html.erb +0 -1
  172. data/spec/spec/rails/example/assigns_hash_proxy_spec.rb +0 -109
  173. data/spec/spec/rails/example/configuration_spec.rb +0 -67
  174. data/spec/spec/rails/example/controller_example_group_spec.rb +0 -307
  175. data/spec/spec/rails/example/controller_isolation_spec.rb +0 -75
  176. data/spec/spec/rails/example/cookies_proxy_spec.rb +0 -87
  177. data/spec/spec/rails/example/error_handling_spec.rb +0 -90
  178. data/spec/spec/rails/example/example_group_factory_spec.rb +0 -112
  179. data/spec/spec/rails/example/helper_example_group_spec.rb +0 -247
  180. data/spec/spec/rails/example/model_example_group_spec.rb +0 -32
  181. data/spec/spec/rails/example/routing_example_group_spec.rb +0 -9
  182. data/spec/spec/rails/example/shared_routing_example_group_examples.rb +0 -237
  183. data/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb +0 -33
  184. data/spec/spec/rails/example/view_example_group_spec.rb +0 -346
  185. data/spec/spec/rails/extensions/action_view_base_spec.rb +0 -79
  186. data/spec/spec/rails/extensions/active_record_spec.rb +0 -14
  187. data/spec/spec/rails/interop/testcase_spec.rb +0 -70
  188. data/spec/spec/rails/matchers/ar_be_valid_spec.rb +0 -19
  189. data/spec/spec/rails/matchers/assert_select_spec.rb +0 -835
  190. data/spec/spec/rails/matchers/errors_on_spec.rb +0 -37
  191. data/spec/spec/rails/matchers/have_text_spec.rb +0 -69
  192. data/spec/spec/rails/matchers/include_text_spec.rb +0 -62
  193. data/spec/spec/rails/matchers/redirect_to_spec.rb +0 -253
  194. data/spec/spec/rails/matchers/render_template_spec.rb +0 -208
  195. data/spec/spec/rails/matchers/should_change_spec.rb +0 -15
  196. data/spec/spec/rails/mocks/ar_classes.rb +0 -10
  197. data/spec/spec/rails/mocks/mock_model_spec.rb +0 -112
  198. data/spec/spec/rails/mocks/stub_model_spec.rb +0 -80
  199. data/spec/spec/rails/sample_modified_fixture.rb +0 -8
  200. data/spec/spec/rails/sample_spec.rb +0 -8
  201. data/spec/spec/rails/spec_spec.rb +0 -11
  202. data/spec/spec_helper.rb +0 -78
@@ -1,79 +0,0 @@
1
- require 'spec_helper'
2
- require 'spec/mocks/errors'
3
-
4
- describe ActionView::Base, "with RSpec extensions:", :type => :view do
5
-
6
- describe "should_receive(:render)" do
7
- it "should not raise when render has been received" do
8
- template.should_receive(:render).with(:partial => "name")
9
- template.render :partial => "name"
10
- end
11
-
12
- it "should not raise when render with local assignments has been received" do
13
- template.should_receive(:render).with('name', :param => 1)
14
- template.render 'name', :param => 1
15
- end
16
-
17
- it "should raise when render has NOT been received" do
18
- template.should_receive(:render).with(:partial => "name")
19
- lambda {
20
- template.verify_rendered
21
- }.should raise_error
22
- end
23
-
24
- it "should return something (like a normal mock)" do
25
- template.should_receive(:render).with(:partial => "name").and_return("Little Johnny")
26
- result = template.render :partial => "name"
27
- result.should == "Little Johnny"
28
- end
29
- end
30
-
31
- [:stub!, :stub].each do |method|
32
- describe "#{method}(:render)" do
33
- it "should not raise when stubbing and render has been received" do
34
- template.send(method, :render).with(:partial => "name")
35
- template.render :partial => "name"
36
- end
37
-
38
- it "should not raise when stubbing and render has NOT been received" do
39
- template.send(method, :render).with(:partial => "name")
40
- end
41
-
42
- it "should not raise when stubbing and render has been received with different options" do
43
- template.send(method, :render).with(:partial => "name")
44
- template.render :partial => "view_spec/spacer"
45
- end
46
-
47
- it "should not raise when stubbing and expecting and render has been received" do
48
- template.send(method, :render).with(:partial => "name")
49
- template.should_receive(:render).with(:partial => "name")
50
- template.render(:partial => "name")
51
- end
52
- end
53
-
54
- describe "#{method}(:helper_method)" do
55
- it "should not raise when stubbing and helper_method has been received" do
56
- template.send(method, :helper_method).with(:arg => "value")
57
- template.helper_method :arg => "value"
58
- end
59
-
60
- it "should not raise when stubbing and helper_method has NOT been received" do
61
- template.send(method, :helper_method).with(:arg => "value")
62
- end
63
-
64
- it "SHOULD raise when stubbing and helper_method has been received with different options" do
65
- template.send(method, :helper_method).with(:arg => "value")
66
- expect { template.helper_method :arg => "other_value" }.
67
- to raise_error(/undefined .* `helper_method'/)
68
- end
69
-
70
- it "should not raise when stubbing and expecting and helper_method has been received" do
71
- template.send(method, :helper_method).with(:arg => "value")
72
- template.should_receive(:helper_method).with(:arg => "value")
73
- template.helper_method(:arg => "value")
74
- end
75
- end
76
-
77
- end
78
-
79
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "A model" do
4
- fixtures :things
5
- it "should tell you its required fields" do
6
- Thing.new.should have(1).error_on(:name)
7
- end
8
-
9
- it "should tell you how many records it has" do
10
- Thing.should have(:no).records
11
- Thing.create(:name => "THE THING")
12
- Thing.should have(1).record
13
- end
14
- end
@@ -1,70 +0,0 @@
1
- require 'spec_helper'
2
-
3
-
4
- if ActiveSupport.const_defined?(:Callbacks) && Test::Unit::TestCase.include?(ActiveSupport::Callbacks)
5
-
6
- class TestUnitTesting < Test::Unit::TestCase
7
- @@setup_callback_count = 0
8
- @@setup_method_count = 0
9
- @@teardown_callback_count = 0
10
- @@teardown_method_count = 0
11
- cattr_accessor :setup_callback_count, :setup_method_count, :teardown_callback_count, :teardown_method_count
12
-
13
- setup :do_some_setup
14
- teardown :do_some_teardown
15
-
16
- @@has_been_run = false
17
- def self.run?
18
- @@has_been_run
19
- end
20
-
21
- def self.run(options=Spec::Runner.options)
22
- super options
23
- end
24
-
25
- def do_some_setup
26
- @@setup_callback_count += 1
27
- end
28
-
29
- def setup
30
- @@setup_method_count += 1
31
- end
32
-
33
- def test_something
34
- assert_equal true, true
35
- @@has_been_run = true
36
- end
37
-
38
- def teardown
39
- @@teardown_method_count += 1
40
- end
41
-
42
- def do_some_teardown
43
- @@teardown_callback_count += 1
44
- end
45
- end
46
-
47
- module Test
48
- module Unit
49
- describe "Running TestCase tests" do
50
- before(:all) do
51
- TestUnitTesting.run unless TestUnitTesting.run?
52
- end
53
-
54
- it "should call the setup callbacks" do
55
- TestUnitTesting.setup_callback_count.should == 1
56
- end
57
- it "should still only call the normal setup method once" do
58
- TestUnitTesting.setup_method_count.should == 1
59
- end
60
- it "should call the teardown callbacks" do
61
- TestUnitTesting.teardown_callback_count.should == 1
62
- end
63
- it "should still only call the normal teardown method once" do
64
- TestUnitTesting.teardown_method_count.should == 1
65
- end
66
- end
67
- end
68
- end
69
-
70
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "be_valid" do
4
- context "with valid attributes" do
5
- it "returns true" do
6
- be_valid.matches?(Thing.new(:name => 'thing')).should == true
7
- end
8
- end
9
-
10
- context "with invalid attributes" do
11
- it "returns false" do
12
- be_valid.matches?(Thing.new).should == false
13
- end
14
-
15
- it "adds errors to the errors " do
16
- expect { Thing.new.should be_valid }.to raise_error(/can't be blank/)
17
- end
18
- end
19
- end
@@ -1,835 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # assert_select plugins for Rails
4
- #
5
- # Copyright (c) 2006 Assaf Arkin, under Creative Commons Attribution and/or MIT License
6
- # Developed for http://co.mments.com
7
- # Code and documention: http://labnotes.org
8
-
9
- class AssertSelectController < ActionController::Base
10
-
11
- def response=(content)
12
- @content = content
13
- end
14
-
15
- def html()
16
- render :text=>@content, :layout=>false, :content_type=>Mime::HTML
17
- @content = nil
18
- end
19
-
20
- def rjs()
21
- update = @update
22
- render :update do |page|
23
- update.call page
24
- end
25
- @update = nil
26
- end
27
-
28
- def xml()
29
- render :text=>@content, :layout=>false, :content_type=>Mime::XML
30
- @content = nil
31
- end
32
-
33
- end
34
-
35
- class AssertSelectMailer < ActionMailer::Base
36
-
37
- def test(html)
38
- recipients "test <test@test.host>"
39
- from "test@test.host"
40
- subject "Test e-mail"
41
- part :content_type=>"text/html", :body=>html
42
- end
43
-
44
- end
45
-
46
- module AssertSelectSpecHelpers
47
- def render_html(html)
48
- @controller.response = html
49
- get :html
50
- end
51
-
52
- def render_rjs(&block)
53
- clear_response
54
- @controller.response &block
55
- get :rjs
56
- end
57
-
58
- def render_xml(xml)
59
- @controller.response = xml
60
- get :xml
61
- end
62
-
63
- def first_non_rspec_line_in_backtrace_of(error)
64
- rlocation = File.join('rspec', 'lib', 'spec')
65
- error.backtrace.reject { |line|
66
- line =~ /#{rlocation}/
67
- }.first
68
- end
69
-
70
- private
71
- # necessary for 1.2.1
72
- def clear_response
73
- render_html("")
74
- end
75
- end
76
-
77
- unless defined?(SpecFailed)
78
- SpecFailed = Spec::Expectations::ExpectationNotMetError
79
- end
80
-
81
- describe "should have_tag", :type => :controller do
82
- include AssertSelectSpecHelpers
83
- controller_name :assert_select
84
- integrate_views
85
-
86
- it "should not care about the XML setting on HTML with unclosed singletons when using a response" do
87
- render_html %Q{<table id="1"><tr><td><img src="image.png" alt="image">Hello</td></tr><tr><td></td></tr><tr><td>World</td></tr></table>}
88
- response.should have_tag("tr", 3)
89
- response.should have_tag("tr", 3, :xml => true)
90
- end
91
-
92
- it "should find specific numbers of elements" do
93
- render_html %Q{<div id="1"></div><div id="2"></div>}
94
- response.should have_tag( "div" )
95
- response.should have_tag("div", 2)
96
- lambda { response.should_not have_tag("div") }.should raise_error(SpecFailed, "should not have tag(\"div\"), but did")
97
-
98
- lambda { response.should have_tag("div", 3) }.should raise_error(SpecFailed)
99
- lambda { response.should have_tag("p") }.should raise_error(SpecFailed)
100
- end
101
-
102
- it "should expect to find elements when using true" do
103
- render_html %Q{<div id="1"></div><div id="2"></div>}
104
- response.should have_tag( "div", true )
105
- lambda { response.should have_tag( "p", true )}.should raise_error(SpecFailed)
106
- end
107
-
108
- it "should expect to not find elements when using false" do
109
- render_html %Q{<div id="1"></div><div id="2"></div>}
110
- response.should have_tag( "p", false )
111
- lambda { response.should have_tag( "div", false )}.should raise_error(SpecFailed)
112
- end
113
-
114
-
115
- it "should match submitted text using text or regexp" do
116
- render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
117
- response.should have_tag("div", "foo")
118
- response.should have_tag("div", /(foo|bar)/)
119
- response.should have_tag("div", :text=>"foo")
120
- response.should have_tag("div", :text=>/(foo|bar)/)
121
-
122
- lambda { response.should have_tag("div", "bar") }.should raise_error(SpecFailed)
123
- lambda { response.should have_tag("div", :text=>"bar") }.should raise_error(SpecFailed)
124
- lambda { response.should have_tag("p", :text=>"foo") }.should raise_error(SpecFailed)
125
-
126
- lambda { response.should have_tag("div", /foobar/) }.should raise_error(SpecFailed)
127
- lambda { response.should have_tag("div", :text=>/foobar/) }.should raise_error(SpecFailed)
128
- lambda { response.should have_tag("p", :text=>/foo/) }.should raise_error(SpecFailed)
129
- end
130
-
131
- it "should use submitted message" do
132
- render_html %Q{nothing here}
133
- lambda {
134
- response.should have_tag("div", {}, "custom message")
135
- }.should raise_error(SpecFailed, /custom message/)
136
- end
137
-
138
- it "should match submitted html" do
139
- render_html %Q{<p>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</p>}
140
- text = "\"This is not a big problem,\" he said."
141
- html = "<em>\"This is <strong>not</strong> a big problem,\"</em> he said."
142
- response.should have_tag("p", text)
143
- lambda { response.should have_tag("p", html) }.should raise_error(SpecFailed)
144
- response.should have_tag("p", :html=>html)
145
- lambda { response.should have_tag("p", :html=>text) }.should raise_error(SpecFailed)
146
-
147
- # # No stripping for pre.
148
- render_html %Q{<pre>\n<em>"This is <strong>not</strong> a big problem,"</em> he said.\n</pre>}
149
- text = "\n\"This is not a big problem,\" he said.\n"
150
- html = "\n<em>\"This is <strong>not</strong> a big problem,\"</em> he said.\n"
151
- response.should have_tag("pre", text)
152
- lambda { response.should have_tag("pre", html) }.should raise_error(SpecFailed)
153
- response.should have_tag("pre", :html=>html)
154
- lambda { response.should have_tag("pre", :html=>text) }.should raise_error(SpecFailed)
155
- end
156
-
157
- it "should match number of instances" do
158
- render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
159
- response.should have_tag("div", 2)
160
- lambda { response.should have_tag("div", 3) }.should raise_error(SpecFailed)
161
- response.should have_tag("div", 1..2)
162
- lambda { response.should have_tag("div", 3..4) }.should raise_error(SpecFailed)
163
- response.should have_tag("div", :count=>2)
164
- lambda { response.should have_tag("div", :count=>3) }.should raise_error(SpecFailed)
165
- response.should have_tag("div", :minimum=>1)
166
- response.should have_tag("div", :minimum=>2)
167
- lambda { response.should have_tag("div", :minimum=>3) }.should raise_error(SpecFailed)
168
- response.should have_tag("div", :maximum=>2)
169
- response.should have_tag("div", :maximum=>3)
170
- lambda { response.should have_tag("div", :maximum=>1) }.should raise_error(SpecFailed)
171
- response.should have_tag("div", :minimum=>1, :maximum=>2)
172
- lambda { response.should have_tag("div", :minimum=>3, :maximum=>4) }.should raise_error(SpecFailed)
173
- end
174
-
175
- it "substitution values" do
176
- render_html %Q{<div id="1">foo</div><div id="2">foo</div><span id="3"></span>}
177
- response.should have_tag("div#?", /\d+/) do |elements| #using do/end
178
- elements.size.should == 2
179
- end
180
- response.should have_tag("div#?", /\d+/) { |elements| #using {}
181
- elements.size.should == 2
182
- }
183
- lambda {
184
- response.should have_tag("div#?", /\d+/) do |elements|
185
- elements.size.should == 3
186
- end
187
- }.should raise_error(SpecFailed, "expected: 3,\n got: 2 (using ==)")
188
-
189
- lambda {
190
- response.should have_tag("div#?", /\d+/) { |elements|
191
- elements.size.should == 3
192
- }
193
- }.should raise_error(SpecFailed, "expected: 3,\n got: 2 (using ==)")
194
-
195
- response.should have_tag("div#?", /\d+/) do |elements|
196
- elements.size.should == 2
197
- with_tag("#1")
198
- with_tag("#2")
199
- without_tag("#3")
200
- end
201
- end
202
-
203
- #added for RSpec
204
- it "nested tags in form" do
205
- render_html %Q{
206
- <form action="test">
207
- <input type="text" name="email">
208
- </form>
209
- <form action="other">
210
- <input type="text" name="other_input">
211
- </form>
212
- }
213
- response.should have_tag("form[action=test]") { |form|
214
- with_tag("input[type=text][name=email]")
215
- }
216
- response.should have_tag("form[action=other]") { |form|
217
- with_tag("input[type=text][name=other_input]")
218
- }
219
-
220
- lambda {
221
- response.should have_tag("form[action=test]") { |form|
222
- with_tag("input[type=text][name=other_input]")
223
- }
224
- }.should raise_error(SpecFailed)
225
-
226
- lambda {
227
- response.should have_tag("form[action=test]") {
228
- with_tag("input[type=text][name=other_input]")
229
- }
230
- }.should raise_error(SpecFailed)
231
- end
232
-
233
- it "should report the correct line number for a nested failed expectation" do
234
- render_html %Q{
235
- <form action="test">
236
- <input type="text" name="email">
237
- </form>
238
- }
239
- begin
240
- response.should have_tag("form[action=test]") {
241
- @expected_error_line = __LINE__; should have_tag("input[type=text][name=other_input]")
242
- }
243
- rescue => e
244
- first_non_rspec_line_in_backtrace_of(e).should =~
245
- /#{File.basename(__FILE__)}:#{@expected_error_line}/
246
- else
247
- fail
248
- end
249
- end
250
-
251
- it "should report the correct line number for a nested raised exception" do
252
- render_html %Q{
253
- <form action="test">
254
- <input type="text" name="email">
255
- </form>
256
- }
257
- begin
258
- response.should have_tag("form[action=test]") {
259
- @expected_error_line = __LINE__; raise "Failed!"
260
- }
261
- rescue => e
262
- first_non_rspec_line_in_backtrace_of(e).should =~
263
- /#{File.basename(__FILE__)}:#{@expected_error_line}/
264
- else
265
- fail
266
- end
267
- end
268
-
269
- it "should report the correct line number for a nested failed test/unit assertion" do
270
- pending "Doesn't work at the moment. Do we want to support this?" do
271
- render_html %Q{
272
- <form action="test">
273
- <input type="text" name="email">
274
- </form>
275
- }
276
- begin
277
- response.should have_tag("form[action=test]") {
278
- @expected_error_line = __LINE__; assert false
279
- }
280
- rescue => e
281
- first_non_rspec_line_in_backtrace_of(e).should =~
282
- /#{File.basename(__FILE__)}:#{@expected_error_line}/
283
- else
284
- fail
285
- end
286
- end
287
- end
288
-
289
-
290
- it "beatles" do
291
- unless defined?(BEATLES)
292
- BEATLES = [
293
- ["John", "Guitar"],
294
- ["George", "Guitar"],
295
- ["Paul", "Bass"],
296
- ["Ringo", "Drums"]
297
- ]
298
- end
299
-
300
- render_html %Q{
301
- <div id="beatles">
302
- <div class="beatle">
303
- <h2>John</h2><p>Guitar</p>
304
- </div>
305
- <div class="beatle">
306
- <h2>George</h2><p>Guitar</p>
307
- </div>
308
- <div class="beatle">
309
- <h2>Paul</h2><p>Bass</p>
310
- </div>
311
- <div class="beatle">
312
- <h2>Ringo</h2><p>Drums</p>
313
- </div>
314
- </div>
315
- }
316
- response.should have_tag("div#beatles>div[class=\"beatle\"]", 4)
317
-
318
- response.should have_tag("div#beatles>div.beatle") {
319
- BEATLES.each { |name, instrument|
320
- with_tag("div.beatle>h2", name)
321
- with_tag("div.beatle>p", instrument)
322
- without_tag("div.beatle>span")
323
- }
324
- }
325
- end
326
-
327
- it "assert_select_text_match" do
328
- render_html %Q{<div id="1"><span>foo</span></div><div id="2"><span>bar</span></div>}
329
- response.should have_tag("div") do |divs|
330
- with_tag("div", "foo")
331
- with_tag("div", "bar")
332
- with_tag("div", /\w*/)
333
- with_tag("div", /\w*/, :count=>2)
334
- without_tag("div", :text=>"foo", :count=>2)
335
- with_tag("div", :html=>"<span>bar</span>")
336
- with_tag("div", :html=>"<span>bar</span>")
337
- with_tag("div", :html=>/\w*/)
338
- with_tag("div", :html=>/\w*/, :count=>2)
339
- without_tag("div", :html=>"<span>foo</span>", :count=>2)
340
- end
341
- end
342
-
343
-
344
- it "assert_select_from_rjs with one item" do
345
- render_rjs do |page|
346
- page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
347
- end
348
- response.should have_tag("div") { |elements|
349
- elements.size.should == 2
350
- with_tag("#1")
351
- with_tag("#2")
352
- }
353
-
354
- lambda {
355
- response.should have_tag("div") { |elements|
356
- elements.size.should == 2
357
- with_tag("#1")
358
- with_tag("#3")
359
- }
360
- }.should raise_error(SpecFailed)
361
-
362
- lambda {
363
- response.should have_tag("div") { |elements|
364
- elements.size.should == 2
365
- with_tag("#1")
366
- without_tag("#2")
367
- }
368
- }.should raise_error(SpecFailed, "should not have tag(\"#2\"), but did")
369
-
370
- lambda {
371
- response.should have_tag("div") { |elements|
372
- elements.size.should == 3
373
- with_tag("#1")
374
- with_tag("#2")
375
- }
376
- }.should raise_error(SpecFailed)
377
-
378
-
379
- response.should have_tag("div#?", /\d+/) { |elements|
380
- with_tag("#1")
381
- with_tag("#2")
382
- }
383
- end
384
-
385
- it "assert_select_from_rjs with multiple items" do
386
- render_rjs do |page|
387
- page.replace_html "test", "<div id=\"1\">foo</div>"
388
- page.replace_html "test2", "<div id=\"2\">foo</div>"
389
- end
390
- response.should have_tag("div")
391
- response.should have_tag("div") { |elements|
392
- elements.size.should == 2
393
- with_tag("#1")
394
- with_tag("#2")
395
- }
396
-
397
- lambda {
398
- response.should have_tag("div") { |elements|
399
- with_tag("#3")
400
- }
401
- }.should raise_error(SpecFailed)
402
- end
403
- end
404
-
405
- describe "css_select", :type => :controller do
406
- include AssertSelectSpecHelpers
407
- controller_name :assert_select
408
- integrate_views
409
-
410
- it "can select tags from html" do
411
- render_html %Q{<div id="1"></div><div id="2"></div>}
412
- css_select("div").size.should == 2
413
- css_select("p").size.should == 0
414
- end
415
-
416
-
417
- it "can select nested tags from html" do
418
- render_html %Q{<div id="1">foo</div><div id="2">foo</div>}
419
- response.should have_tag("div#?", /\d+/) { |elements|
420
- css_select(elements[0], "div").should have(1).element
421
- css_select(elements[1], "div").should have(1).element
422
- }
423
- response.should have_tag("div") {
424
- css_select("div").should have(2).elements
425
- css_select("div").each { |element|
426
- # Testing as a group is one thing
427
- css_select("#1,#2").should have(2).elements
428
- # Testing individually is another
429
- css_select("#1").should have(1).element
430
- css_select("#2").should have(1).element
431
- }
432
- }
433
- end
434
-
435
- it "can select nested tags from rjs (one result)" do
436
- render_rjs do |page|
437
- page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
438
- end
439
- css_select("div").should have(2).elements
440
- css_select("#1").should have(1).element
441
- css_select("#2").should have(1).element
442
- end
443
-
444
- it "can select nested tags from rjs (two results)" do
445
- render_rjs do |page|
446
- page.replace_html "test", "<div id=\"1\">foo</div>"
447
- page.replace_html "test2", "<div id=\"2\">foo</div>"
448
- end
449
- css_select("div").should have(2).elements
450
- css_select("#1").should have(1).element
451
- css_select("#2").should have(1).element
452
- end
453
-
454
- end
455
-
456
- describe "have_rjs behaviour_type", :type => :controller do
457
- include AssertSelectSpecHelpers
458
- controller_name :assert_select
459
- integrate_views
460
-
461
- before(:each) do
462
- render_rjs do |page|
463
- page.replace "test1", "<div id=\"1\">foo</div>"
464
- page.replace_html "test2", "<div id=\"2\">bar</div><div id=\"3\">none</div>"
465
- page.insert_html :top, "test3", "<div id=\"4\">loopy</div>"
466
- page.hide "test4"
467
- page["test5"].hide
468
- end
469
- end
470
-
471
- it "should pass if any rjs exists" do
472
- response.should have_rjs
473
- end
474
-
475
- it "should fail if no rjs exists" do
476
- render_rjs do |page|
477
- end
478
- lambda do
479
- response.should have_rjs
480
- end.should raise_error(SpecFailed)
481
- end
482
-
483
- it "should find all rjs from multiple statements" do
484
- response.should have_rjs do
485
- with_tag("#1")
486
- with_tag("#2")
487
- with_tag("#3")
488
- with_tag("#4")
489
- end
490
- end
491
-
492
- it "should find by id" do
493
- response.should have_rjs("test1") { |rjs|
494
- rjs.size.should == 1
495
- with_tag("div", 1)
496
- with_tag("div#1", "foo")
497
- }
498
-
499
- lambda do
500
- response.should have_rjs("test1") { |rjs|
501
- rjs.size.should == 1
502
- without_tag("div#1", "foo")
503
- }
504
- end.should raise_error(SpecFailed, "should not have tag(\"div#1\", \"foo\"), but did")
505
-
506
- response.should have_rjs("test2") { |rjs|
507
- rjs.size.should == 2
508
- with_tag("div", 2)
509
- with_tag("div#2", "bar")
510
- with_tag("div#3", "none")
511
- }
512
- # response.should have_rjs("test4")
513
- # response.should have_rjs("test5")
514
- end
515
-
516
- # specify "should find rjs using :hide" do
517
- # response.should have_rjs(:hide)
518
- # response.should have_rjs(:hide, "test4")
519
- # response.should have_rjs(:hide, "test5")
520
- # lambda do
521
- # response.should have_rjs(:hide, "test3")
522
- # end.should raise_error(SpecFailed)
523
- # end
524
-
525
- it "should find rjs using :replace" do
526
- response.should have_rjs(:replace) { |rjs|
527
- with_tag("div", 1)
528
- with_tag("div#1", "foo")
529
- }
530
- response.should have_rjs(:replace, "test1") { |rjs|
531
- with_tag("div", 1)
532
- with_tag("div#1", "foo")
533
- }
534
- lambda {
535
- response.should have_rjs(:replace, "test2")
536
- }.should raise_error(SpecFailed)
537
-
538
- lambda {
539
- response.should have_rjs(:replace, "test3")
540
- }.should raise_error(SpecFailed)
541
- end
542
-
543
- it "should find rjs using :replace_html" do
544
- response.should have_rjs(:replace_html) { |rjs|
545
- with_tag("div", 2)
546
- with_tag("div#2", "bar")
547
- with_tag("div#3", "none")
548
- }
549
-
550
- response.should have_rjs(:replace_html, "test2") { |rjs|
551
- with_tag("div", 2)
552
- with_tag("div#2", "bar")
553
- with_tag("div#3", "none")
554
- }
555
-
556
- lambda {
557
- response.should have_rjs(:replace_html, "test1")
558
- }.should raise_error(SpecFailed)
559
-
560
- lambda {
561
- response.should have_rjs(:replace_html, "test3")
562
- }.should raise_error(SpecFailed)
563
- end
564
-
565
- it "should find rjs using :insert_html (non-positioned)" do
566
- response.should have_rjs(:insert_html) { |rjs|
567
- with_tag("div", 1)
568
- with_tag("div#4", "loopy")
569
- }
570
-
571
- response.should have_rjs(:insert_html, "test3") { |rjs|
572
- with_tag("div", 1)
573
- with_tag("div#4", "loopy")
574
- }
575
-
576
- lambda {
577
- response.should have_rjs(:insert_html, "test1")
578
- }.should raise_error(SpecFailed)
579
-
580
- lambda {
581
- response.should have_rjs(:insert_html, "test2")
582
- }.should raise_error(SpecFailed)
583
- end
584
-
585
- it "should find rjs using :insert (positioned)" do
586
- render_rjs do |page|
587
- page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
588
- page.insert_html :bottom, "test2", "<div id=\"2\">bar</div>"
589
- page.insert_html :before, "test3", "<div id=\"3\">none</div>"
590
- page.insert_html :after, "test4", "<div id=\"4\">loopy</div>"
591
- end
592
- response.should have_rjs(:insert, :top) do
593
- with_tag("div", 1)
594
- with_tag("#1")
595
- end
596
- response.should have_rjs(:insert, :top, "test1") do
597
- with_tag("div", 1)
598
- with_tag("#1")
599
- end
600
- response.should have_rjs(:insert, :bottom) {|rjs|
601
- with_tag("div", 1)
602
- with_tag("#2")
603
- }
604
- response.should have_rjs(:insert, :bottom, "test2") {|rjs|
605
- with_tag("div", 1)
606
- with_tag("#2")
607
- }
608
- response.should have_rjs(:insert, :before) {|rjs|
609
- with_tag("div", 1)
610
- with_tag("#3")
611
- }
612
- response.should have_rjs(:insert, :before, "test3") {|rjs|
613
- with_tag("div", 1)
614
- with_tag("#3")
615
- }
616
- response.should have_rjs(:insert, :after) {|rjs|
617
- with_tag("div", 1)
618
- with_tag("#4")
619
- }
620
- response.should have_rjs(:insert, :after, "test4") {|rjs|
621
- with_tag("div", 1)
622
- with_tag("#4")
623
- }
624
- end
625
-
626
- it "should find rjs using :insert (positioned)" do
627
- pending("await fix for http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/982")
628
- render_rjs do |page|
629
- page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
630
- page.insert_html :bottom, "test2", "<div id=\"2\">bar</div>"
631
- end
632
- lambda {
633
- response.should have_rjs(:insert, :top, "test2")
634
- }.should raise_error(SpecFailed)
635
- end
636
- end
637
-
638
- describe "send_email behaviour_type", :type => :controller do
639
- include AssertSelectSpecHelpers
640
- controller_name :assert_select
641
- integrate_views
642
-
643
- before(:each) do
644
- ActionMailer::Base.delivery_method = :test
645
- ActionMailer::Base.perform_deliveries = true
646
- ActionMailer::Base.deliveries = []
647
- end
648
-
649
- after(:each) do
650
- ActionMailer::Base.deliveries.clear
651
- end
652
-
653
- it "should fail with nothing sent" do
654
- response.should_not send_email
655
- lambda {
656
- response.should send_email{}
657
- }.should raise_error(SpecFailed, /No e-mail in delivery list./)
658
- end
659
-
660
- it "should pass otherwise" do
661
- AssertSelectMailer.deliver_test "<div><p>foo</p><p>bar</p></div>"
662
- response.should send_email
663
- lambda {
664
- response.should_not send_email
665
- }.should raise_error(SpecFailed)
666
- response.should send_email{}
667
- response.should send_email {
668
- with_tag("div:root") {
669
- with_tag("p:first-child", "foo")
670
- with_tag("p:last-child", "bar")
671
- }
672
- }
673
-
674
- lambda {
675
- response.should_not send_email
676
- }.should raise_error(SpecFailed, "should not send email, but did")
677
- end
678
-
679
- end
680
-
681
- describe "string.should have_tag", :type => :helper do
682
- include AssertSelectSpecHelpers
683
-
684
- it "should find root element" do
685
- "<p>a paragraph</p>".should have_tag("p", "a paragraph")
686
- end
687
-
688
- it "should not find non-existent element" do
689
- lambda do
690
- "<p>a paragraph</p>".should have_tag("p", "wrong text")
691
- end.should raise_error(SpecFailed)
692
- end
693
-
694
- it "should find child element" do
695
- "<div><p>a paragraph</p></div>".should have_tag("p", "a paragraph")
696
- end
697
-
698
- it "should find nested element in one line" do
699
- "<div><p>a paragraph</p></div>".should have_tag("div p","a paragraph")
700
- end
701
-
702
- it "should find nested element" do
703
- "<div><p>a paragraph</p></div>".should have_tag("div") do
704
- with_tag("p", "a paragraph")
705
- end
706
- end
707
-
708
- it "should not find wrong nested element" do
709
- lambda do
710
- "<div><p>a paragraph</p></div>".should have_tag("div") do
711
- with_tag("p", "wrong text")
712
- end
713
- end.should raise_error(SpecFailed)
714
- end
715
-
716
- it "should raise when using an HTML string with unclosed singleton tags when using the XML parsing setting" do
717
- lambda do
718
- %Q{<table id="1"><tr><td><img src="image.png" alt="image">Hello</td></tr><tr><td></td></tr><tr><td>World</td></tr></table>}.
719
- should have_tag("tr", 3, :xml => true)
720
- end.should raise_error
721
- end
722
-
723
- it "should find the specific number of elements regardless of unclosed singletons in a HTML string" do
724
- %Q{<table id="1"><tr><td><img src="image.png" alt="image">Hello</td></tr><tr><td></td></tr><tr><td>World</td></tr></table>}.
725
- should have_tag("tr", 3)
726
- end
727
-
728
- it "should find nested tags in an HTML string regardless unclosed singletons" do
729
- %Q{<table id="1"><tr><td><img src="image.png" alt="image">Hello</td></tr><tr><td></td></tr><tr><td>World</td></tr></table>}.
730
- should have_tag("table") do
731
- with_tag('tr',3)
732
- end
733
- end
734
-
735
- end
736
-
737
- describe "have_tag", :type => :controller do
738
- include AssertSelectSpecHelpers
739
- controller_name :assert_select
740
- integrate_views
741
-
742
- it "should work exactly the same as assert_select" do
743
- render_html %Q{
744
- <div id="wrapper">foo
745
- <div class="piece">
746
- <h3>Text</h3>
747
- </div>
748
- <div class="piece">
749
- <h3>Another</h3>
750
- </div>
751
- </div>
752
- }
753
-
754
- assert_select "#wrapper .piece h3", :text => "Text"
755
- assert_select "#wrapper .piece h3", :text => "Another"
756
-
757
- response.should have_tag("#wrapper .piece h3", :text => "Text")
758
- response.should have_tag("#wrapper .piece h3", :text => "Another")
759
- end
760
- end
761
-
762
- describe 'selecting in HTML that contains a mock with null_object' do
763
- include ActionController::Assertions::SelectorAssertions
764
- module HTML
765
- class Document
766
- def initialize_with_strict_error_checking(text, strict=false, xml=false)
767
- initialize_without_strict_error_checking(text, true, xml)
768
- end
769
- alias_method :initialize_without_strict_error_checking, :initialize
770
- alias_method :initialize, :initialize_with_strict_error_checking
771
- end
772
- end
773
-
774
- describe 'modified HTML::Document' do
775
- it 'should raise error on valid HTML even though false is specified' do
776
- lambda {HTML::Document.new("<b>#<Spec::Mocks::Mock:0x267b4f0></b>", false, false)}.should raise_error
777
- end
778
- end
779
-
780
- it 'should not print errors from assert_select' do
781
- mock = mock("Dog", :null_object => true)
782
- html = "<b>#{mock.colour}</b>"
783
- lambda {html.should have_tag('b')}.should_not raise_error
784
- end
785
- end
786
-
787
- # describe "An rjs call to :visual_effect, a 'should have_rjs' spec with",
788
- # :type => :view do
789
- #
790
- # before do
791
- # render 'rjs_spec/visual_effect'
792
- # end
793
- #
794
- # it "should pass with the correct element name" do
795
- # response.should have_rjs(:effect, :fade, 'mydiv')
796
- # end
797
- #
798
- # it "should fail the wrong element name" do
799
- # lambda {
800
- # response.should have_rjs(:effect, :fade, 'wrongname')
801
- # }.should raise_error(SpecFailed)
802
- # end
803
- #
804
- # it "should fail with the correct element but the wrong command" do
805
- # lambda {
806
- # response.should have_rjs(:effect, :puff, 'mydiv')
807
- # }.should raise_error(SpecFailed)
808
- # end
809
- #
810
- # end
811
- #
812
- # describe "An rjs call to :visual_effect for a toggle, a 'should have_rjs' spec with",
813
- # :type => :view do
814
- #
815
- # before do
816
- # render 'rjs_spec/visual_toggle_effect'
817
- # end
818
- #
819
- # it "should pass with the correct element name" do
820
- # response.should have_rjs(:effect, :toggle_blind, 'mydiv')
821
- # end
822
- #
823
- # it "should fail with the wrong element name" do
824
- # lambda {
825
- # response.should have_rjs(:effect, :toggle_blind, 'wrongname')
826
- # }.should raise_error(SpecFailed)
827
- # end
828
- #
829
- # it "should fail the correct element but the wrong command" do
830
- # lambda {
831
- # response.should have_rjs(:effect, :puff, 'mydiv')
832
- # }.should raise_error(SpecFailed)
833
- # end
834
- #
835
- # end