{"id":9802,"date":"2020-03-21T11:02:16","date_gmt":"2020-03-21T02:02:16","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=9802"},"modified":"2023-05-01T22:18:49","modified_gmt":"2023-05-01T13:18:49","slug":"%e3%80%90rspec%e3%80%91%e9%ab%98%e9%80%9f%e5%8c%96%e3%81%ae%e6%89%8b%e6%b3%95","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=9802","title":{"rendered":"\u3010RSpec\u3011\u9ad8\u901f\u5316\u306e\u624b\u6cd5(ParallelTests\u306a\u3069\uff09"},"content":{"rendered":"<p>Rspec\u306e\u30c6\u30b9\u30c8\u3092\u9ad8\u901f\u5316\u3059\u308b\u624b\u6cd5\u3068\u3057\u3066\u306f\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>Rails\u306e\u8d77\u52d5\u3092\u9ad8\u901f\u5316\u3059\u308b\u3002<\/li>\n<li>Rails\u3092\u53d6\u308a\u5916\u3059\u3002<\/li>\n<li>\u30c6\u30b9\u30c8\u3092\u4e26\u5217\u5316\u3055\u305b\u308b\u3002<\/li>\n<li>\u30bf\u30b0\u3092\u4f7f\u3046\u3002<\/li>\n<li>\u30e2\u30c3\u30af\u3084\u30b9\u30bf\u30d6\u3092\u4f7f\u7528\u3059\u308b\u3002<\/li>\n<\/ul>\n<h2>Rails\u306e\u8d77\u52d5\u3092\u9ad8\u901f\u5316\u3059\u308b\u3002<\/h2>\n<p>binstub\u3068\u3044\u3046Gem\u3092\u4f7f\u3048\u3070Spring\u7d4c\u7531\u3067Rails\u3092\u8d77\u52d5\u3059\u308b\u306e\u3067\u30c6\u30b9\u30c8\u306e\u5b9f\u884c\u3092\u9ad8\u901f\u5316\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>binstub\u3068\u306f\uff1f<\/h3>\n<p>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8d77\u52d5\u3092\u65e9\u304f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ed5\u7d44\u307f\u7684\u306b\u306fSpring\u306e\u6069\u6075\u3092\u53d7\u3051\u3066\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<pre class=\"lang:default decode:true \">group :development do\r\n  gem 'spring-commands-rspec'\r\nend<\/pre>\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">bundle<\/pre>\n<h3>\u65b0\u3057\u3044binstub\u3092\u4f5c\u6210\u3059\u308b\u3002<\/h3>\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068bin\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306brspec\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">bundle exec spring binstub rspec<\/pre>\n<h3>binstub\u3092\u4f7f\u3063\u3066Rspec\u3092\u8d77\u52d5\u3059\u308b\u3002<\/h3>\n<p>binstub\u306e\u52d5\u4f5c\u78ba\u8a8d\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u884c\u3046\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">bin\/rspec<\/pre>\n<p>\u3061\u3083\u3093\u3068binstub\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308c\u3070\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-9666\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2020\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2020-03-14-11.00.30-1024x192.png\" alt=\"\" width=\"1024\" height=\"192\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2020\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2020-03-14-11.00.30-1024x192.png 1024w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2020\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2020-03-14-11.00.30-300x56.png 300w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2020\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2020-03-14-11.00.30-768x144.png 768w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2020\/03\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2020-03-14-11.00.30.png 1226w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u5168\u3066\u306e\u30b9\u30da\u30c3\u30af\u306e\u30c6\u30b9\u30c8\u304c\u5b9f\u884c\u3055\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u30b9\u30da\u30c3\u30af\u3092\u7d5e\u3063\u3066\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u305f\u3044\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">bin\/rspec \u30b9\u30da\u30c3\u30af\u30d5\u30a9\u30eb\u30c0\uff08\u4f8b\uff1a\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30b9\u30da\u30c3\u30af\u306b\u7d5e\u308b\u5834\u5408\uff1aspec\/controllers)<\/pre>\n<h2>Rails\u3092\u53d6\u308a\u5916\u3059\u3002<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>\u305d\u3082\u305d\u3082Rails\u81ea\u4f53\u304c\u91cd\u3044\u306e\u3067\u51e6\u7406\u306b\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002<\/strong><\/span>\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u305f\u3073\u306b\u6bce\u56deRails\u304c\u8d77\u52d5\u3057\u3066\u3044\u308b\u306e\u3067\u9045\u304f\u306a\u308a\u307e\u3059\u3002\u305d\u3082\u305d\u3082\u3001Rails\u81ea\u4f53\u3092\u53d6\u308a\u5916\u3057\u3066\u9ad8\u901f\u5316\u3059\u308b\u3068\u3044\u3046\u624b\u6cd5\u3082\u4e16\u306e\u4e2d\u306b\u306f\u5b58\u5728\u3057\u307e\u3059\u3002\u5177\u4f53\u7684\u306a\u65b9\u6cd5\u306b\u3064\u3044\u3066\u306f\u5225\u9014\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3059\u3002<\/p>\n<h2>Rails6\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u4e26\u5217\u30c6\u30b9\u30c8\u6a5f\u80fd\u3092\u4f7f\u3046\u3002<\/h2>\n<p>Rails6\u304b\u3089\u8ffd\u52a0\u3055\u308c\u305f\u6a5f\u80fd\u306e\u3053\u3068\u3067\u8907\u6570\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u5206\u5c90\u3055\u305b\u3066\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d<span style=\"color: #ff0000;\"><strong>\u30c6\u30b9\u30c8\u6642\u9593\u3092\u77ed\u7e2e<\/strong><\/span>\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u8a2d\u5b9a<\/h3>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4><strong>test\/test_helper.rb<\/strong><\/h4>\n<pre class=\"lang:default decode:true\">class ActiveSupport::TestCase\r\n  parallelize(workers: :number_of_processors)\r\nend<\/pre>\n<p>\u6709\u52b9\u7121\u52b9\u306e\u5207\u308a\u66ff\u3048\u306f\u4e0a\u8a18\u30b3\u30fc\u30c9\u306b\u3066\u884c\u3044\u307e\u3059\u3002\u300cworkers\u300d\u306b\u6e21\u3059\u5024\u304c2\u4ee5\u4e0a\u306e\u5834\u5408\u306f\u4e26\u5217\u30c6\u30b9\u30c8\u304c\u6709\u52b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h5>:number_of_processors)<\/h5>\n<p>\u4f7f\u7528\u3057\u3066\u3044\u308b\u30de\u30b7\u30f3\u306e\u30b3\u30a2\u6570\u304c\u5165\u308a\u307e\u3059\u3002\u30b3\u30a2\u6570\u3092\u8abf\u3079\u308b\u306b\u306f\u8abf\u3079\u305f\u3044\u30de\u30b7\u30f3\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\uff08\u958b\u767a\u306a\u3069\u3067\u306fdocker\u306a\u3069\u3067\u30b7\u30a7\u30eb\u3067\u5165\u3063\u3066\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u30b1\u30fc\u30b9\u304c\u591a\u3044\u3068\u601d\u3044\u307e\u3059\u3002\uff09<\/p>\n<pre class=\"lang:default decode:true\">nproc<\/pre>\n<h3>\u4ed5\u7d44\u307f<\/h3>\n<p>\u30d7\u30ed\u30bb\u30b9\u6570\u5206\u3060\u3051DB\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002\u300capp_test-0\u300d\u3001\u300capp_test-1\u300d\u306e\u3088\u3046\u306a\u540d\u524d\u306eDB\u304c\u3044\u304f\u3064\u304b\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<h3>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u306e\u6e96\u5099<\/h3>\n<h4>seed\u3092\u6295\u5165\u3057\u305f\u3044\u5834\u5408<\/h4>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">  parallelize_setup do |worker|\r\n    load \"#{Rails.root}\/db\/seeds.rb\"\r\n  end<\/pre>\n<h2>\u30c6\u30b9\u30c8\u3092\u4e26\u5217\u5316\u3055\u305b\u308b\u3002<\/h2>\n<p>RSpec\u3092\u4e26\u5217\u306b\u5b9f\u884c\u3057\u305f\u3044\u5834\u5408\u306f<span style=\"color: #ff0000;\"><strong>\u300cParallelTests\u300d<\/strong><\/span>\u3068\u3044\u3046Gem\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<h3>ParallelTests\u306e\u4ed5\u7d44\u307f<\/h3>\n<ul>\n<li>\u30c6\u30b9\u30c8\u30b9\u30a4\u30fc\u30c8\u304c\u8907\u6570\u306e\u30b3\u30a2\u306b\u5206\u304b\u308c\u308b\u3002<\/li>\n<\/ul>\n<h2>\u30bf\u30b0\u3092\u4f7f\u3046\u3002<\/h2>\n<p>\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u5bfe\u8c61\u3092\u7d5e\u3063\u3066\u30c6\u30b9\u30c8\u6642\u9593\u306b\u304b\u304b\u308b\u6642\u9593\u3092\u6e1b\u3089\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30e2\u30c3\u30af\u3084\u30b9\u30bf\u30d6\u3092\u4f7f\u7528\u3059\u308b\u3002<\/h2>\n<p>DB\u3084\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u7b49\u306e\u5916\u90e8\u30b5\u30fc\u30d3\u30b9\u3068\u306e\u9023\u643a\u306b\u304b\u304b\u308b\u30b3\u30b9\u30c8\u3092\u524a\u6e1b\u3057\u307e\u3059\u3002\u8a73\u3057\u304f\u306f\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"8iPT7gSXjX\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=9784\">\u3010\u30c6\u30b9\u30c8\u3011\u300c\u30e2\u30c3\u30af\u300d\u3068\u300c\u30b9\u30bf\u30d6\u300d\u306b\u3064\u3044\u3066<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=9784&#038;embed=true#?secret=8iPT7gSXjX\" data-secret=\"8iPT7gSXjX\" width=\"500\" height=\"282\" title=\"&#8220;\u3010\u30c6\u30b9\u30c8\u3011\u300c\u30e2\u30c3\u30af\u300d\u3068\u300c\u30b9\u30bf\u30d6\u300d\u306b\u3064\u3044\u3066&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"Rspec\u306e\u30c6\u30b9\u30c8\u3092\u9ad8\u901f\u5316\u3059\u308b\u624b\u6cd5\u3068\u3057\u3066\u306f\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u3002 Rails\u306e\u8d77\u52d5\u3092\u9ad8\u901f\u5316\u3059\u308b\u3002 Rails\u3092\u53d6\u308a\u5916\u3059\u3002 \u30c6\u30b9\u30c8\u3092\u4e26\u5217\u5316\u3055\u305b\u308b\u3002 \u30bf\u30b0\u3092\u4f7f\u3046\u3002 \u30e2\u30c3\u30af\u3084\u30b9\u30bf\u30d6\u3092\u4f7f\u7528\u3059\u308b\u3002 Rails\u306e\u8d77\u52d5\u3092\u9ad8\u901f\u5316\u3059\u308b\u3002 bi [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[82],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/9802"}],"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=9802"}],"version-history":[{"count":8,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/9802\/revisions"}],"predecessor-version":[{"id":19419,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/9802\/revisions\/19419"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9802"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}