GithubHelp home page GithubHelp logo

Rspec 2.11 config issue about specjour HOT 10 CLOSED

pierreozoux avatar pierreozoux commented on July 28, 2024
Rspec 2.11 config issue

from specjour.

Comments (10)

sandro avatar sandro commented on July 28, 2024

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.

from specjour.

pierreozoux avatar pierreozoux commented on July 28, 2024

Hi again,

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

Failure/Error: login_as(user)
     NoMethodError:
       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?

#./spec/spec_helper.rb
RSpec.configure do |config|
  config.before(:each) do
    $stderr.puts "before each"
  end
  config.include Warden::Test::Helpers
end

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

from specjour.

sandro avatar sandro commented on July 28, 2024

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'
end

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
    debugger
    1
  end
end

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

from specjour.

pierreozoux avatar pierreozoux commented on July 28, 2024

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!

from specjour.

pierreozoux avatar pierreozoux commented on July 28, 2024

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 [email protected]:pierreozoux/specjour.git
cd specjour
git checkout issue43
rake
...
(rdb:1) p $toto
1
...
specjour
...
(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 ;)

from specjour.

sandro avatar sandro commented on July 28, 2024

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.

from specjour.

pierreozoux avatar pierreozoux commented on July 28, 2024

Ok, here we are :)

rspec -v
2.11.1

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 ;)

Thanks,

Pierre

from specjour.

sandro avatar sandro commented on July 28, 2024

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

from specjour.

pierreozoux avatar pierreozoux commented on July 28, 2024

Perfect!
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 :) )

from specjour.

sandro avatar sandro commented on July 28, 2024

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.

from specjour.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.