Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix ApplicationHelper issue and release 0.5.4

  • Loading branch information...
commit 5981fdf73ee80e5df50b0c327c2ecdbb3e3bfa8c 1 parent 796febf
@timcharper timcharper authored
View
6 History.txt
@@ -1,3 +1,9 @@
+== 0.5.4 2009-06-08
+
+ === Bugfixes
+
+ * ApplicationHelper delayed loading was causing methods from Rails ApplicationHelper included modules weren't being registered in controller specs. Fixed.
+
== 0.5.3 2009-06-08
=== Bugfixes
View
2  VERSION.yml
@@ -1,4 +1,4 @@
---
:major: 0
:minor: 5
-:patch: 3
+:patch: 4
View
71 features/rails_delayed_loading_workarounds.feature
@@ -0,0 +1,71 @@
+Feature: Rails Delayed Work arounds
+ To allow a rails developer to update as many parts of his application as possible without needing to restart Spork
+ Spork automatically tells rails to delay loading certain parts of the application until after the fork occurs
+ Providing work arounds
+
+ Background: Rails App with RSpec and Spork
+
+ Given I am in a fresh rails project named "test_rails_project"
+ And a file named "spec/spec_helper.rb" with:
+ """
+ require 'rubygems'
+ require 'spork'
+
+ Spork.prefork do
+ require File.dirname(__FILE__) + '/../config/environment.rb'
+ require 'spec'
+ require 'spec/rails'
+ end
+
+ Spork.each_run do
+ end
+ """
+ And the application has a model, observer, route, and application helper
+ Scenario: within a view, calling helper methods from an included module in ApplicationHelper
+ Given a file named "app/helpers/application_helper.rb" with:
+ """
+ module ApplicationHelper
+ include Reverseatron
+ end
+ """
+ Given a file named "lib/reverseatron.rb" with:
+ """
+ module Reverseatron
+ def reverse_text(txt)
+ txt.reverse
+ end
+ end
+ """
+ Given a file named "app/controllers/users_controller.rb" with:
+ """
+ class UsersController < ApplicationController
+ $loaded_stuff << 'UsersController'
+ def index
+ @users = []
+ end
+ end
+ """
+ Given a file named "app/controllers/users_helper.rb" with:
+ """
+ module UsersHelper
+ end
+ """
+ Given a file named "app/views/users/index.html.erb" with:
+ """
+ <%= reverse_text('listing users'.reverse) %>
+ """
+ Given a file named "spec/controllers/users_controller_spec.rb" with:
+ """
+ describe UsersController do
+ integrate_views
+ it "renders a page, using a method inherited from ApplicationController" do
+ get :index
+ response.body.should include('listing users')
+ puts "Controller stack is functioning"
+ end
+ end
+ """
+ When I fire up a spork instance with "spork rspec"
+ And I run spec --drb spec/controllers/users_controller_spec.rb
+ Then the output should contain "Controller stack is functioning"
+
View
33 features/rspec_rails_integration.feature
@@ -33,22 +33,6 @@ Feature: Rails Integration
end
"""
And the application has a model, observer, route, and application helper
- And a file named "spec/did_it_work_spec.rb" with:
- """
- describe "Did it work?" do
- it "checks to see if all worked" do
- Spork.state.should == :using_spork
- $loaded_stuff.should include('ActiveRecord::Base.establish_connection')
- $loaded_stuff.should include('User')
- $loaded_stuff.should include('UserObserver')
- $loaded_stuff.should include('ApplicationHelper')
- $loaded_stuff.should include('config/routes.rb')
- $loaded_stuff.should include('each_run block')
- $loaded_stuff.should include('prefork block')
- puts "Specs successfully run within spork, and all initialization files were loaded"
- end
- end
- """
Scenario: Analyzing files were preloaded
When I run spork --diagnose
Then the output should not contain "user_observer.rb"
@@ -59,7 +43,22 @@ Feature: Rails Integration
Then the output should not contain "config/routes.rb"
Scenario: Running spork with a rails app and observers
-
+ Given a file named "spec/did_it_work_spec.rb" with:
+ """
+ describe "Did it work?" do
+ it "checks to see if all worked" do
+ Spork.state.should == :using_spork
+ $loaded_stuff.should include('ActiveRecord::Base.establish_connection')
+ $loaded_stuff.should include('User')
+ $loaded_stuff.should include('UserObserver')
+ $loaded_stuff.should include('ApplicationHelper')
+ $loaded_stuff.should include('config/routes.rb')
+ $loaded_stuff.should include('each_run block')
+ $loaded_stuff.should include('prefork block')
+ puts "Specs successfully run within spork, and all initialization files were loaded"
+ end
+ end
+ """
When I fire up a spork instance with "spork rspec"
And I run spec --drb spec/did_it_work_spec.rb
Then the output should contain "Specs successfully run within spork, and all initialization files were loaded"
View
19 features/steps/rails_steps.rb
@@ -11,20 +11,19 @@
Given 'a file named "app/models/user.rb" with:',
"""
class User < ActiveRecord::Base
- ($loaded_stuff ||= []) << 'User'
+ $loaded_stuff << 'User'
end
"""
-
- Given 'a file named "app/helpers/application_helper.rb" with:',
+ Given 'a file named "app/models/user_observer.rb" with:',
"""
- module ApplicationHelper
- ($loaded_stuff ||= []) << 'ApplicationHelper'
+ class UserObserver < ActiveRecord::Observer
+ $loaded_stuff << 'UserObserver'
end
"""
- Given 'a file named "app/models/user_observer.rb" with:',
+ Given 'a file named "app/helpers/application_helper.rb" with:',
"""
- class UserObserver < ActiveRecord::Observer
- ($loaded_stuff ||= []) << 'UserObserver'
+ module ApplicationHelper
+ $loaded_stuff << 'ApplicationHelper'
end
"""
Given 'the following code appears in "config/environment.rb" after /Rails::Initializer.run/:',
@@ -33,14 +32,12 @@ class UserObserver < ActiveRecord::Observer
"""
Given 'the following code appears in "config/routes.rb" after /^end/:',
"""
- ($loaded_stuff ||= []) << 'config/routes.rb'
+ $loaded_stuff << 'config/routes.rb'
"""
-
Given 'a file named "config/initializers/initialize_loaded_stuff.rb" with:',
"""
$loaded_stuff ||= []
"""
-
Given 'a file named "config/initializers/log_establish_connection_calls.rb" with:',
"""
class ActiveRecord::Base
View
2  lib/spork/app_framework/rails.rb
@@ -56,6 +56,8 @@ def delay_application_controller_loading
Spork.each_run do
require application_controller_source
require application_helper_source if File.exist?(application_helper_source)
+ # update the rails magic to refresh the module
+ ApplicationController.send(:helper, ApplicationHelper)
end
end
end
View
5 spork.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{spork}
- s.version = "0.5.3"
+ s.version = "0.5.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Tim Harper"]
@@ -21,7 +21,8 @@ Gem::Specification.new do |s|
"assets/bootstrap.rb",
"features/cucumber_rails_integration.feature",
"features/diagnostic_mode.feature",
- "features/rails_integration.feature",
+ "features/rails_delayed_loading_workarounds.feature",
+ "features/rspec_rails_integration.feature",
"features/steps/rails_steps.rb",
"features/steps/sandbox_steps.rb",
"features/support/env.rb",
Please sign in to comment.
Something went wrong with that request. Please try again.