fron-ui 1.0.0rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +38 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/.yardopts +8 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +105 -0
- data/Rakefile +37 -0
- data/Readme.md +4 -0
- data/db.json +192 -0
- data/fron-ui.gemspec +21 -0
- data/lib/fron-ui.rb +1 -0
- data/lib/fron_ui.rb +5 -0
- data/lib/fron_ui/version.rb +7 -0
- data/opal/fron-ui/base.rb +49 -0
- data/opal/fron-ui/behaviors/action.rb +40 -0
- data/opal/fron-ui/behaviors/actions.rb +40 -0
- data/opal/fron-ui/behaviors/confirmation.rb +23 -0
- data/opal/fron-ui/behaviors/dropdown.rb +27 -0
- data/opal/fron-ui/behaviors/file.rb +48 -0
- data/opal/fron-ui/behaviors/intendable_children.rb +76 -0
- data/opal/fron-ui/behaviors/keydown.rb +31 -0
- data/opal/fron-ui/behaviors/loop.rb +41 -0
- data/opal/fron-ui/behaviors/render.rb +30 -0
- data/opal/fron-ui/behaviors/rest.rb +121 -0
- data/opal/fron-ui/behaviors/selectable_children.rb +67 -0
- data/opal/fron-ui/behaviors/serialize.rb +32 -0
- data/opal/fron-ui/behaviors/shortcuts.rb +35 -0
- data/opal/fron-ui/behaviors/state.rb +56 -0
- data/opal/fron-ui/behaviors/transition.rb +63 -0
- data/opal/fron-ui/components/action.rb +18 -0
- data/opal/fron-ui/components/box.rb +17 -0
- data/opal/fron-ui/components/button.rb +61 -0
- data/opal/fron-ui/components/calendar.rb +129 -0
- data/opal/fron-ui/components/checkbox.rb +57 -0
- data/opal/fron-ui/components/chooser.rb +246 -0
- data/opal/fron-ui/components/color_panel.rb +235 -0
- data/opal/fron-ui/components/color_picker.rb +111 -0
- data/opal/fron-ui/components/container.rb +61 -0
- data/opal/fron-ui/components/date_picker.rb +141 -0
- data/opal/fron-ui/components/drag.rb +76 -0
- data/opal/fron-ui/components/dropdown.rb +72 -0
- data/opal/fron-ui/components/icon.rb +29 -0
- data/opal/fron-ui/components/image.rb +77 -0
- data/opal/fron-ui/components/input.rb +30 -0
- data/opal/fron-ui/components/label.rb +9 -0
- data/opal/fron-ui/components/list.rb +34 -0
- data/opal/fron-ui/components/loader.rb +63 -0
- data/opal/fron-ui/components/modal.rb +0 -0
- data/opal/fron-ui/components/notifications.rb +73 -0
- data/opal/fron-ui/components/number.rb +202 -0
- data/opal/fron-ui/components/progress.rb +52 -0
- data/opal/fron-ui/components/slider.rb +47 -0
- data/opal/fron-ui/components/tabs.rb +149 -0
- data/opal/fron-ui/components/textarea.rb +13 -0
- data/opal/fron-ui/components/time.rb +65 -0
- data/opal/fron-ui/components/title.rb +34 -0
- data/opal/fron-ui/examples/blog/index.rb +289 -0
- data/opal/fron-ui/examples/comments/components/comment.rb +75 -0
- data/opal/fron-ui/examples/comments/components/comments.rb +93 -0
- data/opal/fron-ui/examples/comments/components/footer.rb +36 -0
- data/opal/fron-ui/examples/comments/components/header.rb +35 -0
- data/opal/fron-ui/examples/comments/components/list.rb +12 -0
- data/opal/fron-ui/examples/comments/index.rb +6 -0
- data/opal/fron-ui/examples/contacts/components/contacts.rb +100 -0
- data/opal/fron-ui/examples/contacts/components/details.rb +92 -0
- data/opal/fron-ui/examples/contacts/components/item.rb +46 -0
- data/opal/fron-ui/examples/contacts/components/list.rb +10 -0
- data/opal/fron-ui/examples/contacts/components/sidebar.rb +30 -0
- data/opal/fron-ui/examples/contacts/index.rb +6 -0
- data/opal/fron-ui/examples/editor/index.rb +164 -0
- data/opal/fron-ui/examples/kitchensink/index.rb +193 -0
- data/opal/fron-ui/examples/todos/components/item.rb +84 -0
- data/opal/fron-ui/examples/todos/components/options.rb +26 -0
- data/opal/fron-ui/examples/todos/components/todos.rb +145 -0
- data/opal/fron-ui/examples/todos/index.rb +6 -0
- data/opal/fron-ui/examples/webshop/index.rb +0 -0
- data/opal/fron-ui/fonts/ionicons.rb +2954 -0
- data/opal/fron-ui/fonts/open_sans.rb +19 -0
- data/opal/fron-ui/lib/collection.rb +138 -0
- data/opal/fron-ui/lib/date.rb +23 -0
- data/opal/fron-ui/lib/debounce.rb +14 -0
- data/opal/fron-ui/lib/image_loader.rb +13 -0
- data/opal/fron-ui/lib/lorem.rb +93 -0
- data/opal/fron-ui/lib/nil.rb +29 -0
- data/opal/fron-ui/lib/record.rb +23 -0
- data/opal/fron-ui/lib/state_serializer.rb +129 -0
- data/opal/fron-ui/lib/storage.rb +57 -0
- data/opal/fron-ui/spec/setup.rb +40 -0
- data/opal/fron-ui/ui.rb +40 -0
- data/opal/fron-ui/utils/theme_roller.rb +63 -0
- data/opal/fron-ui/vendor/autoprefixer.js +21114 -0
- data/opal/fron-ui/vendor/marked.js +1291 -0
- data/opal/fron-ui/vendor/md5.js +274 -0
- data/opal/fron-ui/vendor/moment.js +3083 -0
- data/opal/fron-ui/vendor/uuid.js +92 -0
- data/opal/fron_ui.rb +13 -0
- data/spec/behaviors/action_spec.rb +34 -0
- data/spec/behaviors/actions_spec.rb +38 -0
- data/spec/behaviors/confirmation_spec.rb +23 -0
- data/spec/behaviors/dropdown_spec.rb +32 -0
- data/spec/behaviors/render_spec.rb +20 -0
- data/spec/behaviors/rest_spec.rb +70 -0
- data/spec/behaviors/selectable_children_spec.rb +40 -0
- data/spec/behaviors/serialize_spec.rb +34 -0
- data/spec/components/action_spec.rb +7 -0
- data/spec/components/base_spec.rb +19 -0
- data/spec/components/box_spec.rb +7 -0
- data/spec/components/button_spec.rb +9 -0
- data/spec/components/calendar_spec.rb +58 -0
- data/spec/components/checkbox_spec.rb +20 -0
- data/spec/components/chooser_spec.rb +75 -0
- data/spec/components/color_panel_spec.rb +49 -0
- data/spec/components/color_picker_spec.rb +41 -0
- data/spec/components/container_spec.rb +23 -0
- data/spec/components/date_picker_spec.rb +71 -0
- data/spec/components/drag_spec.rb +20 -0
- data/spec/components/dropdown_spec.rb +33 -0
- data/spec/components/image_spec.rb +33 -0
- data/spec/components/input_spec.rb +8 -0
- data/spec/components/list_spec.rb +10 -0
- data/spec/components/loader_spec.rb +9 -0
- data/spec/components/notifications_spec.rb +17 -0
- data/spec/components/number_spec.rb +64 -0
- data/spec/components/progress_spec.rb +23 -0
- data/spec/components/slider_spec.rb +25 -0
- data/spec/components/tabs_spec.rb +50 -0
- data/spec/components/textarea_spec.rb +7 -0
- data/spec/components/time_spec.rb +37 -0
- data/spec/components/title_spec.rb +11 -0
- data/spec/examples/comments_spec.rb +72 -0
- data/spec/examples/todos_spec.rb +39 -0
- data/spec/lib/collection_spec.rb +38 -0
- data/spec/lib/lorem_spec.rb +55 -0
- data/spec/lib/state_serializer_spec.rb +58 -0
- data/spec/lib/storage_spec.rb +39 -0
- data/spec/spec_helper.rb +1 -0
- metadata +223 -0
@@ -0,0 +1,92 @@
|
|
1
|
+
/*!
|
2
|
+
Math.uuid.js (v1.4)
|
3
|
+
http://www.broofa.com
|
4
|
+
mailto:robert@broofa.com
|
5
|
+
|
6
|
+
Copyright (c) 2010 Robert Kieffer
|
7
|
+
Dual licensed under the MIT and GPL licenses.
|
8
|
+
*/
|
9
|
+
|
10
|
+
/*
|
11
|
+
* Generate a random uuid.
|
12
|
+
*
|
13
|
+
* USAGE: Math.uuid(length, radix)
|
14
|
+
* length - the desired number of characters
|
15
|
+
* radix - the number of allowable values for each character.
|
16
|
+
*
|
17
|
+
* EXAMPLES:
|
18
|
+
* // No arguments - returns RFC4122, version 4 ID
|
19
|
+
* >>> Math.uuid()
|
20
|
+
* "92329D39-6F5C-4520-ABFC-AAB64544E172"
|
21
|
+
*
|
22
|
+
* // One argument - returns ID of the specified length
|
23
|
+
* >>> Math.uuid(15) // 15 character ID (default base=62)
|
24
|
+
* "VcydxgltxrVZSTV"
|
25
|
+
*
|
26
|
+
* // Two arguments - returns ID of the specified length, and radix. (Radix must be <= 62)
|
27
|
+
* >>> Math.uuid(8, 2) // 8 character ID (base=2)
|
28
|
+
* "01001010"
|
29
|
+
* >>> Math.uuid(8, 10) // 8 character ID (base=10)
|
30
|
+
* "47473046"
|
31
|
+
* >>> Math.uuid(8, 16) // 8 character ID (base=16)
|
32
|
+
* "098F4D35"
|
33
|
+
*/
|
34
|
+
(function() {
|
35
|
+
// Private array of chars to use
|
36
|
+
var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
|
37
|
+
|
38
|
+
Math.uuid = function (len, radix) {
|
39
|
+
var chars = CHARS, uuid = [], i;
|
40
|
+
radix = radix || chars.length;
|
41
|
+
|
42
|
+
if (len) {
|
43
|
+
// Compact form
|
44
|
+
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
|
45
|
+
} else {
|
46
|
+
// rfc4122, version 4 form
|
47
|
+
var r;
|
48
|
+
|
49
|
+
// rfc4122 requires these characters
|
50
|
+
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
51
|
+
uuid[14] = '4';
|
52
|
+
|
53
|
+
// Fill in random data. At i==19 set the high bits of clock sequence as
|
54
|
+
// per rfc4122, sec. 4.1.5
|
55
|
+
for (i = 0; i < 36; i++) {
|
56
|
+
if (!uuid[i]) {
|
57
|
+
r = 0 | Math.random()*16;
|
58
|
+
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
return uuid.join('');
|
64
|
+
};
|
65
|
+
|
66
|
+
// A more performant, but slightly bulkier, RFC4122v4 solution. We boost performance
|
67
|
+
// by minimizing calls to random()
|
68
|
+
Math.uuidFast = function() {
|
69
|
+
var chars = CHARS, uuid = new Array(36), rnd=0, r;
|
70
|
+
for (var i = 0; i < 36; i++) {
|
71
|
+
if (i==8 || i==13 || i==18 || i==23) {
|
72
|
+
uuid[i] = '-';
|
73
|
+
} else if (i==14) {
|
74
|
+
uuid[i] = '4';
|
75
|
+
} else {
|
76
|
+
if (rnd <= 0x02) rnd = 0x2000000 + (Math.random()*0x1000000)|0;
|
77
|
+
r = rnd & 0xf;
|
78
|
+
rnd = rnd >> 4;
|
79
|
+
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
|
80
|
+
}
|
81
|
+
}
|
82
|
+
return uuid.join('');
|
83
|
+
};
|
84
|
+
|
85
|
+
// A more compact, but less performant, RFC4122v4 solution:
|
86
|
+
Math.uuidCompact = function() {
|
87
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
88
|
+
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
89
|
+
return v.toString(16);
|
90
|
+
});
|
91
|
+
};
|
92
|
+
})();
|
data/opal/fron_ui.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'opal'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'fron'
|
4
|
+
require 'color'
|
5
|
+
|
6
|
+
require_tree './fron-ui/fonts'
|
7
|
+
require 'fron-ui/ui'
|
8
|
+
require 'fron-ui/base'
|
9
|
+
|
10
|
+
require_tree './fron-ui/lib'
|
11
|
+
require_tree './fron-ui/vendor'
|
12
|
+
require_tree './fron-ui/behaviors'
|
13
|
+
require_tree './fron-ui/components'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TestClasses
|
4
|
+
class Action < Fron::Component
|
5
|
+
include UI::Behaviors::Action
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe TestClasses::Action do
|
10
|
+
describe '#action' do
|
11
|
+
it 'should trigger click' do
|
12
|
+
subject.should receive(:trigger).with(:click)
|
13
|
+
subject.action
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'Keys' do
|
18
|
+
before do
|
19
|
+
subject.should receive(:action)
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'Enter' do
|
23
|
+
it 'should call action' do
|
24
|
+
subject.trigger :keydown, keyCode: 13
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'Space' do
|
29
|
+
it 'should call action' do
|
30
|
+
subject.trigger :keydown, keyCode: 32
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TestClasses
|
4
|
+
class Actions < Fron::Component
|
5
|
+
include UI::Behaviors::Actions
|
6
|
+
|
7
|
+
component :span, :span, action: :test
|
8
|
+
|
9
|
+
def test
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe TestClasses::Actions do
|
15
|
+
context 'Has method' do
|
16
|
+
let(:event) { double :event, target: { action: 'test' } }
|
17
|
+
|
18
|
+
it 'should handle actions with events' do
|
19
|
+
subject.should receive(:test).with kind_of(DOM::Event)
|
20
|
+
subject.span.trigger :click
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should stop event' do
|
24
|
+
subject.should receive(:test).with event
|
25
|
+
event.should receive(:stop)
|
26
|
+
subject.handle_action event
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'Does not have method' do
|
31
|
+
let(:event) { double :event, target: { action: 'boo' } }
|
32
|
+
|
33
|
+
it 'should not stop event if no method exists' do
|
34
|
+
event.should_not receive(:stop)
|
35
|
+
subject.handle_action event
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TestClasses
|
4
|
+
class Confirmation < Fron::Component
|
5
|
+
include UI::Behaviors::Confirmation
|
6
|
+
|
7
|
+
confirmation :remove!, 'Are you sure?'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe TestClasses::Confirmation do
|
12
|
+
it 'should have confirmed method' do
|
13
|
+
subject.should respond_to(:confirm_remove!)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'Calling the confirmation' do
|
17
|
+
it 'should call the method' do
|
18
|
+
subject.should receive(:confirm).with('Are you sure?').and_return true
|
19
|
+
subject.should receive(:remove!)
|
20
|
+
subject.confirm_remove!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TestClasses
|
4
|
+
class Dropdown < Fron::Component
|
5
|
+
include UI::Behaviors::Dropdown
|
6
|
+
|
7
|
+
component :input, :input
|
8
|
+
component :dropdown, UI::Dropdown
|
9
|
+
|
10
|
+
dropdown :input, :dropdown
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe TestClasses::Dropdown do
|
15
|
+
context 'Focusing the input' do
|
16
|
+
it 'should open the dropdown' do
|
17
|
+
expect {
|
18
|
+
subject.input.trigger :focus
|
19
|
+
}.to change { subject.dropdown.has_class(:open) }.from(false).to(true)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'Bluring the input' do
|
24
|
+
it 'should close the dropdown' do
|
25
|
+
subject.dropdown.open
|
26
|
+
expect {
|
27
|
+
subject.input.trigger :blur
|
28
|
+
subject.dropdown.trigger :animationend, animationName: 'ui-dropdown-hide'
|
29
|
+
}.to change { subject.dropdown.has_class(:open) }.from(true).to(false)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TestClasses
|
4
|
+
class Render < Fron::Component
|
5
|
+
include UI::Behaviors::Render
|
6
|
+
|
7
|
+
render :render_things
|
8
|
+
|
9
|
+
def render_things
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe TestClasses::Render do
|
15
|
+
describe '#render' do
|
16
|
+
it 'should call orginial method' do
|
17
|
+
subject.render
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TestClasses
|
4
|
+
class Rest < Fron::Component
|
5
|
+
include Record
|
6
|
+
include UI::Behaviors::Rest
|
7
|
+
|
8
|
+
rest url: '//test'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe TestClasses::Rest do
|
13
|
+
let(:request) { double :request, url: 'test' }
|
14
|
+
let(:resp) { double :response, status: 200, json: {} }
|
15
|
+
let(:error_resp) { double :response, status: 0, json: {} }
|
16
|
+
|
17
|
+
before do
|
18
|
+
subject.data = { id: 0 }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'Real request' do
|
22
|
+
xit 'should return request' do
|
23
|
+
subject.create_request('/').should be_a(FakeRequest)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'Requests' do
|
28
|
+
before do
|
29
|
+
subject.should receive(:create_request).and_return request
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'Wrong request' do
|
33
|
+
xit 'should raise error' do
|
34
|
+
subject.should receive(:warn)
|
35
|
+
request.should receive(:request).and_yield error_resp
|
36
|
+
subject.request :get, '', {}
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#all' do
|
42
|
+
it 'should return all records' do
|
43
|
+
request.should receive(:request).with(:GET, {}).and_yield resp
|
44
|
+
subject.all
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#update' do
|
49
|
+
it 'should update the model' do
|
50
|
+
request.should receive(:request).with(:PATCH,
|
51
|
+
name: 'test').and_yield resp
|
52
|
+
subject.update name: 'test'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#destroy' do
|
57
|
+
it 'should destroy the model' do
|
58
|
+
request.should receive(:request).with(:DELETE, {}).and_yield resp
|
59
|
+
subject.destroy {}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#create' do
|
64
|
+
it 'should create the model' do
|
65
|
+
request.should receive(:request).with(:POST, name: 'test').and_yield resp
|
66
|
+
subject.create name: 'test'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TestClasses
|
4
|
+
class SelectableChildren < Fron::Component
|
5
|
+
include UI::Behaviors::SelectableChildren
|
6
|
+
|
7
|
+
component :first, :span, text: 'First'
|
8
|
+
component :second, :span, text: 'Second'
|
9
|
+
component :third, :span, text: 'Third'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe TestClasses::SelectableChildren do
|
14
|
+
describe '#select' do
|
15
|
+
it 'should select children' do
|
16
|
+
expect(subject).to receive(:trigger).with :selected_change
|
17
|
+
expect {
|
18
|
+
subject.select_first
|
19
|
+
}.to change { subject.children.first.has_class(:selected) }.from(false).to(true)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'Clicking on a child' do
|
24
|
+
let(:first) { subject.children.first }
|
25
|
+
let(:last) { subject.children.last }
|
26
|
+
|
27
|
+
it 'should select child' do
|
28
|
+
expect {
|
29
|
+
first.trigger :click
|
30
|
+
}.to change { first.has_class(:selected) }.from(false).to(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should de select previous selection' do
|
34
|
+
first.trigger :click
|
35
|
+
expect {
|
36
|
+
last.trigger :click
|
37
|
+
}.to change { first.has_class(:selected) }.from(true).to(false)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module TestClasses
|
4
|
+
class Serialize < Fron::Component
|
5
|
+
include UI::Behaviors::Serialize
|
6
|
+
|
7
|
+
component :test, :test, name: 'something'
|
8
|
+
component :input, :input, name: 'other'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe TestClasses::Serialize do
|
13
|
+
let(:data) { subject.data }
|
14
|
+
|
15
|
+
before do
|
16
|
+
subject.input.value = 'Test'
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#data' do
|
20
|
+
it 'should return data' do
|
21
|
+
data.should have_key(:something)
|
22
|
+
data.should have_key(:other)
|
23
|
+
data[:other].should eq 'Test'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#load' do
|
28
|
+
it 'should set data' do
|
29
|
+
expect {
|
30
|
+
subject.load other: 'some data'
|
31
|
+
}.to change { subject.input.value }.from('Test').to('some data')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UI::Base do
|
4
|
+
describe '#disabled=' do
|
5
|
+
it 'should set disabled' do
|
6
|
+
expect {
|
7
|
+
subject.disabled = true
|
8
|
+
}.to change { subject.attribute?(:disabled) }.from(false).to(true)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#readonly=' do
|
13
|
+
it 'should set readonly' do
|
14
|
+
expect {
|
15
|
+
subject.readonly = true
|
16
|
+
}.to change { subject.attribute?(:readonly) }.from(false).to(true)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|