similar to: Mocking with Calculated Results

Displaying 20 results from an estimated 1000 matches similar to: "Mocking with Calculated Results"

2007 Apr 28
7
[ rspec-Patches-9605 ] Patch for ER 9472, shared behaviour
Hi all - I''ve applied (to trunk) Bob Cotton''s patch which supports shared behaviours (link to tracker below). I''m still toying w/ names, so please be aware that until this is released w/ 0.9 it should be considered experimental and there will NOT be translation support for it. It will definitely be included in some form - just the names (specifically
2007 Apr 19
5
Best practice thoughts: Model helpers, mocks
Hello! I''m pretty new to unit testing, and have only been using RSpec for a few weeks. I found that for my controller specs, my setup methods were getting very long building mocks/stubs for all the model objects I needed to work with. I''ve started creating helpers like the following for each of my models. The "min_" methods are short for "minimum", and
2007 Apr 20
7
Stubbing Model.new w/ block?
Ok, I followed the advice of the list and moved more code into my model from my controller. When developing tests for this new code, I ran into a problem... My model code creates a receipt object and sets some values on it: @receipt = Receipt.new do |r| r.x = 1 r.y = 2 # etc end I wanted to be able to stub out Receipt.new so that I could set expectations on the methods called on the
2006 Oct 23
6
overriding mock expectations
There is one annoyance I''m encountering with the Mock API in rSpec. Overall it works well, as far as dynamic mocks go ;)... but there''s this one thing... It doesn''t allow overriding of expectations. example: m = mock("blah") m.should_receive(:one).any_number_of_times().and_return(1) m.should_receive(:one).and_return(1) The second call to should_receive
2010 Jul 13
2
[Rspec] Difference between stub and message expectation with any_number_of_times
I''m wondering what''s the difference between stub and message expectation with any_number_of_times, for example: myMock = mock("mymock") myMock.stub!(:is_a?).with(MyClass).and_return(false) and myMock = mock("mymock") myMock.should_receive(:is_a?).with(MyClass).any_number_of_times.and_return(false) because is_a? may not be called at all, it just like a
2006 Nov 10
2
mock syntax order
I have the following statement mock_requester.should_receive(:request_with).with ("x").any_number_of_times.and_return(@object) which works fine, but when i do it backwards, which makes the same amount of sense syntactically, it fails mock_requester.should_receive(:request_with).with("x").and_return (@object).any_number_of_times are all of the mock options
2007 May 23
2
rspec mocha and controller specs without integrated_views
The ability to choose a mocking framework is great as I prefer mocha, but I am have problems. On my controller specs, I am forced to ''integrate_views'' as the following code below shows you, the mocking of views is rspec specific. See stub! versus mocha''s stub unless block_given? unless integrate_views?
2007 Jun 24
6
mocking errors
What is the correct way to mock out the errors on a Rails model? I''m assuming i need to say @mock_thing = mock_model(Thing) @mock_thing_errors = mock("errors") @mock_thing_errors.should_receive(:full_messages).and_return("An error") @mock_thing.should_receive(:errors).and_return(@mock_thing_errors) Just wanted to check the best practice on this kind of thing and how
2006 Oct 04
3
do we need stubbing?
Hey all - The trunk currently supports three types of mocking/stubbing: Mock Objects (created dynamically at runtime) Partial Mocking of methods on existing classes Stubbing of methods on existing objects or classes The main difference between Partial Mocking and Stubbing is that Stubs don''t verify. I''m wondering if we really need the stubbing facility at all, given that we
2012 Nov 14
1
[LLVMdev] Is infinite empty loop dead code?
Hi, dear Wenren: Thank you so much for sharing this info. I really appreciate it. Now I can move on deleting dead non-countable loops. Thank you again! Shuxin On 11/14/12 12:56 AM, 陳韋任 (Wei-Ren Chen) wrote: > On Wed, Nov 14, 2012 at 12:22:33AM -0800, Shuxin Yang wrote: >> I do some google, I cannot find the answer... >> I check C std, I cannot find answer either. >>
2012 Nov 14
0
[LLVMdev] Is infinite empty loop dead code?
On Wed, Nov 14, 2012 at 12:22:33AM -0800, Shuxin Yang wrote: > I do some google, I cannot find the answer... > I check C std, I cannot find answer either. > > Delete infinite empty loop is boring, but if C/C++ lawyers could tell it > is safe to to so, > it would obviate the need to prove a non-countable loop infinite or not > before > DCE can delete it. > > That
2007 Aug 11
2
Rspec and acl_system2 plugin
Hello, I''m trying to spec a Rails application using the couple restful_authentication/acl_system2 plugins. In my admin layout, I put the following code : <% restrict_to "admin" do -%> <ul id="admin-tabs"> <li> /users Users management </li> </ul> <% end -%> Then in my spec file
2012 Nov 14
6
[LLVMdev] Is infinite empty loop dead code?
I do some google, I cannot find the answer... I check C std, I cannot find answer either. Delete infinite empty loop is boring, but if C/C++ lawyers could tell it is safe to to so, it would obviate the need to prove a non-countable loop infinite or not before DCE can delete it. That is the answer I'm waiting for to delete a disgusting dead non-countable loop in my way. On 11/14/2012
2007 Aug 23
6
controller spec with model that validates_uniqueness
I want to use mocks and stubs to test the controller, but am having trouble getting my validation not to trigger. Here''s the code: # spec: Image.stub!(:find).and_return(@image) @image.should_receive(:save!).once.with(:any_args) put :update, :id => @image.id, :category_id => @category.id, :image => {:name => ''test'', :image_number =>
2012 Nov 14
2
[LLVMdev] Is infinite empty loop dead code?
If the code is unreachable, such code is easy to be removed, and should be removed. If it is reachable, that is bit difficult to tell. Now that C std already give compiler such permit, perhaps we don't have to keep in sync with gcc. Otherwise, it is very difficult to delete dead non-countable loop. One might argue, do you see many dead non-countable loops? I don't know the answer, but
2007 Jun 02
7
I''m really bad at controllers, help please.
Hey, Sorry for so many questions - I''m really bad at this right now. I''m trying to cover the following code w/ rspec def index if params[:user_id] @user = User.find(params[:user_id]) @messages = @user.messages end end So basically what I''m doing is listing all the messages for a user, provided there is an id parameter. describe
2011 Oct 05
1
Needed help with 3 factor anova !!!
I am a student from Poland. What I am interested in is 3 factor anova with R. Could you please help me find an example with using this method with R? With all possible countable output for anova as the output presents with 3 factor anova with spss? I would be glad with any help. -- View this message in context: http://r.789695.n4.nabble.com/Needed-help-with-3-factor-anova-tp3875620p3875620.html
2012 Nov 14
2
[LLVMdev] Is infinite empty loop dead code?
Thank you all for the input. Seems that I have to prove a non-countable loop is finite before I can delete it. BTW, I think this draft is not clear as to what is "constant expr". The source code may use symbolic value, but later on the symbolic value could be proved to be constant. However, compiler could mistakenly delete the loop before that point. Thank you all for the input
2006 Apr 11
6
asp''s application object rails equivalent?
In asp there''s a built''in object, Application, which behaves like the session, but it allows you to share information among all users of the application. (http://www.microsoft.com/windows2000/en/server/IIs/default.asp?url=/windows2000/en/server/IIs/htm/asp/vbob6zkv.htm) It''s just like if every user would be accessing the same session. what is the rails equivalent?
2006 Dec 12
3
Stubs breaking other things
Hi All I''m working on converting some existing controller specs to use mocks and stubs rather than real ActiveRecord objects in a Rails project. In one of my controller actions, I use a database transaction. So, the obvious thing to do is have this in my setup block: Project.stub!(:transaction) Firstly, is there an easy way to have that stub yield to the block passed to any