Skip to content

Commit

Permalink
Got gem unit tests running with rake test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yosem Sweet committed Jul 28, 2011
1 parent 582faf6 commit 20c0c68
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
11 changes: 10 additions & 1 deletion Rakefile
@@ -1,2 +1,11 @@
require 'bundler'
Bundler::GemHelper.install_tasks
Bundler::GemHelper.install_tasks


require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.test_files = FileList['test/*\.rb']
t.verbose = true
end

30 changes: 30 additions & 0 deletions lib/acts_as_opengraph/helper/acts_as_opengraph_helper.rb
Expand Up @@ -45,6 +45,36 @@ def like_button_for(obj, options = {})
end
config[:locale] ||= 'en_US'

if config[:xfbml]
unless @fb_sdk_included
content_for :javascripts, fb_javascript_include_tag( config[:locale], config[:appid] )
end
like_html = %(<fb:like href="#{CGI.escape(href)}" layout="#{config[:layout]}" show_faces="#{config[:show_faces]}" action="#{config[:action]}" colorscheme="#{config[:colorscheme]}" width="#{config[:width]}" height="#{config[:height]}" font="#{config[:font]}"></fb:like>)
else
like_html = %(<iframe src="http://www.facebook.com/plugins/like.php?href=#{CGI.escape(href)}&amp;layout=#{config[:layout]}&amp;show_faces=#{config[:show_faces]}&amp;width=#{config[:width]}&amp;action=#{config[:action]}&amp;colorscheme=#{config[:colorscheme]}&amp;height=#{config[:height]}" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:#{config[:width]}px; height:#{config[:height]}px;" allowTransparency="true"></iframe>)
end

like_html.respond_to?(:html_safe) ? like_html.html_safe : like_html
end

def comments_for(obj, options = {})
raise(ArgumentError.new, "You need to call acts_as_opengraph on your #{obj.class} model") unless obj.respond_to?(:opengraph_data)
href = options[:href] ? options[:href] : obj.opengraph_url
return unless href.present?

onfig = { :layout => :standard, :show_faces => false, :width => 450, :action => :like, :colorscheme => :light }
config.update(options) if options.is_a?(Hash)

o_layout = config[:layout].to_sym
if o_layout == :standard
config[:height] = config[:show_faces].to_s.to_sym == :true ? 80 : 35
elsif o_layout == :button_count
config[:height] = 21
elsif o_layout == :box_count
config[:height] = 65
end
config[:locale] ||= 'en_US'

if config[:xfbml]
unless @fb_sdk_included
content_for :javascripts, fb_javascript_include_tag( config[:locale], config[:appid] )
Expand Down
2 changes: 1 addition & 1 deletion test/opengraph_test.rb
Expand Up @@ -39,7 +39,7 @@ class MovieTest < Test::Unit::TestCase
<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>
<meta property="og:url" content="#{MOVIE_URL}"/>
<meta property="og:description" content="#{MOVIE_DESCRIPTION}"/>
<meta property="og:site-name" content="IMDb"/>)
<meta property="og:site_name" content="IMDb"/>)

GENERATED_LIKE_BUTTON = %(<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt0117500%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe>)
GENERATED_LIKE_BUTTON_CUSTOM_URL = %(<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fexample.com%2Fmovies%2F6&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe>)
Expand Down

0 comments on commit 20c0c68

Please sign in to comment.