Repository navigation
Expand file tree
/
Copy pathpartial_test.rb
More file actions
94 lines (78 loc) · 2.57 KB
/
Copy pathpartial_test.rb
File metadata and controls
94 lines (78 loc) · 2.57 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require_relative '../test_helper'
require 'rails/all'
require_relative 'abstract_controller'
require_relative 'user'
describe Sync::Partial do
include TestHelper
before do
@context = ActionController::Base.new
@partial = Sync::Partial.new("show", User.new, nil, @context)
end
describe '#self.all' do
it 'returns an array of all Partials for given model' do
# TODO: Must configure Rails application for Rails.root
end
end
describe '#render_to_string' do
it 'renders itself as a string' do
assert_equal "<h1>1<\/h1>", @partial.render_to_string
end
end
describe '#render' do
it 'renders' do
# TODO stub out
assert @partial.respond_to?(:render)
end
end
describe '#sync' do
it 'sends update to faye for given partial and update action' do
# TODO stub out
assert @partial.sync(:update)
end
it 'sends update to faye for given partial and destroy action' do
# TODO stub out
assert @partial.sync(:destroy)
end
end
describe '#message' do
it 'returns a Message instance for the partial for the update action' do
assert_equal Sync.client.class::Message, @partial.message(:update).class
end
it 'returns a Message instance for the partial for the destroy action' do
assert_equal Sync.client.class::Message, @partial.message(:destroy).class
end
end
describe '#channel_prefix' do
it 'returns a unique channel prefix for the partial given its name and resource' do
assert @partial.channel_prefix
end
end
describe 'channel_for_action' do
it 'returns the channel for the update action' do
assert @partial.channel_for_action(:update)
end
it 'returns the channel for the destroy action' do
assert @partial.channel_for_action(:destroy)
end
it 'always starts with a forward slash to provide Faye valid channel' do
assert_equal "/", @partial.channel_for_action(:update).first
assert_equal "/", @partial.channel_for_action(:destroy).first
end
end
describe '#selector_start' do
it 'returns a string for the selector to mark element beginning' do
assert @partial.selector_start.present?
end
end
describe '#selector_end' do
it 'returns a string for the selector to mark element ending' do
assert @partial.selector_end.present?
end
end
describe 'creator_for_scope' do
it 'returns a new PartialCreator for given scope' do
assert_equal Sync::PartialCreator, @partial.creator_for_scope(nil).class
assert @partial, @partial.creator_for_scope(nil).partial
end
end
end