Sha256: b0b7ad7c471ba1dbb5e594e952868dbb5b1e8b6fb5e016df80e12fc9fcf78ade

Contents?: true

Size: 780 Bytes

Versions: 6

Compression:

Stored size: 780 Bytes

Contents

module CoreExt
  module Testing
    module Declarative
      unless defined?(Spec)
        # Helper to define a test method using a String. Under the hood, it replaces
        # spaces with underscores and defines the test method.
        #
        #   test "verify something" do
        #     ...
        #   end
        def test(name, &block)
          test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
          defined = method_defined? test_name
          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

6 entries across 6 versions & 1 rubygems

Version Path
core_ext-0.0.6 lib/core_ext/testing/declarative.rb
core_ext-0.0.5 lib/core_ext/testing/declarative.rb
core_ext-0.0.4 lib/core_ext/testing/declarative.rb
core_ext-0.0.3 lib/core_ext/testing/declarative.rb
core_ext-0.0.2 lib/core_ext/testing/declarative.rb
core_ext-0.0.1 lib/core_ext/testing/declarative.rb