jquery_tag 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,42 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jquery_tag (0.0.1)
4
+ jquery_tag (0.0.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- abstract (1.0.0)
10
- actionpack (3.0.0)
11
- activemodel (= 3.0.0)
12
- activesupport (= 3.0.0)
13
- builder (~> 2.1.2)
14
- erubis (~> 2.6.6)
15
- i18n (~> 0.4.1)
16
- rack (~> 1.2.1)
17
- rack-mount (~> 0.6.12)
18
- rack-test (~> 0.5.4)
19
- tzinfo (~> 0.3.23)
20
- activemodel (3.0.0)
21
- activesupport (= 3.0.0)
22
- builder (~> 2.1.2)
23
- i18n (~> 0.4.1)
24
- activesupport (3.0.0)
25
- builder (2.1.2)
26
- erubis (2.6.6)
27
- abstract (>= 1.0.0)
28
- i18n (0.4.1)
29
- rack (1.2.1)
30
- rack-mount (0.6.13)
31
- rack (>= 1.0.0)
32
- rack-test (0.5.6)
33
- rack (>= 1.0)
34
- tzinfo (0.3.23)
9
+ diff-lcs (1.1.2)
10
+ rspec (2.0.0)
11
+ rspec-core (= 2.0.0)
12
+ rspec-expectations (= 2.0.0)
13
+ rspec-mocks (= 2.0.0)
14
+ rspec-core (2.0.0)
15
+ rspec-expectations (2.0.0)
16
+ diff-lcs (>= 1.1.2)
17
+ rspec-mocks (2.0.0)
18
+ rspec-core (= 2.0.0)
19
+ rspec-expectations (= 2.0.0)
35
20
 
36
21
  PLATFORMS
37
22
  ruby
38
23
 
39
24
  DEPENDENCIES
40
- actionpack
41
25
  bundler (>= 1.0.0)
42
26
  jquery_tag!
27
+ rspec (>= 2.0.0)
data/Rakefile CHANGED
@@ -1,12 +1,10 @@
1
1
  require 'bundler'
2
- require 'rake/testtask'
2
+ require 'rspec/core/rake_task'
3
3
  Bundler::GemHelper.install_tasks
4
4
 
5
- desc 'Run tests.'
6
- Rake::TestTask.new(:test) do |t|
7
- t.libs << 'test'
8
- t.pattern = 'test/**/*_test.rb'
9
- t.verbose = true
5
+ desc "Run specs"
6
+ RSpec::Core::RakeTask.new do |task|
7
+ task.rspec_opts = ["-c"]
10
8
  end
11
9
 
12
- task :default => :test
10
+ task :default => :spec
data/jquery_tag.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
 
14
14
  s.required_rubygems_version = ">= 1.3.6"
15
15
  s.add_development_dependency "bundler", ">= 1.0.0"
16
- s.add_development_dependency "actionpack"
16
+ s.add_development_dependency "rspec", ">= 2.0.0"
17
17
 
18
18
  s.files = `git ls-files`.split("\n")
19
19
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
@@ -1,5 +1,5 @@
1
1
  module Jquery
2
2
  module Tag
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,17 +1,27 @@
1
1
  module Jquery
2
2
  module Tag
3
3
  module ViewHelpers
4
+ def jquery_tag(*args)
5
+
6
+ options = args.first.is_a?(Hash) ? args.pop : {}
4
7
 
5
- def jquery_tag(options = {})
6
- arguments = options.delete(:args) || []
7
- path = options.delete(:file) || "jquery.js"
8
- version = options.delete(:version) || "1.4.2"
8
+ args.unshift(jquery_ui_file(options[:ui])) if options[:ui]
9
+ args.unshift(jquery_file(options[:file], options[:version]))
9
10
 
10
- path = "http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js" if Rails.env.production?
11
-
12
- arguments.unshift(path)
13
- javascript_include_tag arguments
14
- end
11
+ javascript_include_tag args
12
+ end
13
+
14
+ private
15
+ def jquery_file(path, version)
16
+ path ||= 'jquery.js'
17
+ version ||= '1.4.3'
18
+ Rails.env.production? ? "http://ajax.googleapis.com/ajax/libs/jquery/#{version}/jquery.min.js" : path
19
+ end
20
+
21
+ def jquery_ui_file(path)
22
+ path = path.is_a?(String) ? path : "jquery-ui.js"
23
+ Rails.env.production? ? 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js' : path
24
+ end
15
25
  end
16
26
  end
17
27
  end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jquery::Tag::ViewHelpers do
4
+ include Jquery::Tag::ViewHelpers
5
+
6
+ context "development" do
7
+ before { development! }
8
+
9
+ it "renders a local jquery.js file" do
10
+ expects_include_with ['jquery.js']
11
+ jquery_tag
12
+ end
13
+
14
+ it "delegates any other arguments" do
15
+ expects_include_with ['jquery.js', 'application.js']
16
+ jquery_tag 'application.js'
17
+ end
18
+
19
+ it "accepts a different path for the local jquery file" do
20
+ expects_include_with ['frameworks/jquery.min.js']
21
+ jquery_tag :file => "frameworks/jquery.min.js"
22
+ end
23
+
24
+ it "renders the jquery-ui.js file" do
25
+ expects_include_with ['jquery.js', 'jquery-ui.js']
26
+ jquery_tag :ui => true
27
+ end
28
+
29
+ it "receives a path to the jquery-ui.js file" do
30
+ expects_include_with ['jquery.js', 'frameworks/jquery-ui.js']
31
+ jquery_tag :ui => 'frameworks/jquery-ui.js'
32
+ end
33
+ end
34
+
35
+ context "production" do
36
+ before { production! }
37
+
38
+ it "uses the google CDN path" do
39
+ expects_include_with ['http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js']
40
+ jquery_tag
41
+ end
42
+
43
+ it "accepts a different version for the jquery script" do
44
+ expects_include_with ['http://ajax.googleapis.com/ajax/libs/jquery/1.0.0/jquery.min.js']
45
+ jquery_tag :version => '1.0.0'
46
+ end
47
+
48
+ it "uses the google CDN path for the jquery ui script" do
49
+ expects_include_with ['http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js']
50
+ jquery_tag :ui => true
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,22 @@
1
+ require 'jquery_tag/view_helpers'
2
+
3
+ module Rails
4
+ end
5
+
6
+ module SpecHelper
7
+ def production!
8
+ Rails.stub_chain(:env, :production?) { true }
9
+ end
10
+
11
+ def development!
12
+ Rails.stub_chain(:env, :production?) { false }
13
+ end
14
+
15
+ def expects_include_with(*args)
16
+ should_receive(:javascript_include_tag).with(*args)
17
+ end
18
+ end
19
+
20
+ RSpec.configure do |config|
21
+ config.include SpecHelper
22
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery_tag
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lucas Mazza
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-30 00:00:00 -03:00
18
+ date: 2010-10-18 00:00:00 -02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -35,17 +35,19 @@ dependencies:
35
35
  type: :development
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: actionpack
38
+ name: rspec
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- hash: 3
45
+ hash: 15
46
46
  segments:
47
+ - 2
47
48
  - 0
48
- version: "0"
49
+ - 0
50
+ version: 2.0.0
49
51
  type: :development
50
52
  version_requirements: *id002
51
53
  description: Helper gem that toggles between local jquery script and Google CDN version based on your app environment
@@ -67,9 +69,8 @@ files:
67
69
  - lib/jquery_tag.rb
68
70
  - lib/jquery_tag/version.rb
69
71
  - lib/jquery_tag/view_helpers.rb
70
- - test/jquery_tag_test.rb
71
- - test/support.rb
72
- - test/test_helper.rb
72
+ - spec/jquery_tag_spec.rb
73
+ - spec/spec_helper.rb
73
74
  has_rdoc: true
74
75
  homepage: http://rubygems.org/gems/jquery_tag
75
76
  licenses: []
@@ -1,31 +0,0 @@
1
- require 'test_helper'
2
- class HelperTest < ActionView::TestCase
3
- tests Jquery::Tag::ViewHelpers
4
-
5
- test "should render a script tag for a local jquery.js file" do
6
- environment :development do
7
- assert_match /\/javascripts\/jquery.js/, jquery_tag
8
- end
9
- end
10
-
11
- test "should accept a different path for the local script file" do
12
- environment :development do
13
- assert_match /\/javascripts\/frameworks\/jquery.min.js/, jquery_tag(:file => "frameworks/jquery.min.js")
14
- end
15
- end
16
-
17
- test "should use the Google CDN url when in production environment" do
18
- environment :production do
19
- assert_match /ajax.googleapis.com\/\S*\/1.4.2\/jquery.min.js/, jquery_tag
20
- end
21
- end
22
-
23
- test "should accept another jquery version for the Google CDN" do
24
- environment :production do
25
- assert_match /ajax.googleapis.com\/\S*\/1.4.1\/jquery.min.js/, jquery_tag(:version => "1.4.1")
26
- end
27
- end
28
-
29
- end
30
-
31
-
data/test/support.rb DELETED
@@ -1,25 +0,0 @@
1
- Jquery::Routes = ActionDispatch::Routing::RouteSet.new
2
- Jquery::Routes.draw do
3
- match ':controller(/:action(/:id(.:format)))'
4
- end
5
-
6
- class ApplicationController < ActionController::Base; end
7
- ActionController::Base.send :include, Jquery::Routes.url_helpers
8
-
9
- # Here we have some lame workarounds for testing.
10
- ENV["RAILS_ASSET_ID"] = ""
11
-
12
- module Rails
13
- def self.env
14
- @_env ||= ActiveSupport::StringInquirer.new("development")
15
- end
16
-
17
- def self.env=(env)
18
- @_env = env
19
- end
20
- end
21
-
22
- def environment(env)
23
- Rails.env = ActiveSupport::StringInquirer.new(env.to_s)
24
- yield
25
- end
data/test/test_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require "test/unit"
2
- require "rubygems"
3
- require "bundler/setup"
4
-
5
- require "action_controller"
6
- require "action_view"
7
- require "support"
8
-
9
- #$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
10
- require 'jquery_tag'