Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix Rails already initialized error (again)

The initial fix expanded the test paths, which would break when
distributing from Mac to Linux (/private/tmp instead of /tmp). Now, we
utilize the fact that Cucumber checks for RAILS_ROOT to ensure the
environment isn't loaded twice (by non-unique paths).
  • Loading branch information...
commit 5848c94bfce7896219dd20660392b35f90f3e4fc 1 parent d840a9d
@sandro authored
Showing with 4 additions and 1 deletion.
  1. +3 −0  lib/specjour/cucumber/preloader.rb
  2. +1 −1  lib/specjour/manager.rb
View
3  lib/specjour/cucumber/preloader.rb
@@ -3,6 +3,9 @@ module Cucumber
module Preloader
def self.load(paths, output)
Specjour.benchmark("Loading Cucumber Environment") do
+ if defined?(::Rails) && !ENV['RAILS_ROOT']
+ ENV['RAILS_ROOT'] = Rails.root.to_s # Load the current rails environment if it exists
+ end
require 'cucumber' unless defined?(::Cucumber::Cli)
args = paths.unshift '--format', 'Specjour::Cucumber::DistributedFormatter'
cli = ::Cucumber::Cli::Main.new(args, output)
View
2  lib/specjour/manager.rb
@@ -95,7 +95,7 @@ def pid
end
def project_path
- File.expand_path(project_name, File.realpath('/tmp'))
+ File.expand_path(project_name, '/tmp')
@pierreozoux Collaborator

Hi,

on my mac (not Gentoo) I've this (strange) error [0]

/tmp/workspace/config/application.rb:38 is : config.action_view.javascript_expansions[:defaults] = nil

I have the feeling that the path is not well loaded for this specifically... I am taking a look to that issue. If you have an idea?

[0] :
/tmp/workspace/config/application.rb:38:in <class:Application>': undefined method[]=' for nil:NilClass (NoMethodError)
from /tmp/workspace/config/application.rb:13:in <module:Seedrs>'
from /tmp/workspace/config/application.rb:12:in
'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in
block in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in
require'
from /tmp/workspace/config/environment.rb:2:in <top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in
require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in block in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in
load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in require'
from /tmp/workspace/spec/spec_helper.rb:27:in
block in '
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/spork-0.9.2/lib/spork.rb:24:in prefork'
from /tmp/workspace/spec/spec_helper.rb:3:in
'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in
block in require'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:251:in
require'
from /tmp/workspace/spec/models/user_spec.rb:3:in <top (required)>'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:245:in
load'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:245:in block in load'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:236:in
load_dependency'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.10/lib/active_support/dependencies.rb:245:in load'
from /usr/local/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in
block in load_spec_files'
from /usr/local/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in each'
from /usr/local/lib/ruby/gems/1.9.1/gems/rspec-core-2.12.2/lib/rspec/core/configuration.rb:789:in
load_spec_files'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/specjour-0cab17b0f2e9/lib/specjour/rspec/preloader.rb:13:in load_spec_files'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/specjour-0cab17b0f2e9/lib/specjour/rspec/preloader.rb:5:in
block in load'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/1.9.1/benchmark.rb:295:in realtime'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/specjour-0cab17b0f2e9/lib/specjour.rb:86:in
benchmark'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/specjour-0cab17b0f2e9/lib/specjour/rspec/preloader.rb:3:in load'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/specjour-0cab17b0f2e9/lib/specjour/loader.rb:84:in
load_app'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/specjour-0cab17b0f2e9/lib/specjour/loader.rb:22:in start'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/specjour-0cab17b0f2e9/lib/specjour/cli.rb:57:in
load'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/task.rb:27:in run'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/invocation.rb:120:in
invoke_task'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor.rb:275:in dispatch'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/gems/thor-0.16.0/lib/thor/base.rb:425:in
start'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/specjour-0cab17b0f2e9/lib/specjour/cli.rb:24:in start'
from /usr/local/Cellar/ruby/1.9.3-p327/lib/ruby/gems/1.9.1/bundler/gems/specjour-0cab17b0f2e9/bin/specjour:5:in

'

@sandro Owner
sandro added a note

Hmm, not sure about the error. I see spork in your backtrace, maybe we're running into an issue there? Have you tried replacing spork with https://github.com/jstorimer/spin or https://github.com/burke/zeus?

@pierreozoux Collaborator

I tried without spork, it's not from there... It's really strange..

@sandro Owner
sandro added a note

Are we sure that it's this line in particular? If you revert this line in your local copy of the gem, does specjour work as expected?

@pierreozoux Collaborator

Yes, If I revert just this line, it works as expected... And the issue is just MacOS (not Gentoo). The response is different : one is /tmp and the other one is /private/tmp. I don't know which Gem can't understand what's /private/tmp ? Just, you can try also to do a pwd /tmp and sudo pwd /tmp the response is different also. But as a normal user, if I go to cd /private/tmpmy system understand it, and as my gem should run as me (normal user)... Strange...

@pierreozoux I was investigating this and the problem was on some old tests on our project. It is now fixed and specjour is working fine.

@pierreozoux Collaborator

Great! :+1:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
end
def start
Please sign in to comment.
Something went wrong with that request. Please try again.