Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Anyone using Cucumber?

Cucumber RSpec Capybara Rails Testing

  • Please log in to reply
7 replies to this topic

#1 Stuart Hannig

Stuart Hannig

    Signalman

  • Members
  • 15 posts

Posted 15 August 2013 - 07:42 PM

I'm still learning Rails, and testing is something I want to really get a hold of. My only experience so far is from RailsTutorial.org. The tutorial had a small section on Cucumber that I passed on because I was already just trying to grasp RSpec and Capybara, I didn't need to throw another plate onto the table.

 

So I was wondering, how many of you use Cucumber?

 

To me it just seemed like an extra step to the process that didn't really need to be done. Could those who use it express why they use it? I'm trying to see if it's worth the extra work or not.

 

It helps to slightly make the tests look like understandable English, but is that something we need as programmers? When we can read code with little problem, understanding RSpec/Capybara shouldn'y be all that hard. I just see this as another way to throw more human errors that need to be fixed when trying to run the app.



#2 Jemagee

Jemagee

    Inspector

  • Members
  • 60 posts

Posted 15 August 2013 - 07:46 PM

I have started Hartls tutorial twice, i'm almost done the second time the first time I stopped early but I did the 'optional' cucumber section and while I saw the advantage of cucumber because it's more 'normal speak' than even Rspec - I felt that Rspec was 'normal language' enough that putting cucumber on top of it was unnecessary.  I look at it this way, if you can understand in plain english (i.e. say it out loud) what the Rspec tests are testing than Cucumber is not needed, Cucumber just adds a layer to testing that makes it 'closer' to English. 



#3 decisit

decisit

    Passenger

  • Members
  • 1 posts

Posted 15 August 2013 - 08:05 PM

Hi,

 

Like @Jemagee said, Cucumber is really helpful to make your tests more understandable. If you simply do your cucumber features like your rspec tests, it's obviously a waist of time (imho).

 

Cucumber describes basics end-user features, like:

 

When I open http://myapp/login

And I fill the "login" box with: j.smith@mail.com

And I fill the "password" box with: qwerty

And I click on "login" button

Then I should be redirected to http://myapp/welcome

 

Which is pretty simple in fact, but behind the scene, a lot of code is running, maybe you rely on public API for authentication etc. With rspec you will verify that technical part of your code is working. With Cucumber you will only verify that a user with correct credentials is able to login.

 

The true power of Cucumber comes when your customers are able (and agree) to write the features by themselves. Then, you only have to implement the feature and check if it passes their specifications.



#4 james

james

    Guard

  • Moderators
  • 221 posts
  • LocationLeeds, U.K.

Posted 15 August 2013 - 08:43 PM

I have used cucumber until I ran accross the How I test Railscast.

 

http://railscasts.co.../275-how-i-test

 

In all the time I have been cutting code I have never come accross a better tutorial than that particular cast.


Programming is just about problem solving!


#5 Jemagee

Jemagee

    Inspector

  • Members
  • 60 posts

Posted 15 August 2013 - 08:46 PM

I have used cucumber until I ran accross the How I test Railscast.

 

http://railscasts.co.../275-how-i-test

 

In all the time I have been cutting code I have never come accross a better tutorial than that particular cast.

I don't know what guard is yet (cause I don't use mailers yet) but Rspec, Capybarara, Factory Girl is the testing that Hartl teaches you in his tutorial.  I like it very much.



#6 james

james

    Guard

  • Moderators
  • 221 posts
  • LocationLeeds, U.K.

Posted 15 August 2013 - 09:13 PM

Guard is not related to mailers. It just constantly runs your tests so you don't have to keep starting them up all the time. Whenever you save a file the test for that file automatically runs and Spork will notify you of the results. It's a really really cool setup nd has massively improved my productivity


Programming is just about problem solving!


#7 Jemagee

Jemagee

    Inspector

  • Members
  • 60 posts

Posted 15 August 2013 - 09:15 PM

Guard is not related to mailers. It just constantly runs your tests so you don't have to keep starting them up all the time. Whenever you save a file the test for that file automatically runs and Spork will notify you of the results. It's a really really cool setup nd has massively improved my productivity

That's pretty cool, I didn't know that.  I use textmate on my mac to write my stuff and i can run the tests right out of textmate itself. 



#8 Stuart Hannig

Stuart Hannig

    Signalman

  • Members
  • 15 posts

Posted 16 August 2013 - 03:43 AM

Guard is suppose to save a ton of time in TDD because it doesn't make you run through all the tests, which can take a good couple minutes depending on app size. I look forward to using Guard more often. Also, I have the Testing Rails Cast on my TODO list next. Very excited.







Also tagged with one or more of these keywords: Cucumber, RSpec, Capybara, Rails, Testing

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users