[rspec-users] Rspec for this class

umair iqbal lists at ruby-forum.com
Sun Jan 8 15:18:00 EST 2012


Hi All
I am new to rspec. How can I write specs for this class
Anyone please provide me the detail specs for this class
thanks

module Sitemap
  class Job

    def initialize(country_version, directory, country_host)
      @country_version = country_version
      @directory = directory
      @country_host = country_host
      @locale = country_version.name
    end

    def get_data
      ::Function.find_each(:conditions => {:country_version_id =>
@country_version.id}) do |function|
        ::Job.find_each(:conditions => {:country_version_id =>
@country_version.id, :function_id => function.id}) do |job|
          I18n.locale=(@locale)
          yield entry(job)
        end
      end
    end

    private
    def entry(job)
      {
        :loc =>
ActionController::Integration::Session.new.url_for(:controller =>
'jobs', :action => 'show', :title_urlified_with_job_ref_id =>
job.title_urlified + "-" + job.id.to_s, :host => @country_host.value),
        :changefreq => 0.8,
        :priority => 'monthly',
        :lastmod => job.updated_at
      }
    end
  end
end

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list