Sha256: 98b74a69199d6bfed97bba2bff5b3ca87710493b79ad29c20041c6ffd09cd8f0

Contents?: true

Size: 1.02 KB

Versions: 22

Compression:

Stored size: 1.02 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

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

22 entries across 22 versions & 1 rubygems

Version Path
intercom-rails-0.2.17 test/import_test_setup.rb
intercom-rails-0.2.16 test/import_test_setup.rb
intercom-rails-0.2.15 test/import_test_setup.rb
intercom-rails-0.2.14 test/import_test_setup.rb
intercom-rails-0.2.13 test/import_test_setup.rb
intercom-rails-0.2.12 test/import_test_setup.rb
intercom-rails-0.2.11 test/import_test_setup.rb
intercom-rails-0.2.10 test/import_test_setup.rb
intercom-rails-0.2.9 test/import_test_setup.rb
intercom-rails-0.2.8 test/import_test_setup.rb
intercom-rails-0.2.7 test/import_test_setup.rb
intercom-rails-0.2.6 test/import_test_setup.rb
intercom-rails-0.2.5 test/import_test_setup.rb
intercom-rails-0.2.4 test/import_test_setup.rb
intercom-rails-0.2.3 test/import_test_setup.rb
intercom-rails-0.2.2 test/import_test_setup.rb
intercom-rails-0.2.1 test/import_test_setup.rb
intercom-rails-0.2.0 test/import_test_setup.rb
intercom-rails-0.1.1 test/import_test_setup.rb
intercom-rails-0.1.0 test/import_test_setup.rb