Displaying 20 results from an estimated 9000 matches similar to: "Help me with this test/mocks issue please!"
2007 Jun 01
0
rspec_on_rails, could someone provide an example of using mocks/stubs?
hi all
I''m still a little uncertain on how to use mocks/stubs with rspec when
dealing with associations. I know the point is to isolate the code being
tested and remove external dependencies, but I''m not sure how to implement
it. Can someone suggest how they would spec the code below:
I have a Book model and Review model
class Book < ActiveRecord::Base
has_many :reviews
2007 Oct 08
0
Using mocks in classes
I am mocking a rails model that hasn''t been implemented and belongs_to a
model that I am developing with rspec.
The model in development, Audit, has_many AuditItems which is being mocked.
When created, Audit creates the first instance of AuditItem.
To enable me to mock AuditItem I have created a factory method in Audit to
create the AuditItem, rather than creating it in the initialize
2007 Feb 17
1
"warning: object#id will be deprecated" with mocks
hi all
I have the following code in a spec:
@user = mock("user")
User.stub!(:authenticate).and_return(@user)
@user.should_receive(:id).once.and_return(99)
post :login, {:username => ''username'', :password => ''password''}
session[:user_id].should == 99
it works as expected but I get the following warning when I run the spec:
warning:
2007 May 02
4
Terse Mocks
Hello,
I recently made a feature request with a patch for terser mocks.
http://rubyforge.org/tracker/index.php?func=detail&aid=10412&group_id=1917&atid=7480
Here are some examples with their current equivalents:
the_mock.expects.foo(1,2) {|a, b| :bar}
the_mock.expects.foo(1,2).returns(:bar)
the_mock.expects(:foo).with(1,2) {|a, b| :bar}
the_mock.expects(:foo).with(1,2).returns(:bar)
2007 Aug 28
3
How do you keep mocks updated without pain?
Hi!
I know you must be answering a lot of basic questions, sorry about that :-)
However I have not get it, how do you keep mocks updated without pain?
I reached to the point where mocking things for view. I spec
model-controller-view using "correct doc" way mocking-stubbing (plus I
should run integration test to be sure that everything really works
together).
Now, when I want to
2006 Jan 21
2
Documentation for mocks?
Is there any documentation about how mock objects work in RoR,
specifically exactly how one should use the test/mocks directory. Is it
just me being incompetent searching for it, or hasn''t this been
documented yet?
Thanks in advance for your help!
paul.butcher->msgCount++
Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?
--
Posted via
2007 Aug 23
3
test/mocks/ in rails directory structure
Anyone ever uses test/mocks/development && test/mocks/test directories ?
If someone does, test/mocks/development doesn''t really seem like a
nice place for putting development environment mocked classes. May be
mocks/ should be moved to RAILS_ROOT ? Or may be it should be removed.
Views ?
--
Cheers!
- Pratik
http://m.onkey.org
2007 Sep 18
2
rSpec / Nested Routes / Mocks
I''m having a terrible time trying to test a nested route with rSpec.
I can''t seem to tell rSpec to expect the call @item.user. The
following error message plagues me not matter how I try to fuss with
the mock:
Spec::Mocks::MockExpectationError in ''ItemsController handling POST /
items should redirect to the new course on successful save''
Mock
2006 Jun 14
9
Controller testing and mocks...
So far I''ve been doing my controller testing against "real" (testing)
objects; however, I''ve been beginning to wonder if I should "default" to
using mocks in most cases -- both for performence and to enforce a
looser coupling.
In part this is driven by my viewpoint that rail''s "functional" tests
are still "unit" tests, so they
2007 May 30
4
Using mocks
I''ve just started doing TDD/BDD and like the idea of mocks. So I set
out to use them. The doc pages seem great, I setup the mock and then
it just works. Here is what I am trying to do:
Myuser is a non-rails model of user attributes. We are going to be
mocking the connection to the ldap server. The user class has a login
method that connects to the ldap server and if successful,
2007 Jan 30
0
nil object in mocks
RSpecrs,
I''ve been running into some trouble lately when passing mock objects
into rich views. Either I have to obscure my specs by stubbing every
method the view would call on my object, or I have to resort to
trickery like stubbing ActionController#render, which is also less
than ideal.
The solution I''ve some up with is a variant on the :null_object option
that can be passed
2012 May 05
1
rspec-mocks and rspec-rails-2.10.1 are released!
These are patch releases recommended for anybody who has already
upgraded to 2.10.
### rspec-mocks-2.10.1
full changelog: http://github.com/rspec/rspec-mocks/compare/v2.10.0...v2.10.1
Bug fixes
* fix [regression of edge case
behavior](https://github.com/rspec/rspec-mocks/issues/132)
* fixed failure of
`object.should_receive(:message).at_least(0).times.and_return value`
* fixed failure
2007 Jan 08
2
thoughts on mocks and specs
I spent the last couple of days getting my sea legs with Rails and
RSpec. I''d been waiting til things seemed calmer before jumping in,
and I''m overall very happy with my experience so far.
My only real annoyance so far has been forgetting to call "do_post" or
"do_create" from my specify blocks. My mocks don''t get the calls they
want, and it usually
2011 Jul 20
0
why remove "Rails.root/test/mocks/test"
I am upgrading our rails app to rails3 from 2.3.5 and I got the
following deprecation warning: DEPRECATION WARNING: "Rails.root/test/
mocks/test" won''t be added automatically to load paths anymore in
future releases. Question is why ''mocks'' directory should be removed
in future releases, I think sometimes they are useful especially for
selenium tests.
Thanks!
2007 Dec 09
2
Mocks and Manual Tests
Is it possible for me to use Mock objects in manual testing?
They work great for functional testing, but now I need to load the pages and play around with some stuff, but of course I cant load them because there are a number of classes without implementations, which I want to just mock out.
Any ideas?
-----------------------------------------------------------------
Find the home of your dreams
2006 Apr 28
0
Anyone help with using Mocks inside plugins?
I want to use a Mock within a plugin thats writes to the FS. Do I
create a mock folder inside the plugin?
2006 Dec 18
4
How to keep mocks consistent?
Hey all,
Here''s a question for everyone: how do you keep your mocks and stubs
consistent with your real objects?
I''m dipping my toes into the RSpec world, and it''s absolutely
delightful (running dozens of tests in less than a second is nice as
well), but I''m concerned about my ability to keep the mocks in my
specs consistent with the behavior of their
2007 Mar 09
0
Mocks & Stubs in spec_helper?
I have to stub out
setup do
request.stub!(:user_agent).and_return(''Mozilla'')
end
in each context because my Rails application.rb relies on it (for IE
reasons).
Is there a way to create mocks or stubs in spec_helper.rb so I don''t
have to repeat this?
Thanks,
Steve
2005 Dec 27
4
Using mocks
Hi,
What's the purpose of test/mocks? I couldn't quite complete the Wiki
entry on this because all the information I _could_ find was in the
readme.
- Rowan
--
Morality is usually taught by the immoral.
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
2007 Mar 13
1
Opening the singleton class of mocked objects
I wrote a plugin [1] a while ago that lets me do validations on a
single AR instance. Instead of defining validations in an AR class, I
can define them on a AR instance''s singleton class:
class << @video
validates_presence_of :title
end
One of my specs mocks Video.find, and the above code is run on the
mock object. When I run the spec, I get the expected
undefined method