Sha256: f9167bc9b9ebda2a99f49355451672f00fc70d38b5e4a8441ba8cfb63a931f74

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'spec_helper'

describe Scripted::Configuration do

  it "can define groups" do
    subject.group :foo
    subject.group :bar
    expect(subject).to have(2).groups
  end

  it "defines commands on the default group" do
    subject.run "foo"
    expect(subject).to have(1).groups
  end

  it "handles non existing files" do
    subject.config_file "non-existing.rb"
    expect { subject.load_files }.to raise_error Scripted::ConfigFileNotFound
  end

  it "adds the default file on demand" do
    expect {
      subject.with_default_config_file!
    }.to change { subject.config_files }.to ["scripted.rb"]
  end

  it "does not allow setting out without a formatter" do
    expect { subject.out "foo" }.to raise_error Scripted::NoFormatterForOutput
  end

  it "changes the last formatter to use a different output" do
    subject.formatter :table, :out => "old.log"
    expect { subject.out "new.log" }.to change { subject.formatters.first[:out] }.to "new.log"
  end

  it "can set multple formatter" do
    subject.formatter :table, :out => "old.log"
    subject.formatter :websocket
    expect(subject).to have(2).formatters
  end

  it "reraises all configuration errors so they are easily rescued" do
    expect {
      subject.evaluate do
        fooasdad
      end
    }.to raise_error Scripted::ConfigurationSyntaxError
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scripted-0.0.1 spec/scripted/configuration_spec.rb