Sha256: f45dcfaf81a5b43339a8942bcf62592d61360f2ad0ba4ab41c936342788a4f63

Contents?: true

Size: 963 Bytes

Versions: 10

Compression:

Stored size: 963 Bytes

Contents

module NoConnections
  def self.included(mod)
    (class << mod; self; end).class_eval do
      def columns
        []
      end

      def connection
        RSpec::Mocks::Mock.new.as_null_object
      end
    end
  end
end

class NonActiveRecordModel
  extend ActiveModel::Naming
  include ActiveModel::Conversion
end

class MockableModel < ActiveRecord::Base
  include NoConnections
  has_one :associated_model
end

class SubMockableModel < MockableModel
end

class AssociatedModel < ActiveRecord::Base
  include NoConnections
  belongs_to :mockable_model
end

class AlternatePrimaryKeyModel < ActiveRecord::Base
  include NoConnections
  self.primary_key = :my_id
  attr_accessor :my_id
end

class ConnectableModel < ActiveRecord::Base
  establish_connection :adapter => 'sqlite3',
                       :database => ':memory:'

  connection.execute <<-eosql
    CREATE TABLE connectable_models (
      id integer PRIMARY KEY AUTOINCREMENT
    )
  eosql
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rspec-rails-2.4.1 spec/rspec/rails/mocks/ar_classes.rb
rspec-rails-2.4.0 spec/rspec/rails/mocks/ar_classes.rb
rspec-rails-2.3.1 spec/rspec/rails/mocks/ar_classes.rb
rspec-rails-2.3.0 spec/rspec/rails/mocks/ar_classes.rb
rspec-rails-2.2.1 spec/rspec/rails/mocks/ar_classes.rb
rspec-rails-2.2.0 spec/rspec/rails/mocks/ar_classes.rb
rspec-rails-2.1.0 spec/rspec/rails/mocks/ar_classes.rb
rspec-rails-2.0.1 spec/rspec/rails/mocks/ar_classes.rb
rspec-rails-2.0.0 spec/rspec/rails/mocks/ar_classes.rb
rspec-rails-2.0.0.rc spec/rspec/rails/mocks/ar_classes.rb