Sha256: 394345787818192bcf911b9a68dac26179c5c16262c41635d8cb608770430cb3

Contents?: true

Size: 1.42 KB

Versions: 9

Compression:

Stored size: 1.42 KB

Contents

Rails.env = 'test'
require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
require 'action_controller/test_process'
require 'breakpoint'
require 'ostruct'

class Post
  attr_reader :id, :created_at
  def save; @id = 1; @created_at = Time.now.utc end
  def new_record?; @id.nil? end
  
  [:title, :name].each do |attr_name|
    define_method attr_name do
      "feed title (#{attr_name})"
    end
  end

  [:description, :body].each do |attr_name|
    define_method attr_name do
      "<p>feed description (#{attr_name})</p>"
    end
  end
  
  def create_date
    @created_at - 5.minutes
  end
end

class Test::Unit::TestCase
  include ResourceFeeder::Rss, ResourceFeeder::Atom
  
  def render_feed(xml)
    @response = OpenStruct.new
    @response.headers = {'Content-Type' => 'text/xml'}
    @response.body = xml
  end
  
  def rss_feed_for_with_ostruct(resources, options = {})
    render_feed rss_feed_for_without_ostruct(resources, options)
  end
  
  def atom_feed_for_with_ostruct(resources, options = {})
    render_feed atom_feed_for_without_ostruct(resources, options)
  end
  
  alias_method_chain :rss_feed_for,  :ostruct
  alias_method_chain :atom_feed_for, :ostruct

  def html_document
    @html_document ||= HTML::Document.new(@response.body, false, true)
  end

  def user_posts_url
    "http://example.com/posts"
  end
  
  def user_post_url(post)
    "http://example.com/posts/#{post.id}"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
community_engine-3.0.0 vendor/converted2.3plugins_to_lib_leftovers/resource_feeder/test/test_helper.rb
community_engine-2.3.2 vendor/plugins/resource_feeder/test/test_helper.rb
community_engine-2.3.1 vendor/plugins/resource_feeder/test/test_helper.rb
community_engine-2.3.0 vendor/plugins/resource_feeder/test/test_helper.rb
community_engine-2.1.0 vendor/plugins/resource_feeder/test/test_helper.rb
community_engine-2.0.0 vendor/plugins/resource_feeder/test/test_helper.rb
community_engine-2.0.0.beta3 vendor/plugins/resource_feeder/test/test_helper.rb
community_engine-2.0.0.beta2 vendor/plugins/resource_feeder/test/test_helper.rb
community_engine-2.0.0.beta1 vendor/plugins/resource_feeder/test/test_helper.rb