{"id":28,"date":"2023-08-17T14:34:18","date_gmt":"2023-08-17T14:34:18","guid":{"rendered":"http:\/\/tenminutetutorial.com\/?p=28"},"modified":"2023-08-17T14:34:18","modified_gmt":"2023-08-17T14:34:18","slug":"tdd-process-in-rails","status":"publish","type":"post","link":"http:\/\/tenminutetutorial.com\/index.php\/2023\/08\/17\/tdd-process-in-rails\/","title":{"rendered":"TDD process in Rails"},"content":{"rendered":"\n<p>(Red, Green, Refactor) <\/p>\n\n\n\n<p>We wrote the test first, then fixed each subsequent failure(red), running the test again after each step, until it works (green).<\/p>\n\n\n\n<ol><li>Write test first<ul><li>test &#8220;should get about&#8221; do<br>get static_pages_about_url<br>assert_response :success<br>end<\/li><li><strong>ERROR:<\/strong> NameError: undefined local variable or method `static_pages_about_url&#8217; for<\/li><\/ul><\/li><li>Add route for about in config\/routes.rb<ul><li>get &#8216;static_pages\/about&#8217;<\/li><li><strong>ERROR: <\/strong>AbstractController::ActionNotFound: The action &#8216;about&#8217; could not be found for<\/li><\/ul><\/li><li>Add action to the controller in static_pages_controller.rb<ul><li>def about<\/li><li>end<\/li><li><strong>ERROR:<\/strong> ActionController::MissingExactTemplate: StaticPagesController#about is missing a template for request formats: text\/html<\/li><\/ul><\/li><li>Create app\/views\/static_pages\/about.html.erb file<\/li><li>run &#8216;rails test&#8217; again<ul><li>3 runs, 3 assertions, 0 failures, 0 errors, 0 skips<\/li><\/ul><\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>(Red, Green, Refactor) We wrote the test first, then fixed each subsequent failure(red), running the test again after each step, until it works (green). Write test first test &#8220;should get about&#8221; doget static_pages_about_urlassert_response :successend ERROR: NameError: undefined local variable or method `static_pages_about_url&#8217; for Add route for about in config\/routes.rb get &#8216;static_pages\/about&#8217; ERROR: AbstractController::ActionNotFound: The action&hellip; <a class=\"more-link\" href=\"http:\/\/tenminutetutorial.com\/index.php\/2023\/08\/17\/tdd-process-in-rails\/\">Continue reading <span class=\"screen-reader-text\">TDD process in Rails<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,2],"tags":[],"_links":{"self":[{"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/posts\/28"}],"collection":[{"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/comments?post=28"}],"version-history":[{"count":1,"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/posts\/28\/revisions"}],"predecessor-version":[{"id":29,"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/posts\/28\/revisions\/29"}],"wp:attachment":[{"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/media?parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/categories?post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/tenminutetutorial.com\/index.php\/wp-json\/wp\/v2\/tags?post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}