Skip to content

Instantly share code, notes, and snippets.

@anithri
Created March 12, 2013 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anithri/5147357 to your computer and use it in GitHub Desktop.
Save anithri/5147357 to your computer and use it in GitHub Desktop.
Having an issue with rspec should_recieve().with.ordered
1) Ruzo::Crm#get_records should get more than 1 slice for counts over @max_records
Failure/Error: crm.should_receive(:get_record_slice).with("Contacts",{from:1, to: 4}).ordered
#<Ruzo::Crm:0x00000002e2f980> received :get_record_slice with unexpected arguments
expected: ("Contacts", {:from=>1, :to=>4})
got: ("Contacts", {:from=>1, :to=>8}), ("Contacts", {:from=>5, :to=>12})
# ./spec/crm_spec.rb:88:in `block (4 levels) in <top (required)>'
it "should get more than 1 slice for counts over @max_records" do
crm = Ruzo::Crm.new(@authtoken, max_records: 4)
VCR.use_cassette('contacts', record: :new_episodes) do
raw_result = crm.get_record_slice("Contacts",from: 1, to: 4) #get a raw result to use in stub
crm.stub(:get_record_slice).and_return(raw_result) #stub .get_record_slice
#Expect get_record_slice to be called with different arguments each time
crm.should_receive(:get_record_slice).with("Contacts",{from:1, to: 4}).ordered
crm.should_receive(:get_record_slice).with("Contacts",{from:5, to: 8}).ordered
#Call method that calls stubs
result = crm.get_records("Contacts", count: 8)
#make sure we get an 8 element array as a result
result.should be_a Array
result.should have_exactly(8).items
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment