jquery-rails 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of jquery-rails might be problematic. Click here for more details.
- data/.gitignore +1 -1
- data/README.md +1 -3
- data/Rakefile +6 -6
- data/jquery-rails.gemspec +1 -0
- data/lib/jquery-rails.rb +7 -2
- data/lib/jquery-rails/assert_select_jquery.rb +79 -0
- data/lib/jquery-rails/version.rb +1 -1
- data/{test/lib/generators/jquery/install_generator_test.rb → spec/lib/generators/jquery/install_generator_spec.rb} +7 -4
- data/spec/{jquery-rails_spec.rb → lib/jquery-rails_spec.rb} +12 -9
- data/{test/test_helper.rb → spec/spec_helper.rb} +2 -5
- metadata +23 -9
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -18,6 +18,4 @@ You're done! Don't forget to output `csrf_meta_tag` somewhere inside your `<head
|
|
18
18
|
|
19
19
|
### Edge rails
|
20
20
|
|
21
|
-
If you're using edge Rails,
|
22
|
-
|
23
|
-
gem "jquery-rails", :git => "http://github.com/indirect/jquery-rails.git", :branch => "rails-3-1"
|
21
|
+
If you're using edge Rails, everything should just work starting with version 0.2.2. If it's not working, try running `bundle update jquery-rails`, or change your Gemfile to read `gem "jquery-rails", "~>0.2"`.
|
data/Rakefile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
-
require
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
desc "Run all examples"
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
7
|
+
t.ruby_opts = ['-r test/unit']
|
8
|
+
t.rspec_opts = %w[--color]
|
9
9
|
end
|
10
|
-
task :default => :
|
10
|
+
task :default => :spec
|
data/jquery-rails.gemspec
CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
|
17
17
|
s.add_dependency "rails", "~> 3.0"
|
18
18
|
s.add_development_dependency "bundler", "~> 1.0.0"
|
19
|
+
s.add_development_dependency "rspec", "~> 1.3"
|
19
20
|
|
20
21
|
s.files = `git ls-files`.split("\n")
|
21
22
|
s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
|
data/lib/jquery-rails.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
module Jquery
|
2
2
|
module Rails
|
3
3
|
class Railtie < ::Rails::Railtie
|
4
|
+
|
4
5
|
config.before_configuration do
|
6
|
+
require "jquery-rails/assert_select_jquery" if ::Rails.env.test?
|
7
|
+
|
5
8
|
if ::Rails.root.join("public/javascripts/jquery-ui.min.js").exist?
|
6
9
|
jq_defaults = %w(jquery jquery-ui)
|
7
|
-
jq_defaults.map!{|a| a + ".min" }
|
10
|
+
jq_defaults.map!{|a| a + ".min" } if ::Rails.env.production?
|
8
11
|
else
|
9
|
-
jq_defaults = ::Rails.env.
|
12
|
+
jq_defaults = ::Rails.env.production? ? %w(jquery.min) : %w(jquery)
|
10
13
|
end
|
14
|
+
|
11
15
|
config.action_view.javascript_expansions[:defaults] = jq_defaults + %w(rails)
|
12
16
|
end
|
17
|
+
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module ActionDispatch
|
2
|
+
module Assertions
|
3
|
+
module 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
|
+
def assert_select_jquery(*args, &block)
|
46
|
+
jquery_method = args.first.is_a?(Symbol) ? args.shift : nil
|
47
|
+
jquery_opt = args.first.is_a?(Symbol) ? args.shift : nil
|
48
|
+
id = args.first.is_a?(String) ? args.shift : nil
|
49
|
+
|
50
|
+
pattern = "\\.#{jquery_method || '\\w+'}\\("
|
51
|
+
pattern = "#{pattern}['\"]#{jquery_opt}['\"],?\\s*" if jquery_opt
|
52
|
+
pattern = "#{pattern}#{RJS_PATTERN_HTML}" if block
|
53
|
+
pattern = "(?:jQuery|\\$)\\(['\"]#{id}['\"]\\)#{pattern}" if id
|
54
|
+
|
55
|
+
fragments = []
|
56
|
+
response.body.scan(Regexp.new(pattern)).each do |match|
|
57
|
+
doc = HTML::Document.new(unescape_rjs(match.first))
|
58
|
+
doc.root.children.each do |child|
|
59
|
+
fragments.push child if child.tag?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
if fragments.empty?
|
64
|
+
opts = [jquery_method, jquery_opt, id].compact
|
65
|
+
flunk "No JQuery call matches #{opts.inspect}"
|
66
|
+
end
|
67
|
+
|
68
|
+
if block
|
69
|
+
begin
|
70
|
+
in_scope, @selected = @selected, fragments
|
71
|
+
yield
|
72
|
+
ensure
|
73
|
+
@selected = in_scope
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/jquery-rails/version.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec/test/unit'
|
2
|
+
require 'spec_helper'
|
2
3
|
require 'generators/jquery/install/install_generator'
|
3
4
|
|
4
5
|
class Jquery::Generators::InstallGeneratorTest < Rails::Generators::TestCase
|
6
|
+
describe "The jQuery generator"
|
7
|
+
|
5
8
|
destination File.join(Rails.root)
|
6
9
|
tests Jquery::Generators::InstallGenerator
|
7
10
|
arguments []
|
8
11
|
|
9
12
|
setup :prepare_destination
|
10
13
|
|
11
|
-
|
14
|
+
it "should install jquery" do
|
12
15
|
run_generator
|
13
16
|
|
14
17
|
%w(jquery.min.js jquery.js rails.js).each { |js| assert_file "public/javascripts/#{js}" }
|
15
18
|
%w(controls.js dragdrop.js effects.js prototype.js).each { |js| assert_no_file "public/javascripts/#{js}" }
|
16
19
|
end
|
17
|
-
|
18
|
-
|
20
|
+
|
21
|
+
it "should install jquery-ui when asked" do
|
19
22
|
run_generator %w(--ui)
|
20
23
|
|
21
24
|
%w(jquery.min.js jquery.js jquery-ui.min.js jquery-ui.js rails.js).each { |js| assert_file "public/javascripts/#{js}" }
|
@@ -1,12 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Dir.chdir(dir) do
|
5
|
-
`bundle install --local`
|
6
|
-
`rails runner -e #{env} 'puts Rails.application.config.action_view.
|
7
|
-
javascript_expansions[:defaults].inspect'`.chomp
|
8
|
-
end
|
9
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "The jQuery-Rails railtie" do
|
10
4
|
|
11
5
|
it "changes the default javascript expansion" do
|
12
6
|
get_js_defaults("default").should == ["jquery.min", "rails"].inspect
|
@@ -20,4 +14,13 @@ describe "jQuery-Rails" do
|
|
20
14
|
get_js_defaults("custom").should == ["foo", "bar", "baz"].inspect
|
21
15
|
end
|
22
16
|
|
17
|
+
def get_js_defaults(name, env = "production")
|
18
|
+
dir = File.expand_path("../../support/#{name}_app", __FILE__)
|
19
|
+
Dir.chdir(dir) do
|
20
|
+
`bundle install --local`
|
21
|
+
`rails runner -e #{env} 'puts Rails.application.config.action_view.
|
22
|
+
javascript_expansions[:defaults].inspect'`.chomp
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
23
26
|
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'test/unit'
|
1
|
+
# Setup for generator tests
|
3
2
|
require 'rails/all'
|
4
3
|
require 'rails/generators'
|
5
4
|
require 'rails/generators/test_case'
|
@@ -11,7 +10,7 @@ Rails.application = TestApp
|
|
11
10
|
|
12
11
|
module Rails
|
13
12
|
def self.root
|
14
|
-
@root ||= File.expand_path(
|
13
|
+
@root ||= File.expand_path("../../tmp/rails", __FILE__)
|
15
14
|
end
|
16
15
|
end
|
17
16
|
Rails.application.config.root = Rails.root
|
@@ -19,5 +18,3 @@ Rails.application.config.root = Rails.root
|
|
19
18
|
# Call configure to load the settings from
|
20
19
|
# Rails.application.config.generators to Rails::Generators
|
21
20
|
Rails::Generators.configure!
|
22
|
-
|
23
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Andr\xC3\xA9 Arko"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-13 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -49,6 +49,21 @@ dependencies:
|
|
49
49
|
version: 1.0.0
|
50
50
|
type: :development
|
51
51
|
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: rspec
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 9
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 3
|
64
|
+
version: "1.3"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
52
67
|
description: This gem provides a Rails generator to install jQuery and the jQuery-ujs driver into your Rails 3 application, and then have them included automatically instead of Prototype.
|
53
68
|
email:
|
54
69
|
- andre@arko.net
|
@@ -67,11 +82,13 @@ files:
|
|
67
82
|
- jquery-rails.gemspec
|
68
83
|
- lib/generators/jquery/install/install_generator.rb
|
69
84
|
- lib/jquery-rails.rb
|
85
|
+
- lib/jquery-rails/assert_select_jquery.rb
|
70
86
|
- lib/jquery-rails/version.rb
|
71
|
-
- spec/jquery
|
87
|
+
- spec/lib/generators/jquery/install_generator_spec.rb
|
88
|
+
- spec/lib/jquery-rails_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
72
90
|
- spec/support/custom_app/.gitignore
|
73
91
|
- spec/support/custom_app/Gemfile
|
74
|
-
- spec/support/custom_app/Gemfile.lock
|
75
92
|
- spec/support/custom_app/config.ru
|
76
93
|
- spec/support/custom_app/config/application.rb
|
77
94
|
- spec/support/custom_app/config/boot.rb
|
@@ -84,7 +101,6 @@ files:
|
|
84
101
|
- spec/support/custom_app/script/rails
|
85
102
|
- spec/support/default_app/.gitignore
|
86
103
|
- spec/support/default_app/Gemfile
|
87
|
-
- spec/support/default_app/Gemfile.lock
|
88
104
|
- spec/support/default_app/config.ru
|
89
105
|
- spec/support/default_app/config/application.rb
|
90
106
|
- spec/support/default_app/config/boot.rb
|
@@ -95,8 +111,6 @@ files:
|
|
95
111
|
- spec/support/default_app/config/environments/test.rb
|
96
112
|
- spec/support/default_app/config/routes.rb
|
97
113
|
- spec/support/default_app/script/rails
|
98
|
-
- test/lib/generators/jquery/install_generator_test.rb
|
99
|
-
- test/test_helper.rb
|
100
114
|
has_rdoc: true
|
101
115
|
homepage: http://rubygems.org/gems/jquery-rails
|
102
116
|
licenses: []
|