Skip to content

Commit

Permalink
Now with real spec-type thingies
Browse files Browse the repository at this point in the history
  • Loading branch information
indirect committed Oct 17, 2010
1 parent f7a7f13 commit 9678a3d
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions spec/lib/generators/jquery/install_generator_spec.rb
Expand Up @@ -11,21 +11,40 @@ class Jquery::Generators::InstallGeneratorTest < Rails::Generators::TestCase

before(:each) do
prepare_destination
@response = {:body => "abc", :status => 200, :headers => { 'Content-Length' => 3 } }
@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 jquery" do
run_generator
%w(jquery.min.js jquery.js).each { |js| assert_file "public/javascripts/#{js}" }
end

%w(jquery.min.js jquery.js rails.js).each { |js| assert_file "public/javascripts/#{js}" }
%w(controls.js dragdrop.js effects.js prototype.js).each { |js| assert_no_file "public/javascripts/#{js}" }
it "should install old jquery versions" do
run_generator %w(--version 1.4.2)
%w(jquery.min.js jquery.js).each { |js| assert_file "public/javascripts/#{js}" }
end

it "should try to install unknown jquery 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(jquery.min.js jquery.js).each { |js| assert_file "public/javascripts/#{js}" }
end

it "should install jquery-ui when asked" do
run_generator %w(--ui)

%w(jquery.min.js jquery.js jquery-ui.min.js jquery-ui.js rails.js).each { |js| assert_file "public/javascripts/#{js}" }
%w(controls.js dragdrop.js effects.js prototype.js).each { |js| assert_no_file "public/javascripts/#{js}" }
%w(jquery-ui.min.js jquery-ui.js).each { |js| assert_file "public/javascripts/#{js}" }
end
end

0 comments on commit 9678a3d

Please sign in to comment.