开发者

Any chance to DRY Capybara code?

开发者 https://www.devze.com 2023-03-20 19:02 出处:网络
# acceptance/users_spec.rb page.should have_content \'Włosy\' page.should have_content \'Oczy\' page.should have_content \'Wzrost\'
# acceptance/users_spec.rb
page.should have_content 'Włosy'
page.should have_content 'Oczy'
page.should have_content 'Wzrost'
page.should have_content 'Waga'
page.should have_content 'Biust'
page.should have_content 'Biustonosz'
page.should have_content 'Talia'
page.should have_content 'Biodra'
开发者_如何学JAVApage.should have_content 'Ubranie'
page.should have_content 'Obuwie'
page.should have_content 'Zakres pracy'
page.should have_content 'Preferowany region pracy'
page.should have_content 'Języki'
page.should have_content 'O sobie'
page.should have_content 'Twoja strona WWW'
page.should have_content 'Numer Gadu-Gadu'
page.should have_content 'Kursy, szkolenia'
page.should have_content 'Referencje'

I want to know if I could make this code better. I'm using rspec and steak.


Well your test may be overkill -- if the same code is generating each of those items, you can just test one or two of them to make sure the code works.

But otherwise, you could do:

['Włosy', 'Oczy', .....].each { |item| page.should have_content(item) }
0

精彩评论

暂无评论...
验证码 换一张
取 消