Displaying 20 results from an estimated 8000 matches similar to: "RSpec, plugins and stubbing controller methods"
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
2008 Jan 30
2
Stubbing controller methods vs model methods
I had an error that I couldn''t figure out, then when writing up a
question for the forum I figured it out. The thing is I don''t
understand why the change that was made works and why what existed
before didn''t.
Here is the initial post when I had the error:
----------------------------------
In the controllers/application.rb file
I have a method that finds the account
2008 Sep 17
1
Stubbing Paperclip calls to Amazon S3 (for Rspec)
Would anyone happen to know how to stub a call to S3 from Paperclip?
I''ve searched every where and no one seems to have posted anything about
this. I''ve done very little in the way of spec''ing dependencies on
external services, so any ideas on how to do this with Paperclip & S3
would be most appreciated. I''m happy with stubbing out Thinking Sphinx -
would
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
2006 Nov 10
3
Stubbing Time.now in trunk
I''m a big fan of stubbing Time.now so it returns a known value. I used
to be able to use stubba and say:
@time_now = Time.parse("Jan 1 2001")
Time.stubs(:now).returns(lambda{@time_now})
However, something in trunk broke that. Fine, rspec''s got its own
stubbing lib now, so I tried switching to that:
@time_now = Time.parse("Jan 1 2001")
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:
2007 May 17
2
Stubbing authentication across multiple controllers
Hi,
I''m new to RSpec, so I''m not too sure of the best practises in stubbing. I was thinking along the lines of including a helper method that would stub out a users id and posts to sessions/create. It works fine when speccing SessionsController, but of course it fails when it is included into other controllers specs, because of the post. I''ve tried posting to an
2008 Jan 10
4
Mocking and stubbing Rails'' association extensions
I''m having a lot of trouble stubbing out an association extension for
some view tests. Example rails code modeling a music album:
class Album < ActiveRecord::Base
has_many :songs do
def streamable
find(:all, :conditions => ''streamable = 1'')
end
end
end
So for a given Album instance (say @album), I need to be able to stub
both
2011 Jun 23
2
RSpec book help; why won't this stub method work?
Subscription model--------------------------------------------
class Subscription < ActiveRecord::Base
has_one :user
def can_send_message?
if user.sent_messages.count < limit
true
else
false
end
end
end
Subscription model spec--------------------------------------------
require ''spec_helper''
describe Subscription do
describe
2009 Jan 27
2
[RSpec] Error when returning multiple values from a stub
Hey guys. I''ve just found some odd behaviour within RSpec 1.1.12 , and
would like to know whether this is a bug, or I''m doing something wrong.
When I give multiple return values to a stub, like this:
SubtitleFile.stub!(:new).and_return @sf1, @sf2
RSpec complains:
Mock ''SubtitleFile_1001'' received unexpected message :size with (no
args)
However, if I
2011 Jul 27
3
Rspec with ActionMailer and .deliver
I''m in the process of migrating from Rails 2 with rspec 1 to Rails 3 with
rspec 2, the process has been going pretty well, however, today I came
across an issue that I wanted to share.
I have a controller that sends out an email through a mailer.
Rails 2
code: CurriculumCommentMailer.deliver_comment_update(@curriculum_comment,
"created")
Rails 3 code:
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
2006 Dec 21
3
Stubbing an instance method on a class
Hi all,
I''m not sure if I''ve missed it, but I couldn''t find any docs for
stubbing an instance method on a class. For example:
class Foo; end
Foo.stub!(:my_instance_method).and_return(nil)
The reason (I think) I need this is because a certain class
(Test::Unit::TestCase) expects an argument (name of method) to new and
throws an exception if that instance method
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 Aug 11
2
Rspec and acl_system2 plugin
Hello,
I''m trying to spec a Rails application using the couple
restful_authentication/acl_system2 plugins.
In my admin layout, I put the following code :
<% restrict_to "admin" do -%>
<ul id="admin-tabs">
<li> /users Users management </li>
</ul>
<% end -%>
Then in my spec file
2006 Oct 04
0
stubbing/partial mocking
All,
Brian Takita has been contributing to a stubs branch to support
stubbing and partial mocking on Modules (and therefore classes). I
tweaked the syntax a bit and merged it into the trunk, so you can
update from the trunk and check out the new stubbing/mocking love. If
you prefer to wait for a release, there should be one coming soon-ish
(I''m aiming for later this week).
As Brian
2007 Sep 04
3
Model Specs: Fixtures vs Mocks + Stubs?
What is the general opinion about fixtures versus mocking and stubbing
in model specs? I heard from agile on IRC that they save the database
testing for integration testing, but I also see that the caboose
sample applicaiton uses fixtures. I also noticed that on the rspec
site, it says "Ironically (for the traditional TDD''er) these are the
only specs that we feel should actually
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
2008 Sep 25
0
Rspec, HAML with view testing
Hi all,
Has anyone experienced the following problem testing rspec against
haml views
Attempting to run a view spec (partial)
app/view/users/_foo.html.haml
it "should render it" do
render :partial => "users/foo", :locals => template_locals
end
The following error is returned:
1)
ActionView::MissingTemplate in ''shared/_jar_layout should render
2008 Sep 24
0
Rspec, HAML, view testing
Hi all,
Has anybody experience the following problem running testing rspec
against haml views
Attempting to run a view spec
app/view/users/_foo.html.haml
it "should render it" do
render :partial => "users/foo", :locals => template_locals
end
1)
ActionView::MissingTemplate in ''shared/_jar_layout should render it''
Missing templatet