Sha256: 8da6e215914c88250f4664204439a7e09f5a21650876e79f61ba6b4813cdc8a4

Contents?: true

Size: 796 Bytes

Versions: 2

Compression:

Stored size: 796 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(ArEnums::Base)
    expected_attrs.each do |atrib, expected_value|
      enum.send(atrib).should == expected_value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ar-enums-2.0.1 spec/spec_helper.rb
ar-enums-2.0.0 spec/spec_helper.rb