Sha256: 1bf3179c1cfb93e00035aa341df6089746848408ca6289d9935376bb151d967a

Contents?: true

Size: 1022 Bytes

Versions: 9

Compression:

Stored size: 1022 Bytes

Contents

module ActiveSupport
  module Testing
    module Declarative
      
      def self.extended(klass)
        klass.class_eval do
          
          unless method_defined?(:describe)
            def self.describe(text)
              class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
                def self.name
                  "#{text}"
                end
              RUBY_EVAL
            end
          end
          
        end
      end 

      unless defined?(Spec)
        # test "verify something" do
        #   ...
        # end
        def test(name, &block)
          test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
          defined = instance_method(test_name) rescue false
          raise "#{test_name} is already defined in #{self}" if defined
          if block_given?
            define_method(test_name, &block)
          else
            define_method(test_name) do
              flunk "No implementation provided for #{name}"
            end
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
activesupport-3.0.0.rc lib/active_support/testing/declarative.rb
csd-0.1.5 lib/active_support/testing/declarative.rb
csd-0.1.4 lib/active_support/testing/declarative.rb
csd-0.1.3 lib/active_support/testing/declarative.rb
csd-0.1.2 lib/active_support/testing/declarative.rb
csd-0.1.1 lib/active_support/testing/declarative.rb
csd-0.1.0 lib/active_support/testing/declarative.rb
csd-0.0.16 lib/active_support/testing/declarative.rb
activesupport-3.0.0.beta4 lib/active_support/testing/declarative.rb