Sha256: 846c15e6f5983340a3d786748041d484d2ebd0a0ae05da67e2b52193907fc464

Contents?: true

Size: 1.39 KB

Versions: 8

Compression:

Stored size: 1.39 KB

Contents

require 'spec_helper'

describe Picky::Wrappers::Sources::Location do

  context "with backend" do
    before(:each) do
      @source   = stub :source
      @category = stub :category
    end
    context "without grid option" do
      it "fails" do
        lambda { described_class.new(:something) }.should raise_error
      end
    end
    context "with grid option" do
      before(:each) do
        @wrapper = described_class.new @source, 10
      end
      it "uses a default of 1 on the precision" do
        @wrapper.calculation.precision.should == 1
      end
      it "delegates harvest" do
        @category.stub! :exact => {}

        @source.should_receive(:harvest).once.with @category

        @wrapper.harvest @category
      end
      it "delegates take_snapshot" do
        @source.should_receive(:take_snapshot).once.with()

        @wrapper.take_snapshot
      end
      it "delegates connect_backend" do
        @source.should_receive(:connect_backend).once.with()

        @wrapper.connect_backend
      end
    end
    context "with grid and precision option" do
      before(:each) do
        @wrapper = described_class.new @category, 4, 2
      end
      it "uses the given precision" do
        @wrapper.calculation.precision.should == 2
      end
    end
  end
  context "without backend" do
    it "fails" do
      lambda { described_class.new }.should raise_error(ArgumentError)
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
picky-3.4.3 spec/lib/sources/wrappers/location_spec.rb
picky-3.4.2 spec/lib/sources/wrappers/location_spec.rb
picky-3.4.1 spec/lib/sources/wrappers/location_spec.rb
picky-3.4.0 spec/lib/sources/wrappers/location_spec.rb
picky-3.3.3 spec/lib/sources/wrappers/location_spec.rb
picky-3.3.2 spec/lib/sources/wrappers/location_spec.rb
picky-3.3.1 spec/lib/sources/wrappers/location_spec.rb
picky-3.3.0 spec/lib/sources/wrappers/location_spec.rb