Rspec tests are grouped inside describe block. I assume this provides the context for the humans reading the test code and helps in organizing the code (like we can have a ‘before’ block and have a set of common code to be run for each test).
describe "homepage" before(:each) do ## write some common code for this 'describe' end it "has title" do ## write the actual test code here. end it "has subtitle" do ## write another test code here. end end
I understand this. Also I noticed that
describe can be nested. So I can have
describe block for navigation that is inside the
describe of the home page.
Then comes the
context block. This confuses me. Why should I use
context block when I can have nested
describe for different contexts?
Is there any advantage? Also is my assumption of
describe as a context basically wrong?
Thanks for any help.