11 Replies - 1856 Views - Last Post: 14 February 2015 - 12:14 AM Rate Topic: -----

#1 NeoTifa  Icon User is offline

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4081
  • View blog
  • Posts: 18,152
  • Joined: 24-September 08

Cucumber/RSpec gem loading error

Posted 16 January 2015 - 08:58 AM

I'm trying to do a simple example feature so I can get used to the whole Gherkin thing, but when I run it I get:

Unable to activate rspec-expectations-3.1.2, because diff-lcs-1.1.3 conflicts with diff-lcs (< 2.0, >= 1.2.0) (Gem::LoadError)



Feature file:
Feature: Example

  Scenario: Cutting vegetables
    Given a cucumber that is 30 cm long
    When I cut it in halves
    Then I have two cucumbers
    And both are 15 cm long



Step definition file
#encoding: utf-8

Given /^a cucumber that is (\d+) cm long$/ do |length|
  @cucumber = {:color => 'green', :length => length.to_i}
end

When /^I (?:cut|chop) (?:it|the cucmber) in (?:halves|half|two)$/ do
  @choppedCucumbers = [
      {:color => @cucumber[:color], :length => @cucumber[:length] / 2},
      {:color => @cucumber[:color], :length => @cucumber[:length] / 2}
  ]
end

Then /^I have two cucumbers$/ do
  expect(@choppedCucumbers.length).to match(2);
end

And /^both are (\d+) cm long$/ do |length|
  @choppedCucumbers.each do |cuke|
    expect(cuke[:length]).to match(length.to_i)
  end
end



Is This A Good Question/Topic? 0
  • +

Replies To: Cucumber/RSpec gem loading error

#2 xclite  Icon User is offline

  • I wrote you an code
  • member icon


Reputation: 1237
  • View blog
  • Posts: 4,028
  • Joined: 12-May 09

Re: Cucumber/RSpec gem loading error

Posted 16 January 2015 - 09:53 AM

I doubt anything is wrong with your code here, but rather with your dependencies.

Are you developing using RVM, Bundler, or something similar? Or are you using the system ruby and gems?

Edit: Also can you provide the command you're running to activate your tests?

This post has been edited by xclite: 16 January 2015 - 09:54 AM

Was This Post Helpful? 0
  • +
  • -

#3 NeoTifa  Icon User is offline

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4081
  • View blog
  • Posts: 18,152
  • Joined: 24-September 08

Re: Cucumber/RSpec gem loading error

Posted 16 January 2015 - 10:19 AM

I'm using an IDE (RubyMine to be specific). I've been having issues installing gems for a month now, and just this morning got the gems needed for my work's automation testing, but was trying to make my own example projects so I can practice and add on to their framework, and thusly was using RSpec (which they don't use). I went inside the IDE settings and installed this one (I've also tried through the command line but got the same results). I looked up the diff-lcs gem, and it said >= ruby 1.8.7, which is the version I'm using, so wtf?

(I took a screenshot but I don't think my work is letting me upload it. It also blocked imgur so yeah.)

This post has been edited by NeoTifa: 16 January 2015 - 10:20 AM

Was This Post Helpful? 0
  • +
  • -

#4 xclite  Icon User is offline

  • I wrote you an code
  • member icon


Reputation: 1237
  • View blog
  • Posts: 4,028
  • Joined: 12-May 09

Re: Cucumber/RSpec gem loading error

Posted 16 January 2015 - 10:50 AM

The problem as I'm seeing it is that the version of diff-lcs that you're using is too old for the version of rspec-expectations.

You'll either need to get an older version of rspec-expectations or upgrade to a newer version of diff-lcs (I'd try to go with a newer diff-lcs; the current version is 1.2.5).

As an aside, it sounds like you're using whatever gems are installed on the system - I'd encourage you to check out RVM which lets you manage specific versions of gems more easily.
Was This Post Helpful? 0
  • +
  • -

#5 NeoTifa  Icon User is offline

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4081
  • View blog
  • Posts: 18,152
  • Joined: 24-September 08

Re: Cucumber/RSpec gem loading error

Posted 16 January 2015 - 11:21 AM

I've been installing all the gems versions specifically, except RSpec, I just said gem install rspec. It said I had 2 versions of diff-lcs, versions 1.1.3 and 1.2.5 so I tried to get rid of 1.1.3 and it just made problems. ugh.
Was This Post Helpful? 0
  • +
  • -

#6 xclite  Icon User is offline

  • I wrote you an code
  • member icon


Reputation: 1237
  • View blog
  • Posts: 4,028
  • Joined: 12-May 09

Re: Cucumber/RSpec gem loading error

Posted 16 January 2015 - 11:31 AM

There's probably a way to hand-pick your dependencies on the system so it works, but a tool like bundler or RVM is really going to solve this problem for you.
Was This Post Helpful? 0
  • +
  • -

#7 NeoTifa  Icon User is offline

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4081
  • View blog
  • Posts: 18,152
  • Joined: 24-September 08

Re: Cucumber/RSpec gem loading error

Posted 16 January 2015 - 12:16 PM

I was looking into RVM but the commands look like they're for bash, and I suck at command line stuff. Are there Windows ones? jk RVM doesn't even work on Windows. Also my computer doesn't seem to like bundler.

c:\>gem install bundler
WARNING:  Error fetching data:SocketError: getaddrinfo: No such host is known. <http://rubygems.org/latest_specs.4.8.gz>
ERROR:  Could not find a valid gem 'bundler' <>= 0> in any repository
ERROR:  Possible alternatives: bundler


This post has been edited by NeoTifa: 16 January 2015 - 12:34 PM

Was This Post Helpful? 0
  • +
  • -

#8 xclite  Icon User is offline

  • I wrote you an code
  • member icon


Reputation: 1237
  • View blog
  • Posts: 4,028
  • Joined: 12-May 09

Re: Cucumber/RSpec gem loading error

Posted 16 January 2015 - 12:32 PM

You are truly in a suboptimal development environment, it would seem.

Bundler should work on windows. You basically need a way to specify which versions of these things you're going to use, or you're going to be in gem install hell.
Was This Post Helpful? 0
  • +
  • -

#9 NeoTifa  Icon User is offline

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4081
  • View blog
  • Posts: 18,152
  • Joined: 24-September 08

Re: Cucumber/RSpec gem loading error

Posted 16 January 2015 - 01:41 PM

I have no idea why it won't do it. :(
Was This Post Helpful? 0
  • +
  • -

#10 xclite  Icon User is offline

  • I wrote you an code
  • member icon


Reputation: 1237
  • View blog
  • Posts: 4,028
  • Joined: 12-May 09

Re: Cucumber/RSpec gem loading error

Posted 16 January 2015 - 02:35 PM

I found this suggestion:

http://stackoverflow...uby-for-windows

People wonder why I don't even interview for Windows shops...
Was This Post Helpful? 0
  • +
  • -

#11 comp_sci_guy  Icon User is offline

  • New D.I.C Head

Reputation: 7
  • View blog
  • Posts: 22
  • Joined: 30-September 14

Re: Cucumber/RSpec gem loading error

Posted 13 February 2015 - 09:09 PM

This may be a little late, but a lot of time just simply by deleting your gemlock, and re-reunning bundler (either from the command line or from your IDE, in RubyMine, that's under the tools button if installed) you can often get the dependencies fixed. I'm sure you've probably tried it already but just a suggestion.

The reason you may not be able to install it in Windows is because you must first do a "cd" command to navigate to the directory where bundler "lives" otherwise Windows can't "see" it. Once you do cd C:\YourFilePath\WhereBundlerIs then execute the command gem install bundler...it should work (hopefully)

This post has been edited by comp_sci_guy: 13 February 2015 - 09:17 PM

Was This Post Helpful? 0
  • +
  • -

#12 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1439
  • View blog
  • Posts: 3,609
  • Joined: 28-November 09

Re: Cucumber/RSpec gem loading error

Posted 14 February 2015 - 12:14 AM

Don't delete your lock file, that's a horrible idea. The amount of collisions it can potentially cause are insane. No, your lock file is meant to provide a last known good state of gems. Discard it at your own peril, and keep it version controlled at all times.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1