Guard watches files and runs a command after a file is modified. This allows you to automatically run tests in the background, restart your development server, reload the browser, and more.
- source codeProject Files in Zip (260 KB)
- mp4Full Size H.264 Video (17 MB)
- m4vSmaller H.264 Video (10.5 MB)
- webmFull Size VP8 Video (24.8 MB)
- ogvFull Size Theora Video (23.6 MB)
Awesome screencast. Thank you!
Ryan, how did you enabled colored output in guard (failure in red, passes in green); is that guard specific?
Nice RailsCast, as usual.
Ryan, did you know about the -c option when starting guard? It auto clears the screen using the clear shell command before each guard runs after detecting a change.
Very useful, just been looking for this! Thank you.
Does anyone know of a way to 'hyperlink' from an rspec failure message to the correct file & line number in vim ??
Putting a RUBY_PLATFORM condition in the Gemfile is not a good idea. When installing an application bundle on the production server (different platform) with the --deployment or --frozen option, bundler will complain that the Gemfile does not match the Gemfile.lock.
However, I don't see an alternative right now...
+1. Yes this breaks deployment from Mac to a non-Mac platform. I just leave off the OS-specific line, since I'm deploying to production, and the gem is only used for dev/test on my Mac.
The official docs says to require all 3 gems (Linux, OS X and Windows). The gem will know which one to use.
Pair guard with spork and guard-spork. Now you have even faster tests!
Lol, ironic that Guard can't reload it's own config.
Thank's i really love to use it.
livereload is what ! waiting for since so many time.
there is a livereload exetention for firefox 4 now :)
I just installed latest version on my mac, but it seems that it doesn't work properly. No rspec output on console, and some file edits doesn't trigger rerun of the specs... For the moment I'll remain with autotest, at least it works...
Anyway the idea is pretty awesome for other tasks (livereload, passenger and some else)
What didn't work for you? Please open an issue on github with more info. I'll be happy to help you.
I love the way livereload only reloads the stylesheet, not the entire page - great for AJAX preview. I was having temperamental results when trying to get guard-livereload and guard-sass to work together... I could reload the entire page after a sass file is changed, but not the stylesheet alone. If anyone has a solution, please share.
I found out the
get some trouble on heroku. It tries to install it even if it specified on group :test, :development. I commented it and it works fine
We're also have this problem when deploying with bundler. I found our problem on SO
Two of us worked on it for an hour and couldn't come up with any fixes.
FYI, I just found http://livereload.com -- seems pretty interesting for anyone on a mac.
As usual, relevant info presented succinctly with style.
How does Guard compare with Autotest (and Spork)?
I've been using autotest/spork for a while now, and it works well, but if you change a controller or routes the proper specs are run, but fail because spork is running the old version. Does Guard do this better?
I tried using 'guard-test' with Rails 3.1pre5 and apparently the 'test' isn't rack-test.... is there a rack-test guard so you can use this with the default testing framework for Rails3.1?
I find myself getting the following error unless I include guard in my Gemfile too:
No such file or directory - Guardfile (Errno::ENOENT)
FWIW, using rails 3.1.1 and guard-rspec 0.5.0
Just saying incase anyone else runs into this problem too
I already had the gem selector for guard in my Gemfile. But I got around it a different way. I just created the Guardfile before running
guard init rspec:
There is a mistake in the asciicast here:
Text encoding trouble probably :)
Just to clarify for anyone else reading this,
↵is the HTML entity for carriage return. The line in your Gemfile should be:
For trouble on windows
On my windows 7 box I had to do
could not use
I'm trying to use Guard (to execute rspec) for my new project (Rails 3.2 even if I think it does matter), but I cannot start it properly. I have all the required gems and dependencies installed but when I run bundle exec guard, it runs all the specs once and after I get dyld: unknown required load command 0x80000022 and it exits.
My machine is running MAC 10.5.8
Any ideas how to solve my issue?
Thanks for any help.
The same is happening here, I've already installed the correct growlnotify version (MacOS 10.5.8).
Has anyone resolved this error ?
I have the same problem on OSX 10.5.8. Maybe it breaks on the older OSX? Guess I'll try to upgrade at some point... It breaks for me with or without growl/growlnotify.
I am using guard-rspec inside a vbox virtual machine (I cannot upgrade my Mac OS X 10.5.8 at this time, so this way I am developing on a virtual copy of the of the production OS, ubuntu 10).
Anyway it works great! But I would love to make use of guard-livereload.
Can anyone think of a way to have it both ways. IOW, running guard on the virtual machine and have it some how trigger livereload on my host MAc system?
You didn't mention that you need to initialize rspec. I tried for hours to figure out why colors weren't working in Guard over SSH and it turned out I just needed to run
Ryan - This information is really important for developers. In a single day, we run tests or refresh the browser hundreds or thousands(!) of times. This leads to frustration and annoyance, but we don't notice it because we are used to it.
Guard and Guard LiveReload removes these repetitive and annoying actions. Making a tiny improvement in something that is repeated many times can seem like a small accomplishment, but I think it has a large effect.
Is there a way to configure guard to stop running all the features when emacs autosaves a file?
Ex when files beginning with '.#' get saved in the dir being watched;
Hi, is there any episode for gem listen?
Thanks for the info.