Testing is just a means to an end like the code you write. It creates a certain confidence level that your code is doing what it supposed to do based on the instructions you gave it.
Like the other dude said start with model tests because they are generally the easiest to work with.
Maybe start off with something basic. Write down a list of validation constraints that are necessary for the model you're testing in normal english.
Example, maybe you would do something like this for a Profile model.
"expect error when first name is empty"
"expect error when last name is empty"
"expect error when e-mail address is empty"
"expect error when e-mail address is an invalid format"
To get these working with the built in rails 4 test framework you just need to change them so they read:
test "the description would go here" do
# insert test code here
end
I'll fill in 1 test for you and you can do the rest.
test "expect error when first name is empty" do
@profile = Profile.new
@profile.first_name = ""
refute @profile.save
end
If you have no validations in your Profile model then this test will fail because it WILL save. So your goal is to make it pass. Now you would write your validation in the model as so:
validates :first_name, presence: true
If you re-run the test it should pass now because active record will throw an error saying first name can't be blank. The test is designed to refute (ie. refuse) saving the model, which is the opposite of assert.
Like the other dude said start with model tests because they are generally the easiest to work with.
Maybe start off with something basic. Write down a list of validation constraints that are necessary for the model you're testing in normal english.
Example, maybe you would do something like this for a Profile model.
To get these working with the built in rails 4 test framework you just need to change them so they read: I'll fill in 1 test for you and you can do the rest. If you have no validations in your Profile model then this test will fail because it WILL save. So your goal is to make it pass. Now you would write your validation in the model as so: If you re-run the test it should pass now because active record will throw an error saying first name can't be blank. The test is designed to refute (ie. refuse) saving the model, which is the opposite of assert.IMO just read through this: http://guides.rubyonrails.org/testing.html