Sha256: 94476101b7e7fdfe645947b7ff960e7151bd0a2446b2ed25b46db4c897a06787

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require "stepper_motor"
require "active_support/testing/time_helpers"
require "active_job"
require "active_record"
require "globalid"
require_relative "helpers/side_effects"

module StepperMotorRailtieTestHelpers
  def establish_test_connection
    ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: fake_app_root + "/db.sqlite3")
    StepperMotor::InstallGenerator.source_root(File.dirname(__FILE__) + "/../../lib")
  end

  def fake_app_root
    File.dirname(__FILE__) + "/app"
  end

  def run_generator
    generator = StepperMotor::InstallGenerator.new
    generator.destination_root = fake_app_root
    generator.create_migration_file
  end

  def run_migrations
    # Before running the migrations we need to require the migration files, since there is no
    # "full" Rails environment available
    Dir.glob(fake_app_root + "/db/migrate/*.rb").sort.each do |migration_file_path|
      require migration_file_path
    end

    ActiveRecord::Migrator.migrations_paths = [File.join(fake_app_root + "/db/migrate")]
    ActiveRecord::Tasks::DatabaseTasks.root = fake_app_root
    ActiveRecord::Tasks::DatabaseTasks.migrate
  end
end

RSpec.configure do |config|
  # Enable flags like --only-failures and --next-failure
  config.example_status_persistence_file_path = ".rspec_status"

  # Disable RSpec exposing methods globally on `Module` and `main`
  config.disable_monkey_patching!

  config.expect_with :rspec do |c|
    c.syntax = :expect
  end

  config.include ActiveSupport::Testing::TimeHelpers
  config.include StepperMotorRailtieTestHelpers
  config.include SideEffects::SpecHelper
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stepper_motor-0.1.2 spec/spec_helper.rb
stepper_motor-0.1.1 spec/spec_helper.rb
stepper_motor-0.1.0 spec/spec_helper.rb