Sha256: 4ce244c1818cceab0fd3333d23731c6a4486231e976241bd4d03e1713bb05ea6

Contents?: true

Size: 1017 Bytes

Versions: 9

Compression:

Stored size: 1017 Bytes

Contents

require "test_construct"

module Roger
  module Testing
    # 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
    class MockProject < Project
      include TestConstruct::Helpers

      attr_accessor :construct

      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

      # Destroy will remove all files/directories
      def destroy
        teardown_construct(construct) if construct
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
roger-1.4.3 lib/roger/testing/mock_project.rb
roger-1.4.2 lib/roger/testing/mock_project.rb
roger-1.3.5 lib/roger/testing/mock_project.rb
roger-1.4.1 lib/roger/testing/mock_project.rb
roger-1.4.0 lib/roger/testing/mock_project.rb
roger-1.3.4 lib/roger/testing/mock_project.rb
roger-1.3.3 lib/roger/testing/mock_project.rb
roger-1.3.2 lib/roger/testing/mock_project.rb
roger-1.3.0 lib/roger/testing/mock_project.rb