Sha256: d4b819cc57fae57a1e94008155a568152f0d408505b6da06434d5df529d41f19

Contents?: true

Size: 818 Bytes

Versions: 233

Compression:

Stored size: 818 Bytes

Contents

# frozen_string_literal: true

module ActiveSupport
  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

233 entries across 218 versions & 28 rubygems

Version Path
activesupport-6.1.6 lib/active_support/testing/declarative.rb
activesupport-7.0.3 lib/active_support/testing/declarative.rb
activesupport-7.0.2.4 lib/active_support/testing/declarative.rb
activesupport-6.1.5.1 lib/active_support/testing/declarative.rb
activesupport-6.0.4.8 lib/active_support/testing/declarative.rb
activesupport-5.2.7.1 lib/active_support/testing/declarative.rb
activesupport-5.2.7 lib/active_support/testing/declarative.rb
activesupport-6.1.5 lib/active_support/testing/declarative.rb
activesupport-7.0.2.3 lib/active_support/testing/declarative.rb
activesupport-6.1.4.7 lib/active_support/testing/declarative.rb
activesupport-6.0.4.7 lib/active_support/testing/declarative.rb
activesupport-5.2.6.3 lib/active_support/testing/declarative.rb
activesupport-7.0.2.2 lib/active_support/testing/declarative.rb
activesupport-6.1.4.6 lib/active_support/testing/declarative.rb
activesupport-6.0.4.6 lib/active_support/testing/declarative.rb
activesupport-5.2.6.2 lib/active_support/testing/declarative.rb
activesupport-5.2.6.1 lib/active_support/testing/declarative.rb
activesupport-6.0.4.5 lib/active_support/testing/declarative.rb
activesupport-6.1.4.5 lib/active_support/testing/declarative.rb
activesupport-7.0.2.1 lib/active_support/testing/declarative.rb