search for: courtenay

Displaying 20 results from an estimated 43 matches for "courtenay".

2007 Aug 17
4
should_receive, used in the wrong place?
...should_receive outside of an "it" block, it warns you. before(:each) do @foo = Foo.new @foo.should_receive(:monkeys) end would warn you that you''re setting an expectation in the wrong place, and that "stub" is correct when setting up objects. Opinions? courtenay
2007 Jun 12
3
rspec 1.0.x and liquid?
...pected 14: end TestResponse.rendered_file looks like 208: def rendered_file(with_controller=false) 209: unless template.first_render.nil? 210: unless with_controller 211: template.first_render so TestResponse is missing ''template''. Any clues? Courtenay http://blog.caboo.se http://entp.com
2006 Dec 31
2
what''s with the response.should_be_xxxx stacktrace?
...e should_be really could be more nicely formatted ("response should be success but was ''redirect'' to ''http://''") Finally, while I''m assuming that I''m doing it properly, is there a better way to do the response code checking? Thanks, Courtenay http://blog.caboo.se
2007 Feb 13
7
Specs of code that use Time.now
Hi Just trying to spec a Rails model that defaults a valid_until date to this time tomorrow. I''ve done something similar involving Dates, and you can stub the :today method to return something fixed. But when I tried this with Time, I found that RSpec calls Time.now four times per spec. So there''s no way to spec code like 1.days.from_now . The best I can come up
2007 Feb 16
6
some fun functionality for all your specs
I''ve found these two snippets of code useful and would love some feedback. first, .should_have_valid_associations usage: context "A new Product" do specify "should have valid associations" do @product.should_have_valid_associations end end code: (thanks to Wilson/Defiler for converting to rspec) module Spec module Expectations module Should
2006 Dec 30
1
redirect_to(:action => ''foo'') and return
...:92:in `create'' spec/controllers/carts_controller_spec.rb:99: spec/controllers/carts_controller_spec.rb:118: however if I change that to redirect_to(:action => ''error'') return it works just fine. All versions of "..and return" seem to fail. courtenay http://blog.caboo.se
2006 Dec 30
7
Support for processing after the response has been transmitted?
Hi, Is there any interest in allowing controller methods to do post-response processing? This would be useful where some time-consuming statistic or index processing should be done after the response has been sent so as not to delay a response that does not depend on that processing. This could be implemented by allowing the action method to yield to the process method which in turn yields to a
2007 Jul 24
4
spec''ing helpers that use controller
Hi all, I''m in the process of creating rspecs for my helpers. One of the helpers in app/helpers/application_helper.rb looks like this: def page_name @page_name || "Define @page_name in #{controller.controller_name}::#{controller.action_name}" end The rspec is simply: it "should something" do page_name end
2007 Aug 15
4
nuby: how spec redirect_to at ApplicationController
Good morning rspec people! Still rspec nuby: I must do something wrong obviously. How can I spec about redirect_to at ApplicationController describe ApplicationController do it "method login_required should redirect to home path without login" do pending "I tried to use controller.login_required.should be_redirected and got NoMethodError with nil object
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 =>
2006 Nov 24
13
rSpec on Rails 1.2?
I just updated my Rails install to the most current Edge and my controller specs fail: 1) TypeError in ''The User Controller should be a user controller'' can''t convert nil into String Each spec fails the same way. <context string> <spec string> can''t convert nil into String Any ideas what''s up with this? Thanks, s.ross
2007 Mar 29
21
a better "should have valid associations"
This is pretty much the same as last time around, if you recall. Thanks to Wilson for converting to the new form. I''ve added a few lines. Basically, it iterates over your model associations and does two things. - First, just try to call the association. Usually fixes speeling erors or other such silliness. - Second, try to find a record with an :include on the association. This
2007 Aug 15
3
ActsAsList specs
Hi, How are people specifying models which act_as_list? I''m thinking that it would be possible to check that acts_as_list instance methods have been added to a class using something like this: describe Page, "acts_as_list" do it "should act as a list" do Page.ancestors.should be_include(ActiveRecord::Acts::List::InstanceMethods) end it "should use
2007 Jul 18
5
Mocking Rails association collections
Rails model association collections allow you to do nifty things like: article.comments.find(:all, :conditions => {:created_at > 1.day.ago}) Has anyone found a good way to mock this up? I''m currently doing this: @comment1 = mock_model(Comment) comments = mock(Array) comments.stub!(:find).and_return([@comment1]) @article = mock_model(Article)
2007 Nov 02
3
tumblr-0.0.1
NAME tumblr SYNOPSIS tumblr (setup|write|read|authenticate|check-vimeo|check-audio) [options]+ DESCRIPTION tumblr.rb is a command line utility and library which interfaces to the excellent tumblr blogging platform @ http://www.tumblr.com tumblr.rb implements the complete restful api in both library and command line utility, doccumented in full @ http://www.tumblr.com/api
2007 Jun 28
23
DRYing link_to with a symbol
Hi, I just put in a patch that allows you to DRY up this: <%= link_to @company.name, @company %> to this: <%= link_to :name, @company %> The symbol indicates the method to be called on the object passed in the link_to options. http://dev.rubyonrails.org/ticket/8789 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the
2007 Jan 05
4
How To Spec Controllers with Finders
Given this code (which renders rjs), I''m faced with the fixture- driven way of spec-ing or mocking. How the heck to you mock this so the code at line (2) and (4) work right? I''m still struggling with mocks but it seems like this can be done. Forgive the naivety of this question. 1. def change_quantity 2. @line_item = LineItem.find_by_id(params[:id]) 3. unless
2007 Jun 18
7
Testing for cross site scripting, etc.
Being new to testing and ruby, are there "standard" tests that can be done that test for things like cross site scripting and friends? If not, anyone have ideas on what I might do about testing those sorts of things? I''ll be using rails, also. Mike B. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging
2007 Jul 24
6
Mocking Access Control
I''m trying to jump on the TDD/BDD bandwagon, but am having trouble understanding how i should mock my user. The user has a habtm relationship to a roles model (acl_system2 plugin), but I''m not sure how to tell rspec about a model. My code: describe UsersController do integrate_views before(:each) do @user = mock_model(User)
2005 Mar 22
9
am i the only one with this problem?
(clean install) >gem install rails Attempting local installation of ''rails'' Local gem file not found: rails*.gem Attempting remote installation of ''rails'' Install required dependency activesupport? [Yn] y Install required dependency activerecord? [Yn] y Install required dependency actionpack? [Yn] y Install required dependency actionmailer? [Yn] y