I am following Michael Hartl's tutorial and came across this following codes that I am having trouble comprehending.
describe "index" do
let(:user) { FactoryGirl.create(:user) }
before(:each) do
sign_in user
visit users_path
end
it { should have_title('All users') }
it { should have_content('All users') }
describe "pagination" do
before(:all) { 30.times { FactoryGirl.create(:user) } }
after(:all) { User.delete_all }
it { should have_selector('div.pagination') }
it "should list each user" do
User.paginate(page: 1).each do |user|
expect(page).to have_selector('li', text: user.name)
end
end
end
end
My question is: is this a NESTED TEST where the test block of Pagination runs inside Index Test block? in other words, the sequence of testing flow:
- before(:each) outer block of signing in user and visiting user path is executed
- then the inner block of 30.times { FactoryGirl.create(:user) is executed
- then the inner block of it { should have_selector('div.pagination') } is executed
- then the inner block of expect(page).to have_selector('li', text: user.name) is executed
thank you