Sha256: 838b6686ee0ac9cae8167fff5a6d1d3c6730bf868eac6fb6bfff9804f81ce41a

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe MetricFu::Metric do
  before do
    @metric = MetricFu::Metric.get_metric(:flog)
    #@original_options = @metric.run_options.dup
  end

  #it "can have its run_options over-written" do
    #new_options = {:foo => 'bar'}
    #@metric.run_options = new_options
    #expect(@original_options).to_not eq(new_options)
    #expect(@metric.run_options).to eq(new_options)
  #end

  #it "can have its run_options modified" do
    #new_options = {:foo => 'bar'}
    #@metric.run_options.merge!(new_options)
    #expect(@metric.run_options).to eq(@original_options.merge(new_options))
  #end

  context "given a valid configurable option" do

    before do
      allow(@metric).to receive(:default_run_options).and_return({:foo => 'baz'})
    end

    it "can be configured as an attribute" do
      @metric.foo = 'qux'
      expect(@metric.run_options[:foo]).to eq('qux')
    end

  end

  context "given an invalid configurable option" do

    before do
      allow(@metric).to receive(:default_run_options).and_return({})
    end

    it "raises an error" do
      expect { @metric.foo = 'bar' }.to raise_error(RuntimeError, /not a valid configuration option/)
    end

  end

  after do
    @metric.configured_run_options.clear
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metric_fu-4.11.3 spec/metric_fu/metric_spec.rb
metric_fu-4.11.2 spec/metric_fu/metric_spec.rb