Sha256: d383040e91fe58b5aabd125c2e8f4c16a7b575f887c948412c906c6ac5b89f46

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

require 'rspec'
require 'ar-enums'

RSpec.configure do |config|
  config.before :suite do
    ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
    load(File.dirname(__FILE__) + "/schema.rb")
  end
  
  def define_model_class(name = "TestClass", parent_class_name = "ActiveRecord::Base", &block)
  	ActiveSupport::Dependencies.send :remove_const, name rescue nil
  	eval("class #{name} < #{parent_class_name}; end", TOPLEVEL_BINDING)
  	klass = eval(name, TOPLEVEL_BINDING)
  	klass.class_eval(&block) if block_given?
  end
end

RSpec::Matchers.define :be_enum_with do |expected_attrs|
  match do |enum|
    enum.should be_a(ActiveRecord::Enum)
    expected_attrs.each do |atrib, expected_value|
      enum.send(atrib).should == expected_value
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ar-enums-1.0.0 spec/spec_helper.rb