Skip to content

Commit

Permalink
Examples for separating out your specs into other directories
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyhaines committed Oct 29, 2010
1 parent 0c8ad18 commit afe794d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
34 changes: 34 additions & 0 deletions spec/asset_resource/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/scripts_1/script1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$(document).ready(function() {
console.log('I am script 1');
});
3 changes: 3 additions & 0 deletions spec/fixtures/scripts_2/script2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$(document).ready(function() {
console.log('I am script 2');
});

0 comments on commit afe794d

Please sign in to comment.