theine
theine copied to clipboard
Capybara integration tests not working
Running model tests works, but when I try to run a Capybara/Poltergeist integration test I get exception:
An error occurred in an after hook
Java::JavaLang::IllegalArgumentException: Object: #<struct Theine::Worker::InputProxy input=#<DRb::D
RbObject:0x329dffc4 @uri="druby://amberbox:60439", @ref=13816>> is not a legal argument to this wrappe
r, cause it doesn't respond to "read".
occurred at org.jruby.util.IOInputStream.<init>(IOInputStream.java:63)
An error occurred in an after hook
Java::JavaLang::IllegalArgumentException: Object: #<struct Theine::Worker::InputProxy input=#<DRb::D
RbObject:0x329dffc4 @uri="druby://amberbox:60439", @ref=13816>> is not a legal argument to this wrappe
r, cause it doesn't respond to "read".
occurred at org.jruby.util.IOInputStream.<init>(IOInputStream.java:63)
/home/vagrant/.rvm/gems/jruby-1.7.4/gems/rspec-core-2.12.2/lib/rspec/core/example.rb:275 warning: sing
leton on non-persistent Java type Java::JavaLang::IllegalArgumentException (http://wiki.jruby.org/Pers
istence)
Hm so it seems like you are using $stdin (or the methods that use it like gets) in the tests, or maybe Capybara is. I want to fix this, is it possible for you to provide a small example app I can use to reproduce this?
I think I know how to fix this, but I still wonder why your test is using stdin. Could you show me the code of this after hook that is failing?
Can you try the 0.0.10.rc1 version I just released?
gem uninstall theine
gem install theine -v "0.0.10.rc1"
You will probably get a different error or it will work.
any luck?
fixed in 0.0.10.
Hm, there are still fails, but don't know what is the cause, the screen session closes immediately after the results are displayed. Any way to delay screen termination?
Hm it's weird that it closes, that should be prevented by the read command here https://github.com/mrbrdo/theine/blob/master/lib/theine/server.rb#L32 You can try bundle open theine and try to put something else there that would prevent screen from closing, or modify the sh command parameters so the shell will not end after the command is complete. Let me know if you find a solution since I really want to prevent this.
Also you can try https://blogs.oracle.com/samf/entry/smcup_rmcup_hate this will make it so that after the screen terminates you will still see the last output a little above. (note: I had to remove some backslashes from that code for it to work)
PS: I was not able to reproduce not getting the exit prompt (Press [Enter] to exit...), when specs are failing or passing.
Just released 0.0.11 which does this automatically (show output even after screen exits).
https://blogs.oracle.com/samf/entry/smcup_rmcup_hate didn't help, but 0.0.11
works, I had also a problem with:
NameError:
uninitialized constant Capybara::Screenshot
but moving capybara-screenshot above rspec/rails helped and tests pass.
Thanks for the support!
That is great news. Is it possible to give more info about this capybara-screenshot problem? Is there something I can do in theine to avoid this being a problem or was it just a problem with your code?
It was a problem of require order in spec_helper. Found this thread https://github.com/mattheworiordan/capybara-screenshot/issues/54 - other people had the same problem and they probably didn't use theine, so I think everything is good now.
Actually I think there is a problem, when I move capybara-screenshot
above rspec/rails
there are no screenshots created, moving it down makes theine
throw NameError
. If you'd like to see my code I am working on https://github.com/amberbit/KarmaTracker and launching integration tests in spec/features
BTW: require order is a huge fail ... :/
Just to confirm, when you run normally using rspec without theine it works fine?
Yes
just wanna let you know that I didn't forget about this, just need to find some time to get to it
Sure, no worries, I'm also short on time.
@BartlomiejSkwira can you please check if 0.0.13 changed anything? Using "theine rspec" or "theine rake spec" command.
Before it was using the development environment instead of test.
Upgraded the gem to 0.013 and tried to use it with 2 jruby projects but I keep getting:
$ theine_server
(spawn 11001)
Errno::ENOENT: No such file or directory - screen
_spawn_internal at org/jruby/RubyProcess.java:1069
spawn at file:/home/../.rvm/rubies/jruby-1.7.6/lib/jruby.jar!/jruby/kernel19/process.rb:13
spawn at file:/home/../.rvm/rubies/jruby-1.7.6/lib/jruby.jar!/jruby/kernel19/kernel.rb:29
add_worker at /home/../.rvm/gems/jruby-1.7.6@karmatracker/gems/theine-0.0.13/lib/theine/server.rb:32
check_min_free_workers at /home/../.rvm/gems/jruby-1.7.6@karmatracker/gems/theine-0.0.13/lib/theine/server.rb:82
run at /home/../.rvm/gems/jruby-1.7.6@karmatracker/gems/theine-0.0.13/lib/theine/server.rb:127
initialize at /home/../.rvm/gems/jruby-1.7.6@karmatracker/gems/theine-0.0.13/lib/theine/server.rb:23
(root) at /home/../.rvm/gems/jruby-1.7.6@karmatracker/gems/theine-0.0.13/lib/theine/server.rb:133
require at org/jruby/RubyKernel.java:1082
require at /home/../.rvm/rubies/jruby-1.7.6/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:73
require at /home/../.rvm/rubies/jruby-1.7.6/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:71
(root) at /home/../.rvm/gems/jruby-1.7.6@karmatracker/gems/theine-0.0.13/bin/theine_server:1
load at org/jruby/RubyKernel.java:1101
(root) at /home/../.rvm/gems/jruby-1.7.6@karmatracker/gems/theine-0.0.13/bin/theine_server:2
eval at org/jruby/RubyKernel.java:1121
(root) at /home/../.rvm/gems/jruby-1.7.6@karmatracker/bin/jruby_executable_hooks:15
You probably need to install screen.
Yeap sorry, forgot about screen in this env. The problem with capybara screenshot stayed: https://gist.github.com/BartlomiejSkwira/7718985
Jan If you'd like to launch the tests yourself clone https://github.com/amberbit/KarmaTracker and launch something from spec/features dir
@BartlomiejSkwira I know this is very late, but I had some time to work on merging theine into spring (the official rails preloader). I wonder if that helps with your issue. I only tried it with JRuby 9.0.3.0, though.
I think it should be enough to add gem 'spring-jruby'
to your Gemfile, run bundle install
and then run commands like spring rake test
.