Sha256: ccd97527acb866c4836834a98cc2545d10a20552a350485b4498e025210c5ed1

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

require 'test_setup'
require 'active_support/string_inquirer'

class Rails
  def self.env
    ActiveSupport::StringInquirer.new("production")
  end
end

module ActiveRecord
  class Base; end
end

module Mongoid
  module Document 
    def self.included(klass)
      klass.extend ClassMethods
    end

    module ClassMethods
      def all
        @_users ||= User.all
      end

      def limit(*args)
        self
      end

      def skip(*args)
        all
      end
    end
  end
end

class User

  attr_reader :id, :email, :name

  def initialize(options = {})
    options.each do |k,v|
      instance_variable_set(:"@#{k}", v)
    end
  end

  MOCK_USERS = [
    {:id => 1, :email => "ben@intercom.io", :name => "Ben McRedmond"},
    {:id => 2, :email => "ciaran@intercom.io", :name => "Ciaran Lee"}
  ]

  def self.find_in_batches(*args)
    yield(MOCK_USERS.map {|u| new(u)})
  end

  def self.all
    MOCK_USERS.map { |u| new(u) }
  end

  def self.first
    new(MOCK_USERS.first)
  end

  def self.<(other)
    other == ActiveRecord::Base
  end

end

module ImportTest

  def setup
    super
    IntercomRails.config.stub(:api_key).and_return("abcd")
  end

  def teardown
    super
    Rails.rspec_reset
    User.rspec_reset
    IntercomRails::Import.rspec_reset
    IntercomRails::Import.unstub_all_instance_methods
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
intercom-rails-0.2.24 test/import_test_setup.rb
intercom-rails-0.2.23 test/import_test_setup.rb
intercom-rails-0.2.22 test/import_test_setup.rb
intercom-rails-0.2.21 test/import_test_setup.rb
intercom-rails-0.2.20 test/import_test_setup.rb
intercom-rails-0.2.19 test/import_test_setup.rb
intercom-rails-0.2.18 test/import_test_setup.rb