Created
March 7, 2012 15:04
-
-
Save vmu9999/1993681 to your computer and use it in GitHub Desktop.
Mocha functional tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => '[email protected]', | |
:password => "telvue", | |
:first_name => 'TelVue', | |
:last_name => 'User', | |
:email2 => '[email protected]', | |
: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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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