card-mod-machines 0.11.5 → 0.11.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/vendor/jquery_file_upload/CONTRIBUTING.md +15 -0
- data/vendor/jquery_file_upload/LICENSE.txt +21 -0
- data/vendor/jquery_file_upload/README.md +107 -0
- data/vendor/jquery_file_upload/angularjs.html +211 -0
- data/vendor/jquery_file_upload/basic-plus.html +226 -0
- data/vendor/jquery_file_upload/basic.html +136 -0
- data/vendor/jquery_file_upload/bower-version-update.js +16 -0
- data/vendor/jquery_file_upload/bower.json +64 -0
- data/vendor/jquery_file_upload/cors/postmessage.html +75 -0
- data/vendor/jquery_file_upload/cors/result.html +24 -0
- data/vendor/jquery_file_upload/css/jquery-ui-demo-ie8.css +21 -0
- data/vendor/jquery_file_upload/css/jquery-ui-demo.css +67 -0
- data/vendor/jquery_file_upload/css/jquery.fileupload-noscript.css +22 -0
- data/vendor/jquery_file_upload/css/jquery.fileupload-ui-noscript.css +17 -0
- data/vendor/jquery_file_upload/css/jquery.fileupload-ui.css +57 -0
- data/vendor/jquery_file_upload/css/jquery.fileupload.css +37 -0
- data/vendor/jquery_file_upload/css/style.css +15 -0
- data/vendor/jquery_file_upload/img/loading.gif +0 -0
- data/vendor/jquery_file_upload/img/progressbar.gif +0 -0
- data/vendor/jquery_file_upload/index.html +255 -0
- data/vendor/jquery_file_upload/jquery-ui.html +252 -0
- data/vendor/jquery_file_upload/js/app.js +101 -0
- data/vendor/jquery_file_upload/js/cors/jquery.postmessage-transport.js +126 -0
- data/vendor/jquery_file_upload/js/cors/jquery.xdr-transport.js +89 -0
- data/vendor/jquery_file_upload/js/jquery.fileupload-angular.js +437 -0
- data/vendor/jquery_file_upload/js/jquery.fileupload-audio.js +113 -0
- data/vendor/jquery_file_upload/js/jquery.fileupload-image.js +326 -0
- data/vendor/jquery_file_upload/js/jquery.fileupload-jquery-ui.js +161 -0
- data/vendor/jquery_file_upload/js/jquery.fileupload-process.js +178 -0
- data/vendor/jquery_file_upload/js/jquery.fileupload-ui.js +714 -0
- data/vendor/jquery_file_upload/js/jquery.fileupload-validate.js +125 -0
- data/vendor/jquery_file_upload/js/jquery.fileupload-video.js +113 -0
- data/vendor/jquery_file_upload/js/jquery.fileupload.js +1486 -0
- data/vendor/jquery_file_upload/js/jquery.iframe-transport.js +224 -0
- data/vendor/jquery_file_upload/js/main.js +75 -0
- data/vendor/jquery_file_upload/js/vendor/jquery.ui.widget.js +748 -0
- data/vendor/jquery_file_upload/package.json +55 -0
- data/vendor/jquery_file_upload/server/gae-go/app.yaml +12 -0
- data/vendor/jquery_file_upload/server/gae-go/app/main.go +361 -0
- data/vendor/jquery_file_upload/server/gae-go/static/favicon.ico +0 -0
- data/vendor/jquery_file_upload/server/gae-go/static/robots.txt +2 -0
- data/vendor/jquery_file_upload/server/gae-python/app.yaml +17 -0
- data/vendor/jquery_file_upload/server/gae-python/main.py +204 -0
- data/vendor/jquery_file_upload/server/gae-python/static/favicon.ico +0 -0
- data/vendor/jquery_file_upload/server/gae-python/static/robots.txt +2 -0
- data/vendor/jquery_file_upload/server/php/Dockerfile +38 -0
- data/vendor/jquery_file_upload/server/php/UploadHandler.php +1411 -0
- data/vendor/jquery_file_upload/server/php/docker-compose.yml +9 -0
- data/vendor/jquery_file_upload/server/php/index.php +15 -0
- data/vendor/jquery_file_upload/test/index.html +172 -0
- data/vendor/jquery_file_upload/test/test.js +1292 -0
- data/vendor/jquery_rails/CHANGELOG.md +359 -0
- data/vendor/jquery_rails/CONTRIBUTING.md +132 -0
- data/vendor/jquery_rails/Gemfile +22 -0
- data/vendor/jquery_rails/MIT-LICENSE +21 -0
- data/vendor/jquery_rails/README.md +75 -0
- data/vendor/jquery_rails/Rakefile +59 -0
- data/vendor/jquery_rails/VERSIONS.md +62 -0
- data/vendor/jquery_rails/jquery-rails.gemspec +26 -0
- data/vendor/jquery_rails/lib/jquery-rails.rb +1 -0
- data/vendor/jquery_rails/lib/jquery/assert_select.rb +149 -0
- data/vendor/jquery_rails/lib/jquery/rails.rb +8 -0
- data/vendor/jquery_rails/lib/jquery/rails/engine.rb +6 -0
- data/vendor/jquery_rails/lib/jquery/rails/version.rb +9 -0
- data/vendor/jquery_rails/test/assert_select_jquery_test.rb +85 -0
- data/vendor/jquery_rails/test/test_helper.rb +6 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery.js +11008 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.js +5 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.map +1 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.js +9814 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.js +4 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.map +1 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.js +10364 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.js +2 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.map +1 -0
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery_ujs.js +555 -0
- metadata +108 -12
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem "mime-types", "< 3", group: :test
|
4
|
+
|
5
|
+
if RUBY_VERSION >= '2.2.2'
|
6
|
+
gem 'rails'
|
7
|
+
gem 'rack'
|
8
|
+
gem 'json', '>= 2'
|
9
|
+
else
|
10
|
+
gem 'rails', '~> 4.2.0'
|
11
|
+
gem 'rack', '~>1.6'
|
12
|
+
gem 'json', '~> 1.8.0'
|
13
|
+
end
|
14
|
+
|
15
|
+
if RUBY_VERSION >= '2.1'
|
16
|
+
gem 'nokogiri'
|
17
|
+
else
|
18
|
+
gem 'nokogiri', '~> 1.6.0'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Specify your gem's dependencies in jquery-rails.gemspec
|
22
|
+
gemspec
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010-2016 Andre Arko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# jquery-rails
|
2
|
+
|
3
|
+
jQuery! For Rails! So great.
|
4
|
+
|
5
|
+
This gem provides:
|
6
|
+
|
7
|
+
* jQuery 1, 2 and 3
|
8
|
+
* the jQuery UJS adapter
|
9
|
+
* assert_select_jquery to test jQuery responses in Ruby tests
|
10
|
+
|
11
|
+
## Versions
|
12
|
+
|
13
|
+
Starting with v2.1, the jquery-rails gem follows these version guidelines
|
14
|
+
to provide more control over your app's jQuery version from your Gemfile:
|
15
|
+
|
16
|
+
```
|
17
|
+
patch version bump = updates to jquery-ujs, jquery-rails, and patch-level updates to jQuery
|
18
|
+
minor version bump = minor-level updates to jQuery
|
19
|
+
major version bump = major-level updates to jQuery and updates to Rails which may be backwards-incompatible
|
20
|
+
```
|
21
|
+
|
22
|
+
See [VERSIONS.md](VERSIONS.md) to see which versions of jquery-rails bundle which
|
23
|
+
versions of jQuery.
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
The jquery and jquery-ujs files will be added to the asset pipeline and available for you to use. If they're not already in `app/assets/javascripts/application.js` by default, add these lines:
|
28
|
+
|
29
|
+
```js
|
30
|
+
//= require jquery
|
31
|
+
//= require jquery_ujs
|
32
|
+
```
|
33
|
+
|
34
|
+
If you are running Rails 5.1 and up, and if you have included `//= require rails-ujs`, then `jquery_ujs` is not needed anymore. You can just add:
|
35
|
+
|
36
|
+
```js
|
37
|
+
//= require jquery
|
38
|
+
```
|
39
|
+
|
40
|
+
If you want to use jQuery 2, you can require `jquery2` instead:
|
41
|
+
|
42
|
+
```js
|
43
|
+
//= require jquery2
|
44
|
+
//= require jquery_ujs
|
45
|
+
```
|
46
|
+
|
47
|
+
And if you want to use jQuery 3, you can require `jquery3`:
|
48
|
+
|
49
|
+
```js
|
50
|
+
//= require jquery3
|
51
|
+
//= require jquery_ujs
|
52
|
+
```
|
53
|
+
|
54
|
+
For jQuery UI, we recommend the [jquery-ui-rails](https://github.com/joliss/jquery-ui-rails) gem, as it includes the jquery-ui css and allows easier customization.
|
55
|
+
|
56
|
+
*As of v3.0, jquery-rails no longer includes jQuery UI. Use the
|
57
|
+
jquery-ui-rails gem above.*
|
58
|
+
|
59
|
+
## Contributing to jquery-rails
|
60
|
+
|
61
|
+
jquery-rails is work of many contributors. You're encouraged to submit pull requests, propose
|
62
|
+
features and discuss issues.
|
63
|
+
|
64
|
+
* If it's an issue pertaining to the jquery-ujs javascript, please report it to the [jquery-ujs project](https://github.com/rails/jquery-ujs).
|
65
|
+
|
66
|
+
* If the jQuery scripts are outdated (i.e. maybe a new version of jquery was released yesterday), feel free to open an issue and prod us to get that thing updated. However, for security reasons, we won't be accepting pull requests with updated jQuery scripts.
|
67
|
+
|
68
|
+
See [CONTRIBUTING](CONTRIBUTING.md).
|
69
|
+
|
70
|
+
## License
|
71
|
+
jquery-rails is released under the [MIT License](MIT-LICENSE).
|
72
|
+
|
73
|
+
## Acknowledgements
|
74
|
+
|
75
|
+
Many thanks are due to all of [the jquery-rails contributors](https://github.com/rails/jquery-rails/graphs/contributors). Special thanks to [JangoSteve](http://github.com/JangoSteve) for tirelessly answering questions and accepting patches, and the [Rails Core Team](https://github.com/organizations/rails/teams/617) for making jquery-rails an official part of Rails 3.1.
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'rake/testtask'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
task default: :test
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |t|
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.pattern = 'test/**/*_test.rb'
|
10
|
+
t.warning = true
|
11
|
+
t.verbose = true
|
12
|
+
end
|
13
|
+
|
14
|
+
# Check if versions are correct between VERSION constants and .js files
|
15
|
+
#
|
16
|
+
task :release => [:guard_version]
|
17
|
+
|
18
|
+
task :guard_version do
|
19
|
+
def check_version(file, pattern, constant)
|
20
|
+
body = File.read("vendor/assets/javascripts/#{file}")
|
21
|
+
match = body.match(pattern) or abort "Version check failed: no pattern matched in #{file}"
|
22
|
+
file_version = match[1]
|
23
|
+
constant_version = Jquery::Rails.const_get(constant)
|
24
|
+
|
25
|
+
unless constant_version == file_version
|
26
|
+
abort "Jquery::Rails::#{constant} was #{constant_version} but it should be #{file_version}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
check_version('jquery.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_VERSION')
|
31
|
+
check_version('jquery2.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_2_VERSION')
|
32
|
+
check_version('jquery3.js', /jQuery JavaScript Library v([\S]+)/, 'JQUERY_3_VERSION')
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Update jQuery versions"
|
36
|
+
task :update_jquery do
|
37
|
+
def download_jquery(filename, version)
|
38
|
+
suffix = "-#{version}"
|
39
|
+
|
40
|
+
puts "Downloading #{filename}.js"
|
41
|
+
puts `curl -o vendor/assets/javascripts/#{filename}.js https://code.jquery.com/jquery#{suffix}.js`
|
42
|
+
puts "Downloading #{filename}.min.js"
|
43
|
+
puts `curl -o vendor/assets/javascripts/#{filename}.min.js https://code.jquery.com/jquery#{suffix}.min.js`
|
44
|
+
puts "Downloading #{filename}.min.map"
|
45
|
+
puts `curl -o vendor/assets/javascripts/#{filename}.min.map https://code.jquery.com/jquery#{suffix}.min.map`
|
46
|
+
end
|
47
|
+
|
48
|
+
download_jquery('jquery', Jquery::Rails::JQUERY_VERSION)
|
49
|
+
download_jquery('jquery2', Jquery::Rails::JQUERY_2_VERSION)
|
50
|
+
download_jquery('jquery3', Jquery::Rails::JQUERY_3_VERSION)
|
51
|
+
puts "\e[32mDone!\e[0m"
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Update jQuery UJS version"
|
55
|
+
task :update_jquery_ujs do
|
56
|
+
puts "Downloading jquery_ujs.js"
|
57
|
+
puts `curl -o vendor/assets/javascripts/jquery_ujs.js https://raw.githubusercontent.com/rails/jquery-ujs/v#{Jquery::Rails::JQUERY_UJS_VERSION}/src/rails.js`
|
58
|
+
puts "\e[32mDone!\e[0m"
|
59
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Bundled Versions
|
2
|
+
|
3
|
+
| Gem | jQuery | jQuery UJS | jQuery UI |
|
4
|
+
|--------|--------|------------| ----------|
|
5
|
+
| 4.3.3 | 1.12.4 & 2.2.4 & 3.3.1 | 1.2.2 | - |
|
6
|
+
| 4.3.2 | 1.12.4 & 2.2.4 & 3.3.0 | 1.2.2 | - |
|
7
|
+
| 4.3.1 | 1.12.4 & 2.2.4 & 3.2.1 | 1.2.2 | - |
|
8
|
+
| 4.3.0 | 1.12.4 & 2.2.4 & 3.2.0 | 1.2.2 | - |
|
9
|
+
| 4.2.2 | 1.12.4 & 2.2.4 & 3.1.1 | 1.2.2 | - |
|
10
|
+
| 4.2.1 | 1.12.4 & 2.2.4 & 3.1.0 | 1.2.2 | - |
|
11
|
+
| 4.2.0 | 1.12.4 & 2.2.4 & 3.0.0 | 1.2.2 | - |
|
12
|
+
| 4.1.1 | 1.12.1 & 2.2.1 | 1.2.1 | - |
|
13
|
+
| 4.1.0 | 1.12.0 & 2.2.0 | 1.2.0 | - |
|
14
|
+
| 4.0.5 | 1.11.3 & 2.1.4 | 1.1.0 | - |
|
15
|
+
| 4.0.4 | 1.11.2 & 2.1.3 | 1.0.4 | - |
|
16
|
+
| 4.0.3 | 1.11.2 & 2.1.3 | 1.0.3 | - |
|
17
|
+
| 4.0.2 | - | - | - |
|
18
|
+
| 4.0.1 | - | - | - |
|
19
|
+
| 4.0.0 | 1.11.1 & 2.1.1 | 1.0.2 | - |
|
20
|
+
| 3.1.3 | 1.11.1 | 1.0.4 | - |
|
21
|
+
| 3.1.2 | 1.11.1 | 1.0.1 | - |
|
22
|
+
| 3.1.1 | 1.11.1 | 1.0.0 | - |
|
23
|
+
| 3.1.0 | 1.11.0 | - | - |
|
24
|
+
| 3.0.5 | 1.11.0 | - | - |
|
25
|
+
| 3.0.4 | ↾ | - | - |
|
26
|
+
| 3.0.3 | 1.10.2 | - | - |
|
27
|
+
| 3.0.2 | ↾ | - | - |
|
28
|
+
| 3.0.1 | 1.10.1 | - | - |
|
29
|
+
| 3.0.0 | ↾ | - | - |
|
30
|
+
| 2.3.0 | 1.10.0 | - | 1.10.3 |
|
31
|
+
| 2.2.2 | ↾ | - | ↾ |
|
32
|
+
| 2.2.1 | 1.9.1 | - | ↾ |
|
33
|
+
| 2.2.0 | 1.9.0 | - | ↾ |
|
34
|
+
| 2.1.4 | 1.8.3 | - | 1.9.2 |
|
35
|
+
| 2.1.3 | 1.8.2 | - | ↾ |
|
36
|
+
| 2.1.2 | 1.8.1 | - | ↾ |
|
37
|
+
| 2.1.1 | ↾ | - | ↾ |
|
38
|
+
| 2.1.0 | 1.8.0 | - | 1.8.23 |
|
39
|
+
| 2.0.3 | ↾ | - | ↾ |
|
40
|
+
| 2.0.2 | 1.7.2 | - | 1.8.18 |
|
41
|
+
| 2.0.1 | ↾ | - | ↾ |
|
42
|
+
| 2.0.0 | ↾ | - | ↾ |
|
43
|
+
| 1.0.19 | 1.7.1 | - | ↾ |
|
44
|
+
| 1.0.18 | ↾ | - | ↾ |
|
45
|
+
| 1.0.17 | 1.7.0 | - | ↾ |
|
46
|
+
| 1.0.16 | 1.6.4 | - | 1.8.16 |
|
47
|
+
| 1.0.15 | ↾ | - | ↾ |
|
48
|
+
| 1.0.14 | ↾ | - | ↾ |
|
49
|
+
| 1.0.13 | 1.6.2 | - | 1.8.14 |
|
50
|
+
| 1.0.12 | ↾ | - | ↾ |
|
51
|
+
| 1.0.11 | ↾ | - | ↾ |
|
52
|
+
| 1.0.10 | ↾ | - | ↾ |
|
53
|
+
| 1.0.9 | ↾ | - | ↾ |
|
54
|
+
| 1.0.8 | ↾ | - | ↾ |
|
55
|
+
| 1.0.7 | ↾ | - | ↾ |
|
56
|
+
| 1.0.6 | ↾ | - | ↾ |
|
57
|
+
| 1.0.5 | ↾ | - | ↾ |
|
58
|
+
| 1.0.4 | ↾ | - | ↾ |
|
59
|
+
| 1.0.3 | 1.6.1 | - | ↾ |
|
60
|
+
| 1.0.2 | ↾ | - | ↾ |
|
61
|
+
| 1.0.1 | ↾ | - | 1.8.12 |
|
62
|
+
| 1.0.0 | 1.6.0 | - | - |
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/jquery/rails/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "jquery-rails"
|
6
|
+
s.version = Jquery::Rails::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["André Arko"]
|
9
|
+
s.email = ["andre@arko.net"]
|
10
|
+
s.homepage = "https://github.com/rails/jquery-rails"
|
11
|
+
s.summary = "Use jQuery with Rails 4+"
|
12
|
+
s.description = "This gem provides jQuery and the jQuery-ujs driver for your Rails 4+ application."
|
13
|
+
s.license = "MIT"
|
14
|
+
|
15
|
+
s.required_ruby_version = ">= 1.9.3"
|
16
|
+
s.required_rubygems_version = ">= 1.3.6"
|
17
|
+
|
18
|
+
s.add_dependency "railties", ">= 4.2.0"
|
19
|
+
s.add_dependency "thor", ">= 0.14", "< 2.0"
|
20
|
+
|
21
|
+
s.add_dependency "rails-dom-testing", ">= 1", "< 3"
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
25
|
+
s.require_path = 'lib'
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jquery/rails'
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'rails/dom/testing/assertions/selector_assertions'
|
2
|
+
|
3
|
+
module Rails::Dom::Testing::Assertions::SelectorAssertions
|
4
|
+
# Selects content from a JQuery response. Patterned loosely on
|
5
|
+
# assert_select_rjs.
|
6
|
+
#
|
7
|
+
# === Narrowing down
|
8
|
+
#
|
9
|
+
# With no arguments, asserts that one or more method calls are made.
|
10
|
+
#
|
11
|
+
# Use the +method+ argument to narrow down the assertion to only
|
12
|
+
# statements that call that specific method.
|
13
|
+
#
|
14
|
+
# Use the +opt+ argument to narrow down the assertion to only statements
|
15
|
+
# that pass +opt+ as the first argument.
|
16
|
+
#
|
17
|
+
# Use the +id+ argument to narrow down the assertion to only statements
|
18
|
+
# that invoke methods on the result of using that identifier as a
|
19
|
+
# selector.
|
20
|
+
#
|
21
|
+
# === Using blocks
|
22
|
+
#
|
23
|
+
# Without a block, +assert_select_jquery_ merely asserts that the
|
24
|
+
# response contains one or more statements that match the conditions
|
25
|
+
# specified above
|
26
|
+
#
|
27
|
+
# With a block +assert_select_jquery_ also asserts that the method call
|
28
|
+
# passes a javascript escaped string containing HTML. All such HTML
|
29
|
+
# fragments are selected and passed to the block. Nested assertions are
|
30
|
+
# supported.
|
31
|
+
#
|
32
|
+
# === Examples
|
33
|
+
#
|
34
|
+
# # asserts that the #notice element is hidden
|
35
|
+
# assert_select :hide, '#notice'
|
36
|
+
#
|
37
|
+
# # asserts that the #cart element is shown with a blind parameter
|
38
|
+
# assert_select :show, :blind, '#cart'
|
39
|
+
#
|
40
|
+
# # asserts that #cart content contains a #current_item
|
41
|
+
# assert_select :html, '#cart' do
|
42
|
+
# assert_select '#current_item'
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# # asserts that #product append to a #product_list
|
46
|
+
# assert_select_jquery :appendTo, '#product_list' do
|
47
|
+
# assert_select '.product'
|
48
|
+
# end
|
49
|
+
|
50
|
+
PATTERN_HTML = "['\"]((\\\\\"|\\\\'|[^\"'])*)['\"]"
|
51
|
+
PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
|
52
|
+
SKELETAL_PATTERN = "(?:jQuery|\\$)\\(%s\\)\\.%s\\(%s\\)[;]?"
|
53
|
+
|
54
|
+
def assert_select_jquery(*args, &block)
|
55
|
+
jquery_method = args.first.is_a?(Symbol) ? args.shift : nil
|
56
|
+
jquery_opt = args.first.is_a?(Symbol) ? args.shift : nil
|
57
|
+
id = args.first.is_a?(String) ? escape_id(args.shift) : nil
|
58
|
+
|
59
|
+
target_pattern = "['\"]#{id || '.*'}['\"]"
|
60
|
+
method_pattern = "#{jquery_method || '\\w+'}"
|
61
|
+
argument_pattern = jquery_opt ? "['\"]#{jquery_opt}['\"].*" : PATTERN_HTML
|
62
|
+
|
63
|
+
# $("#id").show('blind', 1000);
|
64
|
+
# $("#id").html("<div>something</div>");
|
65
|
+
# $("#id").replaceWith("<div>something</div>");
|
66
|
+
target_as_receiver_pattern = SKELETAL_PATTERN % [target_pattern, method_pattern, argument_pattern]
|
67
|
+
|
68
|
+
# $("<div>something</div>").appendTo("#id");
|
69
|
+
# $("<div>something</div>").prependTo("#id");
|
70
|
+
target_as_argument_pattern = SKELETAL_PATTERN % [argument_pattern, method_pattern, target_pattern]
|
71
|
+
|
72
|
+
# $("#id").remove();
|
73
|
+
# $("#id").hide();
|
74
|
+
argumentless_pattern = SKELETAL_PATTERN % [target_pattern, method_pattern, '']
|
75
|
+
|
76
|
+
patterns = [target_as_receiver_pattern, target_as_argument_pattern]
|
77
|
+
patterns << argumentless_pattern unless jquery_opt
|
78
|
+
|
79
|
+
matched_pattern = nil
|
80
|
+
patterns.each do |pattern|
|
81
|
+
if response.body.match(Regexp.new(pattern))
|
82
|
+
matched_pattern = pattern
|
83
|
+
break
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
unless matched_pattern
|
88
|
+
opts = [jquery_method, jquery_opt, id].compact
|
89
|
+
flunk "No JQuery call matches #{opts.inspect}"
|
90
|
+
end
|
91
|
+
|
92
|
+
if block_given?
|
93
|
+
@selected ||= nil
|
94
|
+
fragments = Nokogiri::HTML::Document.new.fragment
|
95
|
+
|
96
|
+
if matched_pattern
|
97
|
+
response.body.scan(Regexp.new(matched_pattern)).each do |match|
|
98
|
+
flunk 'This function can\'t have HTML argument' if match.is_a?(String)
|
99
|
+
|
100
|
+
doc = Nokogiri::HTML::DocumentFragment.parse(unescape_js(match.first))
|
101
|
+
doc.children.each do |child|
|
102
|
+
fragments << child if child.element?
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
begin
|
108
|
+
in_scope, @selected = @selected, fragments
|
109
|
+
yield
|
110
|
+
ensure
|
111
|
+
@selected = in_scope
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
# Unescapes a JS string.
|
119
|
+
def unescape_js(js_string)
|
120
|
+
# js encodes double quotes and line breaks.
|
121
|
+
unescaped= js_string.gsub('\"', '"')
|
122
|
+
unescaped.gsub!('\\\'', "'")
|
123
|
+
unescaped.gsub!(/\\\//, '/')
|
124
|
+
unescaped.gsub!('\n', "\n")
|
125
|
+
unescaped.gsub!('\076', '>')
|
126
|
+
unescaped.gsub!('\074', '<')
|
127
|
+
# js encodes non-ascii characters.
|
128
|
+
unescaped.gsub!(PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
|
129
|
+
unescaped
|
130
|
+
end
|
131
|
+
|
132
|
+
def escape_id(selector)
|
133
|
+
return unless selector
|
134
|
+
|
135
|
+
id = selector.gsub('[', '\[')
|
136
|
+
id.gsub!(']', '\]')
|
137
|
+
id.gsub!('*', '\*')
|
138
|
+
id.gsub!('(', '\(')
|
139
|
+
id.gsub!(')', '\)')
|
140
|
+
id.gsub!('.', '\.')
|
141
|
+
id.gsub!('|', '\|')
|
142
|
+
id.gsub!('^', '\^')
|
143
|
+
id.gsub!('$', '\$')
|
144
|
+
id.gsub!('+', "\\\\+")
|
145
|
+
id.gsub!(',', '\,')
|
146
|
+
|
147
|
+
id
|
148
|
+
end
|
149
|
+
end
|