Displaying 20 results from an estimated 7000 matches similar to: "Creating a ''default'' mock"
2006 Jul 24
6
Mocking causes empty specification blocks
I''ve found myself mocking out a published api in my set-up method.
This has led to some contexts having a large set-up and empty
specifications. As the mocks get auto-verified, the specification
blocks have nothing to do but serve as documentation. Does this sound
bad?
Chris
2007 Aug 14
4
Stubbing all methods
Mocha''s mock/stub framework has the ability to stub all methods on a
mock given. Does RSpec''s mocking framework have this ability? And
if not, is there some reason it shouldn''t be implemeneted?
Regards,
Scott
2007 Feb 07
5
Mocking ActiveResource
I want to use ActiveResource in my app. Instead of hitting server
though, I want it to load from a file when I call find. Any clue how
I do that?
Pat
2007 Jun 25
5
strange mock error
I''m testing using the rspec mocking framework and rspec 1.0.5 and I''m
getting the following strange error:
#<Spec::Mocks::Mock:0x337f7c8> expected :set_defaults with (#<Service:
0x19c4040 @name="Service_1023">, {"1"=>"1", "2"=>"2"}) but received
it with (#<Service:0x19c4040
2009 May 04
6
cucumber - when to stub/mock
I''m just curious about this, since my solution involved stubbing a
call to GeoIp.
Is there a good rule of thumb for when you make exceptions to the ''no
stubbing'' philosophy of Cucumber?
My step was: "Given I am accessing the site from Japan," but I can
think of other situations - mostly when interacting with web services,
that I''d probably
2007 Feb 23
4
How can I spec this? The method gets passed a block...
I''m using Jim Weirich''s Builder library. The code I want to spec is
xml.video do
xml.id @video_id
xml.views @views
xml.date(@date.to_s) if @date
end
I''d like to mock it, rather than asserting that the XML is the right
string. I can do one spec:
specify "should create a video tag" do
@mock_builder.should_receive(:video)
2007 Apr 10
6
getting output of STDOUT in spec
Consider the following method:
def name_to_terminal
puts "Scott Taylor"
end
How would I spec this out?
Scott
2007 Apr 11
12
redirection doesn''t get detected well?
I''m doing a redirect in one of my controller actions and somehow I can''t
spec it, see this pastie: http://pastie.caboo.se/53120.
When following the link from a browser I''m being redirected to the right
page.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
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 26
2
Acts as Authenticated
I am using Acts as Authenticated and I need to call current_user in my views.
How do I mock current_user and other methods of Acts as Authenticated in my view specs?
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
2007 Aug 06
5
Problems with array mock
Hi everyone,
I''m trying this in my helper spec and it didn''t work:
@curr_odontogram.should_receive(''photos[1]'').and_return(@photo)
and the error is:
SyntaxError in ''PersonHelper Deberia devolverme un link para eliminar una foto''
compile error
/home/gramos/src/rails/r-dental/config/../vendor/plugins/rspec/lib/spec/mocks/proxy.rb:99:
syntax
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
2007 May 20
9
How to test for exceptions
Hi folks,
I''m in the process of converting a Test::Unit functional test to RSpec, but I''ve run into a slight problem. I tried looking through the documentation but I still don''t know what I missed.
Thanks in advance,
Blake
describe VenuesController, "on update" do
before(:each) do
@venue = mock("venue")
2007 Aug 13
8
How to use expect_render?
Hi:
I am a rspec beginner. I have scratched my head for the whole afternoon,
trying to figure out a way of writing render expectation in controller spec.
However, I failed. It kept telling me that the ''expect_render'' was an
undefined method. I have installed rspec 1.0.8 and rspec_on_rails as well.
Below is the controller to be tested.
Controller
def index
pre
2006 Nov 07
7
should_redirect_to in advance - feels unnatural
I can understand that it''s easier for rspec to set up a mock in advance
of the controller call. But it makes it difficult to do something like:
context "The HarkController, given Louie the logged-in user" do
setup do
post :login, :username => ''louie'', :password => ''atest''
end
specify "should redirect Louie to the home
2007 Jan 24
2
A spec where interaction-based testing breaks down... (at least for now)
Here are the specs:
context "Finding all the stylesheets available to a company" do
setup do
@mock_company = mock("company")
@mock_company.stub!(:to_param).and_return "1"
Stylesheet.stub!(:find)
end
def do_find
Stylesheet.find_available_to @mock_company
end
specify "should convert the company into a parameter" do
2007 Feb 28
4
acts_as_authenticated error with Object#id
I''m getting this when I run my Rails controller specs.
<projectroot>/config/../lib/authenticated_system.rb:16: warning: Object#id
will be deprecated; use Object#object_id
I added "include AuthenticatedTestHelper" to /spec/spec_helper.rb so
that my controller tests^H^H^H^H^Hspecs can use the "login_as" helper
method. Anyone know how to fix this?
--
Cheers,
2007 Jul 12
3
Agh, this is annoying. Why is this happening?
My problem:
Mock ''Task_1005'' received unexpected message :user_id= with (1)
No matter what I do to try to stub that out it will still fail out and give
me that message.
Here is my spec
describe TasksController, "handling POST /tasks" do
before(:each) do
@task = mock_model(Task, :to_param => "1", :save => true)
2007 Jun 24
6
mocking errors
What is the correct way to mock out the errors on a Rails model?
I''m assuming i need to say
@mock_thing = mock_model(Thing)
@mock_thing_errors = mock("errors")
@mock_thing_errors.should_receive(:full_messages).and_return("An error")
@mock_thing.should_receive(:errors).and_return(@mock_thing_errors)
Just wanted to check the best practice on this kind of thing and how