-2

I have been unable to run tests on my computer, but when I push the branch to GitHub, and they pull it in, they are able to run them.

Clearly this means that our codebases are identical, including Gemfile and Gemfile.lock.

My app works in development, so my gems are obviously present.

What could be different in the test environment that prevents the tests from running?

The only thing I can think of is that there is something outside the codebase responsible for this. Perhaps something under ~/.gem/ or ~/.rvm/ -- but I don't know where to look for clues. Thoughts?

Error from test attempt:

/Users/bsimpson/.rvm/gems/ruby-2.0.0-p481@books/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require': cannot load such file -- minitest/rails (LoadError)
  from /Users/bsimpson/.rvm/gems/ruby-2.0.0-p481@books/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `block in require'
  from /Users/bsimpson/.rvm/gems/ruby-2.0.0-p481@books/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:214:in `load_dependency'
  from /Users/bsimpson/.rvm/gems/ruby-2.0.0-p481@books/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require'
  from /Volumes/MyHD/Users/bsimpson/Dev/books/books/test/test_helper.rb:10:in `<top (required)>'
  from test/controllers/photos_controller_test.rb:1:in `require'
  from test/controllers/photos_controller_test.rb:1:in `<main>'

gem list --local | grep minitest

minitest (4.7.5, 4.3.2)
minitest-capybara (0.5.0)
minitest-metadata (0.5.0)
minitest-rails (0.9.2)
minitest-rails-capybara (0.10.0)
minitest-test (1.1.0)
user664833
  • 18,397
  • 19
  • 91
  • 140
  • How are your gems activated? Bundler? Rubygems? Also, what exactly do you mean by 'unable to run'? – Fred Sep 03 '14 at 18:58
  • What errors do you get trying to run the tests? – infused Sep 03 '14 at 19:10
  • Sorry, what do you mean by "activated"? I use Bundler, and Bundler downloads the gems from RubyGems. I have updated my question regarding what exactly happens when I try to run tests on the photos controller. – user664833 Sep 03 '14 at 19:15
  • possible duplicate of [cannot load gems in test environment](http://stackoverflow.com/questions/25632655/cannot-load-gems-in-test-environment) – Tim Moore Sep 10 '14 at 06:46
  • What's in your test_helper.rb file? It looks like you may have a custom version of this that isn't checked into the repo? – pdobb Sep 10 '14 at 13:52
  • Nothing has changed in `test_helper.rb` since the time I could run tests. The only thing that happened in-between is that I ran two commands that I am unfamiliar with during my work on `activesupport`: `bundle --deployment` and `bundle --no-deployment`. I believe I undid everything related to those changes (at least as far as `git status` is concerned - I always run `git status`, and I am aware of all codebase changes) - this is the reason I believe the problem is *outside* my *git tracked* codebase. – user664833 Sep 10 '14 at 20:30
  • @TimMoore - Yes, this is a duplicate. Just worded differently. What should I do? Delete this question? You are welcome to put an answer with a link to yours on the other question. This question came second, out of extreme frustration. – user664833 Sep 11 '14 at 04:20
  • You can delete it if you like, but it doesn't hurt to leave it. Usually, moderators close duplicate questions eventually. Here's some info on duplicates http://stackoverflow.com/help/duplicates – Tim Moore Sep 11 '14 at 04:56
  • @TimMoore - Thank you. I will leave it, because perhaps different phrasing can lead someone to the other question/answer, and the moderators are welcome to close it. Actually, I just voted to close it. – user664833 Sep 11 '14 at 05:25

1 Answers1

0

The fact that your application works in development doesn't mean that all gems are present. Testing is done not in the development environment but in the test environment.

Try running:

bundle install

Perhaps some gems were not installed correctly due to missing source dependencies. Try to see if bundle install returns any errors.

Part 2

I've noticed that you use active_support 4.0.5. I've tried to find if upgrading minitest gem will solve the problem. I am not sure if this will work as different sites give minimal version of minitest for your version of active support. Does running:

gem install minitest --version '=5.1'

and restarting everything solve the problem?

Can we see your Gemfile?

Part 3

Also worth trying: In your terminal go to your Rails application directory and run this:

rm ./Gemfile.lock 

bundle install

That might update your gems.

ruby_object
  • 1,229
  • 1
  • 12
  • 30
  • Thanks. I have already tried `bundle install` - no errors, no changes. Any other ideas? – user664833 Sep 03 '14 at 23:28
  • try running: "gem list --local | grep minitest" and show me the output – ruby_object Sep 04 '14 at 17:30
  • By chance I noticed that you edited your answer with additional parts. FYI, SO does not notify me when you make edits to your answer, so you need to write a comment to get my attention. My problem is not an issue of what is in `Gemfile`, or the installed version of `minitest`, as I was able to run my tests perfectly fine until I did something. This something is that I ran `bundle --deployment` and `bundle --no-deployment`, but I undid any changes as far as `git status` is concerned - this is why I believe the problem is *outside* my *git tracked* codebase. I also tried your part 3 to no avail. – user664833 Sep 10 '14 at 20:37
  • FYI, the question was answered in [*cannot load gems in test environment*](http://stackoverflow.com/a/25777800/664833) -- but I also want to thank you for your time and effort in trying to help me. (bow) – user664833 Sep 11 '14 at 05:27