Skip to content

Instantly share code, notes, and snippets.

@thiagoramos23
Created October 23, 2014 10:04
Show Gist options
  • Save thiagoramos23/9076b7eab250b42d894a to your computer and use it in GitHub Desktop.
Save thiagoramos23/9076b7eab250b42d894a to your computer and use it in GitHub Desktop.
Index action Spec
require 'rails_helper'
RSpec.describe Admin::ResidencesController do
let(:user) { build_stubbed(:user) }
let(:residence_101) { build_stubbed(:residence) }
let(:residence_102) { build_stubbed(:residence) }
context 'Valid User' do
before {
sign_in user
setup
}
describe "#index" do
let(:setup) { allow(Residence).to receive(:all) { [residence_101, residence_102] } }
before {
get :index
}
it_behaves_like "renderable action", :index
it "assigns @residences to result of calling all on Residence" do
expect(assigns(:residences)).to eq([residence_101, residence_102])
end
end
end
include_context 'redirect to sign in' do
let(:before_action) { get :index }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment