jquery_on_rails 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,51 +1,49 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "jquery_on_rails"
8
- gem.summary = %Q{JQuery on Rails - Replace prototype/scriptaculous with jquery}
9
- gem.description = %Q{A complete replacement for Rails 3 javascript helpers and unobstrusive javacript (ujs) using JQuery instead of prototype/scriptaculous}
10
- gem.email = "joe@ankhcraft.com"
11
- gem.homepage = "http://github.com/joekhoobyar/jquery_on_rails"
12
- gem.authors = ["Joe Khoobyar"]
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "jquery_on_rails"
8
+ gem.summary = %Q{JQuery on Rails - Replace prototype/scriptaculous with jquery}
9
+ gem.description = %Q{A complete replacement for Rails 3 javascript helpers and unobstrusive javacript (ujs) using JQuery instead of prototype/scriptaculous}
10
+ gem.email = "joe@ankhcraft.com"
11
+ gem.homepage = "http://github.com/joekhoobyar/jquery_on_rails"
12
+ gem.authors = ["Joe Khoobyar"]
13
13
  gem.files = Dir["{lib,public,spec}/**/*", "{bin}/*", "*"]
14
- gem.rubyforge_project = "jquery_on_rails"
15
- gem.add_dependency "actionpack", ">= 3.0.0.beta1"
16
- gem.add_development_dependency "rspec", ">= 1.2.9"
17
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
- end
19
- Jeweler::GemcutterTasks.new
20
- Jeweler::RubyforgeTasks.new do |rubyforge|
21
- rubyforge.doc_task = "rdoc"
22
- end
23
- rescue LoadError
24
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
25
- end
26
-
27
- require 'spec/rake/spectask'
28
- Spec::Rake::SpecTask.new(:spec) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.spec_files = FileList['spec/**/*_spec.rb']
31
- end
32
-
33
- Spec::Rake::SpecTask.new(:rcov) do |spec|
34
- spec.libs << 'lib' << 'spec'
35
- spec.pattern = 'spec/**/*_spec.rb'
36
- spec.rcov = true
37
- end
38
-
39
- task :spec => :check_dependencies
40
-
41
- task :default => :spec
42
-
43
- require 'rake/rdoctask'
44
- Rake::RDocTask.new do |rdoc|
45
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
-
47
- rdoc.rdoc_dir = 'rdoc'
48
- rdoc.title = "jquery_on_rails #{version}"
49
- rdoc.rdoc_files.include('README*')
50
- rdoc.rdoc_files.include('lib/**/*.rb')
51
- end
14
+ gem.rubyforge_project = "jquery_on_rails"
15
+ gem.add_dependency "actionpack", ">= 3.0.0.beta1"
16
+ gem.add_development_dependency "rspec", ">= 2.0.0.beta.8"
17
+ # gem.add_development_dependency "rspec-rails", ">= 2.0.0.beta.8"
18
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ Jeweler::RubyforgeTasks.new do |rubyforge|
22
+ rubyforge.doc_task = "rdoc"
23
+ end
24
+ rescue LoadError
25
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
26
+ end
27
+
28
+ require 'rspec/core/rake_task'
29
+ Rspec::Core::RakeTask.new(:rspec) do |spec|
30
+ spec.pattern = FileList['spec/**/*_spec.rb']
31
+ end
32
+ Rspec::Core::RakeTask.new(:rcov) do |spec|
33
+ spec.pattern = 'spec/**/*_spec.rb'
34
+ spec.rcov = true
35
+ end
36
+
37
+ task :rspec => :check_dependencies
38
+
39
+ task :default => :rspec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "jquery_on_rails #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jquery_on_rails}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joe Khoobyar"]
@@ -27,8 +27,16 @@ Gem::Specification.new do |s|
27
27
  "lib/jquery_on_rails/railtie.rb",
28
28
  "public/javascripts/jquery.js",
29
29
  "public/javascripts/rails.js",
30
+ "spec/dummy/app/controllers/dummy_controller.rb",
31
+ "spec/dummy/app/helpers/dummy_helper.rb",
32
+ "spec/dummy/config/application.rb",
33
+ "spec/dummy/config/boot.rb",
34
+ "spec/dummy/config/environment.rb",
35
+ "spec/dummy/config/environments/test.rb",
36
+ "spec/dummy/config/routes.rb",
37
+ "spec/dummy/log/test.log",
38
+ "spec/jquery_helper_spec.rb",
30
39
  "spec/jquery_on_rails_spec.rb",
31
- "spec/spec.opts",
32
40
  "spec/spec_helper.rb"
33
41
  ]
34
42
  s.homepage = %q{http://github.com/joekhoobyar/jquery_on_rails}
@@ -38,7 +46,15 @@ Gem::Specification.new do |s|
38
46
  s.rubygems_version = %q{1.3.6}
39
47
  s.summary = %q{JQuery on Rails - Replace prototype/scriptaculous with jquery}
40
48
  s.test_files = [
41
- "spec/jquery_on_rails_spec.rb",
49
+ "spec/dummy/app/controllers/dummy_controller.rb",
50
+ "spec/dummy/app/helpers/dummy_helper.rb",
51
+ "spec/dummy/config/application.rb",
52
+ "spec/dummy/config/boot.rb",
53
+ "spec/dummy/config/environment.rb",
54
+ "spec/dummy/config/environments/test.rb",
55
+ "spec/dummy/config/routes.rb",
56
+ "spec/jquery_helper_spec.rb",
57
+ "spec/jquery_on_rails_spec.rb",
42
58
  "spec/spec_helper.rb"
43
59
  ]
44
60
 
@@ -48,14 +64,14 @@ Gem::Specification.new do |s|
48
64
 
49
65
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
66
  s.add_runtime_dependency(%q<actionpack>, [">= 3.0.0.beta1"])
51
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
67
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
52
68
  else
53
69
  s.add_dependency(%q<actionpack>, [">= 3.0.0.beta1"])
54
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
70
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
55
71
  end
56
72
  else
57
73
  s.add_dependency(%q<actionpack>, [">= 3.0.0.beta1"])
58
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
74
+ s.add_dependency(%q<rspec>, [">= 2.0.0.beta.8"])
59
75
  end
60
76
  end
61
77
 
@@ -273,8 +273,8 @@ module JQueryOnRails
273
273
  "}"
274
274
  end
275
275
 
276
- if !(FalseClass === options[:protect_against_forgery?]) or
277
- protect_against_forgery? or !options[:form] or !options[:submit]
276
+ if !(FalseClass === options[:protect_against_forgery]) and
277
+ protect_against_forgery? and !options[:form]
278
278
  then
279
279
  if js_options['data']
280
280
  js_options['data'] << " + '&"
@@ -0,0 +1,5 @@
1
+ class DummyController < ActionController::Base
2
+
3
+ protect_from_forgery
4
+
5
+ end
@@ -0,0 +1,2 @@
1
+ module DummyHelper
2
+ end
@@ -0,0 +1,16 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "action_dispatch/railtie"
4
+ require "action_controller/railtie"
5
+ require "action_view/railtie"
6
+
7
+ require 'jquery_on_rails'
8
+
9
+ module Dummy
10
+ class Application < Rails::Application
11
+ config.root = File.expand_path '../../', __FILE__
12
+ config.secret_token = 'abcdefghijklmnopqrstuvwxyz0123456789'
13
+ config.session_store :cookie_store, :key => '_dummy_session'
14
+ end
15
+ end
16
+
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+
3
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
File without changes
@@ -0,0 +1,3 @@
1
+ Dummy::Application.routes.draw do |map|
2
+ match ':controller(/:action(/:id(.:format)))'
3
+ end
File without changes
@@ -0,0 +1,79 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ require 'dummy_controller'
4
+
5
+ describe JQueryOnRails::Helpers::JQueryHelper do
6
+ before(:each) do
7
+ @t = DummyController.new.tap do |c|
8
+ c.request = ActionDispatch::Request.new Rack::MockRequest.env_for('/dummy')
9
+ end.view_context
10
+ end
11
+
12
+ it "overrides all instance methods ActionView::Helpers::PrototypeHelper" do
13
+ (ActionView::Helpers::PrototypeHelper.instance_methods -
14
+ JQueryOnRails::Helpers::JQueryHelper.instance_methods).should == []
15
+ end
16
+ it "overrides all instance methods ActionView::Helpers::ScriptaculousHelper" do
17
+ return pending("not yet implemented")
18
+ (ActionView::Helpers::ScriptaculousHelper.instance_methods -
19
+ JQueryOnRails::Helpers::JQueryHelper.instance_methods).should == []
20
+ end
21
+
22
+ describe '#options_for_javascript' do
23
+ before(:each) do
24
+ @t.singleton_class.instance_eval{ public :options_for_javascript }
25
+ end
26
+
27
+ it "handles empty options" do
28
+ @t.options_for_javascript({}).should == '{}'
29
+ end
30
+ it "orders options deterministically" do
31
+ @t.options_for_javascript(:b=>1,:c=>3,:a=>2).should == '{a:2, b:1, c:3}'
32
+ end
33
+ end
34
+
35
+ describe '#remote_function' do
36
+ it "calls jQuery.ajax" do
37
+ # jQuery.ajax({async:true, ... method:'GET', processData:false, ... })
38
+ @t.remote_function(:url=>'/foo').should =~ /jQuery\.ajax\(.*.*\)/
39
+ end
40
+ it "is asynchronous by default" do
41
+ @t.remote_function(:url=>'/foo').should =~ /async: *true/
42
+ end
43
+ it "can be explicitly synchronous" do
44
+ @t.remote_function(:url=>'/foo', :type=>:synchronous).should =~ /async: *false/
45
+ end
46
+
47
+ describe 'request forgery protection' do
48
+ before(:each) do
49
+ @regex = /data: *'#{@t.request_forgery_protection_token}=' *\+ *encodeURIComponent/
50
+ end
51
+
52
+ it "is included by default" do
53
+ @t.remote_function(:url=>'/foo').should =~ @regex
54
+ end
55
+ it "can be explicitly omitted" do
56
+ @t.remote_function(:url=>'/foo', :protect_against_forgery=>false).should_not =~ @regex
57
+ end
58
+ it "is omitted when :form is given" do
59
+ @t.remote_function(:url=>'/foo', :form=>true).should_not =~ @regex
60
+ end
61
+ end
62
+ describe ':url' do
63
+ it "accepts a string" do
64
+ @t.remote_function(:url=>'/foo').should =~ /url: *'\/foo'/
65
+ end
66
+ it "accepts a hash" do
67
+ @t.remote_function(:url=>{:controller=>'dummy', :action=>'index'}).should =~ /url: *'\/dummy'/
68
+ end
69
+ end
70
+ describe ':method' do
71
+ it "defaults to GET" do
72
+ @t.remote_function(:url=>'/foo').should =~ /method: *'GET'/
73
+ end
74
+ it "is capitalized" do
75
+ @t.remote_function(:url=>'/foo', :method=>:post).should =~ /method: *'POST'/
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,7 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe "JqueryOnRails" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
3
+ describe "JQueryOnRails" do
4
+
5
+ it "should not screw up the VERSION" do
6
+ JQueryOnRails.constants.should be_include('VERSION')
7
+ version_file = File.expand_path '../../VERSION', __FILE__
8
+ File.should be_exists(version_file)
9
+ JQueryOnRails::VERSION.should == File.read(version_file).strip
6
10
  end
11
+
7
12
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,19 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'jquery_on_rails'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
1
+ ENV["RAILS_ENV"] = "test"
2
+
3
+ require 'pp'
4
+ begin require 'win32console' and include Win32::Console::ANSI
5
+ rescue LoadError
6
+ end if RUBY_PLATFORM =~ /msvc|mingw|cygwin|win32/
7
+
8
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
9
+ require "rails/test_help"
10
+ require "rspec"
11
+ #require "rspec/rails"
12
+
13
+ Rails.backtrace_cleaner.remove_silencers!
14
+
15
+ Rspec.configure do |config|
16
+ require 'rspec/expectations'
17
+ config.include Rspec::Matchers
18
+ config.mock_with :rspec
9
19
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joe Khoobyar
@@ -40,10 +40,12 @@ dependencies:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  segments:
43
- - 1
44
43
  - 2
45
- - 9
46
- version: 1.2.9
44
+ - 0
45
+ - 0
46
+ - beta
47
+ - 8
48
+ version: 2.0.0.beta.8
47
49
  type: :development
48
50
  version_requirements: *id002
49
51
  description: A complete replacement for Rails 3 javascript helpers and unobstrusive javacript (ujs) using JQuery instead of prototype/scriptaculous
@@ -66,8 +68,16 @@ files:
66
68
  - lib/jquery_on_rails/railtie.rb
67
69
  - public/javascripts/jquery.js
68
70
  - public/javascripts/rails.js
71
+ - spec/dummy/app/controllers/dummy_controller.rb
72
+ - spec/dummy/app/helpers/dummy_helper.rb
73
+ - spec/dummy/config/application.rb
74
+ - spec/dummy/config/boot.rb
75
+ - spec/dummy/config/environment.rb
76
+ - spec/dummy/config/environments/test.rb
77
+ - spec/dummy/config/routes.rb
78
+ - spec/dummy/log/test.log
79
+ - spec/jquery_helper_spec.rb
69
80
  - spec/jquery_on_rails_spec.rb
70
- - spec/spec.opts
71
81
  - spec/spec_helper.rb
72
82
  has_rdoc: true
73
83
  homepage: http://github.com/joekhoobyar/jquery_on_rails
@@ -100,5 +110,13 @@ signing_key:
100
110
  specification_version: 3
101
111
  summary: JQuery on Rails - Replace prototype/scriptaculous with jquery
102
112
  test_files:
113
+ - spec/dummy/app/controllers/dummy_controller.rb
114
+ - spec/dummy/app/helpers/dummy_helper.rb
115
+ - spec/dummy/config/application.rb
116
+ - spec/dummy/config/boot.rb
117
+ - spec/dummy/config/environment.rb
118
+ - spec/dummy/config/environments/test.rb
119
+ - spec/dummy/config/routes.rb
120
+ - spec/jquery_helper_spec.rb
103
121
  - spec/jquery_on_rails_spec.rb
104
122
  - spec/spec_helper.rb
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color