Rails4 - confusion testing. Recommendations

I am relatively new to TDD for rails. I started working on a project where I wanted to make sure that my code does what it should do (both in the backend and in the interface)

I see that rails officially have their own test framework (model level, controller level and integration level, as indicated in http://guides.rubyonrails.org/testing.html ), if So, what should I use from this: rspec , cucumber, manufacturer, capybara, etc.) and why use them, rather than rails, your own testing framework?

My task is to ask this question - find out what I will miss if I use my own rails testing method? and in this case, what should I choose from the list above to fully check my code?

My final goal (in order):

1) Write a model - does the test work as expected?
2) Recording controller - does it apply business logic as expected?
3) Front end: make the templates as expected

4) As a user script: does my web page work in anticipation of user actions (in scripts that are logged in or not logged in). (For example, if I click on the sort link, then the data is sorted (using ajax). When the user hovers the div, he changes the color to black, etc.)
5) Now I want to deploy my code to heroku / aws / engineyard, etc. etc., so I want to run full tests (smoke tests, integration testing?) before the code is deployed.

, rails?

/ , , .

+4
2

Rails test/unit ( minitest) . ruby ​​ .

Rspec /, , BDD/TDD. :

# minitest
def test_new_users_should_be_active
  user = User.new
  assert_equal true, user.active?
end

# rspec
describe User do
  it 'should be active' do
    User.new.active?.should be true
  end
end

, , , . minitest rspec.

Factory_girl - , rspec minitest factory , . , , , factory ( ).

Capybara webrat , minitest, rspec . , , , , , , , .

, , , , . Capybara , .

Cucumber , DSL . , , .

- , , , .

, , . :

, . CI-, Jenkins .

, :

minitest ( ) rspec

  • Write model - test , ?
  • - -, ?
  • :

Rails , .

, (). Rspec .

capybara

  • : - ( ). (, , ( ajax). div, ..)

()

  • heroku/aws/engineyard .., ( , ?), .

+4

: https://www.relishapp.com/rspec/rspec-rails/docs .

0

Source: https://habr.com/ru/post/1525368/


All Articles