Permalink
Browse files

Merge pull request #56 from kselden/fix-specs

fix specs
  • Loading branch information...
2 parents 4f6852a + 83debb9 commit b850810b56968db902a6b9978182ba1f1634a161 @krisselden krisselden committed Nov 16, 2012
View
@@ -0,0 +1,13 @@
+rvm:
+ - 1.9.2
+ - 1.9.3
+ - ruby-head
+ - jruby-head
+
+bundler_args: --without docs
+
+install: npm install -g jade
+
+notifications:
+ email:
+ - wycats@gmail.com
View
@@ -1,7 +1,8 @@
-source "http://rubygems.org"
-
-# Specify your gem's dependencies in rake-pipeline-web-filters.gemspec
-gemspec
+source :rubygems
gem "rake-pipeline", :git => "git://github.com/livingsocial/rake-pipeline.git"
gem "pry"
+gem "pry-debugger"
+
+# Specify your gem's dependencies in rake-pipeline-web-filters.gemspec
+gemspec
@@ -1,5 +1,6 @@
describe "CacheBusterFilter" do
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
CacheBusterFilter ||= Rake::Pipeline::Web::Filters::CacheBusterFilter
let(:content) { "it doesn't matter" }
@@ -14,6 +15,8 @@
def setup_filter(filter)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = [ input_file ]
filter.output_root = output_root
filter.rake_application = Rake::Application.new
@@ -1,5 +1,6 @@
describe "ChainedFilter" do
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
ChainedFilter ||= Rake::Pipeline::Web::Filters::ChainedFilter
input_file1 = MemoryFileWrapper.new("/path", "input.js.strip_asserts.erb", "UTF-8", <<-CONTENT)
@@ -58,6 +59,8 @@ def generate_output(inputs, output)
)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = [ file_wrapper ]
filter.output_root = "/output"
filter.rake_application = Rake::Application.new
@@ -1,6 +1,7 @@
describe "CoffeeScriptFilter" do
CoffeeScriptFilter ||= Rake::Pipeline::Web::Filters::CoffeeScriptFilter
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
let(:coffee_input) { <<-COFFEE }
x = 1;
@@ -46,6 +47,8 @@ def should_match(expected, output)
def setup_filter(filter)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = [input_file("input.coffee", coffee_input)]
filter.output_root = "/path/to/output"
filter.rake_application = Rake::Application.new
View
@@ -5,6 +5,7 @@
describe "GzipFilter" do
GzipFilter ||= Rake::Pipeline::Web::Filters::GzipFilter
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
let(:input) { "(function(){console.log('gzip me')})();" }
@@ -18,6 +19,8 @@ def output_file(name)
def setup_filter(filter)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = [input_file("test.js", input)]
filter.output_root = "/path/to/output"
filter.rake_application = Rake::Application.new
@@ -1,6 +1,7 @@
describe "HandlebarsFilter" do
HandlebarsFilter ||= Rake::Pipeline::Web::Filters::HandlebarsFilter
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
let(:handlebars_input) {
'<h1 class="title">{{title}}</h1>'
@@ -20,6 +21,8 @@ def output_file(name)
def setup_filter(filter, input_filename = "test.handlebars")
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = [input_file(input_filename, handlebars_input)]
filter.output_root = "/path/to/output"
filter.rake_application = Rake::Application.new
View
@@ -119,13 +119,8 @@ def filter
end
describe "ProjectHelpers" do
- def project
- @project ||= Rake::Pipeline::Project.new
- end
-
- def dsl
- @dsl ||= Rake::Pipeline::DSL::ProjectDSL.new(project)
- end
+ let(:project) { Rake::Pipeline::Project.new }
+ let(:dsl) { Rake::Pipeline::DSL::ProjectDSL.new(project) }
describe "register" do
it "registers filters per file name" do
View
@@ -1,6 +1,7 @@
describe "IifeFilter" do
IifeFilter ||= Rake::Pipeline::Web::Filters::IifeFilter
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
let(:js_input) { <<-HERE }
var name = "Truckasaurus Gates";
@@ -22,6 +23,8 @@ def output_file(name)
def setup_filter(filter)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = [input_file("name.js", js_input)]
filter.output_root = "/path/to/output"
filter.rake_application = Rake::Application.new
View
@@ -1,21 +1,24 @@
describe "JadeFilter" do
JadeFilter ||= Rake::Pipeline::Web::Filters::JadeFilter
- MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
- let(:jade_input) {"""
+ let(:jade_input) {
+ """
!!! 5
html
head
title Hello
body
h1 Hello
"""
-}
+ }
- let(:expected_html_output) {"""<!DOCTYPE html><html><head><title>Hello</title></head><body><h1>Hello</h1></body></html>"""
-}
+ let(:expected_html_output) {
+ """<!DOCTYPE html><html><head><title>Hello</title></head><body><h1>Hello</h1></body></html>"""
+ }
-let(:expected_prettified_html_output) {"""\
+ let(:expected_prettified_html_output) {
+ """\
<!DOCTYPE html>
<html>
<head>
@@ -25,48 +28,54 @@
<h1>Hello</h1>
</body>
</html>"""
-}
+ }
- def input_file(name, content)
- MemoryFileWrapper.new("/path/to/input", name, "UTF-8", content)
- end
+ let(:input_root) { File.expand_path('./input') }
+ let(:input_path) { 'index.jade' }
- def output_file(name)
- MemoryFileWrapper.new("/path/to/output", name, "UTF-8")
- end
+ let(:input_file) {
+ mkdir_p input_root
+ File.open(File.join(input_root, input_path), 'w+:UTF-8') {|file| file << jade_input }
+ Rake::Pipeline::FileWrapper.new(input_root, input_path, "UTF-8")
+ }
+
+ let(:output_root) { File.expand_path('./output') }
+ let(:output_path) { 'index.html' }
+
+ let(:output_file) {
+ Rake::Pipeline::FileWrapper.new(output_root, output_path, "UTF-8")
+ }
def setup_filter(filter, input=jade_input)
- filter.file_wrapper_class = MemoryFileWrapper
- filter.input_files = [input_file("index.jade", input)]
- filter.output_root = "/path/to/output"
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
+ filter.input_files = [input_file]
+ filter.output_root = output_root
filter.rake_application = Rake::Application.new
filter
end
it "generates output" do
filter = setup_filter JadeFilter.new
-
- filter.output_files.should == [output_file("index.html")]
+ filter.output_files.should == [output_file]
tasks = filter.generate_rake_tasks
tasks.each(&:invoke)
- file = MemoryFileWrapper.files["/path/to/output/index.html"]
- file.body.should == expected_html_output
- file.encoding.should == "UTF-8"
+ output_file.read.should == expected_html_output
+ output_file.encoding.should == "UTF-8"
end
it "prettifies output" do
filter = setup_filter JadeFilter.new :pretty => true
- filter.output_files.should == [output_file("index.html")]
+ filter.output_files.should == [output_file]
tasks = filter.generate_rake_tasks
tasks.each(&:invoke)
- file = MemoryFileWrapper.files["/path/to/output/index.html"]
- file.body.should == expected_prettified_html_output
- file.encoding.should == "UTF-8"
+ output_file.read.should == expected_prettified_html_output
+ output_file.encoding.should == "UTF-8"
end
describe "naming output files" do
View
@@ -1,6 +1,7 @@
describe "LessFilter" do
LessFilter ||= Rake::Pipeline::Web::Filters::LessFilter
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
let(:less_input) { <<-SCSS }
@blue: #3bbfce;
@@ -26,6 +27,8 @@ def output_file(name)
def setup_filter(filter)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = [input_file("border.less", less_input)]
filter.output_root = "/path/to/output"
filter.rake_application = Rake::Application.new
@@ -1,6 +1,7 @@
describe "MarkdownFilter" do
MarkdownFilter ||= Rake::Pipeline::Web::Filters::MarkdownFilter
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
let(:markdown_input) { <<-MARKDOWN }
## This is an H2
@@ -33,6 +34,8 @@ def output_file(name)
def setup_filter(filter)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = [input_file("page.md", markdown_input)]
filter.output_root = "/path/to/output"
filter.rake_application = Rake::Application.new
@@ -2,6 +2,7 @@
describe "MinispadeFilter" do
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
def input_file(contents="var foo = 'bar'; // last-line comment", path="/path/to/input", name="foo.js")
MemoryFileWrapper.new(path, name, "UTF-8", contents)
@@ -20,6 +21,8 @@ def input_file(contents="var foo = 'bar'; // last-line comment", path="/path/to/
def make_filter(input_file, *args)
filter = Rake::Pipeline::Web::Filters::MinispadeFilter.new(*args)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = [input_file]
filter.output_root = "/path/to/output"
filter.rake_application = Rake::Application.new
View
@@ -2,6 +2,7 @@
describe "NeuterFilter" do
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
def make_input(name, data)
make_data(name, data)
@@ -19,10 +20,21 @@ def make_filter(input_files, *args)
filter = Rake::Pipeline::Web::Filters::NeuterFilter.new(*args)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = input_files
filter.output_root = "/path/to/output"
filter.rake_application = Rake::Application.new
- filter.generate_rake_tasks.each(&:invoke)
+
+ tasks = filter.generate_rake_tasks
+
+ # TODO work around a bug in rakep THIS IS TEMPORARY
+ filter.rake_application.tasks.each do |task|
+ task.dynamic_prerequisites.each do |prereq|
+ filter.send :create_file_task, prereq
+ end
+ end
+ tasks.each(&:invoke)
filter
end
View
@@ -1,6 +1,7 @@
describe "SassFilter" do
SassFilter ||= Rake::Pipeline::Web::Filters::SassFilter
MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
let(:scss_input) { <<-SCSS }
$blue: #3bbfce;
@@ -36,6 +37,8 @@ def output_file(name)
def setup_filter(filter, input_files=nil)
filter.file_wrapper_class = MemoryFileWrapper
+ filter.manifest = MemoryManifest.new
+ filter.last_manifest = MemoryManifest.new
filter.input_files = input_files || [input_file("border.scss", scss_input)]
filter.output_root = "/path/to/output"
filter.rake_application = Rake::Application.new
@@ -133,6 +136,8 @@ def write_input_file(filename, contents='', root=tmp)
it "includes @imported files" do
filter = SassFilter.new
+ filter.last_manifest = MemoryManifest.new
+ filter.manifest = MemoryManifest.new
filter.input_files = [main]
filter.output_root = "#{tmp}/output"
filter.rake_application = Rake::Application.new
Oops, something went wrong.

0 comments on commit b850810

Please sign in to comment.