spec/static_assets_spec.rb in sinatra-exstatic-assets-2.0.1 vs spec/static_assets_spec.rb in sinatra-exstatic-assets-2.0.3
- old
+ new
@@ -17,21 +17,21 @@
let(:expected) { "image.jpg" }
it { should_not be_nil }
it { should == expected }
its(:fullpath) { should == fullpath }
its(:timestamp) { should == Time.now.to_i }
- its(:"is_uri?") { should be_false }
+ its(:"is_uri?") { should be_falsy }
its(:querystring) { should == "?ts=#{Time.now.to_i}" }
end
context "Given a url" do
let(:filename) { "http://code.jquery.com/jquery-1.9.1.min.js" }
let(:expected) { "http://code.jquery.com/jquery-1.9.1.min.js" }
it { should_not be_nil }
it { should == expected }
its(:fullpath) { should be_nil }
its(:timestamp) { should == false }
- its(:"is_uri?") { should be_true }
+ its(:"is_uri?") { should be_truthy }
its(:querystring) { should be_nil }
end
end
describe Tag do
@@ -96,14 +96,25 @@
File.stub(:mtime).with(fullpath).and_return(time)
end
context "Stylesheets" do
let(:url) { "/stylesheets/winter.css" }
let(:filename) { "/stylesheets/winter.css" }
- let(:expected) { %Q!<link charset="utf-8" href="/bar/stylesheets/winter.css?ts=#{time}" media="screen" rel="stylesheet" />! }
- subject { o.send :sss_stylesheet_tag, url }
+ context "Given a filename" do
+ context "But no options" do
+ let(:expected) { %Q!<link charset="utf-8" href="/bar/stylesheets/winter.css?ts=#{time}" media="screen" rel="stylesheet" />! }
+ subject { o.send :sss_stylesheet_tag, url }
+ it { should == expected }
+ end
+ context "with options" do
+ context "media=print" do
+ let(:expected) { %Q!<link charset="utf-8" href="/bar/stylesheets/winter.css?ts=#{time}" media="print" rel="stylesheet" />! }
+ subject { o.send :sss_stylesheet_tag, url, media: "print" }
+ it { should == expected }
+ end
+ end
+ end
it { should_not be_nil }
- it { should == expected }
end
context "Javascripts" do
let(:url) { "/js/get_stuff.js" }
let(:filename) { "/js/get_stuff.js" }
let(:expected) { %Q!<script charset="utf-8" src="/bar/js/get_stuff.js?ts=#{time}"></script>! }
@@ -120,9 +131,20 @@
it { should_not be_nil }
it { should == expected }
end
context "Remote" do
let(:url) { "http://example.org/images/foo.png" }
+ let(:filename) { "/images/foo.png" }
+ let(:expected) { %Q!<img src="#{url}" />! }
+ subject {
+ o.send :sss_image_tag,
+ url
+ }
+ it { should_not be_nil }
+ it { should == expected }
+ end
+ context "Remote and secure" do
+ let(:url) { "https://example.org/images/foo.png" }
let(:filename) { "/images/foo.png" }
let(:expected) { %Q!<img src="#{url}" />! }
subject {
o.send :sss_image_tag,
url
\ No newline at end of file