Sha256: a48a9ec36af165d1e8aa296f5586a5ef34d36c820e2fb2f972d6790c0525841d

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require 'spec/test/unit'
require 'spec_helper'
require 'generators/jquery/install/install_generator'

class Mootools::Generators::InstallGeneratorTest < Rails::Generators::TestCase
  describe "The MooTools generator"

  destination File.join(Rails.root)
  tests Mootools::Generators::InstallGenerator
  arguments []

  before(:each) do
    prepare_destination
    @response = {:body => "abc", :status => 200}
    stub_request(:get, /ajax.googleapis.com|github.com/).to_return(@response)
  end

  it "should remove prototype" do
    run_generator
    %w(controls.js dragdrop.js effects.js prototype.js).each { |js| assert_no_file "public/javascripts/#{js}" }
  end

  it "should install the rails ujs shim" do
    run_generator
    assert_file "public/javascripts/rails.js"
  end

  it "should install mootools" do
    run_generator
    %w(mootools.min.js mootools.js).each { |js| assert_file "public/javascripts/#{js}" }
  end

  it "should install old mootools versions" do
    run_generator %w(--version 1.2.4)
    %w(mootools.min.js mootools.js).each { |js| assert_file "public/javascripts/#{js}" }
  end

  it "should try to install unknown mootools versions with fallback" do
    stub_request(:get, /ajax.googleapis.com/).
      to_return(:status => 404, :body => "No").
      to_return(@response)
    run_generator %w(--version 100.0)
    %w(mootools.min.js mootools.js).each { |js| assert_file "public/javascripts/#{js}" }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mootools-rails-0.2 spec/lib/generators/mootools/install_generator_spec.rb