rake-pipeline-fork 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +12 -0
  5. data/.yardopts +2 -0
  6. data/GETTING_STARTED.md +268 -0
  7. data/Gemfile +14 -0
  8. data/LICENSE +20 -0
  9. data/README.markdown +11 -0
  10. data/README.yard +178 -0
  11. data/Rakefile +21 -0
  12. data/bin/rakep +4 -0
  13. data/examples/copying_files.md +12 -0
  14. data/examples/minifying_files.md +37 -0
  15. data/examples/modifying_pipelines.md +67 -0
  16. data/examples/multiple_pipelines.md +77 -0
  17. data/lib/generators/rake/pipeline/install/install_generator.rb +70 -0
  18. data/lib/rake-pipeline.rb +462 -0
  19. data/lib/rake-pipeline/cli.rb +56 -0
  20. data/lib/rake-pipeline/dsl.rb +9 -0
  21. data/lib/rake-pipeline/dsl/pipeline_dsl.rb +246 -0
  22. data/lib/rake-pipeline/dsl/project_dsl.rb +108 -0
  23. data/lib/rake-pipeline/dynamic_file_task.rb +194 -0
  24. data/lib/rake-pipeline/error.rb +17 -0
  25. data/lib/rake-pipeline/file_wrapper.rb +182 -0
  26. data/lib/rake-pipeline/filter.rb +249 -0
  27. data/lib/rake-pipeline/filters.rb +4 -0
  28. data/lib/rake-pipeline/filters/concat_filter.rb +63 -0
  29. data/lib/rake-pipeline/filters/gsub_filter.rb +56 -0
  30. data/lib/rake-pipeline/filters/ordering_concat_filter.rb +38 -0
  31. data/lib/rake-pipeline/filters/pipeline_finalizing_filter.rb +21 -0
  32. data/lib/rake-pipeline/graph.rb +178 -0
  33. data/lib/rake-pipeline/manifest.rb +86 -0
  34. data/lib/rake-pipeline/manifest_entry.rb +34 -0
  35. data/lib/rake-pipeline/matcher.rb +141 -0
  36. data/lib/rake-pipeline/middleware.rb +72 -0
  37. data/lib/rake-pipeline/precompile.rake +8 -0
  38. data/lib/rake-pipeline/project.rb +335 -0
  39. data/lib/rake-pipeline/rails_plugin.rb +10 -0
  40. data/lib/rake-pipeline/railtie.rb +34 -0
  41. data/lib/rake-pipeline/reject_matcher.rb +29 -0
  42. data/lib/rake-pipeline/server.rb +15 -0
  43. data/lib/rake-pipeline/sorted_pipeline.rb +19 -0
  44. data/lib/rake-pipeline/version.rb +6 -0
  45. data/rails/init.rb +2 -0
  46. data/rake-pipeline.gemspec +24 -0
  47. data/spec/cli_spec.rb +71 -0
  48. data/spec/concat_filter_spec.rb +37 -0
  49. data/spec/dsl/pipeline_dsl_spec.rb +165 -0
  50. data/spec/dsl/project_dsl_spec.rb +41 -0
  51. data/spec/dynamic_file_task_spec.rb +119 -0
  52. data/spec/encoding_spec.rb +106 -0
  53. data/spec/file_wrapper_spec.rb +132 -0
  54. data/spec/filter_spec.rb +332 -0
  55. data/spec/graph_spec.rb +56 -0
  56. data/spec/gsub_filter_spec.rb +87 -0
  57. data/spec/manifest_entry_spec.rb +46 -0
  58. data/spec/manifest_spec.rb +67 -0
  59. data/spec/matcher_spec.rb +141 -0
  60. data/spec/middleware_spec.rb +199 -0
  61. data/spec/ordering_concat_filter_spec.rb +42 -0
  62. data/spec/pipeline_spec.rb +232 -0
  63. data/spec/project_spec.rb +295 -0
  64. data/spec/rake_acceptance_spec.rb +738 -0
  65. data/spec/rake_tasks_spec.rb +21 -0
  66. data/spec/reject_matcher_spec.rb +31 -0
  67. data/spec/sorted_pipeline_spec.rb +27 -0
  68. data/spec/spec_helper.rb +38 -0
  69. data/spec/support/spec_helpers/file_utils.rb +35 -0
  70. data/spec/support/spec_helpers/filters.rb +37 -0
  71. data/spec/support/spec_helpers/input_helpers.rb +23 -0
  72. data/spec/support/spec_helpers/memory_file_wrapper.rb +31 -0
  73. data/spec/support/spec_helpers/memory_manifest.rb +19 -0
  74. data/tools/perfs +101 -0
  75. metadata +215 -0
@@ -0,0 +1,56 @@
1
+ describe "Rake::Pipeline::Graph" do
2
+ Graph = Rake::Pipeline::Graph
3
+ Node = Rake::Pipeline::Graph::Node
4
+
5
+ before do
6
+ @graph = Graph.new
7
+ end
8
+
9
+ it "has nodes" do
10
+ @graph.nodes.should == []
11
+ end
12
+
13
+ it "can add nodes" do
14
+ @graph.add("foo")
15
+ @graph["foo"].should == Node.new("foo")
16
+ end
17
+
18
+ it "can link nodes" do
19
+ @graph.add("foo")
20
+ @graph.add("bar")
21
+ @graph.nodes.should == [Node.new("foo"), Node.new("bar")]
22
+ @graph.link("foo", "bar")
23
+ @graph["foo"].children.map(&:name).should == ["bar"]
24
+ @graph["bar"].parents.map(&:name).should == ["foo"]
25
+ end
26
+
27
+ it "can unlink nodes" do
28
+ @graph.add("foo")
29
+ @graph.add("bar")
30
+ @graph.link("foo", "bar")
31
+ @graph.unlink("foo", "bar")
32
+ @graph["foo"].children.should == Set[]
33
+ @graph["bar"].parents.should == Set[]
34
+ end
35
+
36
+ it "can remove nodes" do
37
+ @graph.add("foo")
38
+ @graph.add("bar")
39
+ @graph.nodes.should == [Node.new("foo"), Node.new("bar")]
40
+ @graph.link("foo", "bar")
41
+ @graph.remove("foo")
42
+ @graph.nodes.should == [Node.new("bar")]
43
+ @graph["bar"].children.should == Set[]
44
+ @graph["bar"].parents.should == Set[]
45
+ end
46
+
47
+ it "can add metadata to nodes" do
48
+ @graph.add("foo", :meta => 1)
49
+ @graph.add("bar")
50
+ @graph["bar"].metadata[:meta] = 2
51
+
52
+ @graph["foo"].metadata.should == { :meta => 1 }
53
+ @graph["bar"].metadata.should == { :meta => 2 }
54
+ end
55
+ end
56
+
@@ -0,0 +1,87 @@
1
+ describe "GsubFilter" do
2
+ MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
3
+ MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest
4
+
5
+ let(:input_files) {
6
+ [
7
+ MemoryFileWrapper.new("/path/to/input", "ember.js", "UTF-8", "Ember.assert"),
8
+ ]
9
+ }
10
+
11
+ let(:rake_application) { Rake::Application.new }
12
+
13
+ it "generates output" do
14
+ filter = Rake::Pipeline::GsubFilter.new "Ember.assert", "foo"
15
+ filter.rake_application = rake_application
16
+
17
+ filter.file_wrapper_class = MemoryFileWrapper
18
+ filter.manifest = MemoryManifest.new
19
+ filter.last_manifest = MemoryManifest.new
20
+
21
+ filter.output_root = "/path/to/output"
22
+ filter.input_files = input_files
23
+
24
+ filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "ember.js", "UTF-8")]
25
+
26
+
27
+ tasks = filter.generate_rake_tasks
28
+ tasks.each(&:invoke)
29
+
30
+ file = MemoryFileWrapper.files["/path/to/output/ember.js"]
31
+ file.body.should == "foo"
32
+ end
33
+
34
+ it "accepts a block to use with gsub" do
35
+ filter = Rake::Pipeline::GsubFilter.new "Ember.assert" do
36
+ "foo"
37
+ end
38
+
39
+ filter.rake_application = rake_application
40
+ filter.file_wrapper_class = MemoryFileWrapper
41
+ filter.manifest = MemoryManifest.new
42
+ filter.last_manifest = MemoryManifest.new
43
+
44
+ filter.output_root = "/path/to/output"
45
+ filter.input_files = input_files
46
+
47
+ filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "ember.js", "UTF-8")]
48
+
49
+ tasks = filter.generate_rake_tasks
50
+ tasks.each(&:invoke)
51
+
52
+ file = MemoryFileWrapper.files["/path/to/output/ember.js"]
53
+ file.body.should == "foo"
54
+ end
55
+
56
+ it "should be able to access global match variables" do
57
+ filter = Rake::Pipeline::GsubFilter.new /Ember\.(.+)/ do |match, word|
58
+ word.should == "assert"
59
+ "Ember.#{word}Strongly"
60
+ end
61
+
62
+ filter.rake_application = rake_application
63
+ filter.file_wrapper_class = MemoryFileWrapper
64
+ filter.manifest = MemoryManifest.new
65
+ filter.last_manifest = MemoryManifest.new
66
+
67
+ filter.output_root = "/path/to/output"
68
+ filter.input_files = input_files
69
+
70
+ filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "ember.js", "UTF-8")]
71
+
72
+ tasks = filter.generate_rake_tasks
73
+ tasks.each(&:invoke)
74
+
75
+ file = MemoryFileWrapper.files["/path/to/output/ember.js"]
76
+ file.body.should == "Ember.assertStrongly"
77
+ end
78
+
79
+ it "use the input name for output" do
80
+ filter = Rake::Pipeline::GsubFilter.new
81
+ filter.rake_application = rake_application
82
+ filter.file_wrapper_class = MemoryFileWrapper
83
+ filter.output_root = "/path/to/output"
84
+ filter.input_files = input_files
85
+ filter.output_files.should == [MemoryFileWrapper.new("/path/to/output", "ember.js", "UTF-8")]
86
+ end
87
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rake::Pipeline::ManifestEntry do
4
+ let(:hash) do
5
+ {
6
+ "deps" => {
7
+ "file.h" => 100,
8
+ "other.h" => 100
9
+ },
10
+ "mtime" => 200
11
+ }
12
+ end
13
+
14
+ subject {
15
+ Rake::Pipeline::ManifestEntry.from_hash(hash)
16
+ }
17
+
18
+ describe "#from_hash" do
19
+ it "creates a new ManifestEntry from a hash" do
20
+ subject.should be_kind_of described_class
21
+ end
22
+
23
+ it "should leave mtimes have integers" do
24
+ subject.mtime.should == 200
25
+ end
26
+
27
+ it "parses each time from the deps value into a Time" do
28
+ subject.deps.each do |file, mtime|
29
+ mtime.should == 100
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "#as_json" do
35
+ it "returns a hash representation of the entry for converting to json" do
36
+ subject.as_json.should == {
37
+ :deps => {
38
+ "file.h" => 100,
39
+ "other.h" => 100
40
+ },
41
+ :mtime => 200
42
+ }
43
+ end
44
+ end
45
+ end
46
+
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rake::Pipeline::Manifest do
4
+ before do
5
+ # ensure all our date/time conversions happen in UTC.
6
+ ENV['TZ'] = 'UTC'
7
+ end
8
+
9
+ let(:manifest_file) { "#{tmp}/manifest.json" }
10
+
11
+ let(:json) { <<-JSON }
12
+ {
13
+ "file.h": {
14
+ "deps": {
15
+ "other.h": "2000-01-01 00:00:00 +0000"
16
+ },
17
+ "mtime":"2000-01-01 00:00:00 +0000"
18
+ }
19
+ }
20
+ JSON
21
+
22
+ let(:entries_hash) do
23
+ {
24
+ "file.h" => Rake::Pipeline::ManifestEntry.from_hash({
25
+ "deps" => {
26
+ "other.h" => "2000-01-01 00:00:00 +0000"
27
+ },
28
+ "mtime" => "2000-01-01 00:00:00 +0000"
29
+ })
30
+ }
31
+ end
32
+
33
+ subject do
34
+ Rake::Pipeline::Manifest.new(manifest_file)
35
+ end
36
+
37
+ describe "#write_manifest" do
38
+ before do
39
+ subject.entries = entries_hash
40
+ rm_rf manifest_file
41
+ end
42
+
43
+ it "writes a manifest json file to disk" do
44
+ subject.write_manifest
45
+
46
+ File.exist?(manifest_file).should be_true
47
+ JSON.parse(File.read(manifest_file)).should == JSON.parse(json)
48
+ end
49
+
50
+ it "writes nothing if it's empty" do
51
+ subject.entries = {}
52
+ subject.write_manifest
53
+ File.exist?(manifest_file).should be_false
54
+ end
55
+ end
56
+
57
+ describe "#read_manifest" do
58
+ before do
59
+ File.open(manifest_file, 'w') { |f| f.puts json }
60
+ end
61
+
62
+ it "reads a manifest json file from disk" do
63
+ subject.read_manifest
64
+ subject.entries.should == entries_hash
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,141 @@
1
+ describe "a matcher" do
2
+ sep = File::SEPARATOR
3
+
4
+ let(:project) { Rake::Pipeline::Project.new }
5
+
6
+ before do
7
+ @matcher = Rake::Pipeline::Matcher.new :project => project
8
+
9
+ @files = %w(jquery.js sproutcore.js sproutcore.css).map do |file|
10
+ file_wrapper(file)
11
+ end
12
+
13
+ @matcher.input_files = @files
14
+ end
15
+
16
+ def file_wrapper(file, options={})
17
+ root = options[:root] || tmp
18
+ encoding = options[:encoding] || "UTF-8"
19
+ Rake::Pipeline::FileWrapper.new(root, file, encoding)
20
+ end
21
+
22
+ it "accepts input files" do
23
+ @matcher.input_files.should == @files
24
+ end
25
+
26
+ it "can access its glob" do
27
+ @matcher.glob = "*.js"
28
+ @matcher.glob.should == "*.js"
29
+ end
30
+
31
+ it "knows about its containing pipeline" do
32
+ pipeline = Rake::Pipeline.new
33
+ pipeline.add_filter @matcher
34
+ @matcher.pipeline.should == pipeline
35
+ end
36
+
37
+ it "only processes files matching the matcher" do
38
+ @matcher.glob = "*.js"
39
+ @matcher.output_root = "tmp1"
40
+
41
+ concat = Rake::Pipeline::ConcatFilter.new
42
+ concat.output_name_generator = proc { |input| "app.js" }
43
+ @matcher.add_filter concat
44
+
45
+ @matcher.setup
46
+
47
+ concat.input_files.should == [
48
+ file_wrapper("jquery.js", :encoding => "BINARY"),
49
+ file_wrapper("sproutcore.js", :encoding => "BINARY")
50
+ ]
51
+
52
+ @matcher.output_files.should == [
53
+ file_wrapper("app.js", :root => File.join(tmp, "tmp1")),
54
+ file_wrapper("sproutcore.css")
55
+ ]
56
+ end
57
+
58
+ def should_match_glob(glob, files)
59
+ @matcher.glob = glob
60
+ @matcher.output_root = "tmp1"
61
+
62
+ concat = Rake::Pipeline::ConcatFilter.new
63
+ concat.output_name_generator = proc { |input| input }
64
+ @matcher.add_filter concat
65
+
66
+ @matcher.setup
67
+
68
+ @matcher.output_files.should == files
69
+ end
70
+
71
+ it "understands */* style globs" do
72
+ @matcher.input_files << file_wrapper("javascripts/backbone.js")
73
+ @matcher.input_files << file_wrapper("something/javascripts/backbone.js")
74
+
75
+ should_match_glob "*/*.js", [
76
+ file_wrapper("javascripts/backbone.js", :encoding => "BINARY", :root => File.join(tmp, "tmp1")),
77
+ file_wrapper("jquery.js"),
78
+ file_wrapper("sproutcore.js"),
79
+ file_wrapper("sproutcore.css"),
80
+ file_wrapper("something/javascripts/backbone.js")
81
+ ]
82
+
83
+ should_match_glob "proutcore*.js", [
84
+ file_wrapper("jquery.js"),
85
+ file_wrapper("sproutcore.js"),
86
+ file_wrapper("sproutcore.css"),
87
+ file_wrapper("javascripts/backbone.js"),
88
+ file_wrapper("something/javascripts/backbone.js")
89
+ ]
90
+ end
91
+
92
+ it "understands **/* style globs" do
93
+ @matcher.input_files << file_wrapper("javascripts/backbone.js")
94
+
95
+ output_root = File.join(tmp, "tmp1")
96
+
97
+ should_match_glob "**/*.js", [
98
+ file_wrapper("jquery.js", :encoding => "BINARY", :root => output_root),
99
+ file_wrapper("sproutcore.js", :encoding => "BINARY", :root => output_root),
100
+ file_wrapper("javascripts/backbone.js", :encoding => "BINARY", :root => output_root),
101
+ file_wrapper("sproutcore.css")
102
+ ]
103
+ end
104
+
105
+ it "understands {foo,bar}/* style globs" do
106
+ @matcher.input_files << file_wrapper("javascripts/backbone.js")
107
+
108
+ output_root = File.join(tmp, "tmp1")
109
+
110
+ should_match_glob "{jquery,sproutcore}.js", [
111
+ file_wrapper("jquery.js", :encoding => "BINARY", :root => output_root),
112
+ file_wrapper("sproutcore.js", :encoding => "BINARY", :root => output_root),
113
+ file_wrapper("sproutcore.css"),
114
+ file_wrapper("javascripts/backbone.js")
115
+ ]
116
+ end
117
+
118
+ it "accepts Regexp as glob" do
119
+ regexp = /application\.erb/
120
+ @matcher.glob = regexp
121
+
122
+ @matcher.glob.should == regexp
123
+ end
124
+
125
+ it "underestands regexp globs" do
126
+ regexp = /^*(?<!\.coffee)\.js$/i
127
+
128
+ @matcher.input_files << file_wrapper("application.coffee.js")
129
+ @matcher.input_files << file_wrapper("application.engine.js")
130
+
131
+ output_root = File.join(tmp, "tmp1")
132
+
133
+ should_match_glob regexp, [
134
+ file_wrapper("jquery.js", :encoding => "BINARY", :root => output_root),
135
+ file_wrapper("sproutcore.js", :encoding => "BINARY", :root => output_root),
136
+ file_wrapper("application.engine.js", :encoding => "BINARY", :root => output_root),
137
+ file_wrapper("sproutcore.css"),
138
+ file_wrapper("application.coffee.js")
139
+ ]
140
+ end
141
+ end
@@ -0,0 +1,199 @@
1
+ require "rake-pipeline/middleware"
2
+ require "rake-pipeline/filters"
3
+ require "rack/test"
4
+
5
+ describe "Rake::Pipeline Middleware" do
6
+ include Rack::Test::Methods
7
+
8
+ inputs = {
9
+ "app/javascripts/jquery.js" => "var jQuery = {};\n",
10
+
11
+ "app/javascripts/sproutcore.js" => <<-HERE.gsub(/^ {6}/, ''),
12
+ var SC = {};
13
+ assert(SC);
14
+ SC.hi = function() { console.log("hi"); };
15
+ HERE
16
+
17
+ "app/index.html" => "<html>HI</html>",
18
+ "app/javascripts/index.html" => "<html>JAVASCRIPT</html>",
19
+ "app/empty_dir" => nil
20
+ }
21
+
22
+ expected_output = <<-HERE.gsub(/^ {4}/, '')
23
+ var jQuery = {};
24
+ var SC = {};
25
+
26
+ SC.hi = function() { console.log("hi"); };
27
+ HERE
28
+
29
+ assetfile_source = <<-HERE.gsub(/^ {4}/, '')
30
+ require "#{tmp}/../support/spec_helpers/filters"
31
+ output "public"
32
+
33
+ map "/dynamic-request.js" do
34
+ [200, { "Content-Type" => "text/plain" }, ["I am dynamic!"]]
35
+ end
36
+
37
+ input "#{tmp}", "app/**/*" do
38
+ match "*.js" do
39
+ concat "javascripts/application.js"
40
+ filter(Rake::Pipeline::SpecHelpers::Filters::StripAssertsFilter) { |input| input }
41
+ end
42
+
43
+ # copy the rest
44
+ concat { |input| input.sub(%r|^app/|, '') }
45
+ end
46
+ HERE
47
+
48
+ modified_assetfile_source = <<-HERE.gsub(/^ {4}/, '')
49
+ require "#{tmp}/../support/spec_helpers/filters"
50
+ output "public"
51
+
52
+ input "#{tmp}", "app/**/*" do
53
+ match "*.js" do
54
+ concat { "javascripts/app.js" }
55
+ filter(Rake::Pipeline::SpecHelpers::Filters::StripAssertsFilter) { |input| input }
56
+ end
57
+
58
+ # copy the rest
59
+ concat { |input| input.sub(%r|^app/|, '') }
60
+ end
61
+ HERE
62
+
63
+ app = middleware = nil
64
+
65
+ let(:app) { middleware }
66
+
67
+ before do
68
+ assetfile_path = File.join(tmp, "Assetfile")
69
+ File.open(assetfile_path, "w") { |file| file.write(assetfile_source) }
70
+
71
+ project = Rake::Pipeline::Project.new assetfile_path
72
+
73
+ app = lambda { |env| [404, {}, ['not found']] }
74
+ middleware = Rake::Pipeline::Middleware.new(app, project)
75
+ end
76
+
77
+ describe "dynamic requests" do
78
+ it "returns the value from the given block for paths that have been mapped" do
79
+ get "/dynamic-request.js"
80
+
81
+ last_response.should be_ok
82
+ last_response.headers["Content-Type"].should == "text/plain"
83
+ last_response.body.should == "I am dynamic!"
84
+ end
85
+ end
86
+
87
+ describe "static requests" do
88
+ before do
89
+ inputs.each do |name, string|
90
+ path = File.join(tmp, name)
91
+ if string
92
+ mkdir_p File.dirname(path)
93
+ File.open(path, "w") { |file| file.write(string) }
94
+ else
95
+ mkdir_p path
96
+ end
97
+ end
98
+
99
+ get "/javascripts/application.js"
100
+ end
101
+
102
+ it "returns files relative to the output directory" do
103
+ last_response.should be_ok
104
+
105
+ last_response.body.should == expected_output
106
+ last_response.headers["Content-Type"].should == "application/javascript"
107
+ end
108
+
109
+ it "updates the output when files change" do
110
+ age_existing_files
111
+
112
+ File.open(File.join(tmp, "app/javascripts/jquery.js"), "w") do |file|
113
+ file.write "var jQuery = {};\njQuery.trim = function() {};\n"
114
+ end
115
+
116
+ expected = <<-HERE.gsub(/^ {6}/, '')
117
+ var jQuery = {};
118
+ jQuery.trim = function() {};
119
+ var SC = {};
120
+
121
+ SC.hi = function() { console.log("hi"); };
122
+ HERE
123
+
124
+ get "/javascripts/application.js"
125
+
126
+ last_response.body.should == expected
127
+ last_response.headers["Content-Type"].should == "application/javascript"
128
+ end
129
+
130
+ it "updates the output when new files are added" do
131
+ age_existing_files
132
+
133
+ File.open(File.join(tmp, "app/javascripts/history.js"), "w") do |file|
134
+ file.write "var History = {};\n"
135
+ end
136
+
137
+ expected = <<-HERE.gsub(/^ {6}/, '')
138
+ var History = {};
139
+ var jQuery = {};
140
+ var SC = {};
141
+
142
+ SC.hi = function() { console.log("hi"); };
143
+ HERE
144
+
145
+ get "/javascripts/application.js"
146
+
147
+ last_response.body.should == expected
148
+ last_response.headers["Content-Type"].should == "application/javascript"
149
+ end
150
+
151
+ it "returns index.html for directories" do
152
+ get "/"
153
+
154
+ last_response.body.should == "<html>HI</html>"
155
+ last_response.headers["Content-Type"].should == "text/html"
156
+
157
+ get "/javascripts"
158
+
159
+ last_response.body.should == "<html>JAVASCRIPT</html>"
160
+ last_response.headers["Content-Type"].should == "text/html"
161
+ end
162
+
163
+ it "ignores directories without index.html" do
164
+ get "/empty_dir"
165
+
166
+ last_response.body.should == "not found"
167
+ last_response.status.should == 404
168
+ end
169
+
170
+ it "falls back to the app" do
171
+ get "/zomg.notfound"
172
+
173
+ last_response.body.should == "not found"
174
+ last_response.status.should == 404
175
+ end
176
+
177
+ it "recreates the pipeline when the Assetfile changes" do
178
+ get "/javascripts/app.js"
179
+ last_response.body.should == "not found"
180
+ last_response.status.should == 404
181
+
182
+ File.open(File.join(tmp, "Assetfile"), "w") do |file|
183
+ file.write(modified_assetfile_source)
184
+ end
185
+
186
+ expected = <<-HERE.gsub(/^ {6}/, '')
187
+ var jQuery = {};
188
+ var SC = {};
189
+
190
+ SC.hi = function() { console.log("hi"); };
191
+ HERE
192
+
193
+ get "/javascripts/app.js"
194
+
195
+ last_response.body.should == expected
196
+ last_response.headers["Content-Type"].should == "application/javascript"
197
+ end
198
+ end
199
+ end