Skip to content

Commit

Permalink
Improved routes specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jul 12, 2009
1 parent a6d30f7 commit de72281
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
23 changes: 10 additions & 13 deletions remarkable_rails/spec/action_controller/route_matcher_spec.rb
@@ -1,7 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe 'route_matcher' do
include FunctionalBuilder
controller_name :tasks

describe 'messages' do
before(:each) do
Expand Down Expand Up @@ -62,18 +62,6 @@
should_not_route :xyz, '/projects', :controller => :projects, :action => :index
end

describe TasksController, :type => :routing do
controller_name 'tasks'

# Test the nested routes with implicit controller
should_route :get, '/projects/5/tasks', :action => :index, :project_id => 5
should_route :post, '/projects/5/tasks', :action => :create, :project_id => 5
should_route :get, '/projects/5/tasks/1', :action => :show, :id => 1, :project_id => 5
should_route :delete, '/projects/5/tasks/1', :action => :destroy, :id => 1, :project_id => 5
should_route :get, '/projects/5/tasks/new', :action => :new, :project_id => 5
should_route :put, '/projects/5/tasks/1', :action => :update, :id => 1, :project_id => 5
end

describe 'using controller.request' do
it "should extract environment from controller request" do
@matcher = route(:get, '/projects', :controller => 'projects', :action => 'index')
Expand All @@ -82,5 +70,14 @@
@matcher.matches?(@controller)
end
end
end

# Test implicit controller
describe TasksController, :type => :routing do
should_route :get, '/projects/5/tasks', :action => :index, :project_id => 5
should_route :post, '/projects/5/tasks', :action => :create, :project_id => 5
should_route :get, '/projects/5/tasks/1', :action => :show, :id => 1, :project_id => 5
should_route :delete, '/projects/5/tasks/1', :action => :destroy, :id => 1, :project_id => 5
should_route :get, '/projects/5/tasks/new', :action => :new, :project_id => 5
should_route :put, '/projects/5/tasks/1', :action => :update, :id => 1, :project_id => 5
end
7 changes: 5 additions & 2 deletions remarkable_rails/spec/spec_helper.rb
Expand Up @@ -2,7 +2,6 @@

RAILS_ENV = 'test'
RAILS_VERSION = ENV['RAILS_VERSION'] || '2.3.2'
RSPEC_VERSION = ENV['RSPEC_VERSION'] || Spec::VERSION::STRING

# Load Rails
gem 'activesupport', RAILS_VERSION
Expand Down Expand Up @@ -33,7 +32,11 @@
require File.join(dir, 'functional_builder')

# Load spec-rails
gem 'rspec-rails', RSPEC_VERSION
if ENV['RSPEC_VERSION']
gem 'rspec-rails', ENV['RSPEC_VERSION']
else
gem 'rspec-rails'
end
require 'spec/rails'

require File.join(dir, '..', 'lib', 'remarkable_rails')
Expand Down

0 comments on commit de72281

Please sign in to comment.