Sha256: 6c71bc04920b8277f5095d1712414bd3ba1f97338a47dd6d535e148ae68021d5

Contents?: true

Size: 767 Bytes

Versions: 3

Compression:

Stored size: 767 Bytes

Contents

ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
require 'spec'
require 'spec/rails'

Spec::Runner.configure do |config|

end

class Class
  # Creates a new subclass of self, with a name "under" our own name. Example:
  #
  #     x = Foo::Bar.subclass('Zap'){}
  #     x.name # => Foo::Bar::Zap_1
  #     x.superclass.name # => Foo::Bar
  #
  # Removed from RSpec after 1.1.something; reproduced here because much of the
  # spec suite was already written with dynamic class creation.
  def subclass(base_name, &body)
    klass = Class.new(self)
    class_name = "#{self.name}_#{base_name}"
    instance_eval do
      const_set(class_name, klass)
    end
    klass.instance_eval(&body)
    klass
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rakismet-0.4.2 spec/spec_helper.rb
rakismet-0.4.1 spec/spec_helper.rb
rakismet-0.4.0 spec/spec_helper.rb