RSpec
RSpec
RSpec
https://rspec.info/
Behaviour Driven Development for Ruby.
Making TDD Productive and Fun.
https://blog.softtek.com/es/implementando-bdd-con-cucumber
Testing Pyramid
• Isolated
• Method level
• Automated
• Repeatable
AAA PATTERN
def validate
# Arrange
calculator = Calculator.new()
# Act
result = calculator.sum(2, 3)
# Assert
expect(result).to eq(5)
RSpec
RSpec as TDD
$ rspec spec/burger_spec.rb
option2 = Option.create(
description: ‘1’,
question_id: question.id,
correct: true
)
# Act
answer = Answer.new(
question: question.id,
user: user.id,
option: 3)
# Assert
expect(answer.correct).to eq(true)