Skip to content

Instantly share code, notes, and snippets.

@vmu9999
Created March 7, 2012 15:04
Show Gist options
  • Save vmu9999/1993681 to your computer and use it in GitHub Desktop.
Save vmu9999/1993681 to your computer and use it in GitHub Desktop.
Mocha functional tests
xml.rss('xmlns:itunes' => "http://www.itunes.com/dtds/podcast-1.0.dtd", "version" => "2.0") do
if @channel
xml.channel do
xml.title @channel.organization
xml.link player_url(@channel)
xml.description @channel.description
xml.tag! 'itunes:author', @channel.organization
xml.tag! 'itunes:summary', @channel.description
xml.itunes:owner do
xml.tag! 'itunes:name', @channel.organization
xml.tag! 'itunes:email', @channel.email
end
@channel.published_content_files.each do |cf|
xml.item do
xml.title cf.name
xml.link mrss_link(cf).blank? ? video_player_url(cf) : mrss_link(cf)
xml.tag! :title, cf.name
xml.tag! :description, non_default_description(cf)
xml.tag! 'itunes:author', @channel.organization
xml.tag! 'itunes:summary', non_default_description(cf)
xml.tag! 'image', video_thumbnail_url(cf)
xml.tag! 'guid', vod_path(cf)
xml.tag! 'pubDate', cf.created_at
xml.tag! 'enclosure', {:url=>vod_path(cf), :length=>cf.actual_duration, :type=>"video/mp4"}
end
end
end
end
end
class MrssController < ApplicationController
skip_before_filter :login_required
def index
@channel = User.mrss_published_by_username(params[:username])
@height = params[:height] || 480
@width = params[:width] || 640
if params[:itunes]
respond_to do |format|
format.html { render 'itunes', :layout => false }
end
else
respond_to do |format|
format.xml { render :layout => false }
end
end
end
end
require 'test_helper'
require 'mocha'
class MrssControllerTest < ActionController::TestCase
def test_index
username = 'psguser'
@channel = stub( :id => '1',
:organization => 'Telvue',
:username => username,
:description => 'This is a test description.',
:email => 'Telvuetest@telvue.com',
:password => "telvue",
:first_name => 'TelVue',
:last_name => 'User',
:email2 => 'Telvuetest2@telvue.com',
:status => "AVAILABLE",
:created_at => '2012-02-23 19:01:22' ,
:updated_at => '2012-02-23 19:01:22',
:address_1 => '1600 Horizon Way',
:address_2 => 'Suite 600',
:city => 'Mt.Laurel',
:state_code => 'NJ',
:postal_code => '08032',
:country_code => 'USA',
:zip4 => nil,
:phone => '6675309',
:ecommerce => '1',
:ion_key => 'nil' )
User.expects(:mrss_published_by_username).with(@channel.username).returns(@channel)
response = get :index, :username => username
puts response.inspect
#assert_equal true, false
end
end
1) Error:
test_index(MrssControllerTest):
ActionView::MissingTemplate: Missing template mrss/index.erb in view path app/views
app/controllers/mrss_controller.rb:15:in `index'
app/controllers/mrss_controller.rb:14:in `index'
/test/functional/mrss_controller_test.rb:32:in `test_index'
1 tests, 0 assertions, 0 failures, 1 errors
rake aborted!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment