Sha256: 3d3621b13aafcc96356f36ae39f0ffc65e64cfe4714bfeecdeb09a04df7ada14

Contents?: true

Size: 867 Bytes

Versions: 1

Compression:

Stored size: 867 Bytes

Contents

require 'test_helper'
require 'review/book'

require 'stringio'
require 'tempfile'
require 'tmpdir'

include ReVIEW

module BookTestHelper
  def mktmpbookdir(files = {})
    created_files = {}
    Dir.mktmpdir do |tmpdir|
      Dir.chdir(tmpdir) do
        dir = "."
        files.each_pair do |basename, content|
          path = File.join(dir, basename)
          File.open(path, 'w') {|o| o.print content }
          created_files[basename] = path
        end
        book = Book::Base.load(dir)
        yield(dir, book, created_files)
      end
    end
  end

  def get_instance_variables(obj)
    obj.instance_variables.inject({}) do |memo, name|
      value = obj.instance_variable_get(name)
      if value.instance_variables.empty?
        memo[name] = value
      else
        memo[name] = get_instance_variables(value)
      end
      memo
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
review-2.1.0 test/book_test_helper.rb