Displaying 20 results from an estimated 5000 matches similar to: "Stubbing Model.new w/ block?"
2007 Apr 19
5
Best practice thoughts: Model helpers, mocks
Hello! I''m pretty new to unit testing, and have only been using RSpec
for a few weeks. I found that for my controller specs, my setup
methods were getting very long building mocks/stubs for all the model
objects I needed to work with.
I''ve started creating helpers like the following for each of my
models. The "min_" methods are short for "minimum", and
2007 Apr 30
4
Mocking with Calculated Results
I am setting up an AR mock object and wanted to sanity check it. My
intent is to mix this into all my examples and then override/add
methods where necessary. Note that I''ve anticipated three cases for
find:
find with one numeric argument => object
find with :all => Array
find with anything else => nil
This roughly approximates how ActiveRecord::find works in this case
2007 Aug 12
5
stubbing a method that yeilds sequential results
I''ve just found myself stuck trying to rspec something so am hoping
someone more knowledgable can help.
I have a Connector class which has a class method ''results'' that
yields results it get from a network service based on a set of
attributes that I pass to it. I am wanting to yield these results
from my Intermediate class up to the next
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
2011 Nov 02
2
Specify and validate requirements on an ActiveRecord association
Looking for some guidance/support on what feels like might not be an
uncommon use-case.
`User.has_many accounts`
`User.has_many payment_methods`
`Account.belongs_to :user`
`Account.belongs_to :payment_method`
`PaymentMethod.has_many :accounts`
There are lots of `Accounts`. When I (a `User`) want to assign
accounts to a `PaymentMethod`, I really don''t want to scope against
all of them,
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
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
2006 Jan 01
5
scaffold not working on Windows XP
Hello,
I did a fresh install of ruby182 and gem rails --include-dependencies
Now when I do:
rails receipts
cd receipts
ruby script\generate scaffold receipt receipt
rails does not create the views or controller.
What can I do?
Thanks
Frank
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
2005 Dec 31
6
What does this error mean when using scaffold?
Last login: Fri Dec 30 15:34:43 on ttyp1
source /private/var/tmp/folders.501/TemporaryItems/Locomotive.
1135999534.992790-16807
Welcome to Darwin!
frank-roccos-powerbook58:~ farocco$ source /private/var/tmp/folders.
501/TemporaryItems/Locomotive.1135999534.992790-16807
frank-roccos-powerbook58:~/Documents/receipts farocco$ script/
generate scaffold receipt receipt
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
2008 Jul 16
2
belongs_to causing endless loop on first call to save!
Hi,
I have a situation I''m hoping someone out there may be able to shed some
light on. I have a Rails app (2.1.0 on Ruby 1.8.7) with a wizard-based sign
up process, that has recently been changed from storing incremental data in
the database to having a medium sized object graph living in the user
session until the user completes the entire sign up process (this is a
business
2016 Jul 15
4
VoiceMail Audio playing
Hi Madushan
Maybe I was not clear ?. After SIP negotiation and SDP set up on the VoiceMail Server ?.
Is there a file to specify a MGw (the machine that deliver RTP packages to end user)?
From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Madushan Geethanga
Sent: 15 July 2016 13:00
To: Asterisk Users Mailing List - Non-Commercial
2005 May 12
3
DNS master slave update issue
I have a situation where the slave nameservers for a zone are being
notified by the master that a change has occurred but the slaves
are not requesting a zone file transfer in consequence. Is there
some special flag or directive that I must set somewhere in order
for this activity to be automatic upon receipt of such notices?
All systems involved are running DNS 9.2.4.
Regards,
Jim
--
2019 Jul 20
3
Dovecot eBook
Hi Timo
I have a strange question. I bought the Dovecot Book off Amazon. I can easily prove it with a picture and/or my receipt off Amazon. I still have it o my library but I don?t like to travel around with it. Is there a way for me to get a PDF copy? I just checked Amazon and there is still no PDF version available there.
Regards
SI
Sent from Mail for Windows 10
-------------- next part
2010 May 01
1
My dovecot does not store Thunderbird flags
Hi all,
my Dovecot 1.1.20 does not store flags (I mean, Thunderbird Labels
like ToDo, Important and so on..)
When logging in via telnet, I get:
. examine INBOX
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft NonJunk $MDNSent
Junk $Forwarded NotJunk receipt-handled $Label7 $label1 $label2
$label3 $label4 $label5 expired_2w expired_2m delete rimandata
forwarded)
* OK [PERMANENTFLAGS ()]
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
2016 Jul 15
2
VoiceMail Audio playing
Hi Guys
Which module on Asterisk is the one in charge of playing the VoiceMail Server Audio to the end customer?
I have work with MRFP but is it a module included in the SW? Need and external source?
BR
Joaquin
This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon
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.