Displaying 20 results from an estimated 2000 matches similar to: "Stubbing a Kernel method?"
2006 Apr 14
2
Markaby trunk broken?
Hello!
Does anyone know how I can check out the Markaby trunk? I''m getting this
error:
<code>
ruby script/plugin install
http://code.whytheluckystiff.net/svn/markaby/trunk
+ ./trunk/svnindex.xsl
/usr/local/lib/ruby/1.8/open-uri.rb:290:in `open_http'': 404 Not Found
(OpenURI::HTTPError)
from /usr/local/lib/ruby/1.8/open-uri.rb:629:in `buffer_open''
2008 May 17
1
Can someone help with this error?
Hello all,
I get this intermittent error saying OpenURI::HTTPError. At the bottom of
the email is what is reported in my backgroundrb_server_<port>.log file. The
process_netflix_reviews method is parsing (in the background) Netflix''s RSS
feeds. This error also pretty much brings down the BDRb process and to
recover, I am forced to do a
./script/backgroundrb stop
2007 Oct 25
1
Mocking/Stubbing help with subdomain as account key
My app uses account_location to set up subdomains as account keys. In
my controllers, all my model operations are scoped through the
@current_person object.
The question is: How do I test this with RSpec''s mocking and
stubbing? Basically, I need to test that @current_person.things is
getting the find message and returning @thing. I''ve tried stubbing
and mocking
2007 Jun 15
6
problem getting started with stubbing in rails controller specs
Hello, Ingo!
I''m copying your question to a new e-mail instead of replying to try
to keep message threads separate.
Have you tried setting up your expectation before issuing the get
statement? For example, take this out of the setup block:
get ''index'', :locale => ''en''
and move it after:
2008 Aug 20
2
Re: Stubbing out ThinkingSphinx for Rspec
Thanks Wolas!
Sorry if this seems like a newbie question, what am I supposed replace
the stubbed_method_name with?
Also, I came across the only thread on the Interwebs which seems to
cover this topic - it''s over a year old, but I think they have a
solution which could work around the issues you pointed out. However, I
couldn''t work out how to get their subbing approach to
2007 Nov 13
2
Trouble stubbing a method
Hey guys,
I''ll try to explain this without the model code at first, since there is so
much, but if need be, I''ll pastie it.
I have an Order model that makes API calls to a payment
gateway(TrustCommerce) during validation(to verify the credit card
information). I''d like to stub this behavior to avoid thousands of calls to
TrustCommerce a day(autotest).
All the calls
2007 Mar 27
2
mocking/stubbing newbie questions
I''m new to mocking and stubbing. Can someone help me out with the
following? I don''t exactly know why this spec is failing:
describe "GET /users/1/terms" do
controller_name :terms
setup do
@user = mock_model(User)
User.stub!(:find).and_return(@user)
end
def do_get
get :index, :user_id => 1
end
it "should find all terms
2007 Oct 24
1
Stubbing Kernel.` (backquote)
I''m trying to stub(!) the Kernel.` (backquote) method and I''m having
confusing (to me) results. Here''s the method I''m spec''ing:
class Barcode
...
def raw_barcodes
self.make_temporary_copy
`OcrBarcode #{self.temp_file_path}`
end
...
end
And this is my (newbish) attempt at the spec:
describe "Calling @barcode.raw_barcodes" do
2007 Oct 05
7
Easy AR association stubbing
I''ve added a method to the mock class that makes it pretty easy to
stub associations in rails. I''ve been using it for awhile and it seems
to cut down on a lot of setup code for the controller and model specs
that use associations.
#before
@person = mock_model(Person)
posts = mock(''post_proxy'')
posts.stub!(:build).and_return(mock_model(Post, :save => true))
2007 Jul 06
3
stubbing helper methods for View specs
Hi there
I have several view specs, that include the following snippet in
their "before" block to stub the methods by acts_as_authenticated
before :each do
@u = mock_model(User)
@u.should_receive(:name).and_return("Hans Muster")
template.should_receive(:logged_in?).and_return(true)
template.should_receive(:current_user).and_return(@u)
end
this
2006 Oct 04
3
do we need stubbing?
Hey all -
The trunk currently supports three types of mocking/stubbing:
Mock Objects (created dynamically at runtime)
Partial Mocking of methods on existing classes
Stubbing of methods on existing objects or classes
The main difference between Partial Mocking and Stubbing is that Stubs
don''t verify.
I''m wondering if we really need the stubbing facility at all, given
that we
2010 Jul 13
2
[Rspec] Difference between stub and message expectation with any_number_of_times
I''m wondering what''s the difference between stub and message expectation
with any_number_of_times, for example:
myMock = mock("mymock")
myMock.stub!(:is_a?).with(MyClass).and_return(false)
and
myMock = mock("mymock")
myMock.should_receive(:is_a?).with(MyClass).any_number_of_times.and_return(false)
because is_a? may not be called at all, it just like a
2007 Oct 05
13
spec''ing view render partial collection, local variable not found
I''m trying to spec out a render partial collection but I get the following
error
2)
NoMethodError in ''/games/_game.rhtml should show game name''
undefined method `body'' for #<#<Class:0x316580c>:0x2f1154c>
/Volumes/EXTERNAL/web/omenking.ca/vendor/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb:12:in
`matches?''
2007 Dec 29
15
Do you think it would look cleaner?
I was looking over some of my specs.
I was thinking that the following:
@game.should_receive(:name).and_return(''The Battle for Blaze'')
@game.should_receive(:people).and_return(5000000)
@game.should_receive(:activated).and_return(true)
Would it look cleaner if I could do this instead?
@game.should_recieve_and_return(
:name => ''The Battle for Blaze''
2007 Sep 11
1
Can NOT overides the stub! in the setup
Hello,
I am new to rSpec. I tried to search in the list, but could not find
the answer, please forgive me if somebody already answered this. Here
is my question:
I have a stub in setup:
before(:each) do
@current_user = mock("devsu")
# Generally, prefer stub! over should_receive in setup.
User.stub!(:find).and_return(@current_user)
session[:user] = @current_user.id
2007 Oct 09
23
Testing layouts with RSpec on Rails
Hey guys,
Does anyone have any wisdom to share on the subject of speccing Rails
layouts?
Most of it''s plain old view specs stuff, but are there sensible ways
to verify things like the yield call? (Mocking doesn''t catch that)
Thanks,
Matt
--
Matt Patterson | Design & Code
<matt at reprocessed org> | http://www.reprocessed.org/
2007 Sep 30
9
Problems with testing nested routes using mocking
Hello forum
I have there to files
#----- virtual_host_controller.rb
class VirtualHostsController < ApplicationController
before_filter :capture_domain
# GET /domain/1/virtual_hosts/1
def show
@virtual_host = @domain.virtual_hosts.find(params[:id])
respond_to do |format|
format.html # show.rhtml
end
end
private
def capture_domain
if
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
2010 Mar 24
1
How to stub a has_many relationship in Rails 2.3.5
We have a test that has been working find until we upgraded to rails 2.3.5.
I''m not too familiar with mocks/stubs so maybe there is an easy solution.
Here is a simple example of our scenario.
Class Person < ActiveRecord::Base
has_many :aliases, :dependent => :nullify
before_destroy :mark_aliases_as_deleted
def mark_aliases_as_deleted
self.aliases.each do
2006 Oct 23
6
overriding mock expectations
There is one annoyance I''m encountering with the Mock API in rSpec.
Overall it works well, as far as dynamic mocks go ;)... but there''s
this one thing... It doesn''t allow overriding of expectations.
example:
m = mock("blah")
m.should_receive(:one).any_number_of_times().and_return(1)
m.should_receive(:one).and_return(1)
The second call to should_receive