Skip to content

Instantly share code, notes, and snippets.

@thiagoramos23
Created October 23, 2014 10:05
Show Gist options
  • Save thiagoramos23/3603bd98250642cc7f94 to your computer and use it in GitHub Desktop.
Save thiagoramos23/3603bd98250642cc7f94 to your computer and use it in GitHub Desktop.
Destroy Residence Spec
require 'rails_helper'
RSpec.describe Admin::ResidencesController do
let(:setup) {}
let(:user) { double('user') }
let(:residence_101) { build_stubbed(:residence) }
context "Valid User" do
before {
sign_in user
setup
}
describe "#destroy" do
before {
delete :destroy, id: residence_101.id
}
context "with existing entity" do
let(:setup) {
allow(Residence).to receive(:find).with(residence_101.id.to_s).and_return(residence_101)
allow(residence_101).to receive(:destroy).and_return(true)
allow(residence_101).to receive(:destroyed?).and_return(true)
}
it_behaves_like "redirectable action", "index action for @residences" do
let(:path) { admin_residences_path }
end
it "calls destroy on Residence" do
expect(residence_101).to be_destroyed
end
end
end
end
include_context 'redirect to sign in' do
let(:before_action) { delete :destroy, id: residence_101.id }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment