Sha256: 86a1e749568c024891240c2bf90be3dca88b09e0e67c47d641c1a5927341ce5b

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

require 'rubygems'
require 'test/unit'
require 'shoulda'
require 'redgreen'

$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'espresso'

require 'active_support/core_ext/string'
module Test
  module Unit
    class TestCase
      def self.should_have_class_methods(*methods)
        get_options!(methods)
        klass = described_type
        methods.each do |method|
          should "respond to class method ##{method}" do
            assert_respond_to(klass, method, "#{klass.name} does not have class method #{method}")
          end
        end
      end

      def self.should_have_instance_methods(*methods)
        get_options!(methods)
        klass = described_type
        instance = if block_given?
                     # Class initializer requires some attributes,
                     # or another custom generator used
                     yield
                   elsif klass.is_a?(Class)
                     klass.new
                   else
                     # klass is a module
                     metaclass = Class.new
                     metaclass.send(:include, klass)
                     metaclass.new
                   end
        methods.each do |method|
          should "respond to instance method ##{method}" do
            assert_respond_to(instance, method, "#{klass.name} does not have instance method #{method}")
          end
        end
      end
    end

    class TestCaseTest < TestCase
      should_have_class_methods :should_have_class_methods, :should_have_instance_methods
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
espresso-framework-0.3.0 test/test_helper.rb
espresso-0.2.1 test/test_helper.rb