Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding environment loading to the Spork.prefork block

  • Loading branch information...
commit 323bed0cad5506f10fd24e46aba3632456bdd9e8 1 parent 7474542
@dirksiemers authored
View
13 Guardfile
@@ -24,4 +24,17 @@ guard 'rspec', :version => 2, :all_after_pass => false, :cli => '--drb' do
watch('app/controllers/application_controller.rb') { "spec/controllers" }
# Capybara request specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+
+ # Additions to the default Guardfile
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
+ ["spec/routing/#{m[1]}_routing_spec.rb",
+ "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb",
+ "spec/acceptance/#{m[1]}_spec.rb",
+ (m[1][/_pages/] ? "spec/requests/#{m[1]}_spec.rb" :
+ "spec/requests/#{m[1].singularize}_pages_spec.rb")]
+ end
+ watch(%r{^app/views/(.+)/}) do |m|
+ "spec/requests/#{m[1].singularize}_pages_spec.rb"
+ end
+
end
View
11 app/helpers/application_helper.rb
@@ -1,2 +1,13 @@
module ApplicationHelper
+
+ # Returns the full title on a per-page basis.
+ def full_title(page_title)
+ base_title = "Ruby on Rails Tutorial Sample App"
+ if page_title.empty?
+ base_title
+ else
+ "#{base_title} | #{page_title}"
+ end
+ end
+
end
View
2  app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
+ <title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
View
36 spec/spec_helper.rb
@@ -4,10 +4,42 @@
#require 'spork/ext/ruby-debug'
Spork.prefork do
- # Loading more in this block will cause your tests to run faster. However,
+ # Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
-
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
+ ENV["RAILS_ENV"] ||= 'test'
+ require File.expand_path("../../config/environment", __FILE__)
+ require 'rspec/rails'
+ require 'rspec/autorun'
+
+ # Requires supporting ruby files with custom matchers and macros, etc,
+ # in spec/support/ and its subdirectories.
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+ RSpec.configure do |config|
+ # == Mock Framework
+ #
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
+ #
+ # config.mock_with :mocha
+ # config.mock_with :flexmock
+ # config.mock_with :rr
+ config.mock_with :rspec
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # If true, the base class of anonymous controllers will be inferred
+ # automatically. This will be the default behavior in future versions of
+ # rspec-rails.
+ config.infer_base_class_for_anonymous_controllers = false
+ end
end
Spork.each_run do
Please sign in to comment.
Something went wrong with that request. Please try again.