spec/imgkit_spec.rb in imgkit-1.3.0 vs spec/imgkit_spec.rb in imgkit-1.3.1
- old
+ new
@@ -30,11 +30,11 @@
it "should default to 'UTF-8' encoding" do
imgkit = IMGKit.new('Captación')
end
=end
- it "should not have any stylesheedt by default" do
+ it "should not have any stylesheet by default" do
imgkit = IMGKit.new('<h1>Oh Hai</h1>')
imgkit.stylesheets.should be_empty
end
end
@@ -122,18 +122,26 @@
it "should generate an Image with a symbol parameter" do
imgkit = IMGKit.new('html', :username => 'chris')
img = imgkit.to_img
filetype_of(img).should include('JPEG')
end
-
+
it "should have the stylesheet added to the head if it has one" do
imgkit = IMGKit.new("<html><head></head><body>Hai!</body></html>")
css = File.join(SPEC_ROOT,'fixtures','example.css')
imgkit.stylesheets << css
imgkit.to_img
imgkit.source.to_s.should include("<style>#{File.read(css)}</style>")
end
-
+
+ it "should accept stylesheet as an object which responds to #read" do
+ imgkit = IMGKit.new("<html><head></head><body>Hai!</body></html>")
+ css = StringIO.new( File.read(File.join(SPEC_ROOT,'fixtures','example.css')) )
+ imgkit.stylesheets << css
+ imgkit.to_img
+ imgkit.source.to_s.should include("<style>#{css.string}</style>")
+ end
+
it "should prepend style tags if the HTML doesn't have a head tag" do
imgkit = IMGKit.new("<html><body>Hai!</body></html>")
css = File.join(SPEC_ROOT,'fixtures','example.css')
imgkit.stylesheets << css
imgkit.to_img