Skip to content

Instantly share code, notes, and snippets.

@jwieringa
Forked from cupakromer/gist:7120458
Created October 23, 2013 15:06
Show Gist options
  • Save jwieringa/7120515 to your computer and use it in GitHub Desktop.
Save jwieringa/7120515 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe DashboardController do
include Factories::Godzilla
shared_examples "successfully gets the session cards" do
it "is successful" do
get :session_cards
expect(response).to be_success
end
it "renders no layout" do
get :session_cards
expect(response).to have_rendered layout: false
end
it "renders the card template" do
get :session_cards
expect(response).to have_rendered :session_cards
end
end
context "with no active sessions" do
before do
allow(DeviceSession).to receive(:active_by_company).and_return({})
end
has_behavior "successfully gets the session cards" do
it "assigns no company sessions" do
get :session_cards
expect(assigns(:company_sessions)).to eq Hash.new
end
end
end
context "with active sessions" do
let(:active) { double(Hash) }
before do
allow(DeviceSession).to receive(:active_by_company).and_return(active)
end
has_behavior "successfully gets the session cards" do
it "assigns no company sessions" do
get :session_cards
expect(assigns(:company_sessions)).to eq active
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment