Sha256: 9f00e05bffedacd7ec34de86be5f56c9f001f89bd3833048674bfe547f3accbc
Contents?: true
Size: 1.65 KB
Versions: 4
Compression:
Stored size: 1.65 KB
Contents
require 'spec_helper' class TestBaseClass < Trackerific::Base def required_options [:required, :also_required] end end describe 'Trackerific::Base' do before(:all) do @base = Trackerific::Base.new end describe :required_options do it "should return an Array" do @base.required_options().should be_kind_of Array end end describe "tracking_service" do include Trackerific context "when given a UPS tracking number" do specify { tracking_service("1Z12345E0291980793").should eq Trackerific::UPS } end context "when given a USPS tracking number" do specify { tracking_service("EJ958083578US").should eq Trackerific::USPS } end context "when given a FedEx tracking number" do specify { tracking_service("183689015000001").should eq Trackerific::FedEx } end context "when given an invalid tracking number" do specify { tracking_service("invalid tracking number").should be_nil } end end context "with a new Trackerific::Base class that has required options" do context "has all the required options" do it "should be able to create a new instance" do t = TestBaseClass.new(:required => true, :also_required => :yup) t.should be_a TestBaseClass end end context "is missing some required options" do it "should raise an ArgumentError" do lambda { TestBaseClass.new() }.should raise_error(ArgumentError) end end context "has an invalid option" do it "should raise an ArgumentError" do lambda { TestBaseClass.new(:unknown => :argument ) }.should raise_error(ArgumentError) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems