Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 327 Vote(s) - 3.43 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rails 3, too many ways to test?

#1
If you were just starting out in rails which path would you encourage new users to go down with regards to **Testing**.

Anything I read about regarding Rails 3, tells me I should be using **Rspec 2**. But Rspec comes with a whole whack of other things I need to learn like

gem 'capybara'
gem 'database_cleaner'
gem 'cucumber-rails'
gem 'cucumber'
gem 'spork'
gem 'launchy'

And then one of my friends just told me that I should just stick to the testing framework that comes with rails, and maybe just integrate 'shoulda' into the test process because it has a nice syntax.

When it comes to **testing** it seems like we have way too many options and too many ways of doing something. Maybe this is a good thing, but I always thought rails was about creating common conventions and avoiding doing the same thing in different ways.

I'm fairly new to rails.
I'm unsure where to start.
I feel overwhelmed.
Is this normal?


Reply

#2
Sounds like you have option overload. Which is common to most people in a lot of different situations even outside of programming. The absolute easiest thing for you to do, would be to go with what Rails sets up by default, which is called Test::Unit

Their official guide introduces it here:

[To see links please register here]


Once you are comfortable with testing using plain Test::Unit style then I would suggest you explore some of the addons your friend mentioned such as shoulda (

[To see links please register here]

), and factory_girl (

[To see links please register here]

)

Good luck!
Reply

#3
Since you're beginning with rails, I'd recommend using something that "just works" to get in the habit of testing your code and understanding how to work with your framework. **Don't waste your time comparing solutions, choose one and stick with it for this project.**

That being said, I really think it depends on your experience developing software:

- if you've never used unit tests for your code, learn Test::Unit and consider adopting TDD. Notice that TDD will need you to dedicate a large amount of time to it at first, but that is paid off when you get used to it.
- if you have significant experience with code tests and are just confused on how to start with rails, I recommend following through

[To see links please register here]

. This is a (free) Ruby on Rails book that uses RSpec, Spork and serves as a great introduction

After developing one project from start to end using the testing platform you choose now, you'll have a **much** better task of choosing the testing framework you wish to use.

I'd also recommend you learn RSpec well before diving into Cucumber.
Reply

#4
> But Rspec comes with a whole whack of
> other things I need to learn like ...

Actually, you don't need to learn any of those other gems to get started with RSpec. Just go with `gem 'rspec-rails`, and run `rails generate rspec:install` to set up your project.

A good way to learn RSpec is to look at the code generated by `rails generate scaffold`. This creates spec files for controllers, views and routes that deal with the standard RESTful actions.

While learning RSpec you can add in other gems as you discover the need for them. `Autotest` is essential IMHO. `Webrat` adds useful matchers for view specs. `Factory_girl` adds support for factories.

`Spork` is great, but not really necessary until you have enough specs that performance is an issue.

> I feel overwhelmed. Is this normal?

Less of [this][1], more of [this][2] :)


[1]:
[2]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through