Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
fixed rspec generators o work with rails 2.3 and rspec 1.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Scataglini authored and technoweenie committed Jul 7, 2010
1 parent 7235d91 commit 1f99491
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
@@ -1,12 +1,12 @@
require File.dirname(__FILE__) + '<%= ('/..'*controller_class_nesting_depth) + '/../spec_helper' %>' require File.dirname(__FILE__) + '<%= ('/..'*controller_class_nesting_depth) + '/../spec_helper' %>'
# Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead # Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead
# Then, you can remove it from this and the units test. # Then, you can remove it from this and the units test.
include AuthenticatedTestHelper


# #
# A test controller with and without access controls # A test controller with and without access controls
# #
class AccessControlTestController < ApplicationController class AccessControlTestController < ApplicationController
include AuthenticatedSystem
before_filter :login_required, :only => :login_is_required before_filter :login_required, :only => :login_is_required
def login_is_required def login_is_required
respond_to do |format| respond_to do |format|
Expand Down Expand Up @@ -42,6 +42,8 @@ def login_not_required
:login_is_required,] :login_is_required,]


describe AccessControlTestController do describe AccessControlTestController do
include AuthenticatedTestHelper
include AuthenticatedSystem
fixtures :<%= table_name %> fixtures :<%= table_name %>
before do before do
# is there a better way to do this? # is there a better way to do this?
Expand Down
Expand Up @@ -2,11 +2,11 @@
# Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead # Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead
# Then, you can remove it from this and the units test. # Then, you can remove it from this and the units test.
include AuthenticatedTestHelper
include AuthenticatedSystem
def action_name() end def action_name() end


describe <%= controller_class_name %>Controller do describe <%= controller_class_name %>Controller do
include AuthenticatedTestHelper
include AuthenticatedSystem
fixtures :<%= table_name %> fixtures :<%= table_name %>


before do before do
Expand Down
Expand Up @@ -2,9 +2,10 @@
# Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead # Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead
# Then, you can remove it from this and the units test. # Then, you can remove it from this and the units test.
include AuthenticatedTestHelper


describe <%= controller_class_name %>Controller do describe <%= controller_class_name %>Controller do
include AuthenticatedTestHelper
fixtures :<%= table_name %> fixtures :<%= table_name %>
before do before do
@<%= file_name %> = mock_<%= file_name %> @<%= file_name %> = mock_<%= file_name %>
Expand Down Expand Up @@ -105,7 +106,7 @@ def do_destroy
route_for(:controller => '<%= controller_controller_name %>', :action => 'new').should == "/login" route_for(:controller => '<%= controller_controller_name %>', :action => 'new').should == "/login"
end end
it "should route the create <%= controller_controller_name %> correctly" do it "should route the create <%= controller_controller_name %> correctly" do
route_for(:controller => '<%= controller_controller_name %>', :action => 'create').should == "/<%= controller_routing_path %>" route_for(:controller => '<%= controller_controller_name %>', :action => 'create').should == {:path => "/<%= controller_routing_path %>", :method => :post}
end end
it "should route the destroy <%= controller_controller_name %> action correctly" do it "should route the destroy <%= controller_controller_name %> action correctly" do
route_for(:controller => '<%= controller_controller_name %>', :action => 'destroy').should == "/logout" route_for(:controller => '<%= controller_controller_name %>', :action => 'destroy').should == "/logout"
Expand Down
Expand Up @@ -2,9 +2,10 @@
# Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead # Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead
# Then, you can remove it from this and the units test. # Then, you can remove it from this and the units test.
include AuthenticatedTestHelper


describe <%= model_controller_class_name %>Controller do describe <%= model_controller_class_name %>Controller do
include AuthenticatedTestHelper
fixtures :<%= table_name %> fixtures :<%= table_name %>


it 'allows signup' do it 'allows signup' do
Expand Down Expand Up @@ -117,11 +118,11 @@ def create_<%= file_name %>(options = {})
end end


it "should route <%= model_controller_controller_name %>'s 'update' action correctly" do it "should route <%= model_controller_controller_name %>'s 'update' action correctly" do
route_for(:controller => '<%= model_controller_controller_name %>', :action => 'update', :id => '1').should == "/<%= model_controller_routing_path %>/1" route_for(:controller => '<%= model_controller_controller_name %>', :action => 'update', :id => '1').should == {:path => "/<%= model_controller_routing_path %>/1", :method => :put}
end end


it "should route <%= model_controller_controller_name %>'s 'destroy' action correctly" do it "should route <%= model_controller_controller_name %>'s 'destroy' action correctly" do
route_for(:controller => '<%= model_controller_controller_name %>', :action => 'destroy', :id => '1').should == "/<%= model_controller_routing_path %>/1" route_for(:controller => '<%= model_controller_controller_name %>', :action => 'destroy', :id => '1').should == {:path => "/<%= model_controller_routing_path %>/1", :method => :delete}
end end
end end


