1
votes

I'm using Ruby on Rails Tutorial by Michael Hartl to learn Rails. I'm on section 3.2.2 (Test Driven Development) and when I run the following command to run the rspec tests:

$ bundle exec rspec spec/requests/static_pages_spec.rb

I'm getting the following error:

  c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/childprocess-0.5.1/lib/childprocess/windows.rb:1:in `require': cannot load such file -- ffi (LoadError) from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/childprocess-0.5.1/lib/childprocess/windows.rb:1:in `<top (required)>' from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/childprocess-0.5.1/lib/childprocess.rb:176:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/childprocess-0.5.1/lib/childprocess.rb:176:in `<top (required)>'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver.rb:1:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver.rb:1:in `<top (required)>'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium-webdriver.rb:1:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium-webdriver.rb:1:in `<top (required)>'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from d:/source/training/ruby/railstutorial/sample_app/config/application.rb:12:in `<top (required)>'
from d:/source/training/ruby/railstutorial/sample_app/config/environment.rb:2:in `require'
from d:/source/training/ruby/railstutorial/sample_app/config/environment.rb:2:in `<top (required)>'
from d:/source/training/ruby/railstutorial/sample_app/spec/spec_helper.rb:3:in `require'
from d:/source/training/ruby/railstutorial/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
from d:/source/training/ruby/railstutorial/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
from d:/source/training/ruby/railstutorial/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'

Here is my Gemfile:

     source 'https://rubygems.org'
     ruby '2.0.0'

    gem 'rails', '4.0.3'

    group :development, :test do
     gem 'sqlite3', '1.3.8'
     gem 'rspec-rails', '2.13.1'
   end

   group :test do
    gem  'selenium-webdriver', '~> 2.35.1'
    gem 'capybara', '2.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'

  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

Here is my 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

When i comment this line

  #require 'spec_helper'

Then the Red failing test appears but with some errors saying it doesn't recognize some functions like visit. I try to install the ffi which the error message said it can't be loaded but still, I'm getting this errors.

Os: Windows 7 x64 Any help, please?

Thanks

3

3 Answers

1
votes

According to this https://github.com/ffi/ffi/issues/176 you should install it as

gem install ffi --platform=ruby
1
votes

If none of the above solutions didn't work try declaring the gem explicitly in the gem file. It worked for me in cucumber.

gem 'ffi'

Note : You may still have to install gem as mentioned by MikeZ

gem install ffi --platform=ruby
0
votes

You have to replace del X86 for X64 in the gemfile.lock each time you find it. For example you have to replace this ffi (1.9.3-x86-mingw32) with this ffi (1.9.3-x64-mingw32).

After making these changes, save the gemfile.lock and bundle install