helpers spec references

0 views
Skip to first unread message

rake drop all

unread,
Jun 26, 2008, 2:57:28 AM6/26/08
to rubyonra...@googlegroups.com, peep...@googlegroups.com
I saw very minimum helpers spec references on the net unless one video I
saw on peepcode that contains one chapter talking about helpers spec,
well the example there showed us how to stub and then should receive
from session, model, but no example to show how to do should receive
plain html, like so:

layout view:

<%= top_title %>

application helper:

def top_title
content_tag(:h1, 'Top Title')
end

helper spec:

require File.dirname(__FILE__) + '/../spec_helper'

describe ApplicationHelper do
describe 'top_title' do
top_title = mock('top_title')
self.should_receive(:top_title).and_return('Top Title')
end
end

error.. I've no idea how to do this. Please help me, I would appreciate
anyone who can give me a solution. Thanks!

Michael

unread,
Jun 26, 2008, 2:39:18 PM6/26/08
to Ruby on Rails: Talk
With rspec 1.1.4:

describe ApplicationHelper, "top_title" do
it "should return 'Top Title' in an h1" do
helper.top_title.should have_tag("h1", "Top Title")
end
end
Reply all
Reply to author
Forward
0 new messages