capybaraã2.1ã«upgradeãã¦ãã³ãã£ãæ¹ã¸
以ä¸ãå ¥ãã¦ããã°ãå¿ã«å¹³ç©ãæ»ããããããªãã
spec_helper.rb
Capybara.configure do |config| config.match = :one config.exact_options = false config.ignore_hidden_elements = false config.visible_text_only = true end
https://github.com/jnicklas/capybara/blob/master/History.md
http://www.elabs.se/blog/60-introducing-capybara-2-1
2ç³»ãããããã£ããã§ãã¯åºæºãå³ãããããã©1.xãã2.0ã«ããã¨ãã«ãããããªäººããããã®ã¢ãããã¼ãç¡çã²ã¼ãã£ã¦è¨ããããã2.1ã§ã¯å¾æ¹äºææ§ãä¿ã¤ããã®ãªãã·ã§ã³ãããããç¨æããããçãªãã¨ãããã
ä»åã¼ãã¯2.0â2.1ã®ã¢ãããã¼ãã ã£ããã©ãããã§ããããªãã«ãã¹ãã²ã£ããã£ããã©ã
ãã®ãã¡å¯¾å¿ããããã
追è¨ï¼
ä¸è¿°ã®configããªãã¨ããä¸çªå£ãããã¹ããtitleã¿ã°ã®å
容ãã§ãã¯ã ã£ãã
ãªããã¨ããã¨config.ignore_hidden_elementsã®ããã©ã«ããtrueã«å¤ãã£ãããã§ãconfig.ignore_hidden_elementsããªããªã®ãã¨ããã¨ããã®åã®éãã人ã®ç®ã«è¦ããªãè¦ç´ ã¯è©ä¾¡ããªããã¨ããæå³ã§ãããã¤ãtrueã«ãªãã¨ãdisplay: none ã ã£ããhiddenå¤ã ã£ããtitleãªãããæ¾ãããªããªã£ã¦ããã§ãã¯ãéããªããªããã¨ããæé
ããããtitleã¿ã°ããã©ã¦ã¶ã®ãã¼ã¨ãã¿ãã¨ãã«è¦ãã¦ããããï¼ã£ã¦æã£ããã©ããããããã¨ãããªãã¿ããã
ã§ãtitleãã§ãã¯ã«ã¤ãã¦ã¯ã
page.title # => "The title" page.has_title?("The title") # => true page.should have_title("The title")
ã¨ãã£ãæ¸ãæ¹ããããå ·ä½çã«ã¯
its(:source) { should have_selector('title', text: full_title(I18n.t('edit.title'))) }
ã¿ãããªãã¹ãã¯
it{ expect(page.source).to have_title(full_title(I18n.t('edit.title'))) }
ã¨æ¸ããªããã°ãã¹ãã¯éãããã«ãªããâ»ã¤ãã§ã«shouldãexpectã«æ¸ãæãã¦ããï¼http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax