Sha256: 94165113b5a14afa081692f144fbe72f1eb71881621fb44477062ba3d2991e00

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

require 'test_helper'
require 'book_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.each_with_object({}) do |name, memo|
      value = obj.instance_variable_get(name)
      if value.instance_variables.empty?
        memo[name] = value
      else
        memo[name] = get_instance_variables(value)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
review-2.5.0 test/book_test_helper.rb