Sha256: 44053cb9d14cbc47b51fc1270dccd7f1025a9668e32d48d5446acbea6a06da02

Contents?: true

Size: 866 Bytes

Versions: 2

Compression:

Stored size: 866 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.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

2 entries across 2 versions & 1 rubygems

Version Path
review-2.3.0 test/book_test_helper.rb
review-2.2.0 test/book_test_helper.rb