zoomifier/spec/zoomifier_helper_spec.rb

50 lines
2.1 KiB
Ruby
Raw Normal View History

require File.dirname(__FILE__) + '/spec_helper'
2008-11-24 04:41:10 +00:00
require File.dirname(__FILE__) + '/../../../../config/environment'
require 'zoomifier_helper'
2008-11-24 21:39:13 +00:00
describe Zoomifier::ViewHelpers, "when installed into a rails app" do
before(:all) do
load File.dirname(__FILE__) + '/../install.rb'
end
it "should have copied the zoomify viewer" do
File.file?(File.dirname(__FILE__) + '/../../../../public/swfs/zoomifyViewer.swf').should be_true
end
it "should have copied the swfobject library" do
File.file?(File.dirname(__FILE__) + '/../../../../public/javascripts/swfobject.js').should be_true
end
end
describe Zoomifier::ViewHelpers, "when included into ActionView" do
2008-11-24 04:41:10 +00:00
before(:all) do
ActionView::Base.send :include, Zoomifier::ViewHelpers
@view = ActionView::Base.new
end
it "should respond to zoomify_image_tag" do
@view.should respond_to(:zoomify_image_tag)
end
2008-11-24 04:41:10 +00:00
it "should register swfobject.js as a default javascript library" do
2008-11-24 21:39:13 +00:00
@view.javascript_include_tag(:defaults).match(/"\/javascripts\/swfobject.js/).should_not be_nil
end
2008-11-24 04:41:10 +00:00
it "should generate the zoomify markup" do
2008-11-24 08:18:49 +00:00
@view.zoomify_image_tag('foo.jpg', { :id => 'foo', :alt => 'Foo Bar', :width => 800, :height => 500 }).should ==
'<div id="foo"><img alt="Foo Bar" height="500" src="/images/foo.jpg" width="800" /></div>' +
"<script type=\"text/javascript\">\n//<![CDATA[\n" +
2008-11-25 04:18:47 +00:00
"swfobject.embedSWF('/swfs/zoomifyViewer.swf', 'foo', '800', '500', '9.0.0', false, { zoomifyImagePath: '/images/foo/' });\n//]]>\n" +
2008-11-24 08:18:49 +00:00
'</script>'
2008-11-24 04:41:10 +00:00
end
2008-11-25 04:18:47 +00:00
it "should automatically zoomify an image" do
FileUtils.copy(File.dirname(__FILE__) + '/data/1024x768.jpg', RAILS_ROOT + '/public/images/')
File.directory?(RAILS_ROOT + '/public/images/1024x768/').should be_false
@view.zoomify_image_tag('1024x768.jpg', {:id => 'foo', :alt => 'Foo Bar', :width => 400, :height => 300 })
File.directory?(RAILS_ROOT + '/public/images/1024x768/').should be_true
FileUtils.rm_rf(RAILS_ROOT + '/public/images/1024x768/')
File.delete(RAILS_ROOT + '/public/images/1024x768.jpg')
end
end