From bcb5a6df931dbfd8fe106098721d4b1fdf75d289 Mon Sep 17 00:00:00 2001 From: Donald Ball Date: Sun, 23 Nov 2008 22:41:10 -0600 Subject: [PATCH] iterating towards a working helper --- init.rb | 4 ++++ lib/zoomifier_helper.rb | 4 +++- spec/zoomifier_helper_spec.rb | 16 +++++++++++----- 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 init.rb diff --git a/init.rb b/init.rb new file mode 100644 index 0000000..a384c77 --- /dev/null +++ b/init.rb @@ -0,0 +1,4 @@ +require 'zoomifier' +require 'zoomifier_helper' + +ActionView::Base.send :include, Zoomifier::ViewHelpers diff --git a/lib/zoomifier_helper.rb b/lib/zoomifier_helper.rb index c99f199..e6164a5 100644 --- a/lib/zoomifier_helper.rb +++ b/lib/zoomifier_helper.rb @@ -1,6 +1,8 @@ module Zoomifier module ViewHelpers - def zoomify_image_tag + def zoomify_image_tag(source, options = {}) + raise ArgumentError unless options[:id] + "
\"\"/
" end end end diff --git a/spec/zoomifier_helper_spec.rb b/spec/zoomifier_helper_spec.rb index aa6fd84..2f3767a 100644 --- a/spec/zoomifier_helper_spec.rb +++ b/spec/zoomifier_helper_spec.rb @@ -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 == + '
' + end end