Displaying 20 results from an estimated 3000 matches similar to: "Slimmed down version for inclusion in Rails?"
2006 Sep 03
2
Fwd: Dealing with exec?
---------- Forwarded message ----------
From: Kevin Clark <kevin.clark at gmail.com>
Date: 01-Sep-2006 20:31
Subject: Dealing with exec?
To: James Mead <jamesmead44 at gmail.com>
Hey James,
Sorry to bug you. I was curious how you''d handle a call to exec in a
method you were testing. Kernel.stubs(:exec)... doesn''t seem to work
but I''m not sure where else an
2006 Sep 13
2
Problem with RSpec and Mocha/Stubba
I''ve recently upgraded to the latest versions of Mocha and RSpec
(0.3.2 and 0.6.3 respectively) and I''m no longer able to use Mocha/
Stubba with RSpec. Its actually only Stubba I''m interested in as I
use RSpec''s built-in mocking library.
I require stubba in my spec file but whenever I try and run my spec
it fails with the error:
Unintialized constant
2006 Sep 12
4
ActiveRecord Validations - validates_uniqueness_of
Hello,
I''m wanting to use Mocha and Stubba for my tests in place of the
default Rails testing with fixtures.
I have the following class:
class Person < ActiveRecord::Base
validates_uniqueness_of :email
end
and am wondering how I can test to ensure that the
validates_uniqueness_of validation is running.
Any ideas?
-Jonathan
2007 Apr 11
1
Fwd: [ mocha-Bugs-5892 ] Using a setup method in test_case_class destroys subsequent test cases
---------- Forwarded message ----------
From: noreply at rubyforge.org <noreply at rubyforge.org>
Date: 11-Apr-2007 15:24
Subject: [ mocha-Bugs-5892 ] Using a setup method in test_case_class
destroys subsequent test cases
To: noreply at rubyforge.org
Bugs item #5892, was opened at 2006-09-25 07:49
You can respond by visiting:
2006 Dec 21
4
Stubbing Kernel#open
Anyone know how to stub Kernel#open? I''m trying to mock/stub an
open-uri call, but it doesn''t seem to like it.
Here''s the test code, and the failures:
body = File.open(File.dirname(__FILE__) +
''/../fixtures/google_search_california.html'').read
2006 Oct 25
5
Mocha, Stubba and RSpec
Hi,
I''ve been reading with interest the threads trying to integrate Mocha
and Stubba with RSpec. So far, I''ve made the two changes in
spec_helper.rb suggested, but discovered another one that neither of
the archives mentions:
If you use traditional mocking: object = mock or the stub shortcut
: object = stub(:method => :result), you run into namespace conflicts
with
2006 Sep 25
3
Problem stubbing instances referred to by constants
Hi James,
An instance retains its mocha between tests if that instance is
pointed to by a constant. The simplest failing test is something like
(add as a new file in mocha/test)..
#--code--
require File.join(File.dirname(__FILE__), "test_helper")
require ''stubba''
class WemStubbaTest < Test::Unit::TestCase
Arr = [1, 2, 3]
def test_a
2007 Jan 24
0
Mocha 0.4 released
So I finally got round to releasing a new
version<http://rubyforge.org/frs/?group_id=1917&release_id=9184>of
Mocha <http://mocha.rubyforge.org/>. Much of the functionality has been
available for some time if you''ve been using the Rails plugin based on
subversion HEAD, but now you can get it in all in a gem (or other package).
The most recent changes centre around allowing
2007 Jan 17
8
Mocha Mock''s hanging on after test run?
Hi guys,
I''m running mocha (0.3.2) against Rails core and just found an issue
where the mock doesn''t go away after the test is run.
For example:
def test_reset_bang_doesn_reinstall_named_routes
ActionController::Routing::Routes.named_routes.expects(:install).never
@session.reset!
end
def test_zzz
puts ActionController::Routing::Routes.named_routes.inspect
2006 Aug 17
1
expectations on stubs (stubba) or mock methods on existing classes?
Hello,
First, thanks for releasing Mocha. As someone who''s been practicing
TDD much longer than I''ve been using Rails, one of my biggest
complaints has always been the fact that the "Unit" tests are more
like intefration tests because of how tightly coupled the domain model
is when using ActiveRecord. Stubba looks like it could really help
aleviate this problem.
The
2006 Sep 03
0
Reducing object polution and mocha?
Hi Kevin,
Not currently, I''m afraid - I always realised it was a possible problem, but
we haven''t run into it in our use of Mocha so far. I guess you''re pushing
the envelope with it, which is great.
If you only need to do it for one or two objects, you could just undefine
the offending methods. In the meantime I''ll look into a better solution. It
may not be
2007 Jun 11
12
Mocking system/`
This drives me insane on a regular basis. How does one mock
system(''blah'') or `blah` ?
Adding expectations on Kernel doesn''t do it. Adding expectations on
Object just makes me sad:
Object.any_instance.expects(:system).with(''ls'')
# => #<Mock:0x12b584e>.system(''ls'') - expected calls: 0, actual calls: 1
And this really
2006 Sep 18
2
Mocha + Selenium-on-rails loading problem ?
Hello All,
I need to stub two class methods before a selenium call.
The .rsel is :
require ''mocha''
SalesConfigWork.stubs(:load_work_data)
SalesConfigWork.stubs(:delete_work_data)
setup :fixtures => :sales_config_works
open "/"
The Selenium test runner result is :
undefined method `stubs'' for SalesConfigWork:Class
Extracted source (around line *#0*):
2006 Nov 21
5
stubbing in development environment
Hi guys.
Quite happy with mocha for testing. It''s been a bit of an eye opener
for me, and I expect to begin using it heavily.
One other thing I''d like to do is stub out particular class methods in
development. Is there a way I can do this with mocha?
Jason
2007 Apr 12
15
Preview of Latest Mocha Changes
I''ve finally managed to find some time to do some serious work on
Mocha. There are some code snippets on my blog
(http://blog.floehopper.org/articles/2007/04/12/preview-of-latest-mocha-changes)
showing the new functionality available in trunk (revision 128). I
don''t don''t know how many people out there are using trunk, but it
would be great to get some feedback on these
2006 Oct 13
6
If I stub do I have to mock as well?
Hi, I''m new to mocha and stubba but eager to learn. I have a rails
functional test in which I would like to stub an instance method of
particular class to always return true. I tried the following:
def test_post_checkout
Order.any_instance.stubs(:successful?).returns(true)
post :checkout
assert_response :redirect
assert_equal "Checkout was successful.",
2006 Dec 14
3
Stubbing constructiors
This works:
class X
def X.initialize( stuff )
end
end
X.initialize("bla")
However stubbing it doesn,t:
require ''test/unit''
require ''stubba''
class X
def X.initialize( stuff )
end
end
class XTest < Test::Unit::TestCase
def test_
X.stubs(:initialize).with("bla")
2006 Sep 08
1
A quick guide to Mocha
Hello :)
Having just gone through the (admittedly simple) API of Mocha to learn
how it works, I wrote a quick guide (190 lines) to help others get up to
speed. I''ve attached it as RDOC and as HTML.
It is a first draft - please help me improve by giving feedback !
Contents :
Overview - Quick overview of Mocha
Unit testing, mock object and stubs - Very quick introduction to mock
2007 Mar 04
4
Rails functional testing and Mocha
I''ve always wanted to be able to do stuff like this in my functional
tests
c = customers(:customer_1)
c.expects(:great_customer_service)
post :service_customer, :id => c.id
This of course fails because inside the rails action a different
instance of customer is used. Some of the time setting your
expectation/stubbing on Customer.any_instance works, but it''s not
2006 Sep 03
1
Returning different values with stubs
Right now I''m working on adding tests to a method that looks like this:
def get_via_redirect(path, args={})
get path, args
follow_redirect! while redirect?
status
end
So, I want to confirm that get is called and that status is returned
but I also want to see that when the value of redirect? effects how
many times follow_redirect is called. Is there