Sha256: 0e1022af6fa40cf714480657716de30f398ae47be35d0acef1ef85ec262a30da

Contents?: true

Size: 958 Bytes

Versions: 16

Compression:

Stored size: 958 Bytes

Contents

describe Devtools::Flay::Scale, '#measure' do
  subject(:measure) { instance.measure }

  let(:minimum_mass) { 0        }
  let(:files)        { [instance_double(File)] }
  let(:flay_masses) { { 0 => 5, 1 => 10 } }

  let(:instance) do
    described_class.new(minimum_mass: minimum_mass, files: files)
  end

  let(:flay_hashes) do
    {
      0 => instance_double(Array, size: 3),
      1 => instance_double(Array, size: 11)
    }
  end

  let(:flay) do
    instance_double(
      ::Flay,
      analyze: nil,
      masses:  flay_masses,
      hashes:  flay_hashes
    )
  end

  before do
    allow(::Flay).to receive(:new).with(mass: minimum_mass).and_return(flay)
    allow(flay).to receive(:process).with(*files)
  end

  it { should eql([Rational(5, 3), Rational(10, 11)]) }

  context 'when minimum mass is not 0' do
    let(:minimum_mass) { 1 }

    specify do
      measure
      expect(::Flay).to have_received(:new).with(mass: 1)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
devtools-0.1.19 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.18 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.16 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.15 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.14 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.13 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.12 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.11 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.10 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.9 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.8 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.7 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.6 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.5 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.4 spec/unit/devtools/flay/scale/measure_spec.rb
devtools-0.1.3 spec/unit/devtools/flay/scale/measure_spec.rb