[rspec-users] Rails3 subdomain constraints with Cucumber and RSpec2

Cameron Caine lists at ruby-forum.com
Wed Aug 25 18:15:20 EDT 2010


How do I spec rails3 routing constraints?
My Cucumber features pass whatever subdomain I pass in.  Not sure where
or how to spec the subdomain.  Any help would be appreciated.

I have something like the following:

#features/create_account.feature
Scenario:
  Given I visit subdomain "www"
  And I go to the new account page

#accounts_controller_spec.rb
describe AccountsController do
  describe "GET new" do
    before(:each) do
      get :new
    end

    it "should render new.html.haml" do
      response.should render_template(:new)
    end
  end
end

#routes.rb
constraints Promotional do
  resource :account, :only => :new
end

#lib/promotional.rb
class Promotional
    def self.matches?(request)
      request.subdomain.empty? || request.subdomain == "www"
    end
end
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list