similar to: Test errors without verification

Displaying 20 results from an estimated 4000 matches similar to: "Test errors without verification"

2007 Sep 05
4
Mocking to spec a sort_by method
Hello, I have a question regarding the use of Mocha with rSpec to spec one of my methods. My spec contains the following vehical1 = mock() vehical2 = mock() vehical1.stubs(:mph).returns(150) vehical2.stubs(:mph).returns(250) comparer.add_vehical([@vehical1, @vehical2]) comparer.sort_by(:mph) The comparer is an object that has a basic "stack like" functionality, add_vehical is the
2007 Oct 20
14
Problems with form_for and partials
i''m having problem with a form_for situation where i''m trying to DRY out the repeated parts of my forms and put them in common/form and render the form elements via another partial in controller_name/_form. Here''s the first form # app/views/common/form <% form_for ... do |f| -%> <%= render :partial => "params[:controller]/form", :object => f
2008 May 20
7
Expect with "real world" returns?
Is there a way to do something like this? class Foo def self.hello(name) "Hello #{name}!" end end Foo.expects(:bar).with("Carl").once assert_equal "Hello Carl!", Foo.hello Basically, my problem is that once you set an expectation, the original code is never executed and is not tested. However, it''s still very useful to set expectations to
2007 Jan 02
4
allow stubbing of previously defined methods such as "id"
On my current project I needed to create a stub that responded correctly to the id message. Here''s the change I put into my copy of head. Index: lib/mocha/mock_methods.rb =================================================================== --- lib/mocha/mock_methods.rb (revision 1114) +++ lib/mocha/mock_methods.rb (working copy) @@ -68,6 +68,7 @@ method_names =
2008 Jan 21
4
stubs! method
Hello James et al. I try to set only one expectation per test, but I also dislike having extra stub declarations that are no longer used, thus I often find myself wanting Object.expects(:foo).at_least_once. That works, but I don''t actually "expect" foo to be called, in fact, I don''t care, I only want to know when it isn''t called so I can remember to
2006 Sep 22
2
foo.expects(:blah).returns(10).then(11) syntax
I recently needed the behavior of my object to change on subsequent method calls so I added the syntax above. Here''s the diff of changes I made: Index: test/mocha/expectation_test.rb =================================================================== --- test/mocha/expectation_test.rb (revision 854) +++ test/mocha/expectation_test.rb (working copy) @@ -95,6 +95,12 @@
2009 Jul 09
3
before(:all) and nested contexts
On Thu, Jul 9, 2009 at 5:40 AM, Daniel Tenner<daniel.rspec at tenner.org> wrote: > Hi all, > Like everyone (?), I use nested contexts to keep my specs well organised and > tidy. > However, I have a problem. I have various sets of specs that needs to > perform very time-expensive operations to set up the fixtures that will be > examined in the tests. Two specific examples:
2006 Sep 29
1
yielding consecutive values
I''m not sure if someone has already addressed this issue, but if not, here goes. I need the following behavior: def test_generate(documentation = ''/test_documentation/'', destination = ''/destination/'') yield_results = [''/'', ''filename.yaml'', ''blah.xml'']
2006 Sep 29
2
multiyield
I lied, I don''t actually need different responses each time I call the method. So the last email of mine is probably worthless. Instead, I need yield to yield 3 values when I call it once: (behavior that mimics Find.find) def test_generate(documentation = ''/test_documentation/'', destination = ''/destination/'')
2006 Dec 19
9
Stubbing ActiveRecord Models gets very difficult with instance methods
I have seen some basic examples of using Mocha and Stubba with ActiveRecord Models; However, the ones I read were somewhat simplistic. That is they stubbed the find class method of the model, or the execute method of the connection object. While stubbing the find method had the desired effect for the author it did not help with a situation I was hacking away on. Which was writing a test case
2007 Mar 06
15
mocking missing methods
Hi folks. So I''m using mocha on a ruby project, and I really like it. One thing I''ve noticed is that it can be a bit "surprising" when I''m mocking methods that don''t exist on an object, and I think there''s an easyish fix. At the moment, you use sheep = mock() to create a mock sheep. What I''d like to do is something like sheep =
2006 Dec 15
5
Testing event driven Socket classes
Ok, here is the class, I want to Unit Test, its part of a large app and is based on EventMachine library. I want to mock the class TickServer ( i.e not stub it) . Since in actual scenario, you can''t do this on this class: @server = TickServer.new # will toss an exception at your face you must initialize the server like this: EventMachine.run {
2008 May 03
5
Need some help in reducing my repetions in tests with Mocha
Hi All I''m writing a gem to interact with the todoist JSON API and I''m using mocha to mock the server responses so I don''t have to have a net connection to test and so I don''t need to actually use my own API key anywhere. Mostly I am interested in verifying that a correctly formatted URL has been sent, with the appropriate parameters, e.g API key have been
2007 Jun 21
3
With Parameter Block
I''m curious why the Parameter block check for the with is going to be removed. I like the concept of clean, readable tests, however I also like to test as efficiently as possible. For some tests, I''ll take the approach of putting test assertions inside the parameter block, and always returning true. This is a contrived example: def test_something mock =
2007 Aug 31
48
Deprecating the mocking framework?
I saw in one of Dave C.''s comments to a ticket that "our current plan is to deprecate the mocking framework." I hadn''t heard anything about that, but then again I haven''t paid super close attention to the list. Are we planning on dumping the mock framework in favor of using Mocha (or any other framework one might want to plug in?). Pat
2009 May 23
9
undefined method `assert_select'
I''m having trouble getting the specs to run for a plugin where I want to fix a bug. (I''ve actually already found and fixed the bug, but I don''t want to submit a fix without a test!) When I started the specs weren''t running, but it may be that I''m using Rails 2.3.3 and the plugin has been tested on 2.1 and earlier. I went through writing a spec for a
2007 Nov 11
1
Mongrel and Camping
Why is the camping handler using Mutex#synchronize to serve requests? I was under the impression that camping was considered more thread safe than Rails? -Zach
2007 Sep 24
7
Parameter Matchers with optional params
Hi, Are there any docs for combining parameter matchers, or some way to define optional parameters? I''m trying to match something like: .find( 42 ) || .find( 42, {:conditions=>nil,:includes=>nil} ) Or for that matter, 42 followed by nothing or anything... Halp? I''ve tried different nested combos with any_of/all_of/anything, but getting lost trying. --Andrew
2007 Dec 29
15
Do you think it would look cleaner?
I was looking over some of my specs. I was thinking that the following: @game.should_receive(:name).and_return(''The Battle for Blaze'') @game.should_receive(:people).and_return(5000000) @game.should_receive(:activated).and_return(true) Would it look cleaner if I could do this instead? @game.should_recieve_and_return( :name => ''The Battle for Blaze''
2008 Aug 26
9
stub_model() and ActiveRecord Associations
Hi all, I have what I thought was quite a simple requirement but something to do with the way ActiveRecord''s associations work is making it quite puzzling. I guess I can sum it up with this failing test: before(:each) do @source_comment = @source.comments.create(:user_id => 1) @target_comment = @target.comments.create(:user_id => 1) end