Skip to content
Browse files

paths and module refs

- rely on load path
- prefix refs to Rails modules with ::
  • Loading branch information...
1 parent b903e9c commit e07f513b3c4267b3aae88d96a2e55952604d58ec @dchelimsky committed Sep 6, 2009
View
5 Rakefile
@@ -1,12 +1,13 @@
# -*- ruby -*-
gem 'hoe', '>=2.0.0'
require 'hoe'
-require './lib/spec/rails/version'
-require 'cucumber/rake/task'
$:.unshift(File.join(File.dirname(__FILE__), "/../rspec/lib"))
+$:.unshift(File.join(File.dirname(__FILE__), "/lib"))
+require 'spec/rails/version'
require 'spec/rake/spectask'
+require 'cucumber/rake/task'
Hoe.spec('rspec-rails') do |p|
p.version = Spec::Rails::VERSION::STRING
View
2 generators/integration_spec/templates/integration_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+require 'spec/spec_helper'
describe "<%= class_name.pluralize %>" do
end
View
2 generators/rspec/templates/spec_helper.rb
@@ -1,7 +1,7 @@
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
-require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
+require 'config/environment'
require 'spec/autorun'
require 'spec/rails'
View
2 generators/rspec_controller/templates/controller_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+require 'spec/spec_helper'
describe <%= class_name %>Controller do
View
2 generators/rspec_controller/templates/helper_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+require 'spec/spec_helper'
describe <%= class_name %>Helper do
View
2 generators/rspec_controller/templates/routing_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+require 'spec/spec_helper'
describe <%= controller_class_name %>Controller do
describe "routing" do
View
2 generators/rspec_controller/templates/view_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+require 'spec/spec_helper'
describe "/<%= class_name.underscore %>/<%= action %>" do
before(:each) do
View
2 generators/rspec_model/templates/model_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+require 'spec/spec_helper'
describe <%= class_name %> do
before(:each) do
View
2 generators/rspec_scaffold/templates/controller_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+require 'spec/spec_helper'
describe <%= controller_class_name %>Controller do
View
2 generators/rspec_scaffold/templates/edit_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+require 'spec/spec_helper'
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "/<%= table_name %>/edit.<%= default_file_extension %>" do
View
2 generators/rspec_scaffold/templates/helper_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+require 'spec/spec_helper'
describe <%= controller_class_name %>Helper do
View
2 generators/rspec_scaffold/templates/index_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+require 'spec/spec_helper'
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "/<%= table_name %>/index.<%= default_file_extension %>" do
View
2 generators/rspec_scaffold/templates/new_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+require 'spec/spec_helper'
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "/<%= table_name %>/new.<%= default_file_extension %>" do
View
2 generators/rspec_scaffold/templates/routing_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper')
+require 'spec/spec_helper'
describe <%= controller_class_name %>Controller do
describe "routing" do
View
2 generators/rspec_scaffold/templates/show_erb_spec.rb
@@ -1,4 +1,4 @@
-require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
+require 'spec/spec_helper'
<% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].index(attribute.type) } -%>
describe "/<%= table_name %>/show.<%= default_file_extension %>" do
View
2 lib/spec/rails/example/controller_example_group.rb
@@ -215,7 +215,7 @@ def render(options=nil, extra_options={}, &block)
if matching_stub_exists(options)
@performed_render = true
else
- if Rails::VERSION::STRING > '2.1'
+ if ::Rails::VERSION::STRING > '2.1'
super(options, extra_options, &block)
else
super(options, &block)
View
4 lib/spec/rails/extensions/action_controller/rescue.rb
@@ -9,7 +9,7 @@ def use_rails_error_handling!
Use rescue_action_in_public!, which is defined directly in
rails' testing framework, instead.
WARNING
- if Rails::VERSION::STRING =~ /^2\.0/
+ if ::Rails::VERSION::STRING =~ /^2\.0/
@use_rails_error_handling = true
else
# anything but 0.0.0.0 - borrowed from rails own rescue_action_in_public!
@@ -23,7 +23,7 @@ def use_rails_error_handling?
protected
- if Rails::VERSION::STRING =~ /^2\.0/
+ if ::Rails::VERSION::STRING =~ /^2\.0/
def rescue_action_in_public?
request.respond_to?(:rescue_action_in_public?) and request.rescue_action_in_public?
end
View
2 lib/spec/rails/extensions/action_controller/test_case.rb
@@ -2,7 +2,7 @@ module ActionController
class TestCase
include ::Spec::Rails::Example::RoutingHelpers
- if Rails::VERSION::STRING =~ /2\.0/
+ if ::Rails::VERSION::STRING =~ /2\.0/
# Introduced in Rails 2.1, but we need it for 2.0
def rescue_action_in_public!
# See rescue.rb in this same directory
View
2 spec/spec/rails/example/controller_example_group_spec.rb
@@ -188,7 +188,7 @@
}.should_not raise_error
end
- if Rails::VERSION::STRING > '2.1'
+ if ::Rails::VERSION::STRING > '2.1'
describe "extending #render on a controller" do
it "supports two arguments (as with rails 2.1)" do
get 'action_with_two_arg_render'
View
2 spec/spec/rails/example/helper_example_group_spec.rb
@@ -148,7 +148,7 @@ module Example
helper_name :explicit
before(:each) do
- if Rails::VERSION::STRING <= "2.1"
+ if ::Rails::VERSION::STRING <= "2.1"
pending("need to get this new feature working against pre 2.2 versions of rails")
end
end
View
47 spec/spec_helper.rb
@@ -1,36 +1,35 @@
-dir = File.dirname(__FILE__)
-$LOAD_PATH.unshift(File.expand_path("#{dir}/../rspec/lib"))
-$LOAD_PATH.unshift(File.expand_path("#{dir}/resources/controllers"))
-$LOAD_PATH.unshift(File.expand_path("#{dir}/resources/helpers"))
-require File.expand_path("#{dir}/../../../../spec/spec_helper")
-require File.expand_path("#{dir}/resources/controllers/application")
-require File.expand_path("#{dir}/resources/controllers/render_spec_controller")
-require File.expand_path("#{dir}/resources/controllers/controller_spec_controller")
-require File.expand_path("#{dir}/resources/controllers/rjs_spec_controller")
-require File.expand_path("#{dir}/resources/controllers/redirect_spec_controller")
-require File.expand_path("#{dir}/resources/controllers/action_view_base_spec_controller")
-require File.expand_path("#{dir}/resources/helpers/addition_helper")
-require File.expand_path("#{dir}/resources/helpers/explicit_helper")
-require File.expand_path("#{dir}/resources/helpers/more_explicit_helper")
-require File.expand_path("#{dir}/resources/helpers/view_spec_helper")
-require File.expand_path("#{dir}/resources/helpers/plugin_application_helper")
+$LOAD_PATH.unshift '../rspec/lib'
+$LOAD_PATH.unshift '../../../'
+$LOAD_PATH.unshift 'spec/resources/controllers'
+$LOAD_PATH.unshift 'spec/resources/helpers'
-require File.expand_path("#{dir}/resources/models/animal")
-require File.expand_path("#{dir}/resources/models/person")
-require File.expand_path("#{dir}/resources/models/thing")
+require '../../../spec/spec_helper'
-extra_controller_paths = File.expand_path("#{dir}/resources/controllers")
+require 'spec/resources/controllers/application'
+require 'spec/resources/controllers/render_spec_controller'
+require 'spec/resources/controllers/controller_spec_controller'
+require 'spec/resources/controllers/rjs_spec_controller'
+require 'spec/resources/controllers/redirect_spec_controller'
+require 'spec/resources/controllers/action_view_base_spec_controller'
+require 'spec/resources/helpers/addition_helper'
+require 'spec/resources/helpers/explicit_helper'
+require 'spec/resources/helpers/more_explicit_helper'
+require 'spec/resources/helpers/view_spec_helper'
+require 'spec/resources/helpers/plugin_application_helper'
+require 'spec/resources/models/animal'
+require 'spec/resources/models/person'
+require 'spec/resources/models/thing'
-unless ActionController::Routing.controller_paths.include?(extra_controller_paths)
+unless ActionController::Routing.controller_paths.include?('spec/resources/controllers')
ActionController::Routing.instance_eval {@possible_controllers = nil}
- ActionController::Routing.controller_paths << extra_controller_paths
+ ActionController::Routing.controller_paths << 'spec/resources/controllers'
end
module Spec
module Rails
module Example
class ViewExampleGroupController
- prepend_view_path File.join(File.dirname(__FILE__), "..", "spec", "resources", "views")
+ prepend_view_path 'spec/resources/views'
end
end
end
@@ -56,7 +55,7 @@ def should_pass
map.resources :rspec_on_rails_specs
map.custom_route 'custom_route', :controller => 'custom_route_spec', :action => 'custom_route'
- map.connect ":controller/:action/:id"
+ map.connect ':controller/:action/:id'
end
module HelperMethods

0 comments on commit e07f513

Please sign in to comment.
Something went wrong with that request. Please try again.