Testing with Capybara: Can it be used to test data models?

Just started using rails and still in the midst of putting things together, hence sorry if my question is simple but can Capybara be used for testing databases(data models) because all the examples that i have seen have it testing views and sometimes controllers? And I know that rspec works great for TDD in data models via failing tests but can Capybara do this as well?


Capybara is an Acceptance framework for web applications. That means it tests the full stack, through a browser (or browser-like) interface.

So it wouldn't make sense to use a browser to test a data-model or business-logic class. They don't have an interface for a browser to talk to them. It's web -> framework -> classes. Capybara becomes the "web"

That's where Test::Unit, RSpec, and/or Minitest come in. They are designed to be code -> classes.

Capybara is for integration testing, meaning it simulates requests from a real browser usage, clicking and typing and so on.

If you want to test your models use Test::Unit, Rspec, Shoulda.

Need Your Help

Building Associations in Factory Girl

ruby-on-rails ruby-on-rails-4 rspec associations factory-bot

I have two models Users and Accounts which has the relationship

Drupal 6 : Not able to fetch group_id(gid) from OG table

mysql drupal drupal-6

I am creating nodes pro-grammatically by fetching emails. Where I am splitting the subject of the mail for creating it for specific group & the title of the node.