Sha256: 99f6202ce2336610a1015da0706a584c762672038dec99efd9604b7fa065e698

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require "vagrant-spec/acceptance/output"

describe Vagrant::Spec::OutputTester do
  subject { described_class }

  let(:registry) { described_class }

  it "raises an exception if the matcher doesn't exist" do
    expect { subject.matches?("foo", :i_dont_exist) }.
      to raise_error(ArgumentError)
  end

  context "with a basic matcher" do
    before do
      registry[:test] = lambda do |text|
        text == "foo"
      end
    end

    after do
      registry.delete(:test)
    end

    it "should match with good input" do
      expect(described_class.matches?("foo", :test)).to be_true
    end

    it "should not match with bad output" do
      expect(described_class.matches?("bar", :test)).to_not be_true
    end
  end

  context "with a matcher with args" do
    before do
      registry[:test] = lambda do |text, compare|
        text == compare
      end
    end

    after do
      registry.delete(:test)
    end

    it "should match with good input" do
      expect(described_class.matches?("foo", :test, "foo")).to be_true
      expect(described_class.matches?("bar", :test, "bar")).to be_true
    end

    it "should not match with bad output" do
      expect(described_class.matches?("bar", :test, "foo")).to_not be_true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-spec-1df5a3af81cb/spec/acceptance/shared/output_spec.rb