iterating towards a working helper

This commit is contained in:
Donald Ball 2008-11-23 22:41:10 -06:00
parent 6d055a09b8
commit bcb5a6df93
3 changed files with 18 additions and 6 deletions

4
init.rb Normal file
View File

@ -0,0 +1,4 @@
require 'zoomifier'
require 'zoomifier_helper'
ActionView::Base.send :include, Zoomifier::ViewHelpers

View File

@ -1,6 +1,8 @@
module Zoomifier module Zoomifier
module ViewHelpers module ViewHelpers
def zoomify_image_tag def zoomify_image_tag(source, options = {})
raise ArgumentError unless options[:id]
"<div id=\"#{options[:id]}\"><img src=\"#{source}\" alt=\"\"/></div>"
end end
end end
end end

View File

@ -1,16 +1,22 @@
require File.dirname(__FILE__) + '/spec_helper' require File.dirname(__FILE__) + '/spec_helper'
require File.dirname(__FILE__) + '/../../../../config/environment'
require 'zoomifier_helper' require 'zoomifier_helper'
class MockActionView describe Zoomifier::ViewHelpers do
include Zoomifier::ViewHelpers before(:all) do
ActionView::Base.send :include, Zoomifier::ViewHelpers
end end
describe Zoomifier::ViewHelpers do
before(:each) do before(:each) do
@view = MockActionView.new @view = ActionView::Base.new
end end
it "should respond to zoomify_image_tag" do it "should respond to zoomify_image_tag" do
@view.should respond_to(:zoomify_image_tag) @view.should respond_to(:zoomify_image_tag)
end end
it "should generate the zoomify markup" do
@view.zoomify_image_tag('foo.jpg', { :id => 'foo' }).should ==
'<div id="foo"><img src="foo.jpg" alt=""/></div>'
end
end end