search for: any_number_of_tim

Displaying 13 results from an estimated 13 matches for "any_number_of_tim".

Did you mean: any_number_of_times
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 stub. Is my under...
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 is ignored. I believe it would be most convenient if the second call to should_receive would override the first. Why? What I would like to do is define all the should_receives once in the setup using...
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 deterministic? Can they be...
2007 Apr 30
4
Mocking with Calculated Results
...b!(:errors).and_return(@countable) m.stub!(:setting_name).and_return(''first_name'') m.stub!(:setting_value).and_return(''first_value'') m.stub!(:setting_type).and_return(''first_type'') end Setting.should_receive(:find).any_number_of_times.and_return do |a| case a when :all then [@setting, @setting] when /\d+/ then @setting else nil end end end end
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
2007 May 23
2
rspec mocha and controller specs without integrated_views
...following code below shows you, the mocking of views is rspec specific. See stub! versus mocha''s stub unless block_given? unless integrate_views? @template.stub!(:file_exists?).and_return(true) @template.should_receive(:render_template).any_number_of_times.and_return(true) { |*args| @first_render ||= args[2] } @template.stub!(:find_template_extension_for).and_return("rhtml") @template.stub!(:read_template_file).and_return("this is fake content generated by rspec")...
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
2007 Aug 11
2
Rspec and acl_system2 plugin
...uot;cms", "cms_admin"]) when :cms @role.stub!(:map).and_return(["cms"]) else @role.stub!(:map).and_return([]) end @current_user.stub!(:roles).and_return(@role) @current_user.stub!(:login).and_return(user) User.should_receive(:find_by_id).any_number_of_times.and_return(@current_user) request.session[:user] = @current_user @controller.template.should_receive(:current_user).and_return(@current_user) end end When I run ''ruby script/spec spec/views/layouts/admin.rhtml_spec.rb'', I''ve got the following error mess...
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
2007 Jun 21
4
should_receive stubs methods?
Hey, I''m using rspec and rails and have a spec that tests if a before_filter is executed, I also have a spec that tests if a method called by the filter is executed. It appears however that when I should_receive something, it is no longer actually called when I fire the http request. I''m not sure how, or where exactly I should manually fire the filter, either before or after the
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 =>
2007 Jul 26
5
Coding standards and whitespace
...ories.tmCommand RSpec.tmbundle/info.plist RSpec.tmbundle/Snippets/and_raise.tmSnippet RSpec.tmbundle/Snippets/and_return_block.tmSnippet RSpec.tmbundle/Snippets/and_return_value.tmSnippet RSpec.tmbundle/Snippets/and_throw.tmSnippet RSpec.tmbundle/Snippets/and_yield.tmSnippet RSpec.tmbundle/Snippets/any_number_of_times.tmSnippet RSpec.tmbundle/Snippets/at_least.tmSnippet RSpec.tmbundle/Snippets/at_least_once.tmSnippet RSpec.tmbundle/Snippets/at_least_twice.tmSnippet RSpec.tmbundle/Snippets/at_most.tmSnippet RSpec.tmbundle/Snippets/at_most_once.tmSnippet RSpec.tmbundle/Snippets/at_most_twice.tmSnippet RSpec.tmbu...
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