Sha256: b801f75f45aca124d9ef6520fb3c5416af130d9e3cdea7831d30366038413e18

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

module VoteSmart
  describe Office do
    
    describe "all" do
      
      before :each do
        Office::Type.stub!(:all).and_return([Office::Type.new("officeTypeId" => "P"), 
                                             Office::Type.new("officeTypeId" => "C")])
      end
      
      def do_find
        Office.all
      end
      
      it_should_find :count => 19, :first => {:name => "President", :id => "1"},
                                   :last => {:name => "U.S. House", :id => "5"}
      
    end
    
    describe "find_all_by_type" do
      
      def do_find
        Office.find_all_by_type_id("P")
      end
      
      it_should_find :count => 17, :first => {:name => "President", :id => "1"},
                                   :last => {:name => "Vice President", :id => "2"}
      
    end
    
    describe "find_all_by_name" do
      
      before :each do
        Office::Type.stub!(:all).and_return([Office::Type.new("officeTypeId" => "P"), 
                                             Office::Type.new("officeTypeId" => "C"),
                                             Office::Type.new("officeTypeId" => "S")])
      end
      
      def do_find
        Office.find_all_by_name(["Secretary of State", "Attorney General"])
      end
      
      it_should_find :count => 2, :first => {:name => "Secretary of State", :id => "44"},
                                   :last => {:name => "Attorney General", :id => "12"}
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
votesmart-0.4.1 spec/vote_smart/office_spec.rb