Sha256: f7a30c02a821b7635e05e31daad0e30a0bbcb184eb7df0dc4f7bee8c695d37a6

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

module QBFC::Test
  class Info < QBFC::Info
    def self.qb_name
      "Company"
    end
  end
end

describe QBFC::Info do

 before(:each) do 
    @sess = mock(QBFC::Session)
    @ole_wrapper = mock(QBFC::OLEWrapper)
    @info = mock(QBFC::Test::Info)
    
    # Request related mocks
    @request = mock("QBFC::Request")
    @response = mock("QBFC::Request#response")
    
    QBFC::Request.stub!(:new).with(@sess, 'CompanyQuery').and_return(@request)
    @request.stub!(:response).and_return(@response)
    QBFC::Test::Info.stub!(:new).with(@sess, @response).and_return(@info)
    @request.stub!(:apply_options)
  end
  
  describe ".get" do
    it "should create Request and get response" do
      QBFC::Request.should_receive(:new).with(@sess, 'CompanyQuery').and_return(@request)
      @request.should_receive(:response).and_return(@response)
      QBFC::Test::Info.should_receive(:new).with(@sess, @response).and_return(@info)
      QBFC::Test::Info::get(@sess)
    end
    
    it "applies options to Request" do
      @request.should_receive(:apply_options).with({:owner_id => 0})
      QBFC::Test::Info::get(@sess, :owner_id => 0)
    end
  end
  
  describe ".find" do
    it "should forward request, without 'what' argument, to get" do
      QBFC::Test::Info.should_receive(:get).with(@sess, {})
      QBFC::Test::Info::find(@sess, :first, {})
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qbfc-0.2.0-x86-mswin32-60 spec/unit/info_spec.rb
qbfc-0.1.0-x86-mswin32-60 spec/unit/info_spec.rb