Expand Down Expand Up @@ -174,20 +175,20 @@ def create_<%= file_name %>(options = {})


it "should route <%= model_controller_routing_name %>_path() to /<%= model_controller_routing_path %>" do it "should route <%= model_controller_routing_name %>_path() to /<%= model_controller_routing_path %>" do
<%= model_controller_routing_name %>_path().should == "/<%= model_controller_routing_path %>" <%= model_controller_routing_name %>_path().should == "/<%= model_controller_routing_path %>"
formatted_<%= model_controller_routing_name %>_path(:format => 'xml').should == "/<%= model_controller_routing_path %>.xml" <%= model_controller_routing_name %>_path(:format => 'xml').should == "/<%= model_controller_routing_path %>.xml"
formatted_<%= model_controller_routing_name %>_path(:format => 'json').should == "/<%= model_controller_routing_path %>.json" <%= model_controller_routing_name %>_path(:format => 'json').should == "/<%= model_controller_routing_path %>.json"
end end
it "should route new_<%= model_controller_routing_name.singularize %>_path() to /<%= model_controller_routing_path %>/new" do it "should route new_<%= model_controller_routing_name.singularize %>_path() to /<%= model_controller_routing_path %>/new" do
new_<%= model_controller_routing_name.singularize %>_path().should == "/<%= model_controller_routing_path %>/new" new_<%= model_controller_routing_name.singularize %>_path().should == "/<%= model_controller_routing_path %>/new"
formatted_new_<%= model_controller_routing_name.singularize %>_path(:format => 'xml').should == "/<%= model_controller_routing_path %>/new.xml" new_<%= model_controller_routing_name.singularize %>_path(:format => 'xml').should == "/<%= model_controller_routing_path %>/new.xml"
formatted_new_<%= model_controller_routing_name.singularize %>_path(:format => 'json').should == "/<%= model_controller_routing_path %>/new.json" new_<%= model_controller_routing_name.singularize %>_path(:format => 'json').should == "/<%= model_controller_routing_path %>/new.json"
end end


it "should route <%= model_controller_routing_name.singularize %>_(:id => '1') to /<%= model_controller_routing_path %>/1" do it "should route <%= model_controller_routing_name.singularize %>_(:id => '1') to /<%= model_controller_routing_path %>/1" do
<%= model_controller_routing_name.singularize %>_path(:id => '1').should == "/<%= model_controller_routing_path %>/1" <%= model_controller_routing_name.singularize %>_path(:id => '1').should == "/<%= model_controller_routing_path %>/1"
formatted_<%= model_controller_routing_name.singularize %>_path(:id => '1', :format => 'xml').should == "/<%= model_controller_routing_path %>/1.xml" <%= model_controller_routing_name.singularize %>_path(:id => '1', :format => 'xml').should == "/<%= model_controller_routing_path %>/1.xml"
formatted_<%= model_controller_routing_name.singularize %>_path(:id => '1', :format => 'json').should == "/<%= model_controller_routing_path %>/1.json" <%= model_controller_routing_name.singularize %>_path(:id => '1', :format => 'json').should == "/<%= model_controller_routing_path %>/1.json"
end end


it "should route edit_<%= model_controller_routing_name.singularize %>_path(:id => '1') to /<%= model_controller_routing_path %>/1/edit" do it "should route edit_<%= model_controller_routing_name.singularize %>_path(:id => '1') to /<%= model_controller_routing_path %>/1/edit" do
Expand Down
@@ -1,9 +1,10 @@
require File.dirname(__FILE__) + '<%= ('/..'*model_controller_class_nesting_depth) + '/../spec_helper' %>' require File.dirname(__FILE__) + '<%= ('/..'*model_controller_class_nesting_depth) + '/../spec_helper' %>'
include ApplicationHelper
include <%= model_controller_class_name %>Helper
include AuthenticatedTestHelper
describe <%= model_controller_class_name %>Helper do describe <%= model_controller_class_name %>Helper do
include ApplicationHelper
include <%= model_controller_class_name %>Helper
include AuthenticatedTestHelper
before do before do
@<%= file_name %> = mock_<%= file_name %> @<%= file_name %> = mock_<%= file_name %>
end end
Expand Down
3 changes: 2 additions & 1 deletion generators/authenticated/templates/spec/models/user_spec.rb
Expand Up @@ -3,9 +3,10 @@
# Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead. # Be sure to include AuthenticatedTestHelper in spec/spec_helper.rb instead.
# Then, you can remove it from this and the functional test. # Then, you can remove it from this and the functional test.
include AuthenticatedTestHelper


describe <%= class_name %> do describe <%= class_name %> do
include AuthenticatedTestHelper
fixtures :<%= table_name %> fixtures :<%= table_name %>


describe 'being created' do describe 'being created' do
Expand Down

0 comments on commit 1f99491

Please sign in to comment.