BDD is fine. But it takes too much time when compared to TDD. Cucumber looks cool. But is there any real value of using it, when you are sure of the requirements? Because, it slows down the process so much.
Hi Ryan -
Great stuff, but be careful.
Its lucky all your passwords are 'secret'.
You set up a table in the Outline, but you use literal text in the steps!
if current_user && current_user.admin? || current_user == @user
you should parenthesize the ||, else if there is no current_user and @user is nil, then the viewer could edit the profile. Probably @user could never be nil, of course.
This is a wonderful screencast but I would love it if you could dig a little deeper. As soon as I try to use it for myself I hit walls such as, how do you match '/charts/3/observations/new' in paths.rb when the 3 is dynamic?
I run into similar problems when I try to use Factory Girl with anything more than a trivial association.
Would you consider a 202 level screencast for cucumber and Factory Girl?
I'm new to cucumber and I'm trying to understand some best practices.
For instance after executing an action should I use something like
"then I should be redirect to home_page" or should I concentrate my attention to the page content, such as "then I should see 'welcome to the home page'"?
with machinist you need to change your step definitions as following
Given /^(.+) records$/ do |model, table|
model = model.gsub(/\s/,'_').singularize
klass = eval(model.camelize)
klass.transaction do
klass.destroy_all
table.hashes.each { |hash| klass.make(hash) }
end
end
I am not fully grasping what cucumber is doing behind the scenes here. While scenarios are being "passed" - all in green - nothing is being saved to the test database, correct? So how do we REALLY know they are passing?
BDD is fine. But it takes too much time when compared to TDD. Cucumber looks cool. But is there any real value of using it, when you are sure of the requirements? Because, it slows down the process so much.
You got a real spam problem with your comments. Why don't you add some CAPTCHA or a simple question field?
Thanks for the casts. I've built quite a few hardworking apps with no testing whatsoever. I'm not sure if I should feel proud or ashamed. I don know that they work and every time I look at testing it seems like an unnecessary hindrance.I guess the only way to find out what I'm missing is to get stuck in and see how much it benefits me.
For those of you wondering about aligning the table, it's a feature that comes with the textmate bundle. The most recent version does not support CMD+OPT+\ - instead hit CMD+S to save and align your tables.
OK, repeated you tutorial. Just started with Rails and wanted to check out a good TDD scheme for Ruby and found Cucumber & RSpec. The homepages are nice for experts, but not a single step-by-step guide for getting it to work for newbs. Especially the rake commands are given NOWHERE and as a newb the problem with tables reported by Cucumber (if you don't know you need to clone) and the official Cucumber Wiki example actually using a table in the feature got me going crazy... Your railscast on this should become part of the official documentation! Thanks loads, man!!!
Reply
I'd like to inform you that this cast (as well as some others)
seems to stop working around the minute 5.31 (just after introducing "Tagging Features And Scenarios" paragraph).
I don't think it's me, infact the effect is reproducible, even breaking at the same time and the newer casts are working fine ...
Thank you for this article. That's all I can say. You most definitely have made this blog into something special. You clearly know what you are doing, you've covered so many bases.Thanks!
I suppose ,it will not work on rails 3.2
Following worked on my enviroment.
1 add Gemfile and bundle
ruby
group :testdo
gem 'rspec-rails'
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'factory_girl_rails'end
2 install them
bash
rails g rspec:install
rails g cucumber:install
rails g factory_girl:model YourModelName --dir=spec/factories
3 add features/support/env.rb
ruby
require 'factory_girl_rails'
4 make your *.feature and *_steps.rb file
Now cucumber dosnt use webrat but capybara . I cant find steps file for capybara. so you have to make steps.rb file by yourself,
referencing to https://github.com/jnicklas/capybara.
Really cool! (As a cucumber!)
Thanks Ryan! Another great screencast! I actually get excited to wake up on mondays to see what you've covered!
@Ryanb
BDD is fine. But it takes too much time when compared to TDD. Cucumber looks cool. But is there any real value of using it, when you are sure of the requirements? Because, it slows down the process so much.
Thanks,
Madan Kumar Rajan
*sigh* When I think that I was just starting to enjoy Cucumber, its getting even more awesome... Thanks for the great(est?) cast !
Thanks Ryan for this greeeat screencast!
For my new web application, I will definitely use Cucumber, it's just so... amazing and powerful! ;)
Hi Ryan!
Awesome screencast!
You clearly showed a lot of advantages of cucumber.
Thanks,
- Florian
Couldn't have done it better myself. Awesome job again Ryan! I'm really happy that you're showing people how to use Cucumber!
Very nice screencast. I knew that there is more to Cucumber. Thanks
It's 0.3 not 3.0. :)
Hi Ryan -
Great stuff, but be careful.
Its lucky all your passwords are 'secret'.
You set up a table in the Outline, but you use literal text in the steps!
In the line
if current_user && current_user.admin? || current_user == @user
you should parenthesize the ||, else if there is no current_user and @user is nil, then the viewer could edit the profile. Probably @user could never be nil, of course.
Thanks so much Ryan, Scenario Outlines... who knew?
World class screencast! Many thanks.
Thanks for the screencasts. great one again.
@ryan
maybe you want to add my Netbeans Plugin for Cucumber to your show notes, since i've added the support for 0.3.0 today ;)
Plugin @ my webpage
http://members.chello.at/server/modules.html
Plugin @ Netbeans
http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=17939
It will help Windows users who are using Netbeans (there is a ruby/rails edition) to write their Features.
Hi Ryan,
Any Idea on how to implement the same kind of test using machinist & nifty_auth?
isn`t it hard to add
format.html { redirect_to(posts_url) }
to your comment_controller?
i`m serfing without javascript
Hey, I'm getting "missing argument: -n (OptionParser::MissingArgument)" when I try to run cucumber features -n
Any ideas about this?
V: Since version 0.3.3 -n is an alias for --name, and it expects an argument. Run cucumber --help. Also, read the History.txt file.
This is a wonderful screencast but I would love it if you could dig a little deeper. As soon as I try to use it for myself I hit walls such as, how do you match '/charts/3/observations/new' in paths.rb when the 3 is dynamic?
I run into similar problems when I try to use Factory Girl with anything more than a trivial association.
Would you consider a 202 level screencast for cucumber and Factory Girl?
I'm new to cucumber and I'm trying to understand some best practices.
For instance after executing an action should I use something like
"then I should be redirect to home_page" or should I concentrate my attention to the page content, such as "then I should see 'welcome to the home page'"?
Thanks
to Zasheir
with machinist you need to change your step definitions as following
Given /^(.+) records$/ do |model, table|
model = model.gsub(/\s/,'_').singularize
klass = eval(model.camelize)
klass.transaction do
klass.destroy_all
table.hashes.each { |hash| klass.make(hash) }
end
end
Hey Guys,
Don't panic if you are getting below error when you tried to run "cucumber features -n":
missing argument: -n (OptionParser::MissingArgument)
You are getting this error because cucumber version is now updated.
Try to run "cucumber features" and it will work fine!!!
I am trying to require factories but i keep getting this message.
no such file to load -- /Volumes/Work/visbid/spec/factories
any help? thanks
Hey Guys,
Don't panic if you are getting below error when you tried to run "cucumber features -n":
missing argument: -n (OptionParser::MissingArgument)
You are getting this error because cucumber version is now updated.
Try to run "cucumber features" and it will work fine!!!
I am not fully grasping what cucumber is doing behind the scenes here. While scenarios are being "passed" - all in green - nothing is being saved to the test database, correct? So how do we REALLY know they are passing?
BDD is fine. But it takes too much time when compared to TDD. Cucumber looks cool. But is there any real value of using it, when you are sure of the requirements? Because, it slows down the process so much.
Same problem as Mike:
no such file to load -- /Users/Foo/Projects/test/Rails/blog/spec/factories (MissingSourceFile)
Ah, I see - add the code from http://railscasts.com/episodes/158-factories-not-fixtures
Hey Ryan, would you care to share the textmate magic that you use to align the table?
Hi Ryan,
You got a real spam problem with your comments. Why don't you add some CAPTCHA or a simple question field?
Thanks for the casts. I've built quite a few hardworking apps with no testing whatsoever. I'm not sure if I should feel proud or ashamed. I don know that they work and every time I look at testing it seems like an unnecessary hindrance.I guess the only way to find out what I'm missing is to get stuck in and see how much it benefits me.
Regards,
Kevin.
For those of you wondering about aligning the table, it's a feature that comes with the textmate bundle. The most recent version does not support CMD+OPT+\ - instead hit CMD+S to save and align your tables.
OK, repeated you tutorial. Just started with Rails and wanted to check out a good TDD scheme for Ruby and found Cucumber & RSpec. The homepages are nice for experts, but not a single step-by-step guide for getting it to work for newbs. Especially the rake commands are given NOWHERE and as a newb the problem with tables reported by Cucumber (if you don't know you need to clone) and the official Cucumber Wiki example actually using a table in the feature got me going crazy... Your railscast on this should become part of the official documentation! Thanks loads, man!!!
Reply
Hi,
I'd like to inform you that this cast (as well as some others)
seems to stop working around the minute 5.31 (just after introducing "Tagging Features And Scenarios" paragraph).
I don't think it's me, infact the effect is reproducible, even breaking at the same time and the newer casts are working fine ...
Keep on the good job
Cheers Luca
Thank you for this article. That's all I can say. You most definitely have made this blog into something special. You clearly know what you are doing, you've covered so many bases.Thanks!
This step-by-step-tut is not written for rails 3.2, is it?
I suppose ,it will not work on rails 3.2
Following worked on my enviroment.
1 add Gemfile and bundle
2 install them
3 add features/support/env.rb
require 'factory_girl_rails'
4 make your *.feature and *_steps.rb file
Now cucumber dosnt use webrat but capybara . I cant find steps file for capybara. so you have to make steps.rb file by yourself,
referencing to https://github.com/jnicklas/capybara.