Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. RSpec_test_check_point3
  2. With this chapter, I learnt the following:
  3. How to,
  4. 1. Read Rspec Tests
  5. Methods may not return error, but still may not behave as expected. RSpec helps to test such behaviour.
  6. When tests are written to define future code's behaviour, it is called Test Driven Development (TDD).
  7. RSpec, like most testing frameworks, runs your code in particular conditions and with particular arguments. It sets expectations for the outcome of this process, and the test passes if those expectations are met. In RSpec, instead of returning true/false, the test will either pass or fail depending on if the expectations or met or not. As an example,
  8.  
  9. describe "greet" do
  10. it "says hello to someone" do
  11. greeting = greet("Annie", "Oakley")
  12. expect(greeting).to eq("Hello Annie Oakley.")
  13. end
  14. end
  15. The declaration of the method "greet" remains unchanged, but they are enclosed between describe and it lines.
  16. To make the test pass, the definition of the method greet has to be as below:
  17. def greet(first, last)
  18. "Hello #{first} #{last}. "
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement