{"id":7736,"date":"2019-12-01T12:30:35","date_gmt":"2019-12-01T03:30:35","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=7736"},"modified":"2023-05-27T22:30:36","modified_gmt":"2023-05-27T13:30:36","slug":"%e3%80%90rspec%e3%80%91system-spec%e3%81%ae%e5%9f%ba%e6%9c%ac","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=7736","title":{"rendered":"\u3010Rspec\u3011System Spec(\u30b7\u30b9\u30c6\u30e0\u30b9\u30da\u30c3\u30af)\u306e\u57fa\u672c"},"content":{"rendered":"<p>System Spec\u306fRspec3.7\u304b\u3089\u306e\u6a5f\u80fd\u3067\u6bd4\u8f03\u7684\u6b74\u53f2\u304c\u6d45\u3044\u6a5f\u80fd\u306b\u306a\u308a\u307e\u3059\u3002E2E\u30c6\u30b9\u30c8\u304c\u3067\u304d\u308bspec\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5143\u3005\u306f\u3001Feature Spec\u3068\u3044\u3046E2E\u30c6\u30b9\u30c8\u7528\u306eSpec\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u304c\u305d\u306e\u4ee3\u66ff\u3067\u3059\u3002<\/p>\n<h2>Feature Spec\u3068\u306e\u9055\u3044<\/h2>\n<p>Rails\u3067\u306eE2E\u30c6\u30b9\u30c8\u3092\u3088\u308a\u4fbf\u5229\u306b\u3059\u308b\u3088\u3046\u306b\u4ee5\u4e0b\u304c\u30c7\u30d5\u30a9\u30eb\u30c8\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067selnium-webdriver + Chrome\u4e0a\u3067\u30c6\u30b9\u30c8\u304c\u5b9f\u884c\u3055\u308c\u308b\u3002<\/li>\n<li>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u7ba1\u7406\u3092\u3059\u308b\u5fc5\u8981\u304c\u306a\u3044\u3002<\/li>\n<li>\u30c6\u30b9\u30c8\u5931\u6557\u6642\u306b\u81ea\u52d5\u3067\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u4fdd\u5b58\u3057\u3066\u304f\u308c\u308b\u3002<\/li>\n<\/ul>\n<h2>\u6e96\u5099<\/h2>\n<p>System Spec\u3092\u3059\u308b\u305f\u3081\u306b\u306fCapybara\u3068\u3044\u3046\u5916\u90e8\u306eGem\u3092Rails\u306b\u7d44\u307f\u8fbc\u3080\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002capybara\u81ea\u4f53\u306frails new\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u305f\u969b\u306b\u65e2\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u306f\u305a\u306a\u306e\u3067<span style=\"color: #ff0000;\"><strong>Rspec\u3067capybara\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306e\u6e96\u5099<\/strong><\/span>\u3092\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>spec\/spec_helper.rb<\/h2>\n<p>spec_helper.rb(Rails\u7279\u6709\u306eRspec\u306e\u8a2d\u5b9a\u3092\u3057\u3066\u3044\u304f\u30d5\u30a1\u30a4\u30eb)\u306b\u5bfe\u3057\u3066\u4e0b\u8a18\u306e\u8a18\u8ff0\u3092\u8ffd\u52a0\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"lang:default decode:true\">require 'rspec\/rails'\r\n# Add additional requires below this line. Rails is not loaded until this point!\r\nrequire 'capybara\/rspec'\u3000\u2605\u8ffd\u52a0\r\n\r\n~ \u4e2d\u7565 ~\r\n\r\nRSpec.configure do |config|\r\n  config.before(:each, type: :system) do\u3000\u3000\u2605\u8ffd\u52a0\r\n    driven_by :selenium_chrome_headless\u3000\u3000 \u2605\u8ffd\u52a0\r\n  end\u3000                                     \u2605\u8ffd\u52a0<\/pre>\n<h3>require 'capybara\/rspec'<\/h3>\n<p>Rspec\u3067Capybara\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002\u6ce8\u610f\u70b9\u3068\u3057\u3066\u306f\u300cActiveRecord::Migration.maintain_test_schema!\u300d\u7b49\u306e\u4ed6\u306e\u8a18\u8ff0\u306e\u5f8c\u306b\u306f\u8a18\u8ff0\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002\uff08\u52d5\u304b\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002\uff09<\/p>\n<h3>config.before(:each, type: :system) do\u3000\u301c end<\/h3>\n<p>System Spec\u3092\u4f7f\u7528\u3059\u308b\u305f\u3081\u306e\u8a2d\u5b9a\u3067\u3059\u3002\u305d\u306e\u969b\u306b\u30c9\u30e9\u30a4\u30d0\u3068\u3044\u3046System Spec\u306b\u304a\u3044\u3066\u30d6\u30e9\u30a6\u30b6\u306b\u76f8\u5f53\u3059\u308b\u6a5f\u80fd\u3092\u6301\u3063\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u6307\u5b9a\u3092\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f<span style=\"color: #ff0000;\"><strong>\u300cselenium_chrome_headless\u300d<\/strong><\/span>\u3068\u3044\u3046\u30c9\u30e9\u30a4\u30d0\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"System Spec\u306fRspec3.7\u304b\u3089\u306e\u6a5f\u80fd\u3067\u6bd4\u8f03\u7684\u6b74\u53f2\u304c\u6d45\u3044\u6a5f\u80fd\u306b\u306a\u308a\u307e\u3059\u3002E2E\u30c6\u30b9\u30c8\u304c\u3067\u304d\u308bspec\u306b\u306a\u308a\u307e\u3059\u3002 \u5143\u3005\u306f\u3001Feature Spec\u3068\u3044\u3046E2E\u30c6\u30b9\u30c8\u7528\u306eSpec\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u304c\u305d\u306e\u4ee3\u66ff\u3067 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[82,36],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/7736"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7736"}],"version-history":[{"count":10,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/7736\/revisions"}],"predecessor-version":[{"id":20467,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/7736\/revisions\/20467"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7736"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}