Search code examples
ruby-on-rails-4rspec-rails

`rails new`: different behaviour in Linux and Windows


I've been playing with Ruby on Rails in Windows for some weeks and now I want to move to Linux, which I prefer as my development environment. In both machines, I've created a demo application by running:

rails new demo

Then, in order to install Rspec, I added the appropriate gem into the Gemfile and ran bundle install. In both machines this process succeeded. However when I ran rails generate rspec:install, the process failed in Linux. After browsing StackOverflow I found the issue I was actually facing: rails generate rspec:install config/environments/development.rb:1:in <top (required)>': undefined methodconfigure'.

According to the accepted solution to the question above, the problem is that the first line in development.rb was:

Rails.application.configure do

when it should have been...

Demo::Application.configure do

I noticed that rails new demo in Windows correctly generates the development.rb file, but in Linux doesn't. Why does it happen? The only difference I see is that the Rails version in my Linux box is 4.1.1 whereas in the Windows box is 4.0.4. Provided that the version in Linux is newer than the version in Windows, does it mean that RSpec installation is broken for Rails 4.1.1? Is there any other reason for this different behaviour to occur?

Thank you.


Solution

  • OK, my mistake was copy-pasting the contents of a Gemfile from the project I was writing in Windows. The Gemfile in Windows had the following line:

    gem 'rails', '4.0.4'
    

    whereas the line in the original Gemfile generated by rails new in the linux box was:

    gem 'rails', '4.1.1'
    

    Therefore I was having version mismatch problems. Now I have copy-pasted the contents of the Gemfile from Windows but preserving the line gem 'rails', '4.1.1' and it works.