<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by David Van Der Beek on Medium]]></title>
        <description><![CDATA[Stories by David Van Der Beek on Medium]]></description>
        <link>https://medium.com/@dvanderbeek?source=rss-cce38289ba0d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*8haElWq68XisGzwq.jpg</url>
            <title>Stories by David Van Der Beek on Medium</title>
            <link>https://medium.com/@dvanderbeek?source=rss-cce38289ba0d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 02:03:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dvanderbeek/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Testing a Rails API with RSpec and Devise]]></title>
            <link>https://medium.com/@dvanderbeek/testing-a-rails-api-with-rspec-and-devise-9df0ae09bcac?source=rss-cce38289ba0d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9df0ae09bcac</guid>
            <dc:creator><![CDATA[David Van Der Beek]]></dc:creator>
            <pubDate>Sat, 16 Aug 2014 13:22:29 GMT</pubDate>
            <atom:updated>2014-08-16T13:22:40.647Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I was trying to build a simple API endpoint for a rails app. I was trying to use jquery-tokeninput to create a form field for a model that was using acts-as-taggable-on. To handle the autocomplete, I felt like it would be cleaner to set up a new controller action that had a single purpose: handle JSON requests for a list of tags. So, I created my api/tags_controller.rb and added the code to find the relevant tags and installed the jquery-tokeninput plugin.</p><p>Everything worked great until I decided I should write some tests for the API endpoint. I found some articles online recommending request specs for testing API’s, which seemed to make a lot of sense. Straightforward, right? I just need to write a spec that hits the API endpoint and make sure it gets back the tags I expect in the JSON response.</p><p>I wrote my test and…it failed. Instead of a successful response, I was being redirected. Devise wanted a user to be signed in. So I searched StackOverflow and blogs across the internet. Most of them told me to set up a support file with a login function. Something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20cd2236bed5a76d6b063206d8c02541/href">https://medium.com/media/20cd2236bed5a76d6b063206d8c02541/href</a></iframe><p>The blog post and stack overflow both warned me that this was outdated, but there were no clear instructions on the correct way to handle this problem, so I tried it anyway…to no avail.</p><p>Finally, I managed to find the information I needed on the devise wiki. The article sounds like it’s talking about feature specs since it includes “Capybara” in the title, but this does work in my request specs:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c84a09368f34c4af1ca2218fecd0f6e/href">https://medium.com/media/2c84a09368f34c4af1ca2218fecd0f6e/href</a></iframe><p>Simple, but surprisingly hard to find information!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9df0ae09bcac" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>