iterating towards a working helper
This commit is contained in:
parent
6d055a09b8
commit
bcb5a6df93
4
init.rb
Normal file
4
init.rb
Normal file
@ -0,0 +1,4 @@
|
||||
require 'zoomifier'
|
||||
require 'zoomifier_helper'
|
||||
|
||||
ActionView::Base.send :include, Zoomifier::ViewHelpers
|
@ -1,6 +1,8 @@
|
||||
module Zoomifier
|
||||
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
|
||||
|
@ -1,16 +1,22 @@
|
||||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../../../config/environment'
|
||||
require 'zoomifier_helper'
|
||||
|
||||
class MockActionView
|
||||
include Zoomifier::ViewHelpers
|
||||
end
|
||||
|
||||
describe Zoomifier::ViewHelpers do
|
||||
before(:all) do
|
||||
ActionView::Base.send :include, Zoomifier::ViewHelpers
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
@view = MockActionView.new
|
||||
@view = ActionView::Base.new
|
||||
end
|
||||
|
||||
it "should respond to zoomify_image_tag" do
|
||||
@view.should respond_to(:zoomify_image_tag)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user