similar to: stubbing a method that yeilds sequential results

Displaying 20 results from an estimated 300 matches similar to: "stubbing a method that yeilds sequential results"

2009 Apr 30
2
How to skip rest of code
Dear R users, Suppose I have 2 R script files: 'test1.R' and 'test2.R' and one R file 'main.R' which sources each of them. I wonder if there is a way to skip rest of code in 'test1.R' once a condition is met but still continue to run rest of script from the 'main'R' file. A simple example is shown below. I hope only 'message1' and
2007 Aug 31
48
Deprecating the mocking framework?
I saw in one of Dave C.''s comments to a ticket that "our current plan is to deprecate the mocking framework." I hadn''t heard anything about that, but then again I haven''t paid super close attention to the list. Are we planning on dumping the mock framework in favor of using Mocha (or any other framework one might want to plug in?). Pat
2004 Sep 25
3
Queue and Agent functionality
I've seen alot of posts lately on Queue and Agent functionality, and alot of hacks to make them do different things that most call center managers want. In the sake of doing this one time, I'd like to develop a single list of request so we can consolidate a feature request for the Queue/Agent system. Here are the ones that I run into the most: 1. Queue should know the status of agents
2007 Sep 19
2
Howto make deleted itens visible to users?
Hi! I'm using lazy_expunge to backup that are deleted/expunged, but I would like it to be visible to the user. I tried something like: namespace private { prefix = .EXPUNGED/ separator = / location = maildir:~/Maildir/.Apagadas } namespace private { prefix = .DELETED/ separator = / location = maildir:~/Maildir/.Apagadas } namespace private { prefix = .DELETED/.EXPUNGED/
2005 Jan 17
19
[Bug 973] sshd behaves differently while doing syslog entries for tcpwrappers denied message, with -r and without -r option.
http://bugzilla.mindrot.org/show_bug.cgi?id=973 Summary: sshd behaves differently while doing syslog entries for tcpwrappers denied message, with -r and without -r option. Product: Portable OpenSSH Version: 3.9p1 Platform: All OS/Version: All Status: NEW Severity: normal
2008 Nov 13
2
Mailbox Hashing
First off, the website documentation is really good for Dovecot but while reading I was not able to find anything pertaining to inbox hashing for Maildirs. I saw plenty about hashing the directories that the user mailboxes live in but nothing about specifically hashing an individual user's inbox directory itself. Is there any method for hashing the inbox automatically after say 5,000
2007 Aug 17
11
[rspec] looking for a simple refresher
I''ve been off the rspec for a few months and I''m trying to get back on it. 1) Spec::Mocks::MockExpectationError in ''TicketsController handling POST /tickets should create a new ticket'' Mock ''Ticket_1001'' expected :new with ({}) once, but received it 0 times ./spec/controllers/tickets_controller_spec.rb:16: script/spec:4: class
2006 Jan 03
3
Rails Noob Question
Apparently the first time I posted this, it was tacked onto the end of another thread. Please pardon my repost. Won''t happen again. -------- Howdy. I''m just getting into Rails, and really enjoying it! I''m coming from the .NET world, so I''ll embarrassedly admit that I''m running it on winXP and even using SQLServer (for now, may switch to mysql
2007 Aug 08
5
and_yield + instance_eval(&block)
I have the following code, which yields instance eval''s the block given: class Foo def bar(&blk) instance_eval &blk end def baz yield end end The effect of this is that self is reassigned: Foo.new.bar do # here, self is the instance of Foo # created by new end But normally self is the object in which Foo.new.bar {...} occurs. Foo.new.baz do
2007 Aug 06
1
Stubbing Enumerable#each
I have a mock of an instance of a class which descends from Array: class ArrayDescendent < Array; end #... in the specs... @descendent = mock ArrayDescendent How would I stub out ArrayDescendent#each, which is inherited from Array, to return multiple values successively? I could use and_yield, but that is raising an arity error (the anonymous function/ block should expect only *one
2007 Apr 20
7
Stubbing Model.new w/ block?
Ok, I followed the advice of the list and moved more code into my model from my controller. When developing tests for this new code, I ran into a problem... My model code creates a receipt object and sets some values on it: @receipt = Receipt.new do |r| r.x = 1 r.y = 2 # etc end I wanted to be able to stub out Receipt.new so that I could set expectations on the methods called on the
2008 Jun 05
1
Using and_yield to pass multiple or no iterations
Hi, imagine there''s a class called Egg which has the following method (which calls another method): <CODE> def do_thing has_iterated = false self.each_row do |row| has_iterated = true unless has_iterated end has_iterated end </CODE> Stupid code, I know. I have two questions with it. The first is, would it be possible to set it up to test the case when each_row
2008 Dec 04
3
The RSpec way of doing this? Need help on validating block
Hello, I''m back again with more questions about mocks and how to do good testing in general. Let''s say I''m writing this EmailSender class and I want to make it totally awesomely tested with RSpec. Here''s how far I''ve gotten so far: require ''net/smtp'' class EmailSender def send_email
2007 Jul 24
2
Mocking Resolv::DNS?
Hello Rspecers, I have a rails project where I am calling Resolv::DNS.open and then using the block to check a domain name. The code snippet in question is: domain = "mytest.com" Resolv::DNS.open do |dns| @mx = dns.getresources(domain, Resolv::DNS::Resource::IN::MX) end I obviously want to stub this out, especially for speed but can''t quite work out how. I
2007 Apr 17
8
Verifying that a block calls a method
I have something like the following: def my_fun my_fun2 do raise Error end end I know that I can verify that the method receives my_fun2. How can I mock/stub out the example to verify that it calls raise Error? Scott
2006 Dec 12
3
Stubs breaking other things
Hi All I''m working on converting some existing controller specs to use mocks and stubs rather than real ActiveRecord objects in a Rails project. In one of my controller actions, I use a database transaction. So, the obvious thing to do is have this in my setup block: Project.stub!(:transaction) Firstly, is there an easy way to have that stub yield to the block passed to any
2007 Feb 28
12
Specifying that code is called in a block
Not sure if this is possible currently. I have a section of code like this: ActiveRecord::Base.transaction do cow.save! duck.save! dog.save! end (Names changed to protect the innocent.) I''d like to specify that the saves run in a transaction. I can do ActiveRecord::Base.should_receive(:transaction).and_yield But is there any way to specify that the code is
2013 May 24
1
Asterisk 11 dtmf not recognised
Hi I have a dialplan as per the following, extensions.conf [avgtest] exten = 100,n,Playback(avgtest/message1) exten = 100,n,Set(rightPIN=1) exten = 100,n,Read(inPIN,,1,,5,3) ; Attempts for 5 times with 3 seconds of timeout exten = 100,n,GotoIf($["${inPIN}" = "${rightPIN}"]?pin-accepted,1) exten = 100,n,Hangup() ; Didn't go to pin-accepted, so play badPIN and hangup
2008 Jun 11
3
help with test design
I''m having trouble figuring out how to drive the design of a class. I''m hoping I can get a hint or two from the more experienced BDDers on this list. I''m writing an adapter class that sits between a 3rd party library and my business logic. I would like to extract some information from objects available from the 3rd party lib and covert them into ruby objects.
2007 Nov 04
3
Specing raising error, handling, and then not raising error
Hey guys and gals, I have a snippet of code: Net::SMTP(@host, @port, @from_domain) do |smtp| @emails.each do |email| begin smtp.send_message email.encoded, email.from, email.destinations @emails_sent += 1 rescue Exception => e # blah end end end What I want to do is: Say there are 4 emails. First email is sent OK On the second email smtp raises a IOError