I'm setting up the testing of my rails apps with the combination of Guard, Spork and Rspec.
Everything seems to be correctly installed and I got the notification of the tests through libnotify.
However, in the console where Guard is running, I was expecting the details result of the tests. Nevertheless detailed results do not appear.
What I see instead is for instance:
Spork is ready and listening on 8989!
Spork server for RSpec successfully started
Guard::RSpec is running, with RSpec 2!
Running: spec/controller/sessions_controller_spec.rb spec/controllers/groups_controller_spec.rb
Running tests with args ["--drb", "-f", "progess", "-r", "/var/lib/gems/1.9.1/gems/guard-rspec-1.1.0/lib/guard/rspec/formatters/notification_rspec.rb", "-f", "Guard::RSpec::Formatter::NotificationRSpec", "--out", "/dev/null", "spec/controllers/groups_controller_spec.rb", "spec/controllers/sessions_controller_spec.rb]...
Done
> >
When this is peformed, I got a pop-up in the notification area of Ubuntu telling for instance:
RSpec results
28 examples, 21 failures
in 52.6711 seconds
Fair enough. The test is not passing. Ok, I don't care but I would like to have the details of the tests such the one received when using common Rspec in console through the bundle exec rspec spec/ command.
Do you have an idea how to make the details displayed in such a case?
I noticed in the log of Guard the args being used such as --out and /dev/null and I may expect that the issue is coming from them but then the question is how to change these parameters?
Thanks a lot for your valuable help!
Here is the relevant content of my Gemfile:
gem 'rspec-rails', :group => [:development, :test]
group :test do
gem 'capybara'
gem 'factory_girl_rails'
gem 'guard-rspec'
gem 'guard-spork'
gem 'spork'
gem 'rb-inotify'
gem 'libnotify'
end
Related
Arg, looks like this is a fairly common problem but I can't seem to figure out how to get my debugger working. I've installed a myriad of gems to try to get this bad boy running but no luck. Here is a list for completeness. I've included my gemfile as well. As is probably quite obvious I'm a RoR newb. I'm using RubyMine as my IDE and upon trying to debug I get an error that states "The gem ruby-debug-base19x required by the debugger is not currently installed. Would you like to install it?". Of course, upon saying 'yes' to download the mirror is broken and the download fails resulting in the following error:
5:56:46 PM Error running Development: SponsorBid: Cannot start
debugger. Gem 'ruby-debug-ide' isn't installed or its executable
script 'rdebug-ide' doesn't exist.
Even though this question duplicates two other questions here, I'll answer it for the sake of completeness.
In order to debug from RubyMine you must use only 2 debug gems:
ruby-debug-base19x
ruby-debug-ide
Exactly these gems must be used, not ruby-debug-base19, not ruby-debug19, not debugger . All the other debug gems must be uninstalled and removed from the Gemfile.
See this answer for the details how to install proper debug gem versions. If you have a problem downloading linecache19-0.5.13.gem gem, try this mirror instead.
Verify with gem list that you have the following or more recent versions installed:
ruby-debug-base19x (0.11.30.pre10)
ruby-debug-ide (0.4.17.beta9)
No other debug gems should be listed by this command.
As stated in another answer, debugger gem must not be used, it will conflict with the debug gems used by RubyMine and debugger will not work. You must uninstall this gem, remove it from the Gemfile and ensure that your code doesn't call any methods from this gem and is not trying to load it.
Happy debugging!
As suggested by #Anjan, your Gemfile for debugging can look like this:
gem 'linecache19', '>= 0.5.13', :git => 'https://github.com/robmathews/linecache19-0.5.13.git'
gem 'ruby-debug-base19x', '>= 0.11.30.pre10'
gem 'ruby-debug-ide', '>= 0.4.17.beta14'`
Just run bundle install to get the proper versions of the required debug gems.
This is what I used in my Gemfile to install the required gems through bundler:
gem 'linecache19', '>= 0.5.13', :git => 'https://github.com/robmathews/linecache19-0.5.13.git'
gem 'ruby-debug-base19x', '>= 0.11.30.pre10'
gem 'ruby-debug-ide', '>= 0.4.17.beta14'`
No manual gem installation required and will automatically work on your fellow developers' computers.
I'm using rspec and selenium. Is there soemthing like a pause button I can put in my test so I can interact with the page while I'm developing a test?
Now this is not the most optimal solution, but I found it useful to throw in a breakpoint statement in the middle of the test. This allows for inspection of the document in the browser or/and values inside your code.
I use pry for the debugging and have my Rails test environment set to not cache classes. This allows for quick modifications and browser (capybara forks a separate thread) refreshes. Here is a relevant portion of my Gemfile:
group :development, :test do
gem 'rspec-rails', github: 'rspec/rspec-rails'
gem "factory_girl_rails" # factorygirl instead of fixtures
gem "guard-rspec" # automaticly running the specs when file is saved
gem 'grizzled-rails-logger', github: 'bmc/grizzled-rails-logger'
gem "faker"
end
group :test do
gem "capybara", github: 'jnicklas/capybara' # simulating a user
gem 'database_cleaner' # cleans the database
gem 'launchy'
end # remember to install rb-fsevent if your on a mac
group :epic_console do
gem 'pry' # remember to look in development.rb
gem 'pry-rails'
gem 'pry-doc'
gem 'awesome_print'
gem 'hirb'
gem 'hirb-unicode'
gem 'pry-nav'
gem 'pry-coolline'
gem 'pry-stack_explorer'
gem 'pry-exception_explorer'
end
Google the gems, see if they can optimize your process.
Im not going to start by saying i'm a newbie etc. Jokes, been learning Rails for nearly month using Lynda.com. I use Mac, Mac OS X Lion 10.7.
I am trying to intall Paperclip Gem but i can't seem to figure out what i'm doing wrong.
I followed the instructions on https://github.com/thoughtbot/paperclip/wiki/Installation
I added this line to my config/environment.rb
config.gem 'paperclip', :source => 'http://rubygems.org'
and i then tried to run
rake gems:install
I get an error message:
(in /Users/fred/Ruby/food)
rake aborted!
undefined local variable or method `config' for main:Object
/Users/fred/Ruby/food/Rakefile:4:in `require'
(See full trace by running task with --trace)
I then tried the following as an alternative when the above failed
script/plugin install git://github.com/thoughtbot/paperclip
I get the following error
-bash: script/plugin: No such file or directory
My question is how do install this gem? I have read a lot of other posts that say i should include gem 'paperclip', "~> 2.3" is this the same as what i did above?
Best to use bundler. Steps are
Install bundler: gem install bundler
Add to Gemfile: config.gem 'paperclip'
cd to where the Gemfile is and run: bundle install. This will install all the gems mentioned in the Gemfile
Ps. I assume that you are not using rvm. Also, you may need to prefix sudo to the command in step 1 above in case the command does not work for you due to a permission problem.
This problem was fixed in 0.9.8, but seems to have recurred in the 1.x branch.
In my Gemfile I have a group for the test and development environments that use the rspec gems.
On my production server rspec is not installed.
I used the command bundle install --without test development in my
rails app
Starting my rails app in production mode gives the exception:
Could not find gem 'rspec (>= 0)' in any of the gem sources listed in
your Gemfile.
If I comment out the test group the same error happens with the development group.
The same problem exists if I start in development mode, then it tries to load the gems in the test group.
It seems that bundler completely ignores the environment groups and tries to load all gems in Gemfile:
group :test do
gem "rspec"
end
group :development do
gem "rspec-rails"
end
versions:
bundle 1.0.15
rails 3.0.7
ruby 1.9.2-p180
I was having this problem too, the problem was that .bundle/config file had something like
"--without development test"
even tho I had never ran the bundle command with this parameters(maybe I cloned the repository from the Webbynode server and their system added this automatically for production...)
anyway, the fix was
rm .bundle/config
bundle install
I'm trying to deploy a rails 3 app to heroku for the first time. It seems to push up ok but when I try to run
heroku rake db:migrate
I get the following error:
rake aborted!
no such file to load -- faker
/app/98c71cc3-375f-4397-9de3-034dd7268be3/home/Rakefile:7
(See full trace by running task with --trace)
(in /app/98c71cc3-375f-4397-9de3-034dd7268be3/home)
Here's my rakefile (line 7 is the last one):
require File.expand_path('../config/application', __FILE__)
require 'rake'
SampleApp::Application.load_tasks
Now I have a task called sample_data.rake which uses the faker gem to populate the development database with sample data and that task has the line:
require 'faker'
at the top which must be what's causing the problem.
How can I fix this error or is there a way that I can get heroku to ignore this task file? I'm not going to want to populate the production version with nonsense sample data anyway.
By the way, faker is only active in the development environment in my gemsfile:
# gemfiles for the rspec testing environment
group :development do
gem 'rspec-rails', '2.5.0'
gem 'annotate-models', '1.0.4'
gem 'faker', '0.3.1'
end
Move the require statement into the task.
For instance
# sample_data.rake
require 'faker'
task :sample_data => :environment do
# ...
end
to
# sample_data.rake
task :sample_data => :environment do
require 'faker'
# ...
end
In this way, the library will be required only when the task is invoked.
The other alternative is to not require Faker in your rake file.
In fact, it is already loaded by Bundler when the bundle is executed in development.
If you don't want Bundler to load the Gem, use
gem 'faker', '0.3.1', :require => false
for me, Simone’s first approach didn’t work, but the second did: require 'faker' can be deleted from the rake file.
I too commented out require 'faker' in the lib/tasks/sample_data.rake file and (After committing this change via git) pushed the files to heroku, which allowed
$heroku rake db:migrate --app <my app name> to successfully execute, and ergo the heorku site began working again.
Thanks!