Sha256: 2cf0a9b8d73fa447a40da9519080748f175423268821c82be5189ea0ddbc74c5

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

require 'test_helper'
begin; require 'activerecord'; rescue LoadError; end
begin; require 'dm-core'; rescue LoadError; end
require 'gravatarify'

class GravatarifyIntegrationTest < Test::Unit::TestCase
  def setup; reset_gravatarify! end

  context "ActiveRecord::Base" do
    if defined?(ActiveRecord)    
      should "include Gravatarify::ObjectSupport" do
        assert ActiveRecord::Base.included_modules.include?(Gravatarify::ObjectSupport)
      end
    
      should "respond to #gravatarify" do
        assert_respond_to ActiveRecord::Base, :gravatarify
      end
    else
      context "tests" do
        should "be run (but looks like ActiveRecord is not available)" do
          flunk "ActiveRecord not available -> thus tests are incomplete (error can be ignored though!)"          
        end
      end      
    end
  end
  
  context "DataMapper model (User)" do      
    if defined?(DataMapper)             
      setup do
        class User
          include DataMapper::Resource
          property :id, Serial
          property :name, String
          property :email, String
          property :author_email, String
          
          gravatarify
        end
      end
      
      should "include Gravatarify::ObjectSupport" do
        assert User.included_modules.include?(Gravatarify::ObjectSupport)
      end
      
      should "respond to #gravatarify" do
        assert_respond_to User, :gravatarify
      end
      
      context "as instance" do
        should "be able to build correct gravatar_url's!" do
          u = User.new(:email => "peter.gibbons@initech.com")
          assert_equal "http://0.gravatar.com/avatar/cb7865556d41a3d800ae7dbb31d51d54.jpg", u.gravatar_url
        end
      end
    else
      context "tests" do
        should "be run (but looks like DataMapper is not available)" do
          flunk "DataMapper not available -> thus tests are incomplete (error can be ignored though!)"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gravatarify-1.1.0 test/gravatarify_integration_test.rb
gravatarify-1.0.0 test/gravatarify_integration_test.rb