RSpec Metadata - RSpec

What is RSpec Metadata?

RSpec Metadata is defined as “data about data”, which means data about the describe, context and it blocks.

For instance−

When the above code is run, the output appears as −

Within the RSpec files, variables can be assigned, using Metadata. The example.metadata variable is a Ruby hash which contains other information about the Examples and Example groups.

For instance, the above code is rewritten as −

When the code is run, all of the values in the example.metadata hash are visible −

An Example Group with a metadata variable and a context with another variable can access the metadata variable in the context block.

This is a sentence created from the describe block “description + its contained context block description + the description for the it block.”

The three strings appear to be like normal English sentences, which is the idea behind RSpec, making tests sound like normal English language.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

RSpec Topics