Sha256: 333cc1e4168d3dc76e135ed256d5fce7044358eca30264caa052dcdc08936f62

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe BobTheHelper::Command do

  before(:each) do
    cleanup_working_directory
  end

  it "runs commands" do
    stdout = 'hello world'
    command = "echo #{stdout}"
    search_path = [ '/usr/bin' ]
    result = run_command(command, search_path: search_path)

    expect(result.stdout).to eq(stdout + "\n")
  end

  it "runs commands with default <root>/bin" do
  end

  it "takes input and run commands" do
    stdin = 'hello world'
    command = 'cat'
    search_path = [ '/usr/bin' ]
    result = run_command(command, stdin: stdin, search_path: search_path)

    expect(result.stdout).to eq(stdin)
  end

  it "makes use of ENV" do
    env = { 'THIS_IS_A_LONG_VARIABLE' => 'hello_world' }
    env_output = "THIS_IS_A_LONG_VARIABLE=hello_world\n"
    search_path = [ '/usr/bin' ]
    command = 'env | grep THIS_IS'

    result = run_command(command, env: env, search_path: search_path)
    expect(result.stdout).to eq(env_output)
  end

  it "checks if a directory/file exists" do
    file = 'blub123.txt'

    switch_to_working_directory do
      File.open(file, "wb") do |f|
        f.write ''
      end
    end

    result = path_exists? file
    expect(result).to eq(true)

    result = path_exists? 'asfdasdfsadf.txt'
    expect(result).to eq(false)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pointrb-0.1.2 spec/bob_the_helper/command/command_spec.rb
pointrb-0.1.1 spec/bob_the_helper/command/command_spec.rb
pointrb-0.1.0 spec/bob_the_helper/command/command_spec.rb