Sha256: 3df07dd8ff07c0ed8a50a59d742f67fff21d27ea5206cc252e58448cf3330796

Contents?: true

Size: 1.6 KB

Versions: 5

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'

describe Cuesmash::Compiler do

  before(:each) do
    Cuesmash::Compiler.any_instance.stub(:puts)
  end

  it "should have a scheme instance" do
    compiler = Cuesmash::Compiler.new("scheme", "/tmp")
    expect(compiler.scheme).to match("scheme")
  end

  it "should have a tmp_dir instance" do
    compiler = Cuesmash::Compiler.new("scheme", "/tmp")
    expect(compiler.tmp_dir).to match("/tmp")
  end

  describe "when generating the command" do

    before(:each) do
      Cuesmash::Compiler.any_instance.stub(:workspace)
      @compiler = Cuesmash::Compiler.new("test-scheme", "/tmp")
    end

    it "should contain the scheme" do
      expect(@compiler.instance_eval{command}).to match(/test-scheme/)
    end

    it "should contain the tmp path" do
      expect(@compiler.instance_eval{command}).to match(/tmp/)
    end
  end

  describe "when getting the workspacae" do

    before(:each) do
      @compiler = Cuesmash::Compiler.new(nil, "/tmp")
      Dir.stub(:[]){["workspace-file"]}
    end

    it "should get the workspace from the current directory" do
      expect(@compiler.instance_eval{workspace}).to match(/workspace-file/)
    end
  end

  describe "when compiling" do

    before(:each) do
      wait = double
      @value = double
      wait.stub(:value){@value}
      wait.stub(:join)
      Open3.stub(:popen3).and_yield(nil, nil, nil, wait)

      @compiler = Cuesmash::Compiler.new(nil, "/tmp")
    end

    it "should complete if all is well" do
      @value.stub(:exitstatus){0}
      @compiler.compile do |complete|
        expect(complete).to equal(true)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cuesmash-0.1.6 spec/compiler_spec.rb
cuesmash-0.1.5.1 spec/compiler_spec.rb
cuesmash-0.1.5 spec/compiler_spec.rb
cuesmash-0.1.4 spec/compiler_spec.rb
cuesmash-0.1.3 spec/compiler_spec.rb