ConradIrwin / pry-rescue

Start a pry session whenever something goes wrong.
MIT License
852 stars 49 forks source link

when testing - minitest blows up in my face :( #34

Closed ep-wac closed 11 years ago

ep-wac commented 11 years ago

I'm trying to use pry-rescue with minitest - but it keeps blowing up in my face - and I'm not really sure what to look for in this gist

Once I'd run gem install pry-rescue I was able to do rescue rails server (even though the README says (and what I'm used to) that it's okay to put it in the Gemfile [perhaps you might have a look at that worthing again] :)

But my bundle exec guard with


guard 'spork', wait: 60, cucumber: false, test_unit: false, minitest: true, :minitest_env => { 'RAILS_ENV' => 'test', 'OX_ID' => '1', 'ROOT_PATH' => 'dashboards#show'  } do
    watch('config/application.rb')
    watch('config/environment.rb')
    watch(%r{^config/environments/.*\.rb$})
    watch(%r{^config/initializers/.*\.rb$})
    watch('Gemfile')
    watch('Gemfile.lock')
    watch('test/minitest_helper.rb') { :minitest }
end

guard 'minitest', :minitest_env => { 'RAILS_ENV' => 'test', 'OX_ID' => '1', 'ROOT_PATH' => 'dashboards#show'  } do
  # with Minitest::Unit
  watch(%r|^test/(.*)\/?test_(.*)\.rb|)
  watch(%r|^test/(.*)\/(.*)\.rb|)
  watch(%r|^lib/(.*)([^/]+)\.rb|)     { |m| "test/#{m[1]}test_#{m[2]}.rb" }
  watch(%r|^test/minitest_helper\.rb|)    { "test" }

  # with Minitest::Spec
  # watch(%r|^spec/(.*)_spec\.rb|)
  # watch(%r|^lib/(.*)([^/]+)\.rb|)     { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  # watch(%r|^spec/spec_helper\.rb|)    { "spec" }

  # Rails 3.2
  watch(%r|^app/controllers/(.*)\.rb|) { |m| "test/controllers/#{m[1]}_test.rb" }
  watch(%r|^app/helpers/(.*)\.rb|)     { |m| "test/helpers/#{m[1]}_test.rb" }
  watch(%r|^app/models/(.*)\.rb|)      { |m| "test/models/#{m[1]}_test.rb" }  
  watch(%r|^lib/models/(.*)_(.*)\.rb|)      { |m| "test/models/#{m[1]}_test.rb" }  
end

rolls over flat on its back - only coughing up the above linked to gist :(

I'd really appreciate a gentle push in the right direction :)

cheers, E

rking commented 11 years ago

@ConradIrwin - is this the Ruby patchlevel problem?

Enrique, I had endless problems with guard+spork+minitest until I made the working-but-undocumented guard-sporkminitest gem (but if they fixed it upstream, please let me know).

Thanks for the report!

ConradIrwin commented 11 years ago

@ep-wac I think this is the same bug as Issue pry/pry#931, which has its root cause in binding_of_callers Issue banister/binding_of_callers#14.

Hopefully @badosu will make some progress, if not I'll try and to hit it again.

ep-wac commented 11 years ago

In your experience - should I swap spork-minitest for guard-sporkminitest in my test group ?

# Gems used only in test ------------------------------
group :test do 
  gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i  
  gem 'capybara'
  gem 'turn'
  gem 'minitest'
  gem 'minitest-rails'
  gem 'spork'
  gem 'spork-minitest'
  gem 'guard'
  gem 'guard-spork'
  gem 'terminal-notifier-guard'
  gem 'poltergeist'
  gem "minitest-rails-capybara"
  gem 'database_cleaner'  
end
ep-wac commented 11 years ago

hmmm - with guard-sporkminitest in my Gemfile instead of guard-minitest - I get this load message

$ _st
09:26:01 - ERROR - Could not load 'guard/minitest' or find class Guard::Minitest
09:26:01 - ERROR - cannot load such file -- guard/minitest
09:26:01 - ERROR - Invalid Guardfile, original error is:
> [#] undefined method `new' for nil:NilClass
09:26:01 - INFO - Guard uses TerminalNotifier to send notifications.
09:26:01 - INFO - Guard uses TerminalTitle to send notifications.
09:26:01 - INFO - Starting Spork for MiniTest
Using MiniTest
Preloading Rails environment
Loading Spork.prefork block...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Spork is ready and listening on 8988!
09:26:10 - INFO - Spork server for MiniTest successfully started

09:26:10 - INFO - Guard is now watching at '/Users/walther/Documents/RailsProjects/oxen.3.2'

and when I make changes to files in my /test folder Minitest does not start :(

Any thoughts?

rking commented 11 years ago

Enrique Walther Jesus Phillips notifications@github.com wrote:

hmmm - with guard-sporkminitest in my Gemfile instead of guard-minitest - I get this load message

$ _st
09:26:01 - ERROR - Could not load 'guard/minitest' or find class
Guard::Minitest
09:26:01 - ERROR - cannot load such file -- guard/minitest
09:26:01 - ERROR - Invalid Guardfile, original error is:
> [#] undefined method `new' for nil:NilClass
09:26:01 - INFO - Guard uses TerminalNotifier to send notifications.
09:26:01 - INFO - Guard uses TerminalTitle to send notifications.
09:26:01 - INFO - Starting Spork for MiniTest
Using MiniTest
Preloading Rails environment
Loading Spork.prefork block...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Spork is ready and listening on 8988!
09:26:10 - INFO - Spork server for MiniTest successfully started

09:26:10 - INFO - Guard is now watching at
'/Users/walther/Documents/RailsProjects/oxen.3.2'

and when I make changes to files in my /test folder Minitest does not start :(

Any thoughts?


Reply to this email directly or view it on GitHub: https://github.com/ConradIrwin/pry-rescue/issues/34#issuecomment-18893337

You have to change the Guardfile also:

guard 'sporkminitest' do ...

See https://github.com/rking/working/blob/master/lib/working/guard.rb#L8 for the one place where I use it (then my Guardfiles look like this).

Sent via mobile device: please forgive brevity/errors.

badosu commented 11 years ago

If you use

gem 'binding_of_caller', git: "https://github.com/banister/binding_of_caller.git"

in your Gemfile, does it still happens, @ep-wac ?

ep-wac commented 11 years ago

Perfect! I'm down-right happy - and it's a sunny morning too! :)

@badosu that definitely had me going forward - (bow)

@rking stupid me! The guard obviously has to be on 'sporkminitest' – that was not clever (blush)

Anyways – thank you for sharing!

badosu commented 11 years ago

@cabo wrote the pull request that fixed it.