Displaying 19 results from an estimated 19 matches similar to: "should_receive and multiple return values"
2006 Dec 21
3
Speccing private class methods
Hi
How can I specify that a private method of a class gets called? If
you run the code below, only spec (1) passes. Spec (2) is what I
found causing problems in my code, and class (3) is my failed attempt
to work around it. (3 really puzzles me - why is a private class
method not accessible via send?)
Another problem is that stub! makes public methods, which changes the
behaviour of
2006 Dec 15
3
Partial mock when a complex return value is required
Hi
I''ve come up with a problem using RSpec on a model class in my rails
app. I wanted to test that some data was being cached for some
calculations, so rather than do state-based testing I tried to
specify that the method that fetches the data should NOT be called
when I call the calculate method. However in doing so I have to
simulate the return value, which is about 27
2013 Oct 31
2
Logging in to a virtual users Maildir
Trying to set up a mailserver to run exim4, dovecot2, (clamav procmail
or similar not yet installed) on a virtual machine & access it from
various hosts mostly using Mutt. So far no attempt at encryption
although there are some pem files from a previous attempt & some
evidence from the mutt debug file they may be being used .
So far I have attempted to set up dovecot to by accessed by
2007 Oct 17
0
should_receive
Is there any way to setup a should_receive so that it returns whatever it
was passed in from the actual code? I just want to make sure that a
specific function is called, I don''t want to mess around with the
parameters it receives, or what it does inside, or what it returns. Is
that possible? Using should_receive seems to default to returning nil.
2007 Oct 22
0
Pending should_receive shows as FIXED
I have a mock should_receive expectation wrapped in a "pending" block, and
it appears as being fixed when the specs are run, when in reality it is
not. Anyone else experience this behavior? I''m assuming this is because
the mock waits until the "it" block completion to determine expectations
rather than its enclosing "pending" block.
Steve
2007 Feb 20
1
having should_receive expectation for things that happen in setup
Hi!
The following example doesn''t work for me: http://pastie.caboo.se/41732
However, if the call to msg() happens in the specify block after the
expecation and not in the setup, it will pass.
Why is this? I thought the setup method was there to actually
''construct'' the context and the specifications are some kind of
"postconditions" that only need to be
2008 Jun 12
1
how do I mock the Rails Logger with should_receive?
Hey Guys,
I''m trying to mock the Rails Logger for the following code:
...
rescue TimeoutError => error
$logger.error("#{self.name} Timeout for #{path}: #{error}") and return
rescue SocketError => error
$logger.error("#{self.name} SocketError for #{path}: #{error}") and
return
rescue StandardError => error
2008 Jun 12
1
Does anyone know how to mock the Rails Logger then set expectations with should_receive?
Hey Guys,
I''m trying to mock the Rails Logger for the following code:
...
rescue TimeoutError => error
$logger.error("#{self.name} Timeout for #{path}: #{error}") and return
rescue SocketError => error
$logger.error("#{self.name} SocketError for #{path}: #{error}") and
return
rescue StandardError => error
2013 May 11
1
STDOUT.should_receive(:puts).with Works *** (:print) fails
I use: STDOUT.should_receive(:puts).with...... many times in RSPEC
However, I have a couple of "do you want(Y/N)?" where I use ''print''
and apparently ..(:print).with... does not work. I can change ''print''
to ''puts'' and it works perfectly.
How do I test :print and ...getch("y") for input???
Any help would be
2008 Jan 13
2
should_receive twice and arguments
Hi all, I have a method calling Klass.create! two times with different
arguments (this happens in a class reponsable for reading in a csv file)
I want to test those like this:
in one test: Klass.should_receive(:create!).with(:name => "foo").once
in another: Klass.should_receive(:create!).with(:name => "foo2").once
This doesn''t work because the
2008 Mar 14
2
Multiple should_receive(:render).with
I''m trying to specify that a particular view must render two different partials.
My spec looks like:
describe AClass do
it do
template.should_receive(:render).with(:partial => ''foo'', :locals => { ... })
...
end
describe ''some conditional case'' do
it do
template.should_receive(:render).with(:partial =>
2008 Mar 08
3
should_receive(:foo).with(any_object)
Hey,
I just ran into a situation where I would like to expect a method call
with an argument I know and another one, which is a random number. I
think mocking up the rand method is somehow ugly so I thought maybe
this is the first time where I can take something from Java to Ruby ;)
Java''s EasyMock mocking library knows things like "anyObject()" and
"anyInteger()" in
2007 Aug 17
4
should_receive, used in the wrong place?
What do you guys think of this: if someone calls should_receive
outside of an "it" block, it warns you.
before(:each) do
@foo = Foo.new
@foo.should_receive(:monkeys)
end
would warn you that you''re setting an expectation in the wrong place,
and that "stub" is correct when setting up objects.
Opinions?
courtenay
2007 Nov 15
2
Trouble using should_receive
I have this code trying to ensure my reset method works. I want to
make sure all the participants have their destroy method called.
# in my spec for Room
r = Room.new(:name => ''bob'')
r.save
p = Participant.new(:login => ''a'', :password =>
''b'', :password_confirmation => ''b'')
p.room = r
2007 Jun 03
3
should_receive.again
Hi,
It appears that if I have 2 should_receives in a row, the latest one
overrides the previous one(s).
If there isn''t one, could we add a way to accumulate them, such as
@thing.should_receive(:method).and_return(@value)
@thing.should_receive(:method).again.and_return(@value)
@thing.should_receive(:method).again.and_return(@value)
would be equivalent to
2007 Jun 21
4
should_receive stubs methods?
Hey,
I''m using rspec and rails and have a spec that tests if a before_filter is
executed, I also have a spec that tests if a method called by the filter is
executed. It appears however that when I should_receive something, it is no
longer actually called when I fire the http request. I''m not sure how, or
where exactly I should manually fire the filter, either before or after the
2012 Oct 09
8
unexpected should_receive behaviour
Hi,
surely I''m missing something... but what!?
in my spec I''ve
User.should_receive(:find).with("1").and_return(@user)
and in my controller
User.find(params[:id])
green light... correct...
but if I change my controller using another method, for example first:
User.first
or even
User.all
I get green light too... I was expecting an error like
expected: 1 time
2007 Apr 17
8
problem with rspec_on_rails and @controller.should_receive(:render) in trunk
Hey guys!
I am using rspec trunk, and I am having a little problem with the
latest version. (I am quite sure this worked with an older version
about a week ago)
heres the spec:
it "should render the new user form without layout for a xhr request" do
@controller.should_receive(:render).with(:layout=>false)
xhr :get,:new
end
and the controller:
def new
render
2007 Jul 26
5
Coding standards and whitespace
Recently as a result of using Git I''ve noticed a number of
inconsistencies in the RSpec codebase with respect to whitespace
(mixed line endings, mixed use of spaces and tabs for indentation,
and trailing whitespace at the end of lines). I never would have
noticed, but Git produces nice colorized diff output which highlights
these kinds of inconsistencies.
I wanted to ask if the