Displaying 20 results from an estimated 33 matches for "stubba".
Did you mean:
stubbs
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 Test
Digging around the Mocha source, it seems that it is try...
2006 Aug 17
1
expectations on stubs (stubba) or mock methods on existing classes?
...ing 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 one problem I''m having though, is that I want to be able to stub
out a method on an existing class _and_ use the mock expectations on
that method.
Basically, I have a Product class (ActiveRecord) that has a
class-method Product.i...
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
wit...
2006 Dec 14
1
Patch: make rdoc of lib/mocha/object.rb instead of lib/stubba/object.rb
...#39;README'', ''RELEASE'', ''COPYING'', ''MIT-LICENSE'',
''agiledox.txt'', ''lib/mocha/auto_verify.rb'', ''lib/mocha/mock_methods.rb'',
''lib/mocha/expectation.rb'', ''lib/stubba/object.rb'')
+ task.rdoc_files.include(''README'', ''RELEASE'', ''COPYING'', ''MIT-LICENSE'',
''agiledox.txt'', ''lib/mocha/auto_verify.rb'', ''lib/mocha/mock_methods.rb'',
'...
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
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")
X.initialize("bla")
end
end
Ruby lets me know that:
Loaded suite /tmp/foo
Started
E...
2007 Apr 11
1
Fwd: [ mocha-Bugs-5892 ] Using a setup method in test_case_class destroys subsequent test cases
...riority: 3
Submitted By: Craig Ambrose (craigambrose)
Assigned to: Nobody (None)
Summary: Using a setup method in test_case_class destroys subsequent test
cases
Initial Comment:
Using a method called setup within a Test::Unit::TestCase derived class
works as expected once you start using mocha and stubba, providing that you
run only that test file. If you run several such files, subsequent ones
throw exceptions because the Stubba method setup_stubs is no longer getting
called (your test case setup method has overwritten it) and thus $stubba is
nil.
The error you actually see, if you are usings...
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
Arr.stubs(:size).returns(6)
assert_equal 6, Arr.size
end
def test_b
assert_equal 3, Arr.size #=> Failing test when both tests run consecutively
end
end
#--/code--
I got as far as notic...
2006 Sep 03
1
Slimmed down version for inclusion in Rails?
I''m pushing a major overhaul in testing the Rails codebase. Mocha and
stubba make my life easy so that''s what I''m using. The first major
patch using them is in RailTies
(http://dev.rubyonrails.org/ticket/5970) now. I spoke to DHH today
about using it in the other libraries and I think it''ll be ok, but
they really want to include as little code as...
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*):
2007 Apr 11
0
Fwd: [ mocha-Feature Requests-5856 ] Stubbing of private methods should be allowed
...ils controller that does some processing.
Based on the return value of this method, a particular action decides what
to do. I do not want to make this method public, because public methods in a
controller are callable from a URL. Below is a patch to enable stubbing of
private methods.
Index: lib/stubba/instance_method.rb
===================================================================
--- lib/stubba/instance_method.rb (revision 57)
+++ lib/stubba/instance_method.rb (working copy)
@@ -13,8 +13,9 @@
# intentionally empty
end
- def exists?
- stubbee.respo...
2006 Dec 15
0
Fwd: Re: Re: [HOWTO] Edgemocha
.../unit''
> => true
> irb(main):003:0> require ''mocha''
> => false
> irb(main):004:0> Object.methods.include? "expects"
> => false
> irb(main):005:0>
One of the changes in HEAD has been to do away with the split between
Mocha and Stubba and amalgamate it all under Mocha. However in the gem
0.3.2 you still need to require ''stubba'' as per the example in the
Mocha docs - http://mocha.rubyforge.org/examples/stubba.html
Hope that makes sense.
--
James.
http://blog.floehopper.org
--
James.
http://blog.floehopper.or...
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")
Time.stub!(:now).and_ret...
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 Aug 08
1
Mocking Time, delegating to original object
...stubbing :delegates
end
class Delegator
def initialize expectation
@expectation = expectation
end
def evaluate
@expectation.mock.stub_method.stubbee.send(@expectation.mock.stub_method.hidden_method)
end
end
end
class Object
def expects(symbol)
method = stubba_method.new(stubba_object, symbol)
$stubba.stub(method)
mocha.expects(symbol, caller, method)
end
def stubs(symbol)
method = stubba_method.new(stubba_object, symbol)
$stubba.stub(method)
mocha.stubs(symbol, caller, method)
end
end
Haven''t tested this with anyth...
2007 Jan 24
0
Mocha 0.4 released
...s.com/person/5103-tomas-pospisek>
).
- Reverse order in which expectations are matched, so that last
expectation is matched first. This allows e.g. a call to #stubs to be
effectively overridden by a call to #expects (patch from Tobias
Lutke<http://blog.leetsoft.com/>
).
- Stubba & SmartTestCase modules incorporated into Mocha module so
only need to require ''mocha'' ? no longer need to require ''stubba''.
- AutoMocha removed.
Thanks to all who contributed.
Enjoy :-)
I''ve created a mocha_release category on my blog, so if...
2006 Aug 15
3
Testing deleting files
In unit or functional test, is there a way to check that a file has been
deleted?
It seems that running the test does not really execute deleting files, which
is good because I don''t want it to actually delete the files. But can I
check that the deletion should have been performed in test environment?
thanks,
- reynard
-------------- next part --------------
An HTML attachment was
2006 Aug 14
14
A mock which extends rather than replaces a class?
While running tests, we would like to instrument some of the classes
under test. We still want the classes to do exactly what they currently
do, but we would like them to do more when running in the test
environment.
Clearly we can (and currently do) just extend the objects "on the fly"
where necessary, but this is a bit messy - we''d like some centralised
way to always
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...
2006 Sep 03
2
Fwd: Dealing with exec?
...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 exec call might come from. Ideas?
I''m going to push hard to get mocha and stubba into Rails (or atleast
allow it for tests on the framework). It just saves me too much work
to ignore.
http://glu.ttono.us/articles/2006/09/01/the-flexibility-of-mocha
--
Kevin Clark
http://glu.ttono.us
--
James.
http://blog.floehopper.org
-------------- next part --------------
An HTML attach...