require 'rails_helper' describe MrVideo::EpisodesController do routes { MrVideo::Engine.routes } render_views describe '#show' do let(:cassette) { MrVideo::Cassette.find('bell_house')} let(:cassette_id) { cassette.id } let(:id) { cassette.episodes[0].id } let(:params) { { cassette_id: cassette_id, id: id } } let(:show) { get(:show, params) } subject { show } before do show end it { should be_success } end describe '#destroy' do let(:cassette_id) { 'bell_house' } let(:id) { 0 } let(:params) { { cassette_id: cassette_id, id: id } } let(:cassette) { double(:cassette) } let(:episode) { double(:episode, id: id) } let(:destroy) { xhr(:post, :destroy, params) } subject { destroy } before do expect(MrVideo::Cassette).to receive(:find).with(cassette_id) { cassette } expect(cassette).to receive(:find_episode_by_id).with(id.to_s) { episode } allow(episode).to receive(:destroy) destroy end it { should be_success } it 'should destroy the episode' do expect(episode).to have_received(:destroy) end end # #destroy end # MrVideo::EpisodesController