vedeu 0.4.13 → 0.4.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -1
- data/.travis.yml +2 -1
- data/Guardfile +6 -5
- data/README.md +3 -30
- data/Rakefile +5 -5
- data/bin/vedeu_drb_client +1 -1
- data/bin/vedeu_drb_server +91 -89
- data/bin/vedeu_test +4 -0
- data/config/rubocop_enabled.yml +5 -10
- data/examples/borders_app.rb +2 -1
- data/examples/colours_app.rb +13 -8
- data/examples/configuration_app.rb +3 -2
- data/examples/cursor_app.rb +16 -11
- data/examples/drb_app.rb +88 -89
- data/examples/focus_app.rb +31 -32
- data/examples/geometry_app.rb +2 -1
- data/examples/hello_world.rb +2 -1
- data/examples/lines_app.rb +2 -1
- data/examples/material_colours_app.rb +126 -0
- data/examples/typed_commands/typed_commands_app.rb +5 -1
- data/examples/view_templates_app/view_templates_app.rb +6 -3
- data/lib/vedeu/all.rb +1 -1
- data/lib/vedeu/api.rb +18 -10
- data/lib/vedeu/application.rb +0 -1
- data/lib/vedeu/bindings.rb +77 -16
- data/lib/vedeu/buffers/all.rb +2 -5
- data/lib/vedeu/buffers/buffer.rb +69 -25
- data/lib/vedeu/buffers/display_buffer.rb +3 -7
- data/lib/vedeu/configuration/all.rb +3 -6
- data/lib/vedeu/configuration/api.rb +28 -4
- data/lib/vedeu/configuration/cli.rb +9 -9
- data/lib/vedeu/configuration/configuration.rb +11 -7
- data/lib/vedeu/cursor/all.rb +3 -6
- data/lib/vedeu/cursor/cursor.rb +22 -14
- data/lib/vedeu/cursor/move.rb +32 -22
- data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
- data/lib/vedeu/debug.rb +2 -1
- data/lib/vedeu/distributed/client.rb +1 -7
- data/lib/vedeu/distributed/server.rb +0 -4
- data/lib/vedeu/distributed/subprocess.rb +1 -1
- data/lib/vedeu/distributed/templates/default_configuration.vedeu +1 -1
- data/lib/vedeu/distributed/test_application.rb +3 -5
- data/lib/vedeu/distributed/uri.rb +2 -2
- data/lib/vedeu/dsl/all.rb +6 -6
- data/lib/vedeu/dsl/components/all.rb +0 -3
- data/lib/vedeu/dsl/components/border.rb +20 -12
- data/lib/vedeu/dsl/components/geometry.rb +68 -3
- data/lib/vedeu/dsl/components/keymap.rb +1 -2
- data/lib/vedeu/dsl/composition.rb +8 -1
- data/lib/vedeu/dsl/interface.rb +61 -11
- data/lib/vedeu/dsl/line.rb +12 -12
- data/lib/vedeu/dsl/shared/all.rb +4 -7
- data/lib/vedeu/dsl/shared/colour.rb +2 -2
- data/lib/vedeu/dsl/shared/text.rb +2 -35
- data/lib/vedeu/dsl/shared/use.rb +2 -2
- data/lib/vedeu/dsl/view.rb +4 -4
- data/lib/vedeu/events/all.rb +3 -5
- data/lib/vedeu/events/event.rb +5 -5
- data/lib/vedeu/geometry/all.rb +11 -16
- data/lib/vedeu/geometry/area.rb +2 -5
- data/lib/vedeu/geometry/canvas.rb +12 -16
- data/lib/vedeu/geometry/dimension.rb +20 -22
- data/lib/vedeu/geometry/geometry.rb +28 -30
- data/lib/vedeu/geometry/grid.rb +1 -1
- data/lib/vedeu/geometry/index_position.rb +7 -0
- data/lib/vedeu/geometry/null_geometry.rb +61 -0
- data/lib/vedeu/geometry/position.rb +0 -3
- data/lib/vedeu/geometry/position_index.rb +7 -0
- data/lib/vedeu/geometry/position_validator.rb +44 -33
- data/lib/vedeu/input/all.rb +5 -4
- data/lib/vedeu/input/keymap.rb +0 -1
- data/lib/vedeu/input/mapper.rb +1 -3
- data/lib/vedeu/launcher.rb +6 -7
- data/lib/vedeu/main_loop.rb +1 -2
- data/lib/vedeu/models/all.rb +1 -0
- data/lib/vedeu/models/cell.rb +5 -8
- data/lib/vedeu/models/char.rb +50 -15
- data/lib/vedeu/models/composition.rb +8 -1
- data/lib/vedeu/models/focus.rb +4 -4
- data/lib/vedeu/models/group.rb +3 -3
- data/lib/vedeu/models/interface.rb +62 -46
- data/lib/vedeu/models/line.rb +1 -1
- data/lib/vedeu/models/null.rb +48 -0
- data/lib/vedeu/models/stream.rb +5 -5
- data/lib/vedeu/output/all.rb +20 -30
- data/lib/vedeu/output/border.rb +93 -40
- data/lib/vedeu/output/clear.rb +100 -15
- data/lib/vedeu/output/colour.rb +56 -12
- data/lib/vedeu/output/compressor.rb +59 -0
- data/lib/vedeu/output/html_char.rb +4 -2
- data/lib/vedeu/output/null_border.rb +16 -4
- data/lib/vedeu/output/output.rb +13 -21
- data/lib/vedeu/output/presentation.rb +28 -23
- data/lib/vedeu/output/refresh.rb +2 -2
- data/lib/vedeu/output/renderers/all.rb +80 -3
- data/lib/vedeu/output/renderers/file_renderer.rb +38 -2
- data/lib/vedeu/output/renderers/html_renderer.rb +6 -4
- data/lib/vedeu/output/renderers/json_renderer.rb +52 -0
- data/lib/vedeu/output/renderers/null_renderer.rb +14 -0
- data/lib/vedeu/output/renderers/terminal_renderer.rb +2 -12
- data/lib/vedeu/output/style.rb +33 -3
- data/lib/vedeu/output/text.rb +98 -1
- data/lib/vedeu/output/translator.rb +30 -7
- data/lib/vedeu/output/viewport.rb +43 -79
- data/lib/vedeu/output/wordwrap.rb +4 -4
- data/lib/vedeu/repositories/all.rb +22 -179
- data/lib/vedeu/repositories/collection.rb +11 -13
- data/lib/vedeu/repositories/collections/all.rb +8 -0
- data/lib/vedeu/repositories/collections/chars.rb +9 -0
- data/lib/vedeu/repositories/collections/events.rb +9 -0
- data/lib/vedeu/repositories/collections/interfaces.rb +9 -0
- data/lib/vedeu/repositories/collections/keys.rb +9 -0
- data/lib/vedeu/repositories/collections/lines.rb +9 -0
- data/lib/vedeu/repositories/collections/streams.rb +9 -0
- data/lib/vedeu/repositories/model.rb +7 -2
- data/lib/vedeu/repositories/repositories/all.rb +14 -0
- data/lib/vedeu/repositories/repositories/background_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/borders.rb +38 -0
- data/lib/vedeu/repositories/repositories/buffers.rb +36 -0
- data/lib/vedeu/repositories/repositories/colours.rb +63 -0
- data/lib/vedeu/repositories/repositories/cursors.rb +29 -0
- data/lib/vedeu/repositories/repositories/events_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/foreground_colours.rb +14 -0
- data/lib/vedeu/repositories/repositories/geometries.rb +37 -0
- data/lib/vedeu/repositories/repositories/groups.rb +24 -0
- data/lib/vedeu/repositories/repositories/interfaces_repository.rb +24 -0
- data/lib/vedeu/repositories/repositories/keymaps.rb +24 -0
- data/lib/vedeu/repositories/repositories/menus.rb +24 -0
- data/lib/vedeu/repositories/repository.rb +29 -47
- data/lib/vedeu/storage/all.rb +6 -0
- data/lib/vedeu/storage/associative_store.rb +47 -0
- data/lib/vedeu/storage/conveyor_store.rb +69 -0
- data/lib/vedeu/storage/fifo_store.rb +37 -0
- data/lib/vedeu/storage/store.rb +58 -0
- data/lib/vedeu/support/all.rb +5 -10
- data/lib/vedeu/support/common.rb +0 -8
- data/lib/vedeu/support/log.rb +13 -24
- data/lib/vedeu/support/template.rb +4 -1
- data/lib/vedeu/support/terminal.rb +10 -10
- data/lib/vedeu/support/trace.rb +15 -88
- data/lib/vedeu/support/visibility.rb +73 -0
- data/lib/vedeu.rb +37 -0
- data/test/lib/vedeu/api_test.rb +7 -3
- data/test/lib/vedeu/application_test.rb +9 -3
- data/test/lib/vedeu/bindings_test.rb +21 -0
- data/test/lib/vedeu/buffers/buffer_test.rb +110 -134
- data/test/lib/vedeu/buffers/display_buffer_test.rb +8 -0
- data/test/lib/vedeu/configuration/api_test.rb +5 -1
- data/test/lib/vedeu/configuration/configuration_test.rb +4 -6
- data/test/lib/vedeu/cursor/cursor_test.rb +25 -17
- data/test/lib/vedeu/cursor/move_test.rb +7 -7
- data/test/lib/vedeu/distributed/client_test.rb +1 -1
- data/test/lib/vedeu/distributed/subprocess_test.rb +3 -1
- data/test/lib/vedeu/distributed/uri_test.rb +5 -5
- data/test/lib/vedeu/dsl/components/geometry_test.rb +43 -0
- data/test/lib/vedeu/dsl/components/keymap_test.rb +1 -1
- data/test/lib/vedeu/dsl/composition_test.rb +6 -5
- data/test/lib/vedeu/dsl/interface_test.rb +81 -16
- data/test/lib/vedeu/dsl/shared/colour_test.rb +4 -4
- data/test/lib/vedeu/dsl/shared/text_test.rb +87 -9
- data/test/lib/vedeu/dsl/stream_test.rb +1 -1
- data/test/lib/vedeu/events/event_test.rb +3 -1
- data/test/lib/vedeu/events/trigger_test.rb +8 -4
- data/test/lib/vedeu/geometry/dimension_test.rb +1 -1
- data/test/lib/vedeu/geometry/geometry_test.rb +5 -3
- data/test/lib/vedeu/geometry/index_position_test.rb +30 -7
- data/test/lib/vedeu/geometry/null_geometry_test.rb +57 -0
- data/test/lib/vedeu/geometry/position_index_test.rb +14 -0
- data/test/lib/vedeu/geometry/position_validator_test.rb +17 -3
- data/test/lib/vedeu/input/keymap_test.rb +3 -1
- data/test/lib/vedeu/input/mapper_test.rb +8 -4
- data/test/lib/vedeu/launcher_test.rb +1 -1
- data/test/lib/vedeu/models/cell_test.rb +10 -8
- data/test/lib/vedeu/models/char_test.rb +52 -28
- data/test/lib/vedeu/models/composition_test.rb +26 -4
- data/test/lib/vedeu/models/group_test.rb +11 -5
- data/test/lib/vedeu/models/interface_test.rb +32 -19
- data/test/lib/vedeu/models/line_test.rb +21 -25
- data/test/lib/vedeu/models/menu_test.rb +10 -6
- data/test/lib/vedeu/models/null_test.rb +66 -0
- data/test/lib/vedeu/models/stream_test.rb +13 -10
- data/test/lib/vedeu/output/border_test.rb +29 -8
- data/test/lib/vedeu/output/clear_test.rb +23 -4
- data/test/lib/vedeu/output/colour_test.rb +20 -4
- data/test/lib/vedeu/output/compressor_test.rb +43 -0
- data/test/lib/vedeu/output/html_char_test.rb +29 -17
- data/test/lib/vedeu/output/null_border_test.rb +2 -1
- data/test/lib/vedeu/output/output_test.rb +20 -30
- data/test/lib/vedeu/output/presentation_test.rb +39 -16
- data/test/lib/vedeu/output/refresh_test.rb +14 -10
- data/test/lib/vedeu/output/renderers/all_test.rb +96 -0
- data/test/lib/vedeu/output/renderers/file_renderer_test.rb +1 -1
- data/test/lib/vedeu/output/renderers/html_renderer_test.rb +13 -9
- data/test/lib/vedeu/output/renderers/json_renderer_test.rb +52 -0
- data/test/lib/vedeu/output/renderers/null_renderer_test.rb +19 -0
- data/test/lib/vedeu/output/style_test.rb +41 -1
- data/test/lib/vedeu/output/text_test.rb +61 -10
- data/test/lib/vedeu/output/translator_test.rb +14 -0
- data/test/lib/vedeu/output/viewport_test.rb +22 -3
- data/test/lib/vedeu/output/virtual_terminal_test.rb +3 -3
- data/test/lib/vedeu/output/wordwrap_test.rb +58 -45
- data/test/lib/vedeu/repositories/collections/chars_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/events_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/interfaces_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/keys_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/lines_test.rb +16 -0
- data/test/lib/vedeu/repositories/collections/streams_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/background_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/borders_test.rb +51 -0
- data/test/lib/vedeu/repositories/repositories/buffers_test.rb +52 -0
- data/test/lib/vedeu/repositories/repositories/colours_test.rb +16 -0
- data/test/lib/vedeu/repositories/repositories/cursors_test.rb +39 -0
- data/test/lib/vedeu/repositories/repositories/events_repository_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/foreground_colours_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/geometries_test.rb +42 -0
- data/test/lib/vedeu/repositories/repositories/groups_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/interfaces_repositories_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/keymaps_test.rb +17 -0
- data/test/lib/vedeu/repositories/repositories/menus_test.rb +17 -0
- data/test/lib/vedeu/repositories/repository_test.rb +16 -36
- data/test/lib/vedeu/storage/associative_store_test.rb +69 -0
- data/test/lib/vedeu/storage/conveyor_store_test.rb +135 -0
- data/test/lib/vedeu/storage/fifo_store_test.rb +47 -0
- data/test/lib/vedeu/storage/store_test.rb +123 -0
- data/test/lib/vedeu/support/common_test.rb +0 -9
- data/test/lib/vedeu/support/terminal_test.rb +78 -55
- data/test/lib/vedeu/support/visibility_test.rb +80 -0
- data/test/test_helper.rb +13 -11
- data/vedeu.gemspec +4 -3
- metadata +92 -32
- data/lib/vedeu/cursor/toggle.rb +0 -55
- data/lib/vedeu/exceptions.rb +0 -37
- data/lib/vedeu/geometry/centre.rb +0 -85
- data/lib/vedeu/geometry/content.rb +0 -70
- data/lib/vedeu/geometry/limit.rb +0 -58
- data/lib/vedeu/output/compositor.rb +0 -62
- data/lib/vedeu/repositories/collections.rb +0 -41
- data/lib/vedeu/support/coercions.rb +0 -60
- data/lib/vedeu/support/sentence.rb +0 -91
- data/lib/vedeu/support/visible.rb +0 -90
- data/test/lib/vedeu/cursor/toggle_test.rb +0 -63
- data/test/lib/vedeu/geometry/centre_test.rb +0 -58
- data/test/lib/vedeu/geometry/content_test.rb +0 -98
- data/test/lib/vedeu/geometry/limit_test.rb +0 -30
- data/test/lib/vedeu/output/compositor_test.rb +0 -48
- data/test/lib/vedeu/repositories/all_test.rb +0 -135
- data/test/lib/vedeu/repositories/collections_test.rb +0 -71
- data/test/lib/vedeu/support/coercions_test.rb +0 -84
- data/test/lib/vedeu/support/sentence_test.rb +0 -56
- data/test/lib/vedeu/support/visible_test.rb +0 -161
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Chars do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::Chars }
|
8
|
-
let(:instance) { described.new }
|
9
|
-
|
10
|
-
describe '#initialize' do
|
11
|
-
it { instance.must_be_instance_of(Vedeu::Chars) }
|
12
|
-
end
|
13
|
-
|
14
|
-
end # Chars
|
15
|
-
|
16
|
-
describe Events do
|
17
|
-
|
18
|
-
let(:described) { Vedeu::Events }
|
19
|
-
let(:instance) { described.new }
|
20
|
-
|
21
|
-
describe '#initialize' do
|
22
|
-
it { instance.must_be_instance_of(Vedeu::Events) }
|
23
|
-
end
|
24
|
-
|
25
|
-
end # Events
|
26
|
-
|
27
|
-
describe Interfaces do
|
28
|
-
|
29
|
-
let(:described) { Vedeu::Interfaces }
|
30
|
-
let(:instance) { described.new }
|
31
|
-
|
32
|
-
describe '#initialize' do
|
33
|
-
it { instance.must_be_instance_of(Vedeu::Interfaces) }
|
34
|
-
end
|
35
|
-
|
36
|
-
end # Interfaces
|
37
|
-
|
38
|
-
describe Keys do
|
39
|
-
|
40
|
-
let(:described) { Vedeu::Keys }
|
41
|
-
let(:instance) { described.new }
|
42
|
-
|
43
|
-
describe '#initialize' do
|
44
|
-
it { instance.must_be_instance_of(Vedeu::Keys) }
|
45
|
-
end
|
46
|
-
|
47
|
-
end # Keys
|
48
|
-
|
49
|
-
describe Lines do
|
50
|
-
|
51
|
-
let(:described) { Vedeu::Lines }
|
52
|
-
let(:instance) { described.new }
|
53
|
-
|
54
|
-
describe '#initialize' do
|
55
|
-
it { instance.must_be_instance_of(Vedeu::Lines) }
|
56
|
-
end
|
57
|
-
|
58
|
-
end # Lines
|
59
|
-
|
60
|
-
describe Streams do
|
61
|
-
|
62
|
-
let(:described) { Vedeu::Streams }
|
63
|
-
let(:instance) { described.new }
|
64
|
-
|
65
|
-
describe '#initialize' do
|
66
|
-
it { instance.must_be_instance_of(Vedeu::Streams) }
|
67
|
-
end
|
68
|
-
|
69
|
-
end # Streams
|
70
|
-
|
71
|
-
end # Vedeu
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
class CoercionsTestClass
|
6
|
-
|
7
|
-
include Coercions
|
8
|
-
|
9
|
-
attr_reader :attributes
|
10
|
-
|
11
|
-
def initialize(attributes = {})
|
12
|
-
@attributes = attributes
|
13
|
-
end
|
14
|
-
|
15
|
-
end # CoercionsTestClass
|
16
|
-
|
17
|
-
describe Coercions do
|
18
|
-
|
19
|
-
describe '.coerce' do
|
20
|
-
let(:described) { Vedeu::Style }
|
21
|
-
let(:value) { 'bold' }
|
22
|
-
|
23
|
-
subject { described.coerce(value) }
|
24
|
-
|
25
|
-
it { subject.must_be_instance_of(described) }
|
26
|
-
|
27
|
-
context 'when the value is nil' do
|
28
|
-
let(:value) { nil }
|
29
|
-
|
30
|
-
it { subject.must_be_instance_of(described) }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when the value is a Style already' do
|
34
|
-
let(:value) { Vedeu::Style.new('bold') }
|
35
|
-
|
36
|
-
it { subject.must_equal(value) }
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when the value is an Array' do
|
40
|
-
let(:value) { [:bold, :blink] }
|
41
|
-
|
42
|
-
it { subject.value.must_equal([:bold, :blink]) }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '.coercer' do
|
47
|
-
[nil, [], {}].each do |empty_value|
|
48
|
-
it 'returns an empty collection when nil or empty' do
|
49
|
-
CoercionsTestClass.coercer(empty_value).must_equal([])
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'returns when an object' do
|
54
|
-
klass = CoercionsTestClass.new
|
55
|
-
|
56
|
-
CoercionsTestClass.coercer([klass]).must_equal([klass])
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'returns a collection of models when a single hash' do
|
60
|
-
coerced = CoercionsTestClass.coercer({ name: 'test1' })
|
61
|
-
coerced.must_be_instance_of(Array)
|
62
|
-
coerced.first.attributes.must_equal({ name: 'test1' })
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'returns a collection of models when multiple hashes' do
|
66
|
-
coerced = CoercionsTestClass.coercer([
|
67
|
-
{ name: 'test1' }, { name: 'test2' }
|
68
|
-
])
|
69
|
-
coerced.size.must_equal(2)
|
70
|
-
coerced.map(&:attributes).must_equal(
|
71
|
-
[{ name: 'test1' }, { name: 'test2' }]
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'returns a collection of models when a single array' do
|
76
|
-
coerced = CoercionsTestClass.coercer([{ name: 'test3' }])
|
77
|
-
coerced.size.must_equal(1)
|
78
|
-
coerced.first.attributes.must_equal({ name: "test3" })
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
end # Coercions
|
83
|
-
|
84
|
-
end # Vedeu
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module Vedeu
|
4
|
-
|
5
|
-
describe Sentence do
|
6
|
-
|
7
|
-
let(:described) { Vedeu::Sentence }
|
8
|
-
let(:instance) { described.new(elements, label) }
|
9
|
-
let(:elements) { ['Hydrogen'] }
|
10
|
-
let(:label) { 'elements' }
|
11
|
-
|
12
|
-
describe '#initialize' do
|
13
|
-
it { instance.must_be_instance_of(Sentence) }
|
14
|
-
it { instance.instance_variable_get('@elements').must_equal(elements) }
|
15
|
-
it { instance.instance_variable_get('@label').must_equal(label) }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '.construct' do
|
19
|
-
subject { Sentence.construct(elements, label) }
|
20
|
-
|
21
|
-
context 'when there is one element' do
|
22
|
-
let(:elements) { ['Hydrogen'] }
|
23
|
-
|
24
|
-
it 'returns the element as a string' do
|
25
|
-
subject.must_equal('Hydrogen')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'when there are two elements' do
|
30
|
-
let(:elements) { %w(Hydrogen Helium) }
|
31
|
-
|
32
|
-
it "returns the elements joined with 'and'" do
|
33
|
-
subject.must_equal('Hydrogen and Helium')
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'when there are more than two elements' do
|
38
|
-
let(:elements) { %w(Hydrogen Helium Lithium) }
|
39
|
-
|
40
|
-
it 'returns the elements as a sentence list' do
|
41
|
-
subject.must_equal('Hydrogen, Helium and Lithium')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when there are no elements' do
|
46
|
-
let(:elements) { [] }
|
47
|
-
|
48
|
-
it 'returns a polite message' do
|
49
|
-
subject.must_equal('No elements have been assigned.')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end # Sentence
|
55
|
-
|
56
|
-
end # Vedeu
|
@@ -1,161 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require 'vedeu/support/visible'
|
4
|
-
|
5
|
-
module Vedeu
|
6
|
-
|
7
|
-
describe Visible do
|
8
|
-
|
9
|
-
let(:described) { Vedeu::Visible }
|
10
|
-
let(:instance) { described.new(visible) }
|
11
|
-
let(:visible) { true }
|
12
|
-
|
13
|
-
describe '#initialize' do
|
14
|
-
it { instance.must_be_instance_of(Visible) }
|
15
|
-
it { instance.instance_variable_get('@visible').must_equal(visible) }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '#visible' do
|
19
|
-
subject { instance.visible }
|
20
|
-
|
21
|
-
context 'when visible is :hide' do
|
22
|
-
let(:visible) { :hide }
|
23
|
-
|
24
|
-
it { subject.must_equal(false) }
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'when visible is :show' do
|
28
|
-
let(:visible) { :show }
|
29
|
-
|
30
|
-
it { subject.must_equal(true) }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'when visible is nil' do
|
34
|
-
let(:visible) { nil }
|
35
|
-
|
36
|
-
it { subject.must_equal(false) }
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when visible is false' do
|
40
|
-
let(:visible) { false }
|
41
|
-
|
42
|
-
it { subject.must_equal(false) }
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when visible is anything else that evaluates to true' do
|
46
|
-
let(:visible) { 'yeah show it!' }
|
47
|
-
|
48
|
-
it { subject.must_equal(true) }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '.coerce' do
|
53
|
-
subject { described.coerce(value) }
|
54
|
-
|
55
|
-
context 'when the value is a Visible' do
|
56
|
-
let(:value) { described.new }
|
57
|
-
|
58
|
-
it { subject.must_be_instance_of(Visible) }
|
59
|
-
it { subject.visible?.must_equal(false) }
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'when the value is not a Visible' do
|
63
|
-
let(:value) { :show }
|
64
|
-
|
65
|
-
it { subject.must_be_instance_of(Visible) }
|
66
|
-
it { subject.visible?.must_equal(true) }
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#to_s' do
|
71
|
-
subject { instance.to_s }
|
72
|
-
|
73
|
-
it { subject.must_be_instance_of(String) }
|
74
|
-
|
75
|
-
context 'when visible' do
|
76
|
-
it { subject.must_equal('visible') }
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'when not visible' do
|
80
|
-
let(:visible) { false }
|
81
|
-
|
82
|
-
it { subject.must_equal('invisible') }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
describe '#cursor' do
|
87
|
-
subject { instance.cursor }
|
88
|
-
|
89
|
-
it { subject.must_be_instance_of(String) }
|
90
|
-
|
91
|
-
context 'when visible' do
|
92
|
-
it { subject.must_equal("\e[?25h") }
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'when not visible' do
|
96
|
-
let(:visible) { false }
|
97
|
-
|
98
|
-
it { subject.must_equal("\e[?25l") }
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe '#visible?' do
|
103
|
-
subject { instance.visible? }
|
104
|
-
|
105
|
-
context 'when visible' do
|
106
|
-
it { subject.must_be_instance_of(TrueClass) }
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'when not visible' do
|
110
|
-
let(:visible) { false }
|
111
|
-
|
112
|
-
it { subject.must_be_instance_of(FalseClass) }
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe '#invisible?' do
|
117
|
-
subject { instance.invisible? }
|
118
|
-
|
119
|
-
context 'when not visible' do
|
120
|
-
let(:visible) { false }
|
121
|
-
|
122
|
-
it { subject.must_be_instance_of(TrueClass) }
|
123
|
-
end
|
124
|
-
|
125
|
-
context 'when visible' do
|
126
|
-
it { subject.must_be_instance_of(FalseClass) }
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe '#hide' do
|
131
|
-
subject { instance.hide }
|
132
|
-
|
133
|
-
it { subject.must_be_instance_of(Visible) }
|
134
|
-
it { subject.visible?.must_equal(false) }
|
135
|
-
end
|
136
|
-
|
137
|
-
describe '#show' do
|
138
|
-
subject { instance.show }
|
139
|
-
it { subject.must_be_instance_of(Visible) }
|
140
|
-
it { subject.visible?.must_equal(true) }
|
141
|
-
end
|
142
|
-
|
143
|
-
describe '#toggle' do
|
144
|
-
subject { instance.toggle }
|
145
|
-
|
146
|
-
it { subject.must_be_instance_of(Visible) }
|
147
|
-
|
148
|
-
context 'when visible' do
|
149
|
-
it { subject.visible?.must_be_instance_of(FalseClass) }
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'when not visible' do
|
153
|
-
let(:visible) { false }
|
154
|
-
|
155
|
-
it { subject.visible?.must_be_instance_of(TrueClass) }
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
end # Visible
|
160
|
-
|
161
|
-
end # Vedeu
|