Rspec not displaying colours - ruby-on-rails

I'm running Rspec 2.0.0rc on Windows 7. I am also running the win32console gem (1.3.0 x86-mingw32).
The colours aren't being displayed - everything is showing up in boring old white/grey.
What am I doing wrong?
Edit: I also tried Rspec 2.0.0. and had the same problem

Under normall installation of rspec gems, you should get the colored output. I am not sure which version of gem you are using.
There is one more solution.
While running rspec give the command like this
spec --color sometestfile.rb
--color options is important here

RSpec 2 has been officially released today, perhaps try upgrading?

Finally sorted this out by uninstalling all the gems relating to RSpec and Win32Console. Reinstalled (and specified 2.0.0 for RSpec) and everything worked.

Related

Rspec showing wrong version number

I'm running a Rails 2.3.4 app under ruby 1.8.7 and rvm with a custom gemset.
In trying to get rspec up and running, I've tried several times to uninstall rspec 2 and install rspec and rspec-rails version 1.3.4. However, when I run rspec -v I get 2.10.0 regardless of what I do.
Finally I got this error message:
You are running rspec-2, but it seems as though rspec-1 has been loaded as
well. This is likely due to a statement like this somewhere in the specs:
require 'spec'
Please locate that statement, remove it, and try again.
So it looks like 2.10.0 is actually still loaded. Even if I do a gem uninstall rspec rspec is still loaded. What's going on?
You should use spec (the RSpec 1 executable) instead of rspec, as explained in this answer.

ruby on rails: Spork and Guard: no reaction

I followed the rails tutorial to install Spork and Guard:
http://ruby.railstutorial.org/chapters/static-pages?version=3.2#sec:first_tests
Guard and Spork work when started separately, but when using it together, it hangs with the last output line "Spork is ready and listening on 8989!" without executing any tests.
I even used the argument :wait => 60 as described on https://github.com/guard/guard-spork
Any idea?
And by the way, if I should post the Gemfile or the Guardfile, is there any way to paste it without manually indenting each line by 4 spaces?
Thanks
You should be able to use the " blockquote or {} codeblock buttons to automatically highlight or indent.
Setting up my tests gave me some trouble too as I followed along with the same tutorial. I got lucky by looking for other tutorials (some are listed below) and playing around with different gems and gem versions. Some things I learned the hard way in playing around with gem versions:
1) Calling "guard" from your project directory and calling "bundle exec guard" may or may not execute the same version of the guard gem, if you have more than one version installed. I recommend reading about bundler if you suspect gem versions might be giving you trouble. I know they gave me trouble.
2) The definitive version of the gem you are using for your project is listed in Gemfile.lock, but you're not supposed to modify that file. Modify the Gemfile with specific gem versions to get the right version installed.
Type One Error,
The Carbon Emitter
I hope you realize that when you first start guard and spork together it isn't supposed to execute any tests? It waits until you change a file, and then runs the tests for that file that changed. Or if you want it to run all specs, just hit your key.

How to solve "uninitialized constant Dependencies" error in rake?

I am trying to build Noosfero (http://noosfero.org/), a project done in Ruby, but I am pretty new in Ruby and Linux (my current environment).
I am following the instructions in their tutorial (http://gitorious.org/noosfero/noosfero/blobs/master/INSTALL and http://gitorious.org/noosfero/noosfero/blobs/master/HACKING).
I was supposed to run an apt-get install with many packages, everything worked except for libgettext-ruby-data, to which I get a message that "E: Package libgettext-ruby-data has no installation candidate".
I then download the source and try to run "rake db:schema:load", which I get the following error:
"rake aborted!
uninitialized constant Dependencies
/home/user/noosfero/Rakefile:10"
My rake file is the following:
require(File.join(File.dirname(FILE), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails' #this is the line that the dependency can't be found
I searched around and found this question here: Uninitialized constant ActiveSupport::Dependencies::Mutex (NameError) , but changing the config files didn't help and I could wasn't able to downgrade my RubyGems because I do not know how to do that (gem -update returns a message that I have to do that using apt-get, but I can't find out in which package the gem program is).
The first time I run Rake, I get a message saying:
"I: Installing Debian-installed Rails from /usr/share/rails into vendor/rails.
I: Please note that the recommended Rails version is 2.1.0, and that other versions might not work"
But I don't know how to downgrade my Rails version.
I've got many paths to follow, so I've got many questions, I hope you can help me:
1- Does anyone knows how to fix it directly?
2- How can I downgrade Gems?
3- How can I downgrade Rails?
4- Where can I download gems and how can I install it? (The documentation provides a link, but this link is VERY strange: http://www.yotabanana.com/hiki/ruby-gettext.html?ruby-gettext ).
Any help is very appreciated.
Thanks,
Oscar
Edit: can this error be a problem in the project I downloaded and not in my environment? After some research I am starting to think it is, can it be?
It would help if you share your rake version, by the way.
In the meantime, take a look at this:
https://github.com/jimweirich/rake/issues/33
(Only valid for rake 0.9.0, though).
This was a version conflict I had with the project I was trying to build, not it is solved :)
First of all, I'm a Noosfero developer and I need to admit that the process of preparing the environment to run Noosfero right now is pretty nasty (unless you only want to run it in the production mode since we've got a debian package). But this problem is close to an end since we're a building a vagrant box (for more info see http://vagrantup.com/) to noosfero. Things are going to be much better. But regardless all this nastiness and not having the box yet, Noosfero was supposed to run if you followed all the steps in the INSTALL instructions. Let me try to help you.
Are you using Rails 2.1.0? The best way to do so is to uninstall rails from your system (if you installed through apt-get) and install through rubygems:
gem install rails -v=2.1.0
To avoid problems ensure that there isn't any other version of rails installed through rubygems (gem list).
If you still having problems to run the schema load, run it with --trace and post it here.
If you have other problems you can try contacting us through noosfero-dev#listas.softwarelivre.org or the irc #noosfero at FreeNode.

RSpec: Can I retain the new Rspec (2.0.x) with the old one (1.3.x) and still run autospec on 2.3.x Rails apps?

I gave Rails3 a try and to do so I installed the new gems, like RSpec2. When I went back to my old apps though, autospec stopped working for Rails 2.3.x apps:
$ AUTOFEATURE=true autospec
/usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find executable autospec for rspec-2.0.1 (Gem::Exception)
from /usr/bin/autospec:19
When searching for this error on Google all I find are solutions that are for Rails 3. Based on what I've read, it seems that autospec executable has changed/removed.
Is there a way I can keep the new RSpec gems and still use autospec in 2.3.x apps?
I encountered the exact same problem, and i solved this by using rvm and gemsets. I described that in this article.

MissingSourceFile when I run "cucumber features"

I had cucumber 0.6.1 working quite fine... but I ran the gem update cucumber command, and things went smoothly. Then when I decided to run the cucumber features command, I received this error:
Using the default profile...
no such file to load -- cucumber/webrat/element_locator (MissingSourceFile)
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inpolyglot_original_require'
So I tried a few things... I did a gem update on webrat, that didn't work. I removed all previous versions of cucumber by doing gem uninstall cucumber then selecting past versions. Same with webrat. No luck. What am I doing wrong?
Have you tried to regenerate cucumber files with script/generate cucumber --webrat? Maybe it solves it. Just take care not to overwrite features/support/paths.rb.
I resolved this issue. There was an old version of the 'freelancing-god-thinking-sphinx' gem on the server i was deploying to. Removing this gem enabled everything to work properly.
I had a similar issue using Bundler where my Gemfile had >= 0.4.3 version of cucumber, so it would always look to install newer versions of cucumber when updating/installing the bundler gems. Cucumber's env file (/features/support/env), however, referenced files that were not part of the future releases. In particular, '/cucumber/rails/world'. Therefore, I got the same MissingSourceFile error you are getting.
I think either want to roll back your version of cucumber, or update your cucumber env file so it's compatible with your version of cucumber.
For me, I commented out the following line in my env.rb file
# require 'cucumber/webrat/element_locator'
# Deprecated in favor of #tableish - remove this line if you don't
# use #element_at or #table_at
As you can see by the comment following it, it has been depreciated anyway.

Resources