Last active
August 29, 2015 13:56
-
-
Save nbomberger/9138914 to your computer and use it in GitHub Desktop.
Simple example of shared_examples in Rspec. Put the _shared in your support folder. Example creates a context where you have access to a logged in user.
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
# encoding: UTF-8 | |
require 'spec_helper' | |
describe 'Category JSON Spec', focus: :true do | |
include_examples 'a logged in user' | |
describe 'Someaction#index' do | |
before(:each) { FactoryGirl.create_list(:category, 5) } | |
subject(:response) do | |
# you have access to the @user var | |
end | |
it 'returns a list of categories' do | |
pending('Currently in testing branch') | |
# json[:categories].to_json.should have_json_size(5) | |
end | |
end | |
describe 'Categories#show' do | |
let(:category) { FactoryGirl.create(:category) } | |
subject(:response) do | |
get "/some/get/request", | |
format: :json | |
end | |
let(:valid_json) do | |
{ | |
category: { | |
id: category.id, | |
name: category.name, | |
icon_class: category.icon_class, | |
providers: category.providers | |
} | |
}.to_json | |
end | |
it 'returns the category as] json' do | |
binding.pry | |
# pending('Currently in testing branch') | |
# response.body.should have_json_path('category') | |
# response.body.should be_json_eql(valid_json) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment