[rspec-users] Rspec for this class

7 views
Skip to first unread message

umair iqbal

unread,
Jan 8, 2012, 3:18:00 PM1/8/12
to rspec...@rubyforge.org
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/.
_______________________________________________
rspec-users mailing list
rspec...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

aslak hellesoy

unread,
Jan 8, 2012, 4:51:41 PM1/8/12
to rspec...@rubyforge.org
On Sun, Jan 8, 2012 at 8:18 PM, umair iqbal <li...@ruby-forum.com> wrote:
> 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
>

Start by asking yourself what this class does. Then try to come up
with an example. Then, think about what the initial state of this
example is, what happens and what you expect the end result/state to
be.

Now, implement that in a spec.

If all of this sounds hard, there is a more detailed description in
http://pragprog.com/book/achbd/the-rspec-book

Aslak

Reply all
Reply to author
Forward
0 new messages