What is Rspec?
It is a testing Framework for automated tests
What does Rspec stand for?
Ruby Specifications
What is the structure of a spec?
Given-When-Then
How is RSpec structured
What reasons are there to test?
When should you not write tests?
What makes testing easier?
By thinking in user stories
What do we want to test?
What do we not want to test?
What is the difference between .rspec and .rspec-local ?
.rspec is the global configurations that are used by all the team members, .rspec-local are the local configurations on your computer. So if you want to have your own configurations that should not be shared with the other team members then you use the .rspec-local
What is the first thing you add in a spec file?
The first thing you must do is to require the file you want to test.
we want to require the file car.rb
ex
require ‘car’
what is describe used for?
describe is used to define an example group.
A good practice is to have a describe for each method
What is context?
Context is used an alias for describe these are used when you want to group the methods for a specific usecase
What is the fundamental syntax of the expectations?
expect( ).to ( )
and
expect( ).not_to ( )
What is the RSpec Hierarchy?
It is the order that we group our specs (fundamental structure)
1 Spec file = car_spec.rb 2 example group = describe 3 nested group = describe/context 4 example = it 5 expectations = expect( ).to ( )
How do you describe a class method?
describe .method do
How do you describe an instance method?
describe #method do
How do we skip over describe blocks?
You write an x in front of the describe
xdescribe ‘something
or you write skip(‘message’) inside the describe block
How do you skip specs?
You write an x in front of it
xit ‘something’
How do you mark a block as pending?
you use the word pending inside the block.
pending(‘pending message’)
What is the difference between pending and skip?
Pending still runs the code and gives failiures while skip skips the test altoghether.
How many expectations should you have for an example?
Only one
How is a matcher constructed?
expect(actual).to match(expected)
What are matchers?
Matchers are used as arguments to #to( )
Expectations are simple statements
Matchers provide the variety and complexity