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

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.

Related

Error message when trying to create Gemfile

Can someone please break down the very very beginnings of how to run a Gemfile. I've read the Bundler webiste and it says I have to type "Gem Install Bundler" then source "https://rubygems.org". Everytime I do that I get an error message saying "Source is not recognised as an internal or external command, operable program or batch file. I've tried creating an empty gemfile first by typing "bundle init" but when I type my source, I get the error message. I also found some literature about telling it to look in github and tried to direct it to the actual project in github but it gave me the same error message.
I am completely new to coding but have to run some gems off a file in github to test my answers on some questions I've been given. There's a gemfile on the github page with this in it:
source 'https://rubygems.org'
gem rspec
gem pry
Any help for an absolute beginner is much appreciated.
You need to use source 'http://rubygems.org' not https:// which isn't supported yet
Run
gem install bundler
then you can author a Gemfile like
source 'https://rubygems.org'
gem 'rspec'
gem 'pry'
after this, you may run
bundle install
and as an outcome rspec and pry gems will be installed in your system.
You have more information about Gemfiles in Bundler official documentation.
Also, bear in mind that you are installing those gems system-wide, this might cause dependency problems and/or version problems if you have more projects where those gems are required. If that is the case, I recommend you using something to control Ruby versions and gemsets, for example RVM.

Not able to install bundle

I am new to development of Capybara with Rspec using Ruby with selenium. I have installed Caybara and installed RSpec also. But when I am trying to install it is giving an error "Couldn't locate Gemfile". How to rectify the error? How to locate the Gemfile. Is there any Tutorial for Capybara and Rspec to understand better about those?
I am installing those on Windows8.1Pro

Ruby RSpec test for success or failure based on gem version being used

Is there a way to write an Rspec test to prove that some code fails if we are using a specific version of a gem and passes if we use another version of the same gem?
What I do currently is have one version in my Gemfile and then run rspec spec and see a test pass. Then I modify my Gemfile with the different gem version and bundle update and then run rspec spec again and see the same test fail.
I would like to have two tests, one that loads one version of the gem and tests for normal execution and succeeds and another test that loads a different version of the gem and tests for an exception and succeeds on the raised exception and both tests are run on the same rspec spec run. Is this even possible. If not, any suggestions on anything that does not involve me having to modify my Gemfile manually?
Also, in case it helps
I currently use bundler to install gems.
ruby 1.9.3p545
rspec 2.14.1
Also, I am not using Rails
I think you can specify the gem and version you want to use in the code:
it "does something" do
gem "gemname", "4.0"
require "gemname"
expect(subject).to do_something
end
But I don't know if what you're trying to do is a good idea because you should be testing with the same gems you would be using in production.
You could define a different environment to include the alternative version of your gem and use this while testing. For example, in your Gemfile
group :custom_test do
gem 'gemname', 'x.y.z'
end
And then run your tests as in
RAILS_ENV=custom_test rspec
I strongly suggest however that you look into solutions that let you test against different environments, gemfiles, rails and ruby versions (e.g. Jenkins or Travis etc.)

cucumber on windows - command not found

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

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.

Resources