Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Rspec 2.11 config issue #43

pierreozoux opened this Issue Oct 4, 2012 · 10 comments


None yet
2 participants

pierreozoux commented Oct 4, 2012


I would love to use specjour in production, but it doesn't work.

I tracked the issue, and I get to the point that something between my monkey patch from rails_warden and specjour is not working.

I have a monkey patch in my spec_helper :

# monkey patch
module RailsWarden::Mixins::HelperMethods
  def warden #:nodoc:
    @warden ||= begin
      p "during monkey patch"
      manager = Warden::Manager.new(nil)
      request.env["warden"] = Warden::Proxy.new(request.env, manager)

When I run rspec, it is printing "during monkey patch", and the test is successful.
When I run it with specjour, it is not printing "during monkey patch", and the test is not successful.

If I put this monkey patch in the actual code of rails_warden, I have the same behavior from specjour.

I have time to debug, as it will help us a lot to reduce our time to run our tests...

Do you have any idea where it can come from? Then I'll investigate!

Thanks a lot for your work!



sandro commented Oct 4, 2012

Not sure yet…
Instead of printing to stdout, try printing to stderr:

$stderr.puts "during monkey patch"

If specjour doesn't find any listeners, it forks one, pointing the child's stdout to a StringIO.


pierreozoux commented Oct 9, 2012

Hi again,

1st : I forgot to mention that the error was :

Failure/Error: login_as(user)
       undefined method `login_as' for #<RSpec::Core::ExampleGroup::Nested_6::Nested_2:0x007fcf91b540b0>

I tried many things also your $stderr.puts.

I have the feeling now that there is something wrong with the loading of spec_helper.rb.

Can you tell me if rspec configure is supported by specjour?

RSpec.configure do |config|
  config.before(:each) do
    $stderr.puts "before each"
  config.include Warden::Test::Helpers

This is printing with Rspec, but not with specjour.

I tried also to write this to a file to avoid confusion with outputs, same result. (working with rspec but not specjour)

That's maybe why my login_as method is not loaded? Just a guess..

Thanks for your help again


sandro commented Oct 9, 2012

Specjour initializes the environment by loading your spec_helper (https://github.com/sandro/specjour/blob/master/lib/specjour/rspec/preloader.rb#L4).

I successfully added this to my spec_helper, and it worked fine.

config.before do
  $stderr.puts 'hi foo'

Are you running the latest version of specjour? Type specjour version. I'm running 0.6.4

Note, specjour may not properly handle config.before(:all). Specjour runs every example in isolation, which means before(:all) likely becomes a before(:each). I should fix that, but in the meantime, a specjour hook could mimic before(:all).

Try using a debugger…

# spec/spec_helper.rb
RSpec.configure do |config|
  config.before do

If that doesn't work, then we got some issues.


pierreozoux commented Oct 10, 2012

I'm running 0.6.4.

I tried with a debugger also, same result.

I tried with a small project, I have the same behavior.

I tried on another machine (Gentoo) used to make our tests also, same behavior.

I'll cook a simple Gentoo with just ruby and specjour, and I'll try with my little project.

(I think it is an incompatibility with another Gem)

I'll let you know. Thanks again for your time!


pierreozoux commented Oct 11, 2012

I'm pretty sure, there is a bug there.

I tested it with a fresh VM and I found a way to demonstrate it.

I'm using the code of specjour to demonstrate it.

The idea is to initialize a global variable in a config.before and watch from the debugger if this variable is initialized or not.

The modification is here : pierreozoux/specjour@master...issue43

So you can test, like this:

git clone git@github.com:pierreozoux/specjour.git
cd specjour
git checkout issue43
(rdb:1) p $toto
(rdb:1) p $toto
nil #here should be 1

I reproduced this with my mac, and my freshly cooked Gentoo.
Can you tell me if you can reproduce it?
I'm quiet new to ruby, but I'll try to correct it. If you have some advice, please do not hesitate, and thanks for the debug, I didn't know ;)


sandro commented Oct 11, 2012

Oh! I just thought of something… what version of RSpec are you running? I think specjour is incompatible with the latest version of RSpec (which has slipped my mind). I'm successfully running specjour with rspec-core 2.9.0.


pierreozoux commented Oct 11, 2012

Ok, here we are :)

rspec -v

So be careful, when you update your system :)

I'll try right now to run with 2.9, and why not, try to find a patch to support 2.11.1 ;)




sandro commented Oct 11, 2012

Pretty sure the patch will be all about RSpec.reset. I use reset in specjour/loader.rb. Check rspec/rspec-core#621

@sandro sandro closed this in 6b4cc58 Oct 15, 2012


pierreozoux commented Oct 16, 2012

It's working like a charm with my code! (in fact, I used the monkey patch for my code, but was waiting for some results to publish it here) I'm still having issues with cucumber, I'm investigating, and I'll let you know.

When it will be implemented, I'll send you the time saved for each build thanks to you :)

And we'll send a tweet (we, with my colleagues, are working on a new licence for free software based on beerware, it'll be called TweetWare :) )


sandro commented Oct 16, 2012

Great, look forward to hearing about your success.

I haven't used cucumber for about a year, so I'm certain specjour is out of date with the latest. I haven't made time to work on the update. I'll dig in to it soon, and push a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment