Hi I have a user model with many attributes and validation that are required for login. I want to develop my application using test development, but it's hard for me to write simple tests to check, such as the lack of emails, unique emails, the correct email address.
So what is the best way to start writing tests?
Shoulda ( http://github.com/thoughtbot/shoulda/wiki/Usage ) will make it easy to check such ActiveRecord checks.
should_not_allow_values_for :email, "blah", "b lah" should_allow_values_for :email, "a@b.com", "asdf@asdf.com"
, , , .
, , . . ( rSpec):
obj_under_test = MyModel.new(@valid_attributes) object_under_test.email = nil obj_under_test.should_not be_valid
@valid_attributes . . FactoryGirl, Machinist, Fixjour . , , - :
@valid_attributes
/ , . ( "", BDD). , , " ", " , ", " " ..
Source: https://habr.com/ru/post/1770457/More articles:Soap Client on Android to access Salesforce API - androidHow to insert CURRENT_TIMESTAMP into a PostGreSQL installation of Drupal - databaseWhat are the strengths and weaknesses of the various MVVM environments for Silverlight? - silverlightHow to pass an action method anti-fake token with the HttpDelete attribute in ASP.NET MVC? - asp.net-mvcJavascript img onload - javascriptResizing a UIView subclass with dynamic-size substrings - iphoneSession is not supported between mysite.com and www.example.com - phpHow to hide the image button? - androidHow to display html email address in browser without changing my bg colors and changing table - htmlcross-compilation (hand-not-eabi-as error) garbage at the end of the line / "or undefined character - assemblyAll Articles