Sha256: a4e0e03e9eafa73be3693a6b5a1e659d9679c5381725b9cf91d6b362564c3a66

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'
require 'ronin/script/buildable'
require 'script/classes/buildable_class'

describe Script::Buildable do
  subject do
    obj = BuildableClass.new
    obj.instance_eval do
      build { @output = "hello #{@var}" }
    end

    obj
  end

  it "should not be built by default" do
    expect(subject).not_to be_built
  end

  it "should include Testable" do
    expect(subject.class.included_modules).to include(Script::Testable)
  end

  describe "#build!" do
    it "should call the build block" do
      subject.build!

      expect(subject.output).to eq("hello world")
    end

    it "should mark the script as built" do
      subject.build!

      expect(subject).to be_built
    end

    it "should accept parameters as options" do
      subject.build!(:var => 'dave')

      expect(subject.output).to eq("hello dave")
      expect(subject.var).to eq('dave')
    end
  end

  describe "#verify!" do
    it "should raise a NotBuilt exception when verifying unbuilt scripts" do
      expect {
        subject.test!
      }.to raise_error(Script::NotBuilt)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-1.5.1 spec/script/buildable_spec.rb