mootools-rails 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  pkg/*
2
2
  tmp
3
3
  spec/support/*/Gemfile.lock
4
+ spec/support/*/public/javascripts
data/Gemfile.lock ADDED
@@ -0,0 +1,87 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mootools-rails (0.2)
5
+ rails (~> 3.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.1)
12
+ actionpack (= 3.0.1)
13
+ mail (~> 2.2.5)
14
+ actionpack (3.0.1)
15
+ activemodel (= 3.0.1)
16
+ activesupport (= 3.0.1)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.4.1)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.12)
22
+ rack-test (~> 0.5.4)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.1)
25
+ activesupport (= 3.0.1)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.4.1)
28
+ activerecord (3.0.1)
29
+ activemodel (= 3.0.1)
30
+ activesupport (= 3.0.1)
31
+ arel (~> 1.0.0)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.1)
34
+ activemodel (= 3.0.1)
35
+ activesupport (= 3.0.1)
36
+ activesupport (3.0.1)
37
+ addressable (2.2.2)
38
+ arel (1.0.1)
39
+ activesupport (~> 3.0.0)
40
+ builder (2.1.2)
41
+ crack (0.1.8)
42
+ erubis (2.6.6)
43
+ abstract (>= 1.0.0)
44
+ i18n (0.4.1)
45
+ mail (2.2.7)
46
+ activesupport (>= 2.3.6)
47
+ mime-types
48
+ treetop (>= 1.4.5)
49
+ mime-types (1.16)
50
+ polyglot (0.3.1)
51
+ rack (1.2.1)
52
+ rack-mount (0.6.13)
53
+ rack (>= 1.0.0)
54
+ rack-test (0.5.6)
55
+ rack (>= 1.0)
56
+ rails (3.0.1)
57
+ actionmailer (= 3.0.1)
58
+ actionpack (= 3.0.1)
59
+ activerecord (= 3.0.1)
60
+ activeresource (= 3.0.1)
61
+ activesupport (= 3.0.1)
62
+ bundler (~> 1.0.0)
63
+ railties (= 3.0.1)
64
+ railties (3.0.1)
65
+ actionpack (= 3.0.1)
66
+ activesupport (= 3.0.1)
67
+ rake (>= 0.8.4)
68
+ thor (~> 0.14.0)
69
+ rake (0.8.7)
70
+ rspec (1.3.1)
71
+ thor (0.14.3)
72
+ treetop (1.4.8)
73
+ polyglot (>= 0.3.1)
74
+ tzinfo (0.3.23)
75
+ webmock (1.4.0)
76
+ addressable (>= 2.2.2)
77
+ crack (>= 0.1.7)
78
+
79
+ PLATFORMS
80
+ ruby
81
+
82
+ DEPENDENCIES
83
+ bundler (~> 1.0.0)
84
+ mootools-rails!
85
+ rails (~> 3.0)
86
+ rspec (~> 1.3)
87
+ webmock (~> 1.4.0)
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require "rspec/core/rake_task"
4
+ require "spec/rake/spectask"
5
5
  desc "Run all examples"
6
- RSpec::Core::RakeTask.new(:spec) do |t|
6
+ Spec::Rake::SpecTask.new(:spec) do |t|
7
7
  t.ruby_opts = ['-r test/unit']
8
- t.rspec_opts = %w[--color]
8
+ t.spec_opts = %w[--color]
9
9
  end
10
10
  task :default => :spec
@@ -1,9 +1,9 @@
1
1
  module Mootools
2
2
  module Generators
3
3
  class InstallGenerator < ::Rails::Generators::Base
4
- desc "This generator downloads and installs MooTools, MooTools-ujs HEAD"
4
+ desc "This generator downloads and installs MooTools and MooTools-ujs HEAD"
5
5
  class_option :version, :type => :string, :default => "1.2.5", :desc => "Which version of MooTools to fetch"
6
- @@versions = %w( 1.2.5 1.2.4 1.2.3 1.2.2 1.2.1 1.1.2 1.1.1 )
6
+ @@default_version = "1.2.5"
7
7
 
8
8
  def remove_prototype
9
9
  %w(controls.js dragdrop.js effects.js prototype.js).each do |js|
@@ -12,22 +12,26 @@ module Mootools
12
12
  end
13
13
 
14
14
  def download_mootools
15
- # Downloading latest MooTools
16
- if @@versions.include?(options.version)
17
- puts "Fetching MooTools version #{options.version}!"
18
- get "http://ajax.googleapis.com/ajax/libs/mootools/#{options.version}/mootools-yui-compressed.js", "public/javascripts/mootools.min.js"
19
- get "http://ajax.googleapis.com/ajax/libs/mootools/#{options.version}/mootools.js", "public/javascripts/mootools.js"
20
- else
21
- puts "MooTools #{options.version} is invalid; fetching #{@@versions[1]} instead."
22
- get "http://ajax.googleapis.com/ajax/libs/mootools/#{@@versions[1]}/mootools-yui-compressed.js", "public/javascripts/mootools.min.js"
23
- get "http://ajax.googleapis.com/ajax/libs/mootools/#{@@versions[1]}/mootools.js", "public/javascripts/mootools.js"
24
- end
15
+ say_status("fetching", "MooTools (#{options.version})", :green)
16
+ get_mootools(options.version)
17
+ rescue OpenURI::HTTPError
18
+ say_status("warning", "could not find MooTools (#{options.version})", :yellow)
19
+ say_status("fetching", "MooTools (#{@@default_version})", :green)
20
+ get_mootools(@@default_version)
25
21
  end
26
22
 
27
23
  def download_ujs_driver
28
- # Downloading latest MooTOols drivers
24
+ say_status("fetching", "MooTools UJS adapter (github HEAD)", :green)
29
25
  get "http://github.com/neonlex/mootools-ujs/raw/master/Source/rails.js", "public/javascripts/rails.js"
30
26
  end
27
+
28
+ private
29
+
30
+ def get_mootools(version)
31
+ get "http://ajax.googleapis.com/ajax/libs/mootools/#{version}/mootools.js", "public/javascripts/mootools.js"
32
+ get "http://ajax.googleapis.com/ajax/libs/mootools/#{version}/mootools-yui-compressed.js", "public/javascripts/mootools.min.js"
33
+ end
34
+
31
35
  end
32
36
  end
33
37
  end
@@ -1,6 +1,7 @@
1
1
  module Mootools
2
2
  module Rails
3
3
  class Railtie < ::Rails::Railtie
4
+
4
5
  config.before_configuration do
5
6
  require "mootools-rails/assert_select_mootools" if ::Rails.env.test?
6
7
 
@@ -8,6 +9,7 @@ module Mootools
8
9
 
9
10
  config.action_view.javascript_expansions[:defaults] = jq_defaults + %w(rails)
10
11
  end
12
+
11
13
  end
12
14
  end
13
- end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Mootools
2
2
  module Rails
3
- VERSION = "0.1"
3
+ VERSION = "0.2"
4
4
  end
5
5
  end
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency "rails", "~> 3.0"
18
18
  s.add_development_dependency "bundler", "~> 1.0.0"
19
19
  s.add_development_dependency "rspec", "~> 1.3"
20
+ s.add_development_dependency "webmock", "~> 1.4.0"
20
21
 
21
22
  s.files = `git ls-files`.split("\n")
22
23
  s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
@@ -1,6 +1,6 @@
1
1
  require 'spec/test/unit'
2
2
  require 'spec_helper'
3
- require 'generators/mootools/install/install_generator'
3
+ require 'generators/jquery/install/install_generator'
4
4
 
5
5
  class Mootools::Generators::InstallGeneratorTest < Rails::Generators::TestCase
6
6
  describe "The MooTools generator"
@@ -9,12 +9,37 @@ class Mootools::Generators::InstallGeneratorTest < Rails::Generators::TestCase
9
9
  tests Mootools::Generators::InstallGenerator
10
10
  arguments []
11
11
 
12
- setup :prepare_destination
12
+ before(:each) do
13
+ prepare_destination
14
+ @response = {:body => "abc", :status => 200}
15
+ stub_request(:get, /ajax.googleapis.com|github.com/).to_return(@response)
16
+ end
17
+
18
+ it "should remove prototype" do
19
+ run_generator
20
+ %w(controls.js dragdrop.js effects.js prototype.js).each { |js| assert_no_file "public/javascripts/#{js}" }
21
+ end
22
+
23
+ it "should install the rails ujs shim" do
24
+ run_generator
25
+ assert_file "public/javascripts/rails.js"
26
+ end
13
27
 
14
28
  it "should install mootools" do
15
29
  run_generator
30
+ %w(mootools.min.js mootools.js).each { |js| assert_file "public/javascripts/#{js}" }
31
+ end
16
32
 
17
- %w(mootools.min.js mootools.js rails.js).each { |js| assert_file "public/javascripts/#{js}" }
18
- %w(controls.js dragdrop.js effects.js prototype.js).each { |js| assert_no_file "public/javascripts/#{js}" }
33
+ it "should install old mootools versions" do
34
+ run_generator %w(--version 1.2.4)
35
+ %w(mootools.min.js mootools.js).each { |js| assert_file "public/javascripts/#{js}" }
36
+ end
37
+
38
+ it "should try to install unknown mootools versions with fallback" do
39
+ stub_request(:get, /ajax.googleapis.com/).
40
+ to_return(:status => 404, :body => "No").
41
+ to_return(@response)
42
+ run_generator %w(--version 100.0)
43
+ %w(mootools.min.js mootools.js).each { |js| assert_file "public/javascripts/#{js}" }
19
44
  end
20
- end
45
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,11 @@
1
- # Setup for generator tests
1
+ # Set up RSpec
2
+ require 'webmock/rspec'
3
+
4
+ Spec::Runner.configure do |config|
5
+ config.include WebMock::API
6
+ end
7
+
8
+ # Set up generator tests
2
9
  require 'rails/all'
3
10
  require 'rails/generators'
4
11
  require 'rails/generators/test_case'
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- version: "0.1"
7
+ - 2
8
+ version: "0.2"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Daniel Spangenberg
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-10-14 00:00:00 +02:00
16
+ date: 2010-10-18 00:00:00 +02:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
@@ -59,6 +59,21 @@ dependencies:
59
59
  version: "1.3"
60
60
  type: :development
61
61
  version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: webmock
64
+ prerelease: false
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 1
72
+ - 4
73
+ - 0
74
+ version: 1.4.0
75
+ type: :development
76
+ version_requirements: *id004
62
77
  description: This gem provides a Rails generator to install MooTools and the MooTools-ujs driver into your Rails 3 application, and then have them included automatically instead of Prototype.
63
78
  email:
64
79
  - daniel.spangenberg@gmail.com
@@ -71,6 +86,7 @@ extra_rdoc_files: []
71
86
  files:
72
87
  - .gitignore
73
88
  - Gemfile
89
+ - Gemfile.lock
74
90
  - README.md
75
91
  - Rakefile
76
92
  - lib/generators/mootools/install/install_generator.rb