{"id":6701,"date":"2014-04-08T10:21:14","date_gmt":"2014-04-08T07:21:14","guid":{"rendered":"http:\/\/railsware.com\/blog\/?p=6701"},"modified":"2021-08-12T17:08:38","modified_gmt":"2021-08-12T14:08:38","slug":"pitfalls-of-rspec-boolean-matchers","status":"publish","type":"post","link":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/","title":{"rendered":"Pitfalls of Rspec boolean matchers"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Rspec provides a bunch of build-in matchers. They include matchers that help us work with boolean values. But not always these matchers are safe to use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">be_true and be_false matchers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I guess everybody used <code class=\"\" data-line=\"\">RSpec<\/code> matchers <code class=\"\" data-line=\"\">be_true<\/code> and <code class=\"\" data-line=\"\">be_false<\/code>. There are a few examples with them:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:ruby decode:true\"># be_true examples\nit{ expect(true).to be_true } # passes\n\n# be_false examples\nit{ expect(false).to be_false } # passes\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">but it&#8217;s good to know that the following expectations will also pass:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:ruby decode:true\"># be_true examples\nit{ expect(1).to be_true } # passes with fixnum\nit{ expect(\"string\").to be_true } # passes with string\nit{ expect(:symbol).to be_true } # passes with symbol\nit{ expect(\/pattern\/).to be_true } # passes with regular expression\nit{ expect(Time).to be_true } # passes with class\n\n# be_false examples\nit{ expect(nil).to be_false } # passes\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This happens because <code class=\"\" data-line=\"\">be_true<\/code> and <code class=\"\" data-line=\"\">be_false<\/code> matchers consider <code class=\"\" data-line=\"\">nil<\/code> and <code class=\"\" data-line=\"\">false<\/code> to be <code class=\"\" data-line=\"\">false<\/code> and anything else to be <code class=\"\" data-line=\"\">true<\/code>. To make tighter comparison and avoid potential issues use <code class=\"\" data-line=\"\">eql<\/code> matcher:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:ruby decode:true\"># eql(true) examples\nit{ expect(1).to eql(true) } # fails with fixnum\nit{ expect(\"string\").to eql(true) } # fails with string\nit{ expect(:symbol).to eql(true) } # fails with symbol\nit{ expect(\/pattern\/).to eql(true) } # fails with regular expression\nit{ expect(Time).to eql(true) } # fails with class\n\n# eql(false) examples\nit{ expect(nil).to eql(false) } # fails\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Predicate matchers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code class=\"\" data-line=\"\">Rspec<\/code> provides predicate matchers for each ruby method which ends with &#8216;?&#8217;. For instance, we have a class with method <code class=\"\" data-line=\"\">empty?<\/code> which returns <code class=\"\" data-line=\"\">true<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted &quot;lang:ruby\">Class TestClass\n  def self.empty?\n    true\n  end\nend\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and Rspec file contains:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:ruby decode:true\">it{ expect(TestClass).to be_empty } # passes\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Everything works fine, but let\u2019s do changes in our `empty?` method and return some object instead of `Boolean`:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:ruby decode:true\">Class TestClass\n  def self.empty?\n    'true'\n  end\nend\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and our test still passes even when we return something different from `true`. As `be_true` and `be_false` matchers, predicate matches consider `nil` and `false` to be `false` and anything else to be `true`.<br>To avoid potentials issues with this behaviour we also should make tighter comparison:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:ruby decode:true\">subject{ TestClass.empty? }\n\nit{ should eql(true) } # fails\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">While testing boolean attributes or methods that return boolean value, try to avoid matchers described above.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>UPD<\/strong><br>Since RSpec 3 was released, this article is actual for RSpec 2<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rspec provides a bunch of build-in matchers. They include matchers that help us work with boolean values. But not always these matchers are safe to use. be_true and be_false matchers I guess everybody used RSpec matchers be_true and be_false. There are a few examples with them: # be_true examples it{ expect(true).to be_true } # passes&#8230;<\/p>\n","protected":false},"author":44,"featured_media":9461,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[3],"tags":[],"coauthors":["Olexander Paladiy"],"class_list":["post-6701","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Rspec provides a bunch of build-in matchers. They include matchers that help us work with boolean values. But not always these matchers are safe to use. be_true and be_false matchers I guess everybody used RSpec matchers be_true and be_false. There are a few examples with them: # be_true examples it{ expect(true).to be_true } # passes\" \/>\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"Olexander Paladiy\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"| Blog on Engineering, Product Management, Transparency, Culture and many more...\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Pitfalls of Rspec boolean matchers | Railsware Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Rspec provides a bunch of build-in matchers. They include matchers that help us work with boolean values. But not always these matchers are safe to use. be_true and be_false matchers I guess everybody used RSpec matchers be_true and be_false. There are a few examples with them: # be_true examples it{ expect(true).to be_true } # passes\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Pitfalls-of-Rspec.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Pitfalls-of-Rspec.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"360\" \/>\n\t\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2014-04-08T07:21:14+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2021-08-12T14:08:38+00:00\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#article\",\"name\":\"Pitfalls of Rspec boolean matchers | Railsware Blog\",\"headline\":\"Pitfalls of Rspec boolean matchers\",\"author\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/olexander-paladiy\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/12\\\/Pitfalls-of-Rspec.png\",\"width\":360,\"height\":360,\"caption\":\"Pitfalls of Rspec boolean matchers\"},\"datePublished\":\"2014-04-08T10:21:14+03:00\",\"dateModified\":\"2021-08-12T17:08:38+03:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#webpage\"},\"articleSection\":\"Engineering\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/railsware.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"name\":\"Engineering\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"position\":2,\"name\":\"Engineering\",\"item\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#listItem\",\"name\":\"Pitfalls of Rspec boolean matchers\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#listItem\",\"position\":3,\"name\":\"Pitfalls of Rspec boolean matchers\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"name\":\"Engineering\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\",\"description\":\"Blog on Engineering, Product Management, Transparency, Culture and many more...\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/Logo-circle.png\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#organizationLogo\",\"width\":3137,\"height\":1054,\"caption\":\"Railsware logo\"},\"image\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/olexander-paladiy\\\/#author\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/olexander-paladiy\\\/\",\"name\":\"Olexander Paladiy\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#authorImage\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/olexander-paladiy-96x96.jpg\",\"width\":96,\"height\":96,\"caption\":\"Olexander Paladiy\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#webpage\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/\",\"name\":\"Pitfalls of Rspec boolean matchers | Railsware Blog\",\"description\":\"Rspec provides a bunch of build-in matchers. They include matchers that help us work with boolean values. But not always these matchers are safe to use. be_true and be_false matchers I guess everybody used RSpec matchers be_true and be_false. There are a few examples with them: # be_true examples it{ expect(true).to be_true } # passes\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/olexander-paladiy\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/olexander-paladiy\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/12\\\/Pitfalls-of-Rspec.png\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#mainImage\",\"width\":360,\"height\":360,\"caption\":\"Pitfalls of Rspec boolean matchers\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/pitfalls-of-rspec-boolean-matchers\\\/#mainImage\"},\"datePublished\":\"2014-04-08T10:21:14+03:00\",\"dateModified\":\"2021-08-12T17:08:38+03:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/\",\"description\":\"Blog on Engineering, Product Management, Transparency, Culture and many more...\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Pitfalls of Rspec boolean matchers | Railsware Blog","description":"Rspec provides a bunch of build-in matchers. They include matchers that help us work with boolean values. But not always these matchers are safe to use. be_true and be_false matchers I guess everybody used RSpec matchers be_true and be_false. There are a few examples with them: # be_true examples it{ expect(true).to be_true } # passes","canonical_url":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#article","name":"Pitfalls of Rspec boolean matchers | Railsware Blog","headline":"Pitfalls of Rspec boolean matchers","author":{"@id":"https:\/\/railsware.com\/blog\/author\/olexander-paladiy\/#author"},"publisher":{"@id":"https:\/\/railsware.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Pitfalls-of-Rspec.png","width":360,"height":360,"caption":"Pitfalls of Rspec boolean matchers"},"datePublished":"2014-04-08T10:21:14+03:00","dateModified":"2021-08-12T17:08:38+03:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#webpage"},"isPartOf":{"@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#webpage"},"articleSection":"Engineering"},{"@type":"BreadcrumbList","@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/railsware.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","name":"Engineering"}},{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","position":2,"name":"Engineering","item":"https:\/\/railsware.com\/blog\/category\/development\/","nextItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#listItem","name":"Pitfalls of Rspec boolean matchers"},"previousItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#listItem","position":3,"name":"Pitfalls of Rspec boolean matchers","previousItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","name":"Engineering"}}]},{"@type":"Organization","@id":"https:\/\/railsware.com\/blog\/#organization","description":"Blog on Engineering, Product Management, Transparency, Culture and many more...","url":"https:\/\/railsware.com\/blog\/","logo":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2020\/11\/Logo-circle.png","@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#organizationLogo","width":3137,"height":1054,"caption":"Railsware logo"},"image":{"@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/railsware.com\/blog\/author\/olexander-paladiy\/#author","url":"https:\/\/railsware.com\/blog\/author\/olexander-paladiy\/","name":"Olexander Paladiy","image":{"@type":"ImageObject","@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#authorImage","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2021\/06\/olexander-paladiy-96x96.jpg","width":96,"height":96,"caption":"Olexander Paladiy"}},{"@type":"WebPage","@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#webpage","url":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/","name":"Pitfalls of Rspec boolean matchers | Railsware Blog","description":"Rspec provides a bunch of build-in matchers. They include matchers that help us work with boolean values. But not always these matchers are safe to use. be_true and be_false matchers I guess everybody used RSpec matchers be_true and be_false. There are a few examples with them: # be_true examples it{ expect(true).to be_true } # passes","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/railsware.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#breadcrumblist"},"author":{"@id":"https:\/\/railsware.com\/blog\/author\/olexander-paladiy\/#author"},"creator":{"@id":"https:\/\/railsware.com\/blog\/author\/olexander-paladiy\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Pitfalls-of-Rspec.png","@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#mainImage","width":360,"height":360,"caption":"Pitfalls of Rspec boolean matchers"},"primaryImageOfPage":{"@id":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/#mainImage"},"datePublished":"2014-04-08T10:21:14+03:00","dateModified":"2021-08-12T17:08:38+03:00"},{"@type":"WebSite","@id":"https:\/\/railsware.com\/blog\/#website","url":"https:\/\/railsware.com\/blog\/","description":"Blog on Engineering, Product Management, Transparency, Culture and many more...","inLanguage":"en-US","publisher":{"@id":"https:\/\/railsware.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"| Blog on Engineering, Product Management, Transparency, Culture and many more...","og:type":"article","og:title":"Pitfalls of Rspec boolean matchers | Railsware Blog","og:description":"Rspec provides a bunch of build-in matchers. They include matchers that help us work with boolean values. But not always these matchers are safe to use. be_true and be_false matchers I guess everybody used RSpec matchers be_true and be_false. There are a few examples with them: # be_true examples it{ expect(true).to be_true } # passes","og:url":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/","og:image":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Pitfalls-of-Rspec.png","og:image:secure_url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Pitfalls-of-Rspec.png","og:image:width":360,"og:image:height":360,"article:published_time":"2014-04-08T07:21:14+00:00","article:modified_time":"2021-08-12T14:08:38+00:00"},"aioseo_meta_data":{"post_id":"6701","title":null,"description":null,"keywords":[],"keyphrases":{"focus":[],"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":{"id":"aioseo-article-6385f5b1b5825","slug":"article","graphName":"Article","label":"Article","properties":{"type":"BlogPosting","name":"#post_title","headline":"#post_title","description":"#post_excerpt","image":"","keywords":"","author":{"name":"#author_name","url":"#author_url"},"dates":{"include":true,"datePublished":"","dateModified":""}}},"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","location":null,"local_seo":{"locations":{"business":{"name":"","businessType":"","image":"","areaServed":"","urls":{"website":"","aboutPage":"","contactPage":""},"address":{"streetLine1":"","streetLine2":"","zipCode":"","city":"","state":"","country":"","addressFormat":"#streetLineOne\n#streetLineTwo\n#city, #state #zipCode"},"contact":{"email":"","phone":"","phoneFormatted":"","fax":"","faxFormatted":""},"ids":{"vat":"","tax":"","chamberOfCommerce":""},"payment":{"priceRange":"","currenciesAccepted":"","methods":""}}},"openingHours":{"useDefaults":true,"show":true,"alwaysOpen":false,"use24hFormat":false,"timezone":"","labels":{"closed":"","alwaysOpen":""},"days":{"monday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"tuesday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"wednesday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"thursday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"friday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"saturday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"sunday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"}}}},"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-01-04 12:44:29","updated":"2025-09-26 11:20:39","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/railsware.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/railsware.com\/blog\/category\/development\/\" title=\"Engineering\">Engineering<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tPitfalls of Rspec boolean matchers\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/railsware.com\/blog"},{"label":"Engineering","link":"https:\/\/railsware.com\/blog\/category\/development\/"},{"label":"Pitfalls of Rspec boolean matchers","link":"https:\/\/railsware.com\/blog\/pitfalls-of-rspec-boolean-matchers\/"}],"reading_time":"2 min read","categories_data":[{"name":"Engineering","link":"https:\/\/railsware.com\/blog?category=development"}],"post_thumbnails":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/Pitfalls-of-Rspec.png","article_background":"","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/6701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/comments?post=6701"}],"version-history":[{"count":28,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/6701\/revisions"}],"predecessor-version":[{"id":13998,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/6701\/revisions\/13998"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media\/9461"}],"wp:attachment":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media?parent=6701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/categories?post=6701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/tags?post=6701"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/coauthors?post=6701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}