Andrey
Andrey

Reputation: 299

rspec error (cannot load such file)

Im doing Rails Tutorial (by Michael Hartl). In part 3.2.1 i followed all instructions and ran rspec test: bundle exec rspec spec/requests/static_pages_spec.rb. Im trying to run a unit-test for a home page as tutorial says. Test was generated with this command: rails generate integration_test static_pages and then i edited it, again as tutorial says (code of static_pages_spec.rb below). Im using a rubymine IDE. Versions are different from the tutorial cus Railsinstaller for Windows changed those for ruby and rails. And it seems there is no rvm for Windows. So i changed versions in gemfile. Haven't problems with it before. Here is that the author says about this command:

To actually run the test, we have several options, including some convenient but rather advanced tools discussed in Section 3.6. For now, we’ll use the rspec command at the command line (executed with bundle exec to ensure that RSpec runs in the environment specified by our Gemfile)

Im getting this respond:

D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/win32console-1.3.2-x86-mingw32/lib/Win32/Console
.rb:12:in `require': cannot load such file -- 2.1/Console_ext (LoadError)
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/win32console-1.3.2-x86-mingw32/lib/
Win32/Console.rb:12:in `rescue in <top (required)>'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/win32console-1.3.2-x86-mingw32/lib/
Win32/Console.rb:8:in `<top (required)>'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/win32console-1.3.2-x86-mingw32/lib/
Win32/Console/ANSI.rb:13:in `require'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/win32console-1.3.2-x86-mingw32/lib/
Win32/Console/ANSI.rb:13:in `<top (required)>'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/win32console-1.3.2-x86-mingw32/lib/
win32console.rb:1:in `require'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/win32console-1.3.2-x86-mingw32/lib/
win32console.rb:1:in `<top (required)>'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/lib/bundler/runtime.r
b:76:in `require'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/lib/bundler/runtime.r
b:76:in `block (2 levels) in require'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/lib/bundler/runtime.r
b:72:in `each'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/lib/bundler/runtime.r
b:72:in `block in require'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/lib/bundler/runtime.r
b:61:in `each'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/lib/bundler/runtime.r
b:61:in `require'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/lib/bundler.rb:133:in
 `require'
        from D:/Programming/Projects/Ruby/Rails/sample_app/config/application.rb:14:in `<top (required)>'
        from D:/Programming/Projects/Ruby/Rails/sample_app/config/environment.rb:2:in `require'
        from D:/Programming/Projects/Ruby/Rails/sample_app/config/environment.rb:2:in `<top (required)>'
        from D:/Programming/Projects/Ruby/Rails/sample_app/spec/spec_helper.rb:3:in `require'
        from D:/Programming/Projects/Ruby/Rails/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
        from D:/Programming/Projects/Ruby/Rails/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
        from D:/Programming/Projects/Ruby/Rails/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/co
nfiguration.rb:819:in `load'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/co
nfiguration.rb:819:in `block in load_spec_files'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/co
nfiguration.rb:819:in `each'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/co
nfiguration.rb:819:in `load_spec_files'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/co
mmand_line.rb:22:in `run'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/ru
nner.rb:80:in `run'
        from D:/Programming/Programs/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rspec-core-2.13.1/lib/rspec/core/ru
nner.rb:17:in `block in autorun'

static_pages_spec.rb:

require 'spec_helper'

describe "Static pages" do

  describe "Home page" do

    it "should have the content 'Sample App'" do
      visit '/static_pages/home'
      expect(page).to have_content('Sample App')
    end
  end
end

My gemfile:

source 'https://rubygems.org'

ruby '2.1.5'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.1.8'
gem 'bootstrap-sass', '2.3.2.0'
gem 'bcrypt-ruby', '3.1.2'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'

group :development, :test do
  gem 'sqlite3'
  gem 'rspec-rails', '2.13.1'
  # The following optional lines are part of the advanced setup.
  # gem 'guard-rspec', '2.5.0'
  # gem 'spork-rails', '4.0.0'
  # gem 'guard-spork', '1.5.0'
  # gem 'childprocess', '0.3.6'
end

group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
  gem 'factory_girl_rails', '4.2.0'
  gem 'cucumber-rails', '1.4.0', :require => false
  gem 'database_cleaner', github: 'bmabey/database_cleaner'

  # Uncomment this line on OS X.
  # gem 'growl', '1.0.3'

  # Uncomment these lines on Linux.
  # gem 'libnotify', '0.8.0'

  # Uncomment these lines on Windows.
  gem 'rb-notifu', '0.0.4'
  gem 'win32console', '1.3.2'
  gem 'wdm', '0.1.0'
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
gem 'coffee-script-source', '1.8.0'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

group :production do
  gem 'pg', '0.15.1'
  gem 'rails_12factor', '0.0.2'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

Platform: Windows

Seems there is something with win32console gem. But i dont know what exactly.

P.S. Sorry for posting not enough information. I have poor understanding of what is going on at all.

Upvotes: 1

Views: 777

Answers (1)

Andrey
Andrey

Reputation: 299

I found out that win32Console is an old gem and not needed in Ruby 2.0, so i removed it from gemfile. Then i got this message:

Warning: you should require 'minitest/autorun' instead. Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'

So i added minitest gem and it worked. Thanks everyone!

Upvotes: 1

Related Questions