search for: jayfields

Displaying 20 results from an estimated 25 matches for "jayfields".

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
2007 Jul 26
5
Test errors without verification
I''m not sure if this is by design, but I''ve stumbled across this a few times trying to debug my own tests. If an assertion fails the test, and a mock expectation was to blame, the test''s failure / error messages don''t give enough info. I''ve had to resort to def teardown mocha_verify end which just gets tedious. I''ve created a patch
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 =
2007 Sep 04
3
Model Specs: Fixtures vs Mocks + Stubs?
What is the general opinion about fixtures versus mocking and stubbing in model specs? I heard from agile on IRC that they save the database testing for integration testing, but I also see that the caboose sample applicaiton uses fixtures. I also noticed that on the rspec site, it says "Ironically (for the traditional TDD''er) these are the only specs that we feel should actually
2007 Jul 26
3
Spec for validation plugin
Hi, I''m writing a specification for a model called Location which has a post_code attribute which should be a valid UK postcode. I''m using the http://svn.designbyfront.com/rails/plugins/validates_as_uk_postcode/ validates_as_uk_postcode plugin to handle the validation but I''m not sure how I should properly specify my model. Heres the model code: class Location <
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 @@
2007 Oct 16
12
Example for attr_accessible?
Is anyone out there writing specs to check attr_accessible fields? I had originally written my spec to check for allowing the desired fields, and then none of the other regular db fields. Unfortunately this isn''t satisfactory, because attr_protected could have been used instead, which of course wouldn''t prevent mass assignment to any whatever=(val) method. I''m thinking
2007 Feb 21
3
Using rspec_on_rails without a test database
Is there some way to remove the database hit when running rake rspec:models ? I''d like to mock all of my objects (or at least remove all reliance on fixtures and the database itself) - both for speed and because static fixtures are brittle. Best Regards, Scott Taylor
2011 Sep 29
2
constant variable
How to make a variable constant in ruby so that the value remains fixed throughout and cannot be altered at any cost -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to
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
2008 Jan 20
2
Bug #17118 - expectations should take precedence over stubs
...goal [2]. This should be released as a > gem soon. > > Thanks, James. > http://blog.floehopper.org > > [1] "Stubs, Expectations and the Dispatch of Mocked Methods" > http://www.jmock.org/jmock1-dispatch.html > [2] "Testing: Inline Setup" > http://blog.jayfields.com/2007/06/testing-inline-setup.html > [3] OverrideExpectationsFromSetUpAcceptanceTest > http://pastie.caboo.se/141188 > -- James. http://blog.floehopper.org [A] http://tinyurl.com/29ba6d
2007 Nov 27
2
Expectations on Class Methods
Sorry about the non-specific subject. Here''s what I''m trying to do. I have a method: DataMapper::Database.setup That I want to create an expectation on. I wrote: DataMapper::Database.should_receive(:setup).once.and_return (connection_hash) The call to setup is invoked in the "Object" namespace. I.e., it is setup code, and not in any method or class. I can see
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'']
2008 Jun 07
2
rcov causing a segmentation fault on rspec 1.1.4 and rails 2.1
Hello again :) I''m trying to run rcov on my specs here but i''m getting a lot of segmentation faults (and they usually happen at different places): /home/mauricio/NetBeansProjects/reeds/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:211: [BUG] Segmentation fault ruby 1.8.6 (2007-09-24) [i486-linux]
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
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 Oct 20
7
MVC and modules. Views telling models to behave
I was thinking today, it would be nice if a view could tell a model how to format it''s data for that particular view. Kind of like, the view is bestowing instant, and temporary knowledge on the model for the duration of the views run. It seemed to me that this would be more objecty than say a helper that formats a string format_my_string( my_string ) Instead, in my view. Lets assume I
2007 Feb 05
1
long jumping out of code in specs
I wrote this abomination just now, and wonder if anyone else has had experience with the pattern behind it. In short, I''m specing an after_create hook on an ActiveRecord model, that calls a bunch of private methods. Instead of stubbing all those private methods (which is verboten anyway, as well as impossible because creating the object which owns those methods is what I''m
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 =
2007 Jul 25
5
editing multiple models in one form
Very new to this but would appreciate a hand as this is driving me mad, I''m trying to update both degree and assigned from a single form, the degree section updates fine but assigned just retains the same values, any help much appreciated! my edit.rhtml file looks like: <h1>Editing degree</h1> <%= error_messages_for :degree %> <%= start_form_tag :action =>