Sha256: 7ac983bb1ed8dbd11a2d52cd779d0afa0905699a7c9b692b15e1cacd027fe441

Contents?: true

Size: 1.47 KB

Versions: 12

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe "Cmds.chomp" do
  it "gets echo output" do
    expect( Cmds.chomp "echo %s", "hey there!" ).to eq "hey there!"
  end

  it "reads input" do
    expect(
      Cmds.chomp("ruby -e %{script}", script: "puts STDIN.read") {
        "hey there!"
      }
    ).to eq "hey there!"
  end
end # Cmds.chomp

describe "Cmds.chomp!" do
  it "gets echo output" do
    expect( Cmds.chomp! "echo %s", "hey there!" ).to eq "hey there!"
  end

  it "reads input" do
    expect(
      Cmds.chomp!("ruby -e %{script}", script: "puts STDIN.read") {
        "hey there!"
      }
    ).to eq "hey there!"
  end

  it "errors when the command fails" do
    expect { Cmds.chomp! "false" }.to raise_error SystemCallError
  end
end # Cmds.chomp!

describe "Cmds#chomp" do
  it "gets echo output" do
    expect( Cmds.new("echo %s").chomp "hey there!" ).to eq "hey there!"
  end

  it "reads input" do
    expect(
      Cmds.new("ruby -e %{script}").chomp(script: "puts STDIN.read") {
        "hey there!"
      }
    ).to eq "hey there!"
  end
end # Cmds#chomp

describe "Cmds#chomp!" do
  it "gets echo output" do
    expect( Cmds.new("echo %s").chomp! "hey there!" ).to eq "hey there!"
  end

  it "reads input" do
    expect(
      Cmds.new("ruby -e %{script}").chomp!(script: "puts STDIN.read") {
        "hey there!"
      }
    ).to eq "hey there!"
  end

  it "errors when the command fails" do
    expect { Cmds.new("false").chomp! }.to raise_error SystemCallError
  end
end # Cmds#chomp!

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cmds-0.2.11 spec/cmds/chomp_spec.rb
cmds-0.2.10 spec/cmds/chomp_spec.rb
cmds-0.2.9 spec/cmds/chomp_spec.rb
cmds-0.2.8 spec/cmds/chomp_spec.rb
cmds-0.2.7 spec/cmds/chomp_spec.rb
cmds-0.2.6 spec/cmds/chomp_spec.rb
cmds-0.2.5 spec/cmds/chomp_spec.rb
cmds-0.2.4 spec/cmds/chomp_spec.rb
cmds-0.2.3 spec/cmds/chomp_spec.rb
cmds-0.2.2 spec/cmds/chomp_spec.rb
cmds-0.2.1 spec/cmds/chomp_spec.rb
cmds-0.2.0 spec/cmds/chomp_spec.rb