cucumber on windows - command not found - windows

I'm trying to get started with testing in Ruby on Windows, and I have the gems installed for cucumber
capybara (1.0.0, 0.4.1.1)
cucumber (0.10.2)
cucumber-rails (0.4.1)
rspec (2.6.0)
rspec-rails (2.6.1)
webrat (0.7.3)
I wrote my first feature, but when I try to run
cucumber features -n
I get an error 'cucumber' is not a recognized internal or external command, operable program or batch file.
How do you run cucumber tests under windows? I'm running Ruby 1.9.2 and rails 3.0.0

I had the same issue as you. The solution was to add the bin folder of the cucumber gem in the PATH environment variable:
<path_to_jruby>\lib\ruby\gems\1.8\gems\cucumber-1.2.1\bin
This seams to be a windows related issue. Not sure why but it resolved the problem. Hope it helps.

Using bundle exec cucumber features -n should work.
Edit: Or maybe rake cucumber

There are few gotchas under windows like missing "a" character or no colored output but you should be able to use cucumber under windows just fine.
Try to setup cucumber again. Maybe you missed soemthing during setup. If that does not help, you could try to play with http://cygwin.com/index.html

Related

cannot load such file -- capybara (LoadError)

I'm trying to run a ruby file that uses capybara and selenium.
When I run cucumber, I get the error :
cannot load such file -- capybara (LoadError)
I saw in another answer that, in order to solve this problem, I had to install poltergeist, but when I run - gem install poltergeist
, I get the error ERROR: While executing gem ... (ArgumentError)
wrong number of arguments (given 1, expected 0)
Any help will be appreciated
You need to include/install the capybara gem, not poltergeist.
I recommend running cucumber with params -v -b , so that you can see where it's failed with verbose & backtrace log.
cucumber -v -b <your_cucumber_features/tag>
The message
cannot load such file -- capybara (LoadError)
was prompted when you've defined to use capybara in your ruby file but your machine hasn't been installed that gem. So need installing capybara via
gem install capybara
However, gem will be installed to specific RVM, so that if you have any error, then try to see which Ruby version that you install onto your system. I suggest install rbenv so that you can manage it better.

Old version of minitest used when running unit tests through rake

I have some classes with unit tests and I have a rake task to run these unit tests. However, I'm running into a problem where when the tests are run via rake an old version of minitest is being used. How can I get rake to use the newer version?
If I use the Minitest::Test subclass it runs fine when the tests are directly run through the ruby
command-line. However, if I use the following rake task:
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = 'tests/**/*_test.rb'
end
When I check the minitest version using puts MiniTest::Unit::VERSION it prints 5.5.0 when run with ruby, but prints 4.3.2 when run with rake. (When using gem list minitest -d version 4.3.2 is listed as the default.)
The reason I want to use the newer version of minitest is that when I directly run the unit tests using Ruby 2.0 I get the following warning:
MiniTest::Unit::TestCase is now Minitest::Test.
However, if I change MiniTest::Unit::TestCase to Minitest::Test I get the following error when I run the tests using rake.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rake/ext/module.rb:36:in `const_missing': uninitialized constant MiniTest::Test (NameError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/minitest/unit.rb:28:in `const_missing'
I want to avoid requiring any changes to the system configuration, because I want these tests to run on the default OS X ruby installation.
Using gem 'minitest', '=5.5.0' does not change the version of minitest that gets used.
Possibility #1: Run Rake with bundle exec to force it to use the version of Minitest managed by Bundler:
bundle exec rake test
Possibility #2: Create a binstub for Rake for your project that will load your bundle automatically:
bundle binstub rake
After that, you should be able to run Rake without bundle exec to get the same result.
Caveat: This has worked for the Ruby environment managers I've used recently, but you might need to Google around for a solution if it doesn't work for you.
Ruby is having a hard time loading minitest from the gem instead of the standard library, so we need to give it a little help. Add the following to your helper or rake task:
gem "minitest"
That will tell ruby to use the gem version. Just be sure to add that before minitest is required.

Rails server command generates error report

When I used rails server command, found following errors in terminal. It shows that "could not find a JavaScript runtime". I am newbie in ROR and don't know to configure different files. I Google and found solutions of this problem 1 2 3. Still I am not getting the things. Please suggest some solutions.
Ruby and Rail versions on my system
Ruby version:- ruby 1.8.7 , Rails version:- Rails 3.2.6
I suppose you lack executable on your system/
Haven't you try to run gem install execjs or bundle install(from your project directory) in console?
UPDATE
Also visit execjs homepage and try instaling any of JS runtimes supported.
UPDATE 2
I was able to reproduce your error (with ruby 1.9.2). Just add gem 'therubyracer' to your Gemfile and run bundle install. For some weird reason ROR is not working out of the box on Ubuntu. See this and search for runtime word for more info.
PS
Please put your Gemfile here. This might help.
The error message also tells your to
See https://github.com/sstephenson/execjs for a list of available runtimes.
You have to install one of the JavaScript runtimes listed there:
therubyracer
therubyrhino
Node.js
Microsoft Windows Script Host
For Rails 3.2.6 I suggest to use Ruby 1.9.3. for better performance.

What is the easyest way to use gems in a macruby application, in XCode?

I need to include a rubygem in a simple macruby application i am creating in XCode. Using require 'rubygems' does not give an error, but the next line to require any other gems has a load error. I installed the gems using macgems. Thanks in advance.
The load error might be an indication that the gem doesn't work on Macruby. Post the error and someone might have more info on that gem or that error.
Did the gem actually install correctly? If it did install, does it work from the command line? Try creating a simple script that requires rubygems and your gem and run that on the command line outside of xcode and see if the problem is compatibility with that gem.
A while back in the 0.5 days I had this problem with a gem (miniexif iirc) that would install via macgems but not load or run. This might be a similar problem.

Test::unit and Rubymine "No tests were found"

I'm a newbie in Ruby and I try to use the test::unit framework with the RubyMine IDE (3.1.1).
I don't understand the note about test::unit here:
http://www.jetbrains.com/ruby/webhelp/test-unit-special-note.html
Specially this instruction: "Include test-unit gem in your Gemfile." I use gem install "test-unit" and attach it to my project but I still got 0 tests and the error message "No tests were found"
Make sure that you have a Gemfile in your project root which contains:
gem 'test-unit'
There is another reason that can cause some scenario not to be recognized. If there is an scenario with the same name in other feature, it may cause your scenario not to be detected.

Resources