Sha256: 9b4244ffaaa2a33d878833209fbd86430fe7b406f6b065dd460a7e021796a2d7

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)

describe CognitiveDistance::Measurements::Measurement do
  it "registers a named measurement" do
    class Foobar
      extend CognitiveDistance::Measurements::Measurement
      register :lameness
    end
    CognitiveDistance::Measurements.must_respond_to :measure_lameness
  end

  it "performs the registered measurement" do
    class Foobaz
      extend CognitiveDistance::Measurements::Measurement
      register :suckiness

      class << self
        attr_reader :received_args
        def measure *args
          @received_args = args
        end
      end
    end
    CognitiveDistance::Measurements.measure_suckiness('foo', 'bar', 'blarg')
    Foobaz.received_args.must_equal ['foo', 'bar', 'blarg']
  end

  it "allows a measurement method to be defined" do
    class Fooboss
      extend CognitiveDistance::Measurements::Measurement
      register :unfortunately, :most_unfortunate

      class << self
        attr_reader :received_args
        def most_unfortunate *args
          @received_args = args
        end
      end
    end
    CognitiveDistance::Measurements.measure_unfortunately(:x, :y, :z)
    Fooboss.received_args.must_equal [:x, :y, :z]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cognitive_distance-0.0.1.pre spec/cognitive_distance/measurements/measurement_spec.rb