Sha256: 96093fcca1b61a68c5d8567b1af21b2bb695bfc087df0b503fd9d9d5cdff7b55

Contents?: true

Size: 1.33 KB

Versions: 11

Compression:

Stored size: 1.33 KB

Contents

# encoding: UTF-8

require "tetra"

module Tetra
  # custom mock methods
  module Mockers
    # creates a minimal tetra project
    def create_mock_project
      @project_path = File.join("spec", "data", "test-project")
      Dir.mkdir(@project_path)

      Tetra::Project.init(@project_path, false)
      @project = Tetra::Project.new(@project_path)
    end

    # deletes the mock project and all contents
    def delete_mock_project
      FileUtils.rm_rf(@project_path)
    end

    # creates an executable in kit that will print its parameters
    # in a test_out file for checking. Returns mocked executable
    # full path
    def create_mock_executable(executable_name)
      Dir.chdir(@project_path) do
        dir = mock_executable_dir(executable_name)
        FileUtils.mkdir_p(dir)
        executable_path = mock_executable_path(executable_name)
        File.open(executable_path, "w") { |io| io.puts "echo $0 $*>test_out" }
        File.chmod(0777, executable_path)
        executable_path
      end
    end

    # returns the path for a mocked executable's directory
    def mock_executable_dir(executable_name)
      File.join("kit", executable_name, "bin")
    end

    # returns the path for a mocked executable
    def mock_executable_path(executable_name)
      File.join(mock_executable_dir(executable_name), executable_name)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
tetra-1.2.2 spec/spec_helper.rb
tetra-1.2.1 spec/spec_helper.rb
tetra-1.2.0 spec/spec_helper.rb
tetra-1.1.0 spec/spec_helper.rb
tetra-1.0.0 spec/spec_helper.rb
tetra-0.54.0 spec/spec_helper.rb
tetra-0.53.0 spec/spec_helper.rb
tetra-0.52.0 spec/spec_helper.rb
tetra-0.51.0 spec/spec_helper.rb
tetra-0.50.0 spec/spec_helper.rb
tetra-0.49.0 spec/spec_helper.rb