File: posix_spec.rb

package info (click to toggle)
ruby-librarian 1.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 624 kB
  • sloc: ruby: 6,109; makefile: 11
file content (32 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require "librarian/posix"

require "support/project_path_macro"

describe Librarian::Posix do
  include Support::ProjectPathMacro

  let(:tmp_path) { project_path + "tmp/spec/functional/posix" }
  after { tmp_path.rmtree if tmp_path && tmp_path.exist? }

  describe ".run!" do

    it "returns the stdout" do
      res = described_class.run!(%w[echo hello there]).strip
      expect(res).to eq "hello there"
    end

    it "changes directory" do
      tmp_path.mkpath
      res = described_class.run!(%w[pwd], :chdir => tmp_path).strip
      expect(res).to eq tmp_path.to_s
    end

    it "reads the env" do
      res = described_class.run!(%w[env], :env => {"KOALA" => "BEAR"})
      line = res.lines.find{|l| l.start_with?("KOALA=")}.strip
      expect(line).to eq "KOALA=BEAR"
    end

  end

end