Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Examples for separating out your specs into other directories

Signed-off-by: David Dollar <ddollar@gmail.com>
  • Loading branch information...
commit c8150d296654b71f8020301793f87266b330c2c5 1 parent 319a43a
@coreyhaines coreyhaines authored committed
View
34 spec/asset_resource/middleware_spec.rb
@@ -10,6 +10,40 @@
Artifice.activate_with(middleware)
end
+ context "separating out cache" do
+ let(:middleware) { AssetResource::Middleware.new(app, :base_path => asset_fixture,
+ :handlers => {:scripts_1 => "text/javascript",
+ :scripts_2 => 'text/javascript'}) }
+ before do
+ middleware.options[:handlers] = { :scripts_1 => "text/javascript",
+ :scripts_2 => "text/javascript" }
+ end
+
+ context "first split" do
+ it "includes the files in the first split" do
+ data = RestClient.get("http://localhost/assets/scripts_1.js")
+ data.should include("console.log('I am script 1')")
+ end
+
+ it "does not include the files in the second split" do
+ data = RestClient.get("http://localhost/assets/scripts_1.js")
+ data.should_not include("console.log('I am script 2')")
+ end
+ end
+
+ context "second split" do
+ it "includes the files in the second split" do
+ data = RestClient.get("http://localhost/assets/scripts_1.js")
+ data.should include("console.log('I am script 1')")
+ end
+
+ it "does not include the files in the first split" do
+ data = RestClient.get("http://localhost/assets/scripts_1.js")
+ data.should_not include("console.log('I am script 2')")
+ end
+ end
+ end
+
it "passes unhandled requests" do
RestClient.get("http://localhost/foo").to_s.should == "bar"
end
View
3  spec/fixtures/scripts_1/script1.js
@@ -0,0 +1,3 @@
+$(document).ready(function() {
+ console.log('I am script 1');
+});
View
3  spec/fixtures/scripts_2/script2.js
@@ -0,0 +1,3 @@
+$(document).ready(function() {
+ console.log('I am script 2');
+});
Please sign in to comment.
Something went wrong with that request. Please try again.