lightbox_helper_test.rb
2.74 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
59
60
61
62
63
64
65
require File.dirname(__FILE__) + '/../test_helper'
class LightboxHelperTest < ActiveSupport::TestCase
include LightboxHelper
def setup
stubs(:_).with(anything).returns('TEXT')
end
should 'provide the needed files' do
assert File.exists?(File.join(RAILS_ROOT, 'public', 'stylesheets', 'lightbox.css')), 'lightbox.css expected to be in public/stylesheets, but not found'
assert File.exists?(File.join(RAILS_ROOT, 'public', 'javascripts', 'lightbox.js')), 'lightbox.js expected to be in public/javascripts, but not found'
end
should 'provide lightbox_link_to helper' do
expects(:link_to).with('text', { :action => 'view', :id => '1' }, has_entries({ :class => 'lbOn', :id => 'my-link' })).returns('[link]')
assert_equal '[link]', lightbox_link_to('text', { :action => 'view', :id => '1'}, { :id => 'my-link' })
end
should 'merge existing :class option in lightbox_link_to' do
expects(:link_to).with('text', { :action => 'view', :id => '1' }, has_entries({ :class => 'lbOn my-button', :id => 'my-link' })).returns('[link]')
assert_equal '[link]', lightbox_link_to('text', { :action => 'view', :id => '1'}, { :class => 'my-button', :id => 'my-link' })
end
should 'provide link to close lightbox' do
expects(:button).with(:close, 'text', '#', has_entries({ :class => 'lbAction', :rel => 'deactivate', :id => 'my-id' })).returns('[close-lightbox]')
assert_equal '[close-lightbox]', lightbox_close_button('text', :id => 'my-id')
end
should 'merge existing :class option in lightbox_close_button' do
expects(:button).with(:close, 'text', '#', has_entries({ :class => 'lbAction my-class', :rel => 'deactivate', :id => 'my-id' })).returns('[close-lightbox]')
assert_equal '[close-lightbox]', lightbox_close_button('text', :class => 'my-class', :id => 'my-id' )
end
should 'provide lightbox_button' do
expects(:button).with('type', 'label', { :action => 'popup'}, has_entries({ :class => 'lbOn' })).returns('[button]')
assert_equal '[button]', lightbox_button('type', 'label', { :action => 'popup'})
end
should 'provide lightbox_icon_button' do
expects(:icon_button).with('type', 'label', { :action => 'popup'}, has_entries({ :class => 'lbOn' })).returns('[button]')
assert_equal '[button]', lightbox_icon_button('type', 'label', { :action => 'popup'})
end
should 'tell if rendering inside lightbox' do
request = mock
expects(:request).returns(request)
request.expects(:xhr?).returns(true)
assert lightbox?
end
should 'provide lightbox_remote_button' do
expects(:button).with('type', 'label', { :action => 'popup'}, has_entries({ :class => 'remote-lbOn' })).returns('[button]')
assert_equal '[button]', lightbox_remote_button('type', 'label', { :action => 'popup'})
end
end