{"id":4898,"date":"2022-02-15T10:48:49","date_gmt":"2022-02-15T01:48:49","guid":{"rendered":"https:\/\/suzutukiblog.com\/?p=4898"},"modified":"2022-02-15T11:21:28","modified_gmt":"2022-02-15T02:21:28","slug":"rspec-7","status":"publish","type":"post","link":"https:\/\/suzutukiblog.com\/index.php\/2022\/02\/15\/rspec-7\/","title":{"rendered":"RSpec\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<h3>RSpec\u3092\u4f7f\u3044\u305f\u3044\u6642\u306b\u898b\u308b\u8a18\u4e8b<\/h3>\n<h3>1:Gemfile\u306b\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/h3>\n<pre>source 'https:\/\/rubygems.org'\r\ngit_source(:github) { |repo| \"https:\/\/github.com\/#{repo}.git\" }\r\n\r\n:\r\n(\u7701\u7565)\r\n:\r\n\r\n<strong>group :development, :test do<\/strong>\r\n# Call 'byebug' anywhere in the code to stop execution and get a debugger console\r\ngem 'byebug', platforms: [:mri, :mingw, :x64_mingw]\r\n\r\n<strong># \u8ffd\u52a0<\/strong>\r\n<strong>gem 'rspec-rails', '~&gt; 3.8'<\/strong>\r\n<strong>gem 'factory_bot_rails', '~&gt; 5.0'<\/strong>\r\n\r\n\r\nend\r\n\r\ngroup :development do\r\n\r\n:\r\n(\u7701\u7565)\r\n:\r\n\r\nend\r\n\r\n# Windows does not include zoneinfo files, so bundle the tzinfo-data gem\r\ngem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]<\/pre>\n<p>Gem\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre>\u00a0bundle install<\/pre>\n<h3>2. \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/h3>\n<p>RSpec\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre>bundle exec rspec --version<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5b9f\u884c\u7d50\u679c\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>bundle exec rspec --version\r\nRSpec 3.8\r\n- rspec-core 3.8.2\r\n- rspec-expectations 3.8.4\r\n- rspec-mocks 3.8.1\r\n- rspec-rails 3.8.2\r\n- rspec-support 3.8.2<\/pre>\n<p>FactoryBot\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<pre>bundle exec gem list | grep factory_bot_rails<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5b9f\u884c\u7d50\u679c\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>bundle exec gem list | grep factory_bot_rails\r\nfactory_bot_rails (5.0.2)<\/pre>\n<h3>3. \u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u3067RSpec\u3092\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/h3>\n<p>\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306bRSpec\u3092\u5c0e\u5165\u3057\u307e\u3059\u3002<\/p>\n<pre>rails generate rspec:install<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<pre>\u30a2\u30d7\u30ea\u540d\r\n\u2514\u2500\u2500 spec\r\n\u251c\u2500\u2500 rails_helper.rb\r\n\u2514\u2500\u2500 spec_helper.rb<\/pre>\n<p>\u30c6\u30b9\u30c8\u7528\u306eDB\u3092\u6700\u65b0\u306e\u69cb\u6210\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>rails db:migrate:reset RAILS_ENV=test<\/pre>\n<p>\u30c6\u30b9\u30c8\u7528\u306eDB\u3068\u306f\u81ea\u52d5\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3068\u304d\u306b\u5229\u7528\u3059\u308b\u5c02\u7528\u306eDB\u3067\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u81ea\u52d5\u30c6\u30b9\u30c8\u3067\u300c\u5168\u30c7\u30fc\u30bf\u304c\u6d88\u3048\u308b\u3053\u3068\u300d\u3092\u78ba\u8a8d\u3059\u308b\u3068\u304d\u3001<br \/>\n\u958b\u767a\u4e2d\u306b\u5229\u7528\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u304c\u6d88\u3048\u3066\u3057\u307e\u3063\u3066\u306f\u56f0\u308a\u307e\u3059\u3002<\/p>\n<p>\u958b\u767a\u4e2d\u306e\u30c7\u30fc\u30bf\u3068\u81ea\u52d5\u30c6\u30b9\u30c8\u7528\u306e\u30c7\u30fc\u30bf\u3092\u5206\u96e2\u3057\u3066\u8003\u3048\u308b\u3053\u3068\u3067\u3001\u53cc\u65b9\u304c\u5e72\u6e09\u3057\u306a\u3044\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RSpec\u3092\u4f7f\u3044\u305f\u3044\u6642\u306b\u898b\u308b\u8a18\u4e8b 1:Gemfile\u306b\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002 source &#8216;https:\/\/rubygems.org&#8217; git_source(:github) { |repo| &#8220;https:\/\/g [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[27,34],"tags":[],"class_list":["post-4898","post","type-post","status-publish","format-standard","hentry","category-programming-note","category-rspec"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/4898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=4898"}],"version-history":[{"count":7,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/4898\/revisions"}],"predecessor-version":[{"id":4905,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/4898\/revisions\/4905"}],"wp:attachment":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=4898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=4898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=4898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}