profile_helper_test.rb
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require File.dirname(__FILE__) + '/../test_helper'
class ProfileHelperTest < Test::Unit::TestCase
def setup
@profile = mock
@helper = mock
helper.extend(ProfileHelper)
end
attr_reader :profile, :helper
def test_should_ignore_nil
profile.expects(:info).returns(nil)
helper.expects(:content_tag)
helper.expects(:_)
helper.display_profile_info(profile)
end
def test_should_display_info
f1 = 'Field 1'
v1 = 'value 1'
f2 = 'Field 2'
v2 = 'value 2'
array = [
[ f1, v1 ],
[ f2, v2 ]
]
info = mock
info.expects(:summary).returns(array)
profile.stubs(:info).returns(info)
helper.expects(:content_tag).returns('').at_least_once
helper.expects(:_).with('edit your information').returns('edit your information')
helper.expects(:button).with(:edit, 'edit your information', :controller => 'profile_editor', :action => 'edit').returns("BUTTON")
helper.display_profile_info(profile)
end
def test_should_call_blocks
myproc = lambda { content_tag('div', 'lalala') }
info = mock
info.expects(:summary).returns([['f1', myproc ]])
profile.stubs(:info).returns(info)
helper.stubs(:content_tag).returns('')
helper.expects(:instance_eval).with(myproc)
helper.expects(:_)
helper.expects(:button).returns('')
helper.display_profile_info(profile)
end
end