Last active
February 2, 2020 21:02
-
-
Save rcoproc/810f9cdac6d3b13b37e003d9fa8a96ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Padrâo xUnit 4 fases de teste - 4 Standard test phases XUnit | |
| # Setup | |
| # Exercise | |
| # Verify | |
| # Teardown | |
| # "Mocks são para a fase de Verify" - "Mocks are for the Verify stage" | |
| # "Mocks são usados para testar comportamentos" - "Mocks are used to test behaviors" | |
| # Com mocks fica assim a ordem das fases de teste(With mock objects so is the order of the test phases): | |
| # Setup | |
| # Verify** | |
| # Exercise | |
| # Teardown | |
| require 'student' | |
| require 'course' | |
| describe 'Mocks' do | |
| it '#bar' do | |
| # setup | |
| student = Student.new | |
| # verify | |
| expect(student).to receive(:bar) | |
| # exercise | |
| student.bar | |
| end | |
| it 'args' do | |
| student = Student.new | |
| expect(student).to receive(:foo).with(123) | |
| student.foo(123) | |
| end | |
| it 'repetição' do | |
| student = Student.new | |
| expect(student).to receive(:foo).with(123).twice | |
| student.foo(123) | |
| student.foo(123) | |
| end | |
| it 'retorno' do | |
| student = Student.new | |
| expect(student).to receive(:foo).with(123).and_return(true) | |
| puts student.foo(123) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment