Sha256: d831d55aeb970172c7b5e842b4d5fc32feb538dc3b0924a90cce5d2a8031a605

Contents?: true

Size: 981 Bytes

Versions: 1

Compression:

Stored size: 981 Bytes

Contents

require 'minitest/spec'

class MyWorld
  include Minitest::Assertions

  attr_accessor :assertions

  def initialize
    self.assertions = 0
    @temp_pathes = {}
  end

  def write_test_file(filename, content)
    # RSpec.describe -> describe
    content.gsub!("RSpec.describe", "describe")
    # example.run -> example.call
    content.gsub!("example.run", "example.call")

    content = <<-RUBY + content
      require 'minitest/autorun'
      require "#{File.expand_path("../../../lib/minitest/around/spec", __FILE__)}"

      require 'rspec/expectations/minitest_integration'
    RUBY
    write_file(filename, content)
  end

  def write_file(filename, content)
    Tempfile.open(filename) do |file|
      file.write content
      assoc_tempfile filename, file.path
    end
  end

  def path_for(filename)
    @temp_pathes.fetch(filename)
  end

  private

  def assoc_tempfile(filename, temp_path)
    @temp_pathes[filename] = temp_path
  end
end

World do
  MyWorld.new
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minitest-around-0.3.1 features/support/env.rb