{"id":1820,"date":"2013-11-14T23:55:21","date_gmt":"2013-11-15T04:55:21","guid":{"rendered":"http:\/\/www.rexfeng.com\/blog\/?p=1820"},"modified":"2013-11-14T23:55:21","modified_gmt":"2013-11-15T04:55:21","slug":"misc-rails-integration-test-tips","status":"publish","type":"post","link":"https:\/\/www.rexfeng.com\/blog\/2013\/11\/misc-rails-integration-test-tips\/","title":{"rendered":"Misc Rails Integration Test Tips"},"content":{"rendered":"<p>I attended an <a href=\"http:\/\/www.meetup.com\/Automated-Testing-NYC\/\">Automated Testing meetup<\/a> yesterday. In my experience, integration tests turn your speedy test suite into a slowpoke. Here are some different tips and gems to consider using in your tests:<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/railsware\/rack_session_access\">rack_session_access<\/a> Gem<br \/>\nInstead of making a user log in with capybara, why not set the user_id in the session. This gem sounds amazing.<\/li>\n<li><a href=\"https:\/\/github.com\/jeffkreeftmeijer\/fuubar\">fuubar<\/a> Gem<br \/>\nAnother way to format your test results. Perhaps you&#8217;d like to use a progress slider.<\/li>\n<li><a href=\"https:\/\/github.com\/y310\/rspec-retry\">rspec-retry<\/a> Gem<br \/>\nIf a test does not pass on the first try, you can run it again until it passes. This feels like a code smell. In the meetup, the speaker mentioned that they were running their tests against live web requests (instead of pre-recorded requests).<\/li>\n<li><a href=\"http:\/\/martinfowler.com\/bliki\/PageObject.html\">Page Objects<\/a><br \/>\nCapybara syntax seems\u00a0procedural since you are telling it to visit a path and click on things. With page objects, you can have DRY code that abstracts away all the step by step page interactions with something like [cci]ProjectPageObject.create[\/cci]<\/li>\n<li><a href=\"https:\/\/www.relishapp.com\/rspec\/rspec-rails\/v\/2-1\/docs\/view-specs\/view-spec\">View Tests<\/a><br \/>\nInstead of doing full blown integration (feature) testing that uses a browser, you can try view tests that assert things are found on your page.<\/li>\n<\/ul>\n<p>Hopefully you can use some of these tips to improve your test suite.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I attended an Automated Testing meetup yesterday. In my experience, integration tests turn your speedy test suite into a slowpoke. Here are some different tips and gems to consider using in your tests: rack_session_access Gem Instead of making a user log in with capybara, why not set the user_id in the session. This gem sounds [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1029],"tags":[1097,1095,1093,1094,1091,1096,1092],"class_list":["post-1820","post","type-post","status-publish","format-standard","hentry","category-programming","tag-capybara","tag-gem","tag-integration","tag-rails","tag-rspec","tag-tdd","tag-tests"],"_links":{"self":[{"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/posts\/1820","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/comments?post=1820"}],"version-history":[{"count":4,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/posts\/1820\/revisions"}],"predecessor-version":[{"id":1824,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/posts\/1820\/revisions\/1824"}],"wp:attachment":[{"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/media?parent=1820"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/categories?post=1820"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rexfeng.com\/blog\/wp-json\/wp\/v2\/tags?post=1820"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}