Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Act, arrange, assert - better organisation of your tests #6

Open
jerryjohnjacob opened this issue Jul 19, 2016 · 0 comments
Open

Act, arrange, assert - better organisation of your tests #6

jerryjohnjacob opened this issue Jul 19, 2016 · 0 comments

Comments

@jerryjohnjacob
Copy link

When writing a test, there are generally 3 parts - arrange, act, assert.

  • Arrange refers to the setup necessary for the test happens - setting up objects, assigning values, etc.
  • Act is the actual action - the main line that produces the effect the test is checking.
  • Assert refers to the 'test' part, where you're checking the output of the action and the desired result.

Keep these sections separated by a space.

Let's have a look at one of the tests you've written. Right now, all the lines are not separated in any way. Here's how to space them apart according to the scheme I've mentioned above:

it 'returns a hash with name, age, place when called to_hash' do
  the_hash = user.to_hash

  expect(the_hash).to be_a(Hash)
  expect(the_hash).to eq({name: 'Some Name', age: '21', place: 'Some Place'})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant