Sha256: 66fb77cefaac9178a880caac99932e882993a80482a0b96e04fc7678ee2fec9a

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

require 'aruba/rspec'
require 'arel'

module ChronoTest

  module Aruba
    def aruba_working_directory
      File.expand_path("../../#{::Aruba.config.working_directory}", __dir__)
    end

    def dummy_app_directory
      File.expand_path("../../tmp/railsapp/", __dir__)
    end

    def copy_dummy_app_into_aruba_working_directory
      unless File.file?(Pathname.new(dummy_app_directory).join('Rakefile'))
        raise %q(
          The dummy application does not exist
          Run `bundle exec rake testapp:create`
        )
      end
      FileUtils.rm_rf(Dir.glob("#{aruba_working_directory}/*"))
      FileUtils.cp_r(Dir.glob("#{dummy_app_directory}/*"), aruba_working_directory)
    end

    def recreate_railsapp_database
      connection = AR.connection # we're still the 'chronomodel' user
      database = 'chronomodel_railsapp'
      connection.drop_database   database
      connection.create_database database
    end

    def file_mangle!(file, &block)
      # Read
      file_contents = read(file).join("\n")

      # Mangle
      file_contents = block.call(file_contents)

      # Write
      write_file file, file_contents
    end

    def gem_version(name)
      spec = Bundler.locked_gems.specs.find {|s| s.name == name }
      return spec.version if spec
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
chrono_model-0.13.2 spec/support/aruba.rb
chrono_model-0.13.1 spec/support/aruba.rb
chrono_model-0.13.0 spec/support/aruba.rb
chrono_model-0.12.3 spec/support/aruba.rb
chrono_model-0.12.2 spec/support/aruba.rb
chrono_model-0.12.1 spec/support/aruba.rb