rspec2

How to mock request object for rspec helper tests?

I've a view helper method which generates a url by looking at request.domain and request.port_string. module ApplicationHelper def root_with_subdomain(subdomain) subdomain += "." unless subdomain.empty? [subdomain, request.domain, request.port_string].join end end I would like to...

Rspec Test Error

Ruby 1.9.2, RoR 3.0.1. When I run 'rspec spec' I get this error. Can't really make sense of it. connor@connor-desktop:~/rubystore$ rspec spec /usr/local/lib/ruby/gems/1.9.1/gems/rspec-core-2.0.1/lib/rspec/core/backward_compatibility.rb:20:in `const_missing': uninitialized constant Admins (NameError) from /usr/local/lib/ruby/gems/1.9.1/...

fakefs + paperclip on rails3 + rspec2 will give me an error "cannot generate tempfile"

rails (3.0.1) fakefs (0.2.1) paperclip (2.3.4) rspec (2.0.1) I am testing my model with rspec. Since this is a test, I want to prevent any file creations under the public directory as paperclip normally does. I am thinking this workaround is to use fakefs. Although I implemented this http://trevorturk.com/2008/12/11/easy-upload-via-u...

FactoryGirl: How do define a factory without passing parameters

Hello. I'm using Rails 3 / factory_girl_rails / Rspec 2 and Ruby 1.8 I've defined my factories this way: Factory.define :user do |u| u.name 'Some guy' u.sequence(:email) {|n| "person#{n}@example.com" } u.password 'password' end Factory.define :password_reset_user, :parent => :user do |user| user.password_reset_key '...

Rspec2 and Rails 3 - View Spec Routing for Nested Resources

I have a nested resource, setup like this: resources :chickens do resources :eggs end The views for the EggsController are under views/eggs, but: describe "eggs/index.html.erb" do gives a "No route matches {:action => "create", :controller => "eggs"} error on calling render. How do I get RSpec to find the correct (nested) ...

How do I trace which file RSpec is loading?

I'm using Rails 3.0.1, RSpec-Rails 2.0.1 and Webrat 0.7.1. I have the following test: describe PagesController do describe "GET 'main'" do it "should have the right title" do get 'main' response.should have_selector("title", :content => "My title") end end end The HTML of pages#main checks out: it contains My ...