prototype-rails 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +20 -0
- data/{README → README.md} +12 -0
- data/Rakefile +2 -0
- data/lib/prototype-rails/on_load_action_view.rb +5 -3
- metadata +15 -46
- data/test/assert_select_test.rb +0 -457
- data/test/controller/caching_test.rb +0 -43
- data/test/controller/content_type_test.rb +0 -16
- data/test/controller/mime_responds_test.rb +0 -213
- data/test/controller/new_base/content_type_test.rb +0 -19
- data/test/controller/new_base/render_rjs_test.rb +0 -71
- data/test/controller/render_js_test.rb +0 -22
- data/test/fixtures/functional_caching/_partial.erb +0 -3
- data/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs +0 -6
- data/test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs +0 -1
- data/test/fixtures/old_content_type/render_default_for_rjs.rjs +0 -1
- data/test/fixtures/respond_to/all_types_with_layout.js.rjs +0 -1
- data/test/fixtures/respond_to/layouts/standard.html.erb +0 -1
- data/test/fixtures/respond_to/using_defaults.js.rjs +0 -1
- data/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +0 -1
- data/test/fixtures/respond_with/using_resource.js.rjs +0 -1
- data/test/fixtures/test/_one.html.erb +0 -1
- data/test/fixtures/test/_partial.html.erb +0 -1
- data/test/fixtures/test/_partial.js.erb +0 -1
- data/test/fixtures/test/_two.html.erb +0 -1
- data/test/fixtures/test/delete_with_js.rjs +0 -2
- data/test/fixtures/test/enum_rjs_test.rjs +0 -6
- data/test/fixtures/test/greeting.js.rjs +0 -1
- data/test/fixtures/test/render_explicit_html_template.js.rjs +0 -1
- data/test/fixtures/test/render_implicit_html_template.js.rjs +0 -1
- data/test/javascript_helper_test.rb +0 -61
- data/test/lib/abstract_unit.rb +0 -225
- data/test/lib/controller/fake_models.rb +0 -29
- data/test/render_other_test.rb +0 -256
- data/test/template/prototype_helper_test.rb +0 -476
- data/test/template/render_test.rb +0 -24
- data/test/template/scriptaculous_helper_test.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7658b98a54c6729cfd24b97864e96e6437f50bcf
|
4
|
+
data.tar.gz: 7d2e040bbef9b56c34cf3c882d17987843d3e735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3f1bc8fcd2d564bb2fd5d8d14b160e992ade91c69b1f5684759ac5a971e64e0e40e38703c10166e7e310f4244103ee39e930c68be55c238ca0ec808918cdd80
|
7
|
+
data.tar.gz: 7689332311d8617b48adccd2fe248c7765a8fc6b90fc5cfac24fe80d16705b19650adf0fb90ee125b6b9ea7f3adbf70deb401ac266d0d2dcd1adc94201d3cc9a
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2004-2013 David Heinemeier Hansson
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/{README → README.md}
RENAMED
@@ -15,3 +15,15 @@ prototype-rails supports RJS debugging. RJS responses are wrapped to catch
|
|
15
15
|
exceptions, alert() them, and re-raise the exception. Debugging is disabled by
|
16
16
|
default. To enable in development, set `config.action_view.debug_rjs = true`
|
17
17
|
in config/environments/development.rb.
|
18
|
+
|
19
|
+
---
|
20
|
+
|
21
|
+
## Support for Rails 4.1 and above
|
22
|
+
|
23
|
+
Unfortunately, due to limited manpower and resources, the Rails core team has
|
24
|
+
not been able to confirm if this gem currently works with Rails 4.1 and above.
|
25
|
+
If you have found any problems while upgrading your application, please report
|
26
|
+
them at the [issue tracker](https://github.com/rails/prototype-rails/issues),
|
27
|
+
or better yet, submit patches by sending a [pull request](https://github.com/rails/prototype-rails/pulls).
|
28
|
+
|
29
|
+
In any case, this gem will *NOT* be officially supported on Rails 5.0 and above.
|
data/Rakefile
CHANGED
@@ -14,9 +14,11 @@ ActionView::Base.class_eval do
|
|
14
14
|
include ActionView::Helpers::ScriptaculousHelper
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
if defined?(Rails.env) && Rails.env.test?
|
18
|
+
ActionView::TestCase.class_eval do
|
19
|
+
include ActionView::Helpers::PrototypeHelper
|
20
|
+
include ActionView::Helpers::ScriptaculousHelper
|
21
|
+
end
|
20
22
|
end
|
21
23
|
|
22
24
|
ActionView::Template.register_template_handler :rjs, ActionView::Template::Handlers::RJS.new
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prototype-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xavier Noria
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mocha
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description:
|
@@ -44,58 +44,28 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
-
- README
|
48
|
-
- Rakefile
|
49
47
|
- Gemfile
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
50
51
|
- lib/action_view/helpers/prototype_helper.rb
|
51
52
|
- lib/action_view/helpers/scriptaculous_helper.rb
|
52
53
|
- lib/action_view/template/handlers/rjs.rb
|
54
|
+
- lib/prototype-rails.rb
|
53
55
|
- lib/prototype-rails/javascript_helper.rb
|
54
56
|
- lib/prototype-rails/on_load_action_controller.rb
|
55
57
|
- lib/prototype-rails/on_load_action_view.rb
|
56
58
|
- lib/prototype-rails/renderers.rb
|
57
59
|
- lib/prototype-rails/rendering.rb
|
58
60
|
- lib/prototype-rails/selector_assertions.rb
|
59
|
-
- lib/prototype-rails.rb
|
60
61
|
- vendor/assets/javascripts/controls.js
|
61
62
|
- vendor/assets/javascripts/dragdrop.js
|
62
63
|
- vendor/assets/javascripts/effects.js
|
63
64
|
- vendor/assets/javascripts/prototype.js
|
64
65
|
- vendor/assets/javascripts/prototype_ujs.js
|
65
|
-
- test/assert_select_test.rb
|
66
|
-
- test/controller/caching_test.rb
|
67
|
-
- test/controller/content_type_test.rb
|
68
|
-
- test/controller/mime_responds_test.rb
|
69
|
-
- test/controller/new_base/content_type_test.rb
|
70
|
-
- test/controller/new_base/render_rjs_test.rb
|
71
|
-
- test/controller/render_js_test.rb
|
72
|
-
- test/fixtures/functional_caching/_partial.erb
|
73
|
-
- test/fixtures/functional_caching/formatted_fragment_cached.js.rjs
|
74
|
-
- test/fixtures/functional_caching/js_fragment_cached_with_partial.js.rjs
|
75
|
-
- test/fixtures/old_content_type/render_default_for_rjs.rjs
|
76
|
-
- test/fixtures/respond_to/all_types_with_layout.js.rjs
|
77
|
-
- test/fixtures/respond_to/layouts/standard.html.erb
|
78
|
-
- test/fixtures/respond_to/using_defaults.js.rjs
|
79
|
-
- test/fixtures/respond_to/using_defaults_with_type_list.js.rjs
|
80
|
-
- test/fixtures/respond_with/using_resource.js.rjs
|
81
|
-
- test/fixtures/test/_one.html.erb
|
82
|
-
- test/fixtures/test/_partial.html.erb
|
83
|
-
- test/fixtures/test/_partial.js.erb
|
84
|
-
- test/fixtures/test/_two.html.erb
|
85
|
-
- test/fixtures/test/delete_with_js.rjs
|
86
|
-
- test/fixtures/test/enum_rjs_test.rjs
|
87
|
-
- test/fixtures/test/greeting.js.rjs
|
88
|
-
- test/fixtures/test/render_explicit_html_template.js.rjs
|
89
|
-
- test/fixtures/test/render_implicit_html_template.js.rjs
|
90
|
-
- test/javascript_helper_test.rb
|
91
|
-
- test/lib/abstract_unit.rb
|
92
|
-
- test/lib/controller/fake_models.rb
|
93
|
-
- test/render_other_test.rb
|
94
|
-
- test/template/prototype_helper_test.rb
|
95
|
-
- test/template/render_test.rb
|
96
|
-
- test/template/scriptaculous_helper_test.rb
|
97
66
|
homepage: http://github.com/rails/prototype-rails
|
98
|
-
licenses:
|
67
|
+
licenses:
|
68
|
+
- MIT
|
99
69
|
metadata: {}
|
100
70
|
post_install_message:
|
101
71
|
rdoc_options: []
|
@@ -103,19 +73,18 @@ require_paths:
|
|
103
73
|
- lib
|
104
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
75
|
requirements:
|
106
|
-
- -
|
76
|
+
- - ">="
|
107
77
|
- !ruby/object:Gem::Version
|
108
78
|
version: '0'
|
109
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
80
|
requirements:
|
111
|
-
- -
|
81
|
+
- - ">="
|
112
82
|
- !ruby/object:Gem::Version
|
113
83
|
version: '0'
|
114
84
|
requirements: []
|
115
85
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.4.5
|
117
87
|
signing_key:
|
118
88
|
specification_version: 4
|
119
89
|
summary: Prototype, Scriptaculous, and RJS for Ruby on Rails
|
120
90
|
test_files: []
|
121
|
-
has_rdoc:
|
data/test/assert_select_test.rb
DELETED
@@ -1,457 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'abstract_unit'
|
4
|
-
|
5
|
-
class AssertSelectTest < ActionController::TestCase
|
6
|
-
Assertion = ActiveSupport::TestCase::Assertion
|
7
|
-
|
8
|
-
class AssertSelectController < ActionController::Base
|
9
|
-
def response_with=(content)
|
10
|
-
@content = content
|
11
|
-
end
|
12
|
-
|
13
|
-
def response_with(&block)
|
14
|
-
@update = block
|
15
|
-
end
|
16
|
-
|
17
|
-
def rjs
|
18
|
-
render :update do |page|
|
19
|
-
@update.call page
|
20
|
-
end
|
21
|
-
@update = nil
|
22
|
-
end
|
23
|
-
|
24
|
-
def rescue_action(e)
|
25
|
-
raise e
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
tests AssertSelectController
|
30
|
-
|
31
|
-
def assert_failure(message, &block)
|
32
|
-
e = assert_raise(Assertion, &block)
|
33
|
-
assert_match(message, e.message) if Regexp === message
|
34
|
-
assert_equal(message, e.message) if String === message
|
35
|
-
end
|
36
|
-
|
37
|
-
# With single result.
|
38
|
-
def test_assert_select_from_rjs_with_single_result
|
39
|
-
render_rjs do |page|
|
40
|
-
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
|
41
|
-
end
|
42
|
-
assert_select "div" do |elements|
|
43
|
-
assert elements.size == 2
|
44
|
-
assert_select "#1"
|
45
|
-
assert_select "#2"
|
46
|
-
end
|
47
|
-
assert_select "div#?", /\d+/ do |elements|
|
48
|
-
assert_select "#1"
|
49
|
-
assert_select "#2"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# With multiple results.
|
54
|
-
def test_assert_select_from_rjs_with_multiple_results
|
55
|
-
render_rjs do |page|
|
56
|
-
page.replace_html "test", "<div id=\"1\">foo</div>"
|
57
|
-
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
58
|
-
end
|
59
|
-
assert_select "div" do |elements|
|
60
|
-
assert elements.size == 2
|
61
|
-
assert_select "#1"
|
62
|
-
assert_select "#2"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# With one result.
|
67
|
-
def test_css_select_from_rjs_with_single_result
|
68
|
-
render_rjs do |page|
|
69
|
-
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
|
70
|
-
end
|
71
|
-
assert_equal 2, css_select("div").size
|
72
|
-
assert_equal 1, css_select("#1").size
|
73
|
-
assert_equal 1, css_select("#2").size
|
74
|
-
end
|
75
|
-
|
76
|
-
# With multiple results.
|
77
|
-
def test_css_select_from_rjs_with_multiple_results
|
78
|
-
render_rjs do |page|
|
79
|
-
page.replace_html "test", "<div id=\"1\">foo</div>"
|
80
|
-
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
81
|
-
end
|
82
|
-
|
83
|
-
assert_equal 2, css_select("div").size
|
84
|
-
assert_equal 1, css_select("#1").size
|
85
|
-
assert_equal 1, css_select("#2").size
|
86
|
-
end
|
87
|
-
|
88
|
-
#
|
89
|
-
# Test assert_select_rjs.
|
90
|
-
#
|
91
|
-
|
92
|
-
def test_assert_select_rjs_for_positioned_insert_should_fail_when_mixing_arguments
|
93
|
-
render_rjs do |page|
|
94
|
-
page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
|
95
|
-
page.insert_html :bottom, "test2", "<div id=\"2\">foo</div>"
|
96
|
-
end
|
97
|
-
assert_raise(Assertion) {assert_select_rjs :insert, :top, "test2"}
|
98
|
-
end
|
99
|
-
|
100
|
-
# Test that we can pick up all statements in the result.
|
101
|
-
def test_assert_select_rjs_picks_up_all_statements
|
102
|
-
render_rjs do |page|
|
103
|
-
page.replace "test", "<div id=\"1\">foo</div>"
|
104
|
-
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
105
|
-
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
106
|
-
end
|
107
|
-
|
108
|
-
found = false
|
109
|
-
assert_select_rjs do
|
110
|
-
assert_select "#1"
|
111
|
-
assert_select "#2"
|
112
|
-
assert_select "#3"
|
113
|
-
found = true
|
114
|
-
end
|
115
|
-
assert found
|
116
|
-
end
|
117
|
-
|
118
|
-
# Test that we fail if there is nothing to pick.
|
119
|
-
def test_assert_select_rjs_fails_if_nothing_to_pick
|
120
|
-
render_rjs { }
|
121
|
-
assert_raise(Assertion) { assert_select_rjs }
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_assert_select_rjs_with_unicode
|
125
|
-
# Test that non-ascii characters (which are converted into \uXXXX in RJS) are decoded correctly.
|
126
|
-
|
127
|
-
unicode = "\343\203\201\343\202\261\343\203\203\343\203\210"
|
128
|
-
render_rjs do |page|
|
129
|
-
page.replace "test", %(<div id="1">#{unicode}</div>)
|
130
|
-
end
|
131
|
-
|
132
|
-
assert_select_rjs do
|
133
|
-
str = "#1"
|
134
|
-
assert_select str, :text => unicode
|
135
|
-
assert_select str, unicode
|
136
|
-
if str.respond_to?(:force_encoding)
|
137
|
-
assert_select str, /\343\203\201..\343\203\210/u
|
138
|
-
assert_raise(Assertion) { assert_select str, /\343\203\201.\343\203\210/u }
|
139
|
-
else
|
140
|
-
assert_select str, Regexp.new("\343\203\201..\343\203\210", 0, 'U')
|
141
|
-
assert_raise(Assertion) { assert_select str, Regexp.new("\343\203\201.\343\203\210", 0, 'U') }
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def test_assert_select_rjs_with_id
|
147
|
-
# Test that we can pick up all statements in the result.
|
148
|
-
render_rjs do |page|
|
149
|
-
page.replace "test1", "<div id=\"1\">foo</div>"
|
150
|
-
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
151
|
-
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
152
|
-
end
|
153
|
-
assert_select_rjs "test1" do
|
154
|
-
assert_select "div", 1
|
155
|
-
assert_select "#1"
|
156
|
-
end
|
157
|
-
assert_select_rjs "test2" do
|
158
|
-
assert_select "div", 1
|
159
|
-
assert_select "#2"
|
160
|
-
end
|
161
|
-
assert_select_rjs "test3" do
|
162
|
-
assert_select "div", 1
|
163
|
-
assert_select "#3"
|
164
|
-
end
|
165
|
-
assert_raise(Assertion) { assert_select_rjs "test4" }
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_assert_select_rjs_for_replace
|
169
|
-
render_rjs do |page|
|
170
|
-
page.replace "test1", "<div id=\"1\">foo</div>"
|
171
|
-
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
172
|
-
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
173
|
-
end
|
174
|
-
# Replace.
|
175
|
-
assert_select_rjs :replace do
|
176
|
-
assert_select "div", 1
|
177
|
-
assert_select "#1"
|
178
|
-
end
|
179
|
-
assert_select_rjs :replace, "test1" do
|
180
|
-
assert_select "div", 1
|
181
|
-
assert_select "#1"
|
182
|
-
end
|
183
|
-
assert_raise(Assertion) { assert_select_rjs :replace, "test2" }
|
184
|
-
# Replace HTML.
|
185
|
-
assert_select_rjs :replace_html do
|
186
|
-
assert_select "div", 1
|
187
|
-
assert_select "#2"
|
188
|
-
end
|
189
|
-
assert_select_rjs :replace_html, "test2" do
|
190
|
-
assert_select "div", 1
|
191
|
-
assert_select "#2"
|
192
|
-
end
|
193
|
-
assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" }
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_assert_select_rjs_for_chained_replace
|
197
|
-
render_rjs do |page|
|
198
|
-
page['test1'].replace "<div id=\"1\">foo</div>"
|
199
|
-
page['test2'].replace_html "<div id=\"2\">foo</div>"
|
200
|
-
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
201
|
-
end
|
202
|
-
# Replace.
|
203
|
-
assert_select_rjs :chained_replace do
|
204
|
-
assert_select "div", 1
|
205
|
-
assert_select "#1"
|
206
|
-
end
|
207
|
-
assert_select_rjs :chained_replace, "test1" do
|
208
|
-
assert_select "div", 1
|
209
|
-
assert_select "#1"
|
210
|
-
end
|
211
|
-
assert_raise(Assertion) { assert_select_rjs :chained_replace, "test2" }
|
212
|
-
# Replace HTML.
|
213
|
-
assert_select_rjs :chained_replace_html do
|
214
|
-
assert_select "div", 1
|
215
|
-
assert_select "#2"
|
216
|
-
end
|
217
|
-
assert_select_rjs :chained_replace_html, "test2" do
|
218
|
-
assert_select "div", 1
|
219
|
-
assert_select "#2"
|
220
|
-
end
|
221
|
-
assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" }
|
222
|
-
end
|
223
|
-
|
224
|
-
# Simple remove
|
225
|
-
def test_assert_select_rjs_for_remove
|
226
|
-
render_rjs do |page|
|
227
|
-
page.remove "test1"
|
228
|
-
end
|
229
|
-
|
230
|
-
assert_select_rjs :remove, "test1"
|
231
|
-
end
|
232
|
-
|
233
|
-
def test_assert_select_rjs_for_remove_offers_useful_error_when_assertion_fails
|
234
|
-
render_rjs do |page|
|
235
|
-
page.remove "test_with_typo"
|
236
|
-
end
|
237
|
-
|
238
|
-
assert_select_rjs :remove, "test1"
|
239
|
-
|
240
|
-
rescue Assertion => e
|
241
|
-
assert_equal "No RJS statement that removes 'test1' was rendered.", e.message
|
242
|
-
end
|
243
|
-
|
244
|
-
def test_assert_select_rjs_for_remove_ignores_block
|
245
|
-
render_rjs do |page|
|
246
|
-
page.remove "test1"
|
247
|
-
end
|
248
|
-
|
249
|
-
assert_nothing_raised do
|
250
|
-
assert_select_rjs :remove, "test1" do
|
251
|
-
assert_select "p"
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
# Simple show
|
257
|
-
def test_assert_select_rjs_for_show
|
258
|
-
render_rjs do |page|
|
259
|
-
page.show "test1"
|
260
|
-
end
|
261
|
-
|
262
|
-
assert_select_rjs :show, "test1"
|
263
|
-
end
|
264
|
-
|
265
|
-
def test_assert_select_rjs_for_show_offers_useful_error_when_assertion_fails
|
266
|
-
render_rjs do |page|
|
267
|
-
page.show "test_with_typo"
|
268
|
-
end
|
269
|
-
|
270
|
-
assert_select_rjs :show, "test1"
|
271
|
-
|
272
|
-
rescue Assertion => e
|
273
|
-
assert_equal "No RJS statement that shows 'test1' was rendered.", e.message
|
274
|
-
end
|
275
|
-
|
276
|
-
def test_assert_select_rjs_for_show_ignores_block
|
277
|
-
render_rjs do |page|
|
278
|
-
page.show "test1"
|
279
|
-
end
|
280
|
-
|
281
|
-
assert_nothing_raised do
|
282
|
-
assert_select_rjs :show, "test1" do
|
283
|
-
assert_select "p"
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
# Simple hide
|
289
|
-
def test_assert_select_rjs_for_hide
|
290
|
-
render_rjs do |page|
|
291
|
-
page.hide "test1"
|
292
|
-
end
|
293
|
-
|
294
|
-
assert_select_rjs :hide, "test1"
|
295
|
-
end
|
296
|
-
|
297
|
-
def test_assert_select_rjs_for_hide_offers_useful_error_when_assertion_fails
|
298
|
-
render_rjs do |page|
|
299
|
-
page.hide "test_with_typo"
|
300
|
-
end
|
301
|
-
|
302
|
-
assert_select_rjs :hide, "test1"
|
303
|
-
|
304
|
-
rescue Assertion => e
|
305
|
-
assert_equal "No RJS statement that hides 'test1' was rendered.", e.message
|
306
|
-
end
|
307
|
-
|
308
|
-
def test_assert_select_rjs_for_hide_ignores_block
|
309
|
-
render_rjs do |page|
|
310
|
-
page.hide "test1"
|
311
|
-
end
|
312
|
-
|
313
|
-
assert_nothing_raised do
|
314
|
-
assert_select_rjs :hide, "test1" do
|
315
|
-
assert_select "p"
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
# Simple toggle
|
321
|
-
def test_assert_select_rjs_for_toggle
|
322
|
-
render_rjs do |page|
|
323
|
-
page.toggle "test1"
|
324
|
-
end
|
325
|
-
|
326
|
-
assert_select_rjs :toggle, "test1"
|
327
|
-
end
|
328
|
-
|
329
|
-
def test_assert_select_rjs_for_toggle_offers_useful_error_when_assertion_fails
|
330
|
-
render_rjs do |page|
|
331
|
-
page.toggle "test_with_typo"
|
332
|
-
end
|
333
|
-
|
334
|
-
assert_select_rjs :toggle, "test1"
|
335
|
-
|
336
|
-
rescue Assertion => e
|
337
|
-
assert_equal "No RJS statement that toggles 'test1' was rendered.", e.message
|
338
|
-
end
|
339
|
-
|
340
|
-
def test_assert_select_rjs_for_toggle_ignores_block
|
341
|
-
render_rjs do |page|
|
342
|
-
page.toggle "test1"
|
343
|
-
end
|
344
|
-
|
345
|
-
assert_nothing_raised do
|
346
|
-
assert_select_rjs :toggle, "test1" do
|
347
|
-
assert_select "p"
|
348
|
-
end
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
# Non-positioned insert.
|
353
|
-
def test_assert_select_rjs_for_nonpositioned_insert
|
354
|
-
render_rjs do |page|
|
355
|
-
page.replace "test1", "<div id=\"1\">foo</div>"
|
356
|
-
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
357
|
-
page.insert_html :top, "test3", "<div id=\"3\">foo</div>"
|
358
|
-
end
|
359
|
-
assert_select_rjs :insert_html do
|
360
|
-
assert_select "div", 1
|
361
|
-
assert_select "#3"
|
362
|
-
end
|
363
|
-
assert_select_rjs :insert_html, "test3" do
|
364
|
-
assert_select "div", 1
|
365
|
-
assert_select "#3"
|
366
|
-
end
|
367
|
-
assert_raise(Assertion) { assert_select_rjs :insert_html, "test1" }
|
368
|
-
end
|
369
|
-
|
370
|
-
# Positioned insert.
|
371
|
-
def test_assert_select_rjs_for_positioned_insert
|
372
|
-
render_rjs do |page|
|
373
|
-
page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
|
374
|
-
page.insert_html :bottom, "test2", "<div id=\"2\">foo</div>"
|
375
|
-
page.insert_html :before, "test3", "<div id=\"3\">foo</div>"
|
376
|
-
page.insert_html :after, "test4", "<div id=\"4\">foo</div>"
|
377
|
-
end
|
378
|
-
assert_select_rjs :insert, :top do
|
379
|
-
assert_select "div", 1
|
380
|
-
assert_select "#1"
|
381
|
-
end
|
382
|
-
assert_select_rjs :insert, :bottom do
|
383
|
-
assert_select "div", 1
|
384
|
-
assert_select "#2"
|
385
|
-
end
|
386
|
-
assert_select_rjs :insert, :before do
|
387
|
-
assert_select "div", 1
|
388
|
-
assert_select "#3"
|
389
|
-
end
|
390
|
-
assert_select_rjs :insert, :after do
|
391
|
-
assert_select "div", 1
|
392
|
-
assert_select "#4"
|
393
|
-
end
|
394
|
-
assert_select_rjs :insert_html do
|
395
|
-
assert_select "div", 4
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
def test_assert_select_rjs_raise_errors
|
400
|
-
assert_raise(ArgumentError) { assert_select_rjs(:destroy) }
|
401
|
-
assert_raise(ArgumentError) { assert_select_rjs(:insert, :left) }
|
402
|
-
end
|
403
|
-
|
404
|
-
# Simple selection from a single result.
|
405
|
-
def test_nested_assert_select_rjs_with_single_result
|
406
|
-
render_rjs do |page|
|
407
|
-
page.replace_html "test", "<div id=\"1\">foo</div>\n<div id=\"2\">foo</div>"
|
408
|
-
end
|
409
|
-
|
410
|
-
assert_select_rjs "test" do |elements|
|
411
|
-
assert_equal 2, elements.size
|
412
|
-
assert_select "#1"
|
413
|
-
assert_select "#2"
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
417
|
-
# Deal with two results.
|
418
|
-
def test_nested_assert_select_rjs_with_two_results
|
419
|
-
render_rjs do |page|
|
420
|
-
page.replace_html "test", "<div id=\"1\">foo</div>"
|
421
|
-
page.replace_html "test2", "<div id=\"2\">foo</div>"
|
422
|
-
end
|
423
|
-
|
424
|
-
assert_select_rjs "test" do |elements|
|
425
|
-
assert_equal 1, elements.size
|
426
|
-
assert_select "#1"
|
427
|
-
end
|
428
|
-
|
429
|
-
assert_select_rjs "test2" do |elements|
|
430
|
-
assert_equal 1, elements.size
|
431
|
-
assert_select "#2"
|
432
|
-
end
|
433
|
-
end
|
434
|
-
|
435
|
-
def test_assert_select_rjs_for_redirect_to
|
436
|
-
render_rjs do |page|
|
437
|
-
page.redirect_to '/'
|
438
|
-
end
|
439
|
-
assert_select_rjs :redirect, '/'
|
440
|
-
end
|
441
|
-
|
442
|
-
protected
|
443
|
-
def render_html(html)
|
444
|
-
@controller.response_with = html
|
445
|
-
get :html
|
446
|
-
end
|
447
|
-
|
448
|
-
def render_rjs(&block)
|
449
|
-
@controller.response_with(&block)
|
450
|
-
get :rjs
|
451
|
-
end
|
452
|
-
|
453
|
-
def render_xml(xml)
|
454
|
-
@controller.response_with = xml
|
455
|
-
get :xml
|
456
|
-
end
|
457
|
-
end
|