Skip to content

Commit

Permalink
Update sprocketize in tests too
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Dec 16, 2011
1 parent 897c497 commit 8620c88
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/test_sprocketize.rb
Expand Up @@ -2,9 +2,9 @@
require 'shellwords'
require 'tmpdir'

class TestSprocketize < Sprockets::TestCase
class TestSprockets < Sprockets::TestCase
def setup
@dir = File.join(Dir::tmpdir, 'sprocketize')
@dir = File.join(Dir::tmpdir, 'sprockets')
end

def teardown
Expand All @@ -15,38 +15,38 @@ def teardown
end

test "show version for -v flag" do
output = sprocketize "-v"
output = sprockets "-v"
assert_equal "#{Sprockets::VERSION}\n", output
end

test "show help for -h flag" do
output = sprocketize "-h"
assert_match "Usage: sprocketize", output
output = sprockets "-h"
assert_match "Usage: sprockets", output
end

test "show help for no flags or inputs" do
output = sprocketize
assert_match "Usage: sprocketize", output
output = sprockets
assert_match "Usage: sprockets", output
end

test "compile simple file" do
output = sprocketize fixture_path("default/gallery.js")
output = sprockets fixture_path("default/gallery.js")
assert_equal "var Gallery = {};\n", output
end

test "compile file with dependencies" do
output = sprocketize "-I", fixture_path("asset"), fixture_path("asset/application.js")
output = sprockets "-I", fixture_path("asset"), fixture_path("asset/application.js")
assert_equal "var Project = {\n find: function(id) {\n }\n};\nvar Users = {\n find: function(id) {\n }\n};\n\n\n\ndocument.on('dom:loaded', function() {\n $('search').focus();\n});\n", output
end

test "compile asset to output directory" do
output = sprocketize "-I", fixture_path("default"), "-o", @dir, fixture_path("default/gallery.js")
output = sprockets "-I", fixture_path("default"), "-o", @dir, fixture_path("default/gallery.js")
assert_equal "", output
assert File.exist?("#{@dir}/manifest.json")
assert File.exist?("#{@dir}/gallery-14c3b648520bac7a78379b54161c8a9e.js")
end

def sprocketize(*args)
def sprockets(*args)
script = File.expand_path("../../bin/sprockets", __FILE__)
lib = File.expand_path("../../lib", __FILE__)
`ruby -I#{lib} #{script} #{Shellwords.join(args)}`
Expand Down

0 comments on commit 8620c88

Please sign in to comment.