Backo
Backo

Reputation: 18871

How and what to test by using respectively Cucumber and Rspec?

I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1 and capybara-1.1.2 with the Selenium driver. I would like to know how and what to test by using respectively Cucumber and Rspec? That is, what "behavior" should I treat with Cucumber and what with Rspec so to divide testing "concerns" in a proper way?

For example, in order to test a view, should I test the presence of a CSS id in a page content by using Cucumber or RSpec? or both?

Upvotes: 0

Views: 512

Answers (3)

byterussian
byterussian

Reputation: 3609

Use RSpec to test the various parts(Controllers, Models and Views) of your app by isolating them. (with Mock, Stub and the others tools that gives you RSpec)

Use Cucumber to test all parts of your app togheter, as you see the app in the browser... for example, if you need to test the sign in form of your app without cucumber you should:

1) Open a shell and run rails server.

2) Go to browser and type the url of login.

3) Fill in form fields.

4) Click Submit button.

You should automate this process, and similar process with Cucumber, for others test use Rspec.

Upvotes: 2

Muhammad Sannan Khalid
Muhammad Sannan Khalid

Reputation: 3137

Use UnitTest & capybara for testing because its more simple and fast. Checkout this URL for more details.

http://guides.rubyonrails.org/testing.html

Upvotes: 0

Andre Dublin
Andre Dublin

Reputation: 1158

They both can test for node attributes, but I would use Capybara only for request specs. Ultimately it is personal preference. I use rspec and capybara together, but the language syntax of capybara makes more sense/is semantic as rspec when testing for request/expectations.

Upvotes: 0

Related Questions