Sha256: d63a4d5080a409417b2c1a44ebf1fbdc0acd8b43ea8fdc335bab5a59a9d07275

Contents?: true

Size: 914 Bytes

Versions: 11

Compression:

Stored size: 914 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)
        book.config = ReVIEW::Configure.values
        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

11 entries across 11 versions & 1 rubygems

Version Path
review-4.2.0 test/book_test_helper.rb
review-4.1.0 test/book_test_helper.rb
review-4.0.0 test/book_test_helper.rb
review-3.2.0 test/book_test_helper.rb
review-3.1.0 test/book_test_helper.rb
review-3.0.0 test/book_test_helper.rb
review-3.0.0.rc1 test/book_test_helper.rb
review-3.0.0.preview4 test/book_test_helper.rb
review-3.0.0.preview3 test/book_test_helper.rb
review-3.0.0.preview2 test/book_test_helper.rb
review-3.0.0.preview1 test/book_test_helper.rb