Created
April 1, 2014 04:54
RABL testing example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CardsController < ApplicationController | |
respond_to :json | |
def index | |
@cards = Card.all | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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