vedeu 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -2
  3. data/.travis.yml +1 -1
  4. data/README.md +2 -6
  5. data/config/rubocop_enabled.yml +0 -6
  6. data/docs/dsl/by_method/clock_time.md +4 -1
  7. data/lib/vedeu/application/application_controller.rb +2 -2
  8. data/lib/vedeu/application/controller.rb +3 -3
  9. data/lib/vedeu/borders/border.rb +6 -6
  10. data/lib/vedeu/borders/dsl.rb +26 -26
  11. data/lib/vedeu/borders/refresh.rb +2 -2
  12. data/lib/vedeu/borders/title.rb +4 -4
  13. data/lib/vedeu/buffers/refresh.rb +8 -7
  14. data/lib/vedeu/buffers/terminal.rb +1 -1
  15. data/lib/vedeu/buffers/view.rb +2 -2
  16. data/lib/vedeu/cells/clear.rb +1 -1
  17. data/lib/vedeu/cells/cursor.rb +6 -6
  18. data/lib/vedeu/cells/empty.rb +2 -2
  19. data/lib/vedeu/cells/escape.rb +6 -6
  20. data/lib/vedeu/coercers/alignment.rb +1 -1
  21. data/lib/vedeu/coercers/colour_attributes.rb +8 -16
  22. data/lib/vedeu/colours/background.rb +4 -8
  23. data/lib/vedeu/colours/colour.rb +4 -4
  24. data/lib/vedeu/colours/foreground.rb +4 -8
  25. data/lib/vedeu/colours/repository.rb +1 -1
  26. data/lib/vedeu/colours/translator.rb +6 -6
  27. data/lib/vedeu/common.rb +1 -1
  28. data/lib/vedeu/configuration/api.rb +15 -15
  29. data/lib/vedeu/configuration/configuration.rb +8 -8
  30. data/lib/vedeu/cursors/coordinate.rb +4 -4
  31. data/lib/vedeu/cursors/cursor.rb +2 -2
  32. data/lib/vedeu/distributed/client.rb +2 -2
  33. data/lib/vedeu/distributed/server.rb +8 -10
  34. data/lib/vedeu/distributed/subprocess.rb +1 -1
  35. data/lib/vedeu/distributed/uri.rb +1 -1
  36. data/lib/vedeu/dsl/cursors.rb +2 -2
  37. data/lib/vedeu/dsl/elements.rb +5 -5
  38. data/lib/vedeu/dsl/helpers/align.rb +1 -1
  39. data/lib/vedeu/dsl/helpers/attributes.rb +1 -1
  40. data/lib/vedeu/dsl/presentation.rb +15 -15
  41. data/lib/vedeu/dsl/view.rb +1 -1
  42. data/lib/vedeu/dsl/views.rb +1 -1
  43. data/lib/vedeu/editor/cursor.rb +1 -1
  44. data/lib/vedeu/editor/line.rb +2 -2
  45. data/lib/vedeu/editor/lines.rb +2 -2
  46. data/lib/vedeu/esc/borders.rb +19 -19
  47. data/lib/vedeu/esc/colours.rb +1 -1
  48. data/lib/vedeu/events/aliases.rb +3 -15
  49. data/lib/vedeu/events/event.rb +14 -14
  50. data/lib/vedeu/events/repository.rb +1 -1
  51. data/lib/vedeu/geometries/area/area.rb +5 -5
  52. data/lib/vedeu/geometries/area/dimension.rb +1 -1
  53. data/lib/vedeu/geometries/dsl/dsl.rb +7 -7
  54. data/lib/vedeu/geometries/geometry.rb +2 -2
  55. data/lib/vedeu/geometries/position.rb +6 -6
  56. data/lib/vedeu/groups/clear.rb +2 -2
  57. data/lib/vedeu/groups/group.rb +2 -2
  58. data/lib/vedeu/input/dsl.rb +1 -1
  59. data/lib/vedeu/input/key.rb +3 -3
  60. data/lib/vedeu/input/mapper.rb +2 -2
  61. data/lib/vedeu/input/read.rb +2 -4
  62. data/lib/vedeu/input/store.rb +1 -17
  63. data/lib/vedeu/input/translator.rb +49 -45
  64. data/lib/vedeu/interfaces/clear.rb +3 -3
  65. data/lib/vedeu/interfaces/dsl.rb +4 -4
  66. data/lib/vedeu/interfaces/interface.rb +2 -2
  67. data/lib/vedeu/logging/clock_time.rb +3 -3
  68. data/lib/vedeu/logging/debug.rb +14 -6
  69. data/lib/vedeu/logging/log.rb +1 -1
  70. data/lib/vedeu/menus/dsl.rb +2 -2
  71. data/lib/vedeu/menus/menu.rb +9 -9
  72. data/lib/vedeu/models/focus.rb +11 -11
  73. data/lib/vedeu/models/page.rb +1 -1
  74. data/lib/vedeu/models/row.rb +1 -1
  75. data/lib/vedeu/models/toggleable.rb +7 -7
  76. data/lib/vedeu/null/generic.rb +29 -29
  77. data/lib/vedeu/output/compressor_cache.rb +1 -11
  78. data/lib/vedeu/output/viewport.rb +4 -12
  79. data/lib/vedeu/output/write.rb +3 -3
  80. data/lib/vedeu/plugins/plugin.rb +1 -1
  81. data/lib/vedeu/presentation/colour.rb +1 -1
  82. data/lib/vedeu/presentation/presentation.rb +1 -1
  83. data/lib/vedeu/presentation/style.rb +4 -4
  84. data/lib/vedeu/renderers/all.rb +1 -14
  85. data/lib/vedeu/renderers/options.rb +1 -1
  86. data/lib/vedeu/repositories/all.rb +1 -0
  87. data/lib/vedeu/repositories/assemblage.rb +1 -1
  88. data/lib/vedeu/repositories/collection.rb +4 -4
  89. data/lib/vedeu/repositories/registerable.rb +2 -2
  90. data/lib/vedeu/repositories/repositories.rb +1 -1
  91. data/lib/vedeu/repositories/repository.rb +3 -3
  92. data/lib/vedeu/repositories/storage.rb +38 -0
  93. data/lib/vedeu/repositories/store.rb +5 -22
  94. data/lib/vedeu/runtime/application.rb +1 -1
  95. data/lib/vedeu/runtime/flags.rb +3 -3
  96. data/lib/vedeu/runtime/router.rb +3 -18
  97. data/lib/vedeu/templating/helpers.rb +5 -3
  98. data/lib/vedeu/templating/view_template.rb +26 -18
  99. data/lib/vedeu/terminal/terminal.rb +5 -5
  100. data/lib/vedeu/version.rb +1 -1
  101. data/lib/vedeu/views/chars.rb +1 -1
  102. data/lib/vedeu/views/composition.rb +4 -4
  103. data/lib/vedeu/views/default_attributes.rb +2 -2
  104. data/lib/vedeu/views/line.rb +6 -6
  105. data/lib/vedeu/views/lines.rb +1 -1
  106. data/lib/vedeu/views/stream.rb +6 -6
  107. data/lib/vedeu/views/streams.rb +1 -1
  108. data/lib/vedeu/views/view.rb +4 -4
  109. data/test/lib/vedeu/borders/border_test.rb +1 -1
  110. data/test/lib/vedeu/borders/caption_test.rb +1 -1
  111. data/test/lib/vedeu/borders/dsl_test.rb +2 -3
  112. data/test/lib/vedeu/borders/refresh_test.rb +1 -1
  113. data/test/lib/vedeu/borders/title_test.rb +1 -1
  114. data/test/lib/vedeu/buffers/buffer_test.rb +7 -7
  115. data/test/lib/vedeu/buffers/refresh_test.rb +1 -1
  116. data/test/lib/vedeu/colours/background_test.rb +27 -0
  117. data/test/lib/vedeu/colours/foreground_test.rb +27 -0
  118. data/test/lib/vedeu/cursors/cursor_test.rb +3 -3
  119. data/test/lib/vedeu/cursors/move_test.rb +1 -1
  120. data/test/lib/vedeu/cursors/refresh_test.rb +1 -1
  121. data/test/lib/vedeu/cursors/reposition_test.rb +2 -2
  122. data/test/lib/vedeu/dsl/view_test.rb +6 -8
  123. data/test/lib/vedeu/editor/cropper_test.rb +1 -1
  124. data/test/lib/vedeu/editor/cursor_test.rb +1 -1
  125. data/test/lib/vedeu/editor/document_test.rb +1 -1
  126. data/test/lib/vedeu/editor/editor_test.rb +1 -1
  127. data/test/lib/vedeu/events/aliases_test.rb +0 -14
  128. data/test/lib/vedeu/geometries/area/area_test.rb +1 -1
  129. data/test/lib/vedeu/geometries/geometry_test.rb +1 -1
  130. data/test/lib/vedeu/geometries/move_test.rb +1 -1
  131. data/test/lib/vedeu/groups/clear_test.rb +1 -1
  132. data/test/lib/vedeu/groups/dsl_test.rb +1 -1
  133. data/test/lib/vedeu/groups/group_test.rb +1 -1
  134. data/test/lib/vedeu/groups/refresh_test.rb +1 -1
  135. data/test/lib/vedeu/input/capture_test.rb +2 -2
  136. data/test/lib/vedeu/input/store_test.rb +0 -34
  137. data/test/lib/vedeu/interfaces/clear_test.rb +1 -1
  138. data/test/lib/vedeu/interfaces/dsl_test.rb +4 -4
  139. data/test/lib/vedeu/interfaces/interface_test.rb +1 -1
  140. data/test/lib/vedeu/menus/dsl_test.rb +1 -1
  141. data/test/lib/vedeu/null/generic_test.rb +1 -1
  142. data/test/lib/vedeu/output/compressor_cache_test.rb +0 -33
  143. data/test/lib/vedeu/renderers/all_test.rb +0 -8
  144. data/test/lib/vedeu/repositories/repository_test.rb +2 -2
  145. data/test/lib/vedeu/repositories/storage_test.rb +74 -0
  146. data/test/lib/vedeu/repositories/store_test.rb +10 -28
  147. data/test/lib/vedeu/runtime/router_test.rb +0 -8
  148. data/test/lib/vedeu/views/default_attributes_test.rb +5 -5
  149. data/test/lib/vedeu/views/view_test.rb +5 -2
  150. data/test/test_helper.rb +1 -1
  151. data/vedeu.gemspec +1 -1
  152. metadata +7 -4
@@ -26,8 +26,8 @@ module Vedeu
26
26
  Vedeu::Templating::Decoder.process(stream)
27
27
 
28
28
  else
29
- Vedeu::Views::Stream.new(colour: default_colour,
30
- style: default_style,
29
+ Vedeu::Views::Stream.new(colour: stream_colour,
30
+ style: stream_style,
31
31
  value: stream)
32
32
 
33
33
  end
@@ -54,24 +54,22 @@ module Vedeu
54
54
  # Return the interface colours if a name option is set,
55
55
  # otherwise use the default colours.
56
56
  #
57
- # @return [Vedeu::Colours::Colour|Hash<Symbol => Symbol>]
58
- def default_colour
59
- return interface.colour if options[:name]
57
+ # @return [Vedeu::Colours::Colour|Hash<Symbol => NilClass,String,Symbol>]
58
+ def stream_colour
59
+ return interface.colour if name
60
60
 
61
- {
62
- background: :default,
63
- foreground: :default,
64
- }
61
+ default[:colour]
65
62
  end
66
63
 
67
- # Return the interface style(s) if a name option is set,
68
- # otherwise use the default style.
69
- #
70
- # @return [Symbol]
71
- def default_style
72
- return interface.style if options[:name]
73
-
74
- :normal
64
+ # @return [Hash<Symbol => Hash<Symbol => Symbol>,Symbol>]
65
+ def default
66
+ {
67
+ colour: {
68
+ background: :default,
69
+ foreground: :default,
70
+ },
71
+ style: :normal,
72
+ }
75
73
  end
76
74
 
77
75
  # Returns the interface by name.
@@ -80,7 +78,7 @@ module Vedeu
80
78
  def interface
81
79
  Vedeu.interfaces.by_name(name)
82
80
  end
83
- alias_method :interface?, :interface
81
+ alias interface? interface
84
82
 
85
83
  # @return [String|Symbol]
86
84
  def name
@@ -95,6 +93,16 @@ module Vedeu
95
93
  line.split(/({{\s*[^}]+\s*}})/)
96
94
  end
97
95
 
96
+ # Return the interface style(s) if a name option is set,
97
+ # otherwise use the default style.
98
+ #
99
+ # @return [Symbol]
100
+ def stream_style
101
+ return interface.style if name
102
+
103
+ default[:style]
104
+ end
105
+
98
106
  # Convert the content into an array of strings without the line
99
107
  # ending character.
100
108
  #
@@ -15,8 +15,8 @@ module Vedeu
15
15
  :height,
16
16
  :width
17
17
 
18
- alias_method :tyn, :height
19
- alias_method :txn, :width
18
+ alias tyn height
19
+ alias txn width
20
20
 
21
21
  # Opens a terminal screen in either `raw` or `cooked` mode. On
22
22
  # exit, attempts to restore the screen. See
@@ -51,7 +51,7 @@ module Vedeu
51
51
  console.print(stream)
52
52
  end
53
53
  end
54
- alias_method :write, :output
54
+ alias write output
55
55
 
56
56
  # {include:file:docs/dsl/by_method/resize.md}
57
57
  # @return [Boolean]
@@ -140,8 +140,8 @@ module Vedeu
140
140
  def origin
141
141
  1
142
142
  end
143
- alias_method :tx, :origin
144
- alias_method :ty, :origin
143
+ alias tx origin
144
+ alias ty origin
145
145
 
146
146
  # Returns a tuple containing the height and width of the current
147
147
  # terminal.
data/lib/vedeu/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
  module Vedeu
4
4
 
5
5
  # The current version of Vedeu.
6
- VERSION = '0.8.6'
6
+ VERSION = '0.8.7'.freeze
7
7
 
8
8
  end
@@ -52,7 +52,7 @@ module Vedeu
52
52
  end
53
53
  end
54
54
 
55
- alias_method :chars, :value
55
+ alias chars value
56
56
 
57
57
  end # Chars
58
58
 
@@ -18,9 +18,9 @@ module Vedeu
18
18
  deputy Vedeu::DSL::View
19
19
  entity Vedeu::Views::View
20
20
 
21
- alias_method :views, :value
22
- alias_method :views=, :value=
23
- alias_method :views?, :value?
21
+ alias views value
22
+ alias views= value=
23
+ alias views? value?
24
24
 
25
25
  # Returns a new instance of Vedeu::Views::Composition.
26
26
  #
@@ -41,7 +41,7 @@ module Vedeu
41
41
  def add(child)
42
42
  @value = value.add(child)
43
43
  end
44
- alias_method :<<, :add
44
+ alias << add
45
45
 
46
46
  # @return [Hash<Symbol => void>]
47
47
  def attributes
@@ -23,7 +23,7 @@ module Vedeu
23
23
  # @!attribute [r] truncate
24
24
  # @return [Boolean]
25
25
  attr_reader :truncate
26
- alias_method :truncate?, :truncate
26
+ alias truncate? truncate
27
27
 
28
28
  # @!attribute [r] width
29
29
  # @return [Fixnum|NilClass]
@@ -32,7 +32,7 @@ module Vedeu
32
32
  # @!attribute [r] wordwrap
33
33
  # @return [Boolean]
34
34
  attr_reader :wordwrap
35
- alias_method :wordwrap?, :wordwrap
35
+ alias wordwrap? wordwrap
36
36
 
37
37
  # @return [Hash<Symbol => void>]
38
38
  def attributes
@@ -37,8 +37,8 @@ module Vedeu
37
37
  def_delegators :value,
38
38
  :streams
39
39
 
40
- alias_method :streams=, :value=
41
- alias_method :streams?, :value?
40
+ alias streams= value=
41
+ alias streams? value?
42
42
 
43
43
  # Returns a new instance of Vedeu::Views::Line.
44
44
  #
@@ -61,7 +61,7 @@ module Vedeu
61
61
  def add(child)
62
62
  @value = value.add(child)
63
63
  end
64
- alias_method :<<, :add
64
+ alias << add
65
65
 
66
66
  # Returns an array of all the characters with formatting for
67
67
  # this line.
@@ -69,7 +69,7 @@ module Vedeu
69
69
  # @return [Array]
70
70
  # @see Vedeu::Views::Stream
71
71
  def chars
72
- return [] unless value?
72
+ return [] unless streams?
73
73
 
74
74
  @chars ||= streams.flat_map(&:chars)
75
75
  end
@@ -81,7 +81,7 @@ module Vedeu
81
81
  def eql?(other)
82
82
  self.class == other.class && value == other.value
83
83
  end
84
- alias_method :==, :eql?
84
+ alias == eql?
85
85
 
86
86
  # @return [NilClass|String|Symbol]
87
87
  def name
@@ -104,7 +104,7 @@ module Vedeu
104
104
  #
105
105
  # @return [Fixnum]
106
106
  def size
107
- value.map(&:size).inject(0, :+)
107
+ streams.map(&:size).inject(0, :+)
108
108
  end
109
109
 
110
110
  end # Line
@@ -43,7 +43,7 @@ module Vedeu
43
43
  end
44
44
  end
45
45
 
46
- alias_method :lines, :value
46
+ alias lines value
47
47
 
48
48
  end # Lines
49
49
 
@@ -39,10 +39,10 @@ module Vedeu
39
39
  :chars,
40
40
  :size
41
41
 
42
- alias_method :content, :value
43
- alias_method :text, :value
44
- alias_method :chars=, :value=
45
- alias_method :chars?, :value?
42
+ alias content value
43
+ alias text value
44
+ alias chars= value=
45
+ alias chars? value?
46
46
 
47
47
  # @!attribute [w] value
48
48
  # @return [String]
@@ -76,7 +76,7 @@ module Vedeu
76
76
  self
77
77
  end
78
78
  end
79
- alias_method :<<, :add
79
+ alias << add
80
80
 
81
81
  # An object is equal when its values are the same.
82
82
  #
@@ -85,7 +85,7 @@ module Vedeu
85
85
  def eql?(other)
86
86
  self.class == other.class && value == other.value
87
87
  end
88
- alias_method :==, :eql?
88
+ alias == eql?
89
89
 
90
90
  # @return [NilClass|String|Symbol]
91
91
  def name
@@ -54,7 +54,7 @@ module Vedeu
54
54
  end
55
55
  end
56
56
 
57
- alias_method :streams, :value
57
+ alias streams value
58
58
 
59
59
  end # Streams
60
60
 
@@ -38,13 +38,13 @@ module Vedeu
38
38
  def_delegators :value,
39
39
  :lines
40
40
 
41
- alias_method :lines=, :value=
42
- alias_method :lines?, :value?
41
+ alias lines= value=
42
+ alias lines? value?
43
43
 
44
44
  # @!attribute [rw] cursor_visible
45
45
  # @return [Boolean]
46
46
  attr_accessor :cursor_visible
47
- alias_method :cursor_visible?, :cursor_visible
47
+ alias cursor_visible? cursor_visible
48
48
 
49
49
  # @!attribute [rw] name
50
50
  # @return [String|Symbol]
@@ -77,7 +77,7 @@ module Vedeu
77
77
  def add(child)
78
78
  @value = value.add(child)
79
79
  end
80
- alias_method :<<, :add
80
+ alias << add
81
81
 
82
82
  # @return [Hash]
83
83
  def attributes
@@ -46,7 +46,7 @@ module Vedeu
46
46
  let(:top_left) { 'l' }
47
47
  let(:top_right) { 'k' }
48
48
  let(:geometry) {}
49
- let(:_name) { 'borders' }
49
+ let(:_name) { :vedeu_borders_border }
50
50
 
51
51
  describe '.build' do
52
52
  subject {
@@ -10,7 +10,7 @@ module Vedeu
10
10
 
11
11
  let(:described) { Vedeu::Borders::Caption }
12
12
  let(:instance) { described.new(_name, _value, horizontal) }
13
- let(:_name) { 'Vedeu::Borders::Caption' }
13
+ let(:_name) { :vedeu_borders_caption }
14
14
  let(:_value) { 'Bismuth' }
15
15
  let(:type) { :bottom_horizontal }
16
16
  let(:horizontal) {
@@ -12,12 +12,11 @@ module Vedeu
12
12
  let(:instance) { described.new(model, client) }
13
13
  let(:model) { Vedeu::Borders::Border.new(attributes) }
14
14
  let(:client) {}
15
- let(:attributes) { { name: 'borders' } }
15
+ let(:attributes) { { name: _name } }
16
16
  let(:boolean) { true }
17
+ let(:_name) { :vedeu_borders_dsl }
17
18
 
18
19
  describe '.border' do
19
- let(:_name) { 'Vedeu::Borders::DSL' }
20
-
21
20
  after { Vedeu.borders.reset! }
22
21
 
23
22
  subject { described.border(_name) { } }
@@ -26,7 +26,7 @@ module Vedeu
26
26
  }
27
27
  let(:visible) { true }
28
28
  let(:enabled) { false }
29
- let(:_name) { 'Vedeu::Borders::Refresh' }
29
+ let(:_name) { :vedeu_borders_refresh }
30
30
  let(:title) {}
31
31
  let(:caption) {}
32
32
  let(:show_top) { true }
@@ -10,7 +10,7 @@ module Vedeu
10
10
 
11
11
  let(:described) { Vedeu::Borders::Title }
12
12
  let(:instance) { described.new(_name, _value, horizontal) }
13
- let(:_name) { 'Vedeu::Borders::Title' }
13
+ let(:_name) { :vedeu_borders_title }
14
14
  let(:_value) { 'Aluminium' }
15
15
  let(:horizontal) {
16
16
  [
@@ -10,19 +10,18 @@ module Vedeu
10
10
 
11
11
  let(:described) { Vedeu::Buffers::Buffer }
12
12
  let(:instance) { described.new(attributes) }
13
- let(:_name) { 'krypton' }
14
- let(:back) {}
15
- let(:front) {}
16
- let(:previous) {}
17
- let(:interface) {}
18
13
  let(:attributes) {
19
14
  {
20
- name: _name,
21
15
  back: back,
22
16
  front: front,
17
+ name: _name,
23
18
  previous: previous,
24
19
  }
25
20
  }
21
+ let(:back) {}
22
+ let(:front) {}
23
+ let(:_name) { :vedeu_buffers_buffer }
24
+ let(:previous) {}
26
25
 
27
26
  describe '#initialize' do
28
27
  it { instance.must_be_instance_of(described) }
@@ -31,7 +30,8 @@ module Vedeu
31
30
  it { instance.instance_variable_get('@front').must_equal(front) }
32
31
  it { instance.instance_variable_get('@previous').must_equal(previous) }
33
32
  it do
34
- instance.instance_variable_get('@repository').must_equal(Vedeu.buffers)
33
+ instance.instance_variable_get('@repository')
34
+ .must_equal(Vedeu.buffers)
35
35
  end
36
36
  end
37
37
 
@@ -15,7 +15,7 @@ module Vedeu
15
15
 
16
16
  let(:described) { Vedeu::Buffers::Refresh }
17
17
  let(:instance) { described.new(_name, options) }
18
- let(:_name) { 'Vedeu::Buffers::Refresh' }
18
+ let(:_name) { :vedeu_buffers_refresh }
19
19
  let(:options) {
20
20
  {
21
21
  content_only: content_only,
@@ -92,6 +92,33 @@ module Vedeu
92
92
  end
93
93
  end
94
94
 
95
+ describe '#to_ast' do
96
+ subject { instance.to_ast }
97
+
98
+ context 'when there is no background' do
99
+ let(:colour) { '' }
100
+ let(:expected) { '' }
101
+
102
+ it { subject.must_equal(expected) }
103
+ end
104
+
105
+ context 'when there is a background' do
106
+ context 'when the background is an CSS/HTML value' do
107
+ let(:colour) { '#ff0000' }
108
+ let(:expected) { ':bg_ff0000' }
109
+
110
+ it { subject.must_equal(expected) }
111
+ end
112
+
113
+ context 'when the background is not a CSS/HTML value' do
114
+ let(:colour) { 233 }
115
+ let(:expected) { ':bg' }
116
+
117
+ it { subject.must_equal(expected) }
118
+ end
119
+ end
120
+ end
121
+
95
122
  describe '#to_h' do
96
123
  subject { instance.to_h }
97
124
 
@@ -92,6 +92,33 @@ module Vedeu
92
92
  end
93
93
  end
94
94
 
95
+ describe '#to_ast' do
96
+ subject { instance.to_ast }
97
+
98
+ context 'when there is no foreground' do
99
+ let(:colour) { '' }
100
+ let(:expected) { '' }
101
+
102
+ it { subject.must_equal(expected) }
103
+ end
104
+
105
+ context 'when there is a foreground' do
106
+ context 'when the foreground is an CSS/HTML value' do
107
+ let(:colour) { '#ff0000' }
108
+ let(:expected) { ':fg_ff0000' }
109
+
110
+ it { subject.must_equal(expected) }
111
+ end
112
+
113
+ context 'when the foreground is not a CSS/HTML value' do
114
+ let(:colour) { 233 }
115
+ let(:expected) { ':fg' }
116
+
117
+ it { subject.must_equal(expected) }
118
+ end
119
+ end
120
+ end
121
+
95
122
  describe '#to_h' do
96
123
  subject { instance.to_h }
97
124