Sha256: de80150f76d4ab630d34eafa8180500e85be6037f8c61e9f748aaf53356f1a90

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mr_video-1.0.1 spec/controllers/video_store/episodes_controller_spec.rb
mr_video-1.0.0 spec/controllers/video_store/episodes_controller_spec.rb