Class: Roger::Testing::MockProject

Inherits:
Project
  • Object
show all
Includes:
TestConstruct::Helpers
Defined in:
lib/roger/testing/mock_project.rb

Overview

A Mock project. If initialized without a path it will create a test_construct with the following (empty) paths:

  • html

  • partials

  • layouts

  • releases

Use MockProject in testing but never forget to call:

MockProject#destroy

in teardown otherwise you pollute your filesystem with build directories

Instance Attribute Summary collapse

Attributes inherited from Project

#html_path, #layouts_path, #mode, #options, #partial_path, #path, #rogerfile, #rogerfile_path

Instance Method Summary collapse

Methods inherited from Project

#release, #server, #test

Constructor Details

#initialize(path = nil, config = {}) ⇒ MockProject

Returns a new instance of MockProject.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/roger/testing/mock_project.rb', line 25

def initialize(path = nil, config = {})
  unless path
    self.construct = setup_construct
    path = construct

    %w(html partials layouts releases).each do |dir|
      construct.directory dir
    end
  end
  # Call super to initialize
  super(path, config)
end

Instance Attribute Details

#constructObject

Returns the value of attribute construct.



23
24
25
# File 'lib/roger/testing/mock_project.rb', line 23

def construct
  @construct
end

Instance Method Details

#destroyObject

Destroy will remove all files/directories



39
40
41
# File 'lib/roger/testing/mock_project.rb', line 39

def destroy
  teardown_construct(construct) if construct
end

#shellObject



43
44
45
# File 'lib/roger/testing/mock_project.rb', line 43

def shell
  @shell ||= MockShell.new
end