Skip to content

Instantly share code, notes, and snippets.

@imogenkinsman
Created April 1, 2014 04:54
Show Gist options
  • Save imogenkinsman/9907931 to your computer and use it in GitHub Desktop.
Save imogenkinsman/9907931 to your computer and use it in GitHub Desktop.
RABL testing example
class CardsController < ApplicationController
respond_to :json
def index
@cards = Card.all
end
end
require 'spec_helper'
describe CardsController do
render_views
describe 'GET #index' do
it 'populates an array of cards' do
card = create(:card)
get :index, format: :json
expect(response).to be_success
expect(JSON.parse(response.body).first["card"]["name"]).to eq "angry chicken"
end
end
end
collection @cards
cache @cards
attributes :name, :image_id, :image_url, :cost, :hero_id, :rarity, :type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment