如何将一些测试分组显示?
我启动:
bin/rspec --format=documentation
实际上,我知道了:
Countries API
GET /countries
return list of countries
returns status code 200
GET /states/{country_abbrev}
return list of states
returns status code 200
Companies API
GET /companies
returns companies
returns status code 200
InvoiceLineRepository
#create
create invoice line in database
InvoiceRepository
#create
create invoice in database
我想拥有:
API
Countries API
GET /countries
return list of countries
returns status code 200
GET /states/{country_abbrev}
return list of states
returns status code 200
Companies API
GET /companies
returns companies
returns status code 200
Repository
InvoiceLineRepository
#create
create invoice line in database
InvoiceRepository
#create
create invoice in database
与API有关的测试被分组为togheter。 与存储库相关的测试被分组到togheter中。
我希望这可以更好地组织测试的可视化和探索
编辑:
上下文(请参阅mrzasa答复)不能满足我的要求:
Repository
AddressRepository
#create
create address in database
Repository
AgencyRepository
#create
create agency in database
Repository
ArticleRepository
#create
create article in database
答案 0 :(得分:1)
您可以实现一个custom formatter,以一个documentation formatter为例,但是正如其他人所说的那样,这不能扩展,什么是“组”?
答案 1 :(得分:0)
您需要为API
和Repository
添加上下文:
context 'API' do
context 'Countries' do
describe 'GET /countries' do
# examples
end
describe 'GET /states/{country_abbrev}' do
# examples
end
end
end
context 'Repository do
# context/describe blocks for InvoiceLineRepository and InvoiceRepository
end