Write cleaner, self-documented tests by defining methods in RSpec

When we write clean Ruby code, we try to pull out methods with descriptive names that do small amounts of work. It’s possible to do the same in RSpec, just as we would in a less “fluent” test framework like Ruby’s standard testing library Minitest.RSpec’s describe and context methods define anonymous classes that behave like any other Ruby class as far as scope. Nested blocks even inherit methods from their containers and can use super. Each it block is more like a method, creating an instance of its outer describe/ context and executing in that scope.
Write cleaner, self-documented tests by defining methods in RSpec #ruby #rubydeveloper #rubyonrails #rspec #tests https://rubyonrails.ba/single/write-cleaner-self-documented-tests-by-defining-methods-in-rspec

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles