Sha256: e61b3729cb7dada46a0f62d20c92ae8c586ee9855983a1148a0bdd4f0de2f046

Contents?: true

Size: 1.79 KB

Versions: 4

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'
describe Qfill::Result do
  context "#new" do
    context "with no arguments" do
      it "should raise ArgumentError" do
        expect { Qfill::Result.new() }.to raise_error(ArgumentError)
      end
    end
    context "with name" do
      before :each do
        @arguments = { :name => "Best Results" }
      end
      it "should not raise any errors" do
        expect { Qfill::Result.new(@arguments) }.to_not raise_error
      end
      it "should instantiate with name" do
        Qfill::Result.new(@arguments).name.should == 'Best Results'
      end
    end
    context "with ratio" do
      before :each do
        @arguments = {  :name => "Best Results",
                        :ratio => 0.5 }
      end
      it "should instantiate with elements" do
        Qfill::Result.new(@arguments).ratio.should == 0.5
      end
    end
    context "with filter" do
      before :each do
        lambda = -> (object) { !object.nil? }
        @filter = Qfill::Filter.new(lambda)
        @arguments = {  :name => "Best Results",
                        :ratio => 0.5,
                        :filter => @filter }
      end
      it "should instantiate with filter" do
        Qfill::Result.new(@arguments).filter.should be_a(Qfill::Filter)
        Qfill::Result.new(@arguments).filter.should == @filter
      end
    end
    context "with list_ratios" do
      before :each do
        @arguments = {  :name => "Best Results",
                        :ratio => 0.5,
                        :list_ratios => {
                          "High Price" => 0.4,
                          "Medium Price" => 0.3,
                          "Low Price" => 0.3 } }
      end
      it "should instantiate with elements" do
        Qfill::Result.new(@arguments).list_ratios["High Price"].should == 0.4
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
qfill-0.0.4 spec/qfill/result_spec.rb
qfill-0.0.3 spec/qfill/result_spec.rb
qfill-0.0.2 spec/qfill/result_spec.rb
qfill-0.0.1 spec/qfill/result_spec.rb