curses_menu 0.0.1 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,123 @@
1
+ describe CursesMenu do
2
+
3
+ it 'displays a menu with 1 item' do
4
+ test_menu(title: 'Menu title') do |menu|
5
+ menu.item 'Menu item'
6
+ end
7
+ assert_line 1, '= Menu title'
8
+ assert_line 3, 'Menu item'
9
+ assert_line(-1, '= Arrows/Home/End: Navigate | Esc: Exit')
10
+ end
11
+
12
+ it 'displays a menu with several items' do
13
+ test_menu do |menu|
14
+ menu.item 'Menu item 1'
15
+ menu.item 'Menu item 2'
16
+ menu.item 'Menu item 3'
17
+ end
18
+ assert_line 3, 'Menu item 1'
19
+ assert_line 4, 'Menu item 2'
20
+ assert_line 5, 'Menu item 3'
21
+ end
22
+
23
+ it 'displays a menu item with more actions' do
24
+ test_menu do |menu|
25
+ menu.item 'Menu item', actions: {
26
+ 'a' => {
27
+ name: 'First action',
28
+ execute: proc {}
29
+ },
30
+ 'b' => {
31
+ name: 'Second action',
32
+ execute: proc {}
33
+ }
34
+ }
35
+ end
36
+ assert_line(-1, '= Arrows/Home/End: Navigate | Esc: Exit | a: First action | b: Second action')
37
+ end
38
+
39
+ it 'navigates by using down key' do
40
+ test_menu(keys: [Curses::KEY_DOWN, Curses::KEY_DOWN]) do |menu|
41
+ menu.item 'Menu item 1'
42
+ menu.item 'Menu item 2'
43
+ menu.item 'Menu item 3', actions: { 'a' => { name: 'Special action', execute: proc {} } }
44
+ menu.item 'Menu item 4'
45
+ end
46
+ assert_line(-1, '= Arrows/Home/End: Navigate | Esc: Exit | a: Special action')
47
+ end
48
+
49
+ it 'navigates by using end key' do
50
+ test_menu(keys: [Curses::KEY_END]) do |menu|
51
+ menu.item 'Menu item 1'
52
+ menu.item 'Menu item 2'
53
+ menu.item 'Menu item 3'
54
+ menu.item 'Menu item 4', actions: { 'a' => { name: 'Special action', execute: proc {} } }
55
+ end
56
+ assert_line(-1, '= Arrows/Home/End: Navigate | Esc: Exit | a: Special action')
57
+ end
58
+
59
+ it 'navigates by using up key' do
60
+ test_menu(keys: [Curses::KEY_END, Curses::KEY_UP]) do |menu|
61
+ menu.item 'Menu item 1'
62
+ menu.item 'Menu item 2'
63
+ menu.item 'Menu item 3', actions: { 'a' => { name: 'Special action', execute: proc {} } }
64
+ menu.item 'Menu item 4'
65
+ end
66
+ assert_line(-1, '= Arrows/Home/End: Navigate | Esc: Exit | a: Special action')
67
+ end
68
+
69
+ it 'navigates by using home key' do
70
+ test_menu(keys: [Curses::KEY_END, Curses::KEY_HOME]) do |menu|
71
+ menu.item 'Menu item 1', actions: { 'a' => { name: 'Special action', execute: proc {} } }
72
+ menu.item 'Menu item 2'
73
+ menu.item 'Menu item 3'
74
+ menu.item 'Menu item 4'
75
+ end
76
+ assert_line(-1, '= Arrows/Home/End: Navigate | Esc: Exit | a: Special action')
77
+ end
78
+
79
+ it 'navigates by using right key' do
80
+ test_menu(keys: [Curses::KEY_RIGHT, Curses::KEY_RIGHT]) do |menu|
81
+ menu.item 'Menu item'
82
+ end
83
+ assert_line 3, 'nu item'
84
+ assert_line(-1, 'Arrows/Home/End: Navigate | Esc: Exit')
85
+ end
86
+
87
+ it 'navigates by using left key' do
88
+ test_menu(keys: [Curses::KEY_RIGHT, Curses::KEY_RIGHT, Curses::KEY_LEFT]) do |menu|
89
+ menu.item 'Menu item'
90
+ end
91
+ assert_line 3, 'enu item'
92
+ assert_line(-1, ' Arrows/Home/End: Navigate | Esc: Exit')
93
+ end
94
+
95
+ it 'navigates by using page down key' do
96
+ nbr_visible_items = Curses.stdscr.maxy - 5
97
+ test_menu(keys: [Curses::KEY_NPAGE]) do |menu|
98
+ (nbr_visible_items * 2).times do |idx|
99
+ if idx == nbr_visible_items - 1
100
+ menu.item "Menu item #{idx}", actions: { 'a' => { name: "Special action #{idx}", execute: proc {} } }
101
+ else
102
+ menu.item "Menu item #{idx}"
103
+ end
104
+ end
105
+ end
106
+ assert_line(-1, "= Arrows/Home/End: Navigate | Esc: Exit | a: Special action #{nbr_visible_items - 1}")
107
+ end
108
+
109
+ it 'navigates by using page up key' do
110
+ nbr_visible_items = Curses.stdscr.maxy - 5
111
+ test_menu(keys: [Curses::KEY_END, Curses::KEY_PPAGE]) do |menu|
112
+ (nbr_visible_items * 2).times do |idx|
113
+ if idx == nbr_visible_items
114
+ menu.item "Menu item #{idx}", actions: { 'a' => { name: "Special action #{idx}", execute: proc {} } }
115
+ else
116
+ menu.item "Menu item #{idx}"
117
+ end
118
+ end
119
+ end
120
+ assert_line(-1, "= Arrows/Home/End: Navigate | Esc: Exit | a: Special action #{nbr_visible_items}")
121
+ end
122
+
123
+ end
@@ -0,0 +1,105 @@
1
+ require 'curses_menu_test'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # Add our own helpers
34
+ config.include CursesMenuTest::Helpers
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+
45
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
46
+ # have no way to turn it off -- the option exists only for backwards
47
+ # compatibility in RSpec 3). It causes shared context metadata to be
48
+ # inherited by the metadata hash of host groups and examples, rather than
49
+ # triggering implicit auto-inclusion in groups with matching metadata.
50
+ config.shared_context_metadata_behavior = :apply_to_host_groups
51
+
52
+ # The settings below are suggested to provide a good initial experience
53
+ # with RSpec, but feel free to customize to your heart's content.
54
+
55
+ # This allows you to limit a spec run to individual examples or groups
56
+ # you care about by tagging them with `:focus` metadata. When nothing
57
+ # is tagged with `:focus`, all examples get run. RSpec also provides
58
+ # aliases for `it`, `describe`, and `context` that include `:focus`
59
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
60
+ # config.filter_run_when_matching :focus
61
+
62
+ # Allows RSpec to persist some state between runs in order to support
63
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
64
+ # you configure your source control system to ignore this file.
65
+ # config.example_status_persistence_file_path = "spec/examples.txt"
66
+
67
+ # Limits the available syntax to the non-monkey patched syntax that is
68
+ # recommended. For more details, see:
69
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
70
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
71
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
72
+ # config.disable_monkey_patching!
73
+
74
+ # This setting enables warnings. It's recommended, but in some cases may
75
+ # be too noisy due to issues in dependencies.
76
+ # config.warnings = true
77
+
78
+ # Many RSpec users commonly either run the entire suite or an individual
79
+ # file, and it's useful to allow more verbose output when running an
80
+ # individual spec file.
81
+ # if config.files_to_run.one?
82
+ # # Use the documentation formatter for detailed output,
83
+ # # unless a formatter has already been configured
84
+ # # (e.g. via a command-line flag).
85
+ # config.default_formatter = "doc"
86
+ # end
87
+
88
+ # Print the 10 slowest examples and example groups at the
89
+ # end of the spec run, to help surface which specs are running
90
+ # particularly slow.
91
+ # config.profile_examples = 10
92
+
93
+ # Run specs in random order to surface order dependencies. If you find an
94
+ # order dependency and want to debug it, you can fix the order by providing
95
+ # the seed, which is printed after each run.
96
+ # --seed 1234
97
+ # config.order = :random
98
+
99
+ # Seed global randomization in this process using the `--seed` CLI option.
100
+ # Setting this allows you to use `--seed` to deterministically reproduce
101
+ # test failures related to randomization by passing the same `--seed` value
102
+ # as the one that triggered the failure.
103
+ # Kernel.srand config.seed
104
+
105
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curses_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-01 00:00:00.000000000 Z
11
+ date: 2021-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -16,21 +16,92 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '1.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sem_ver_components
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.19'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.19'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.4'
27
83
  description:
28
84
  email:
29
85
  - muriel@x-aeon.com
30
86
  executables: []
31
87
  extensions: []
32
- extra_rdoc_files: []
88
+ extra_rdoc_files:
89
+ - CHANGELOG.md
90
+ - README.md
91
+ - LICENSE.md
92
+ - examples/utf_8.rb
93
+ - examples/hello.rb
94
+ - examples/sub_menus.rb
95
+ - examples/automatic_key_presses.rb
96
+ - examples/refresh.rb
97
+ - examples/formatting.rb
98
+ - examples/several_items.rb
99
+ - examples/actions.rb
100
+ - examples/scrolling.rb
33
101
  files:
102
+ - CHANGELOG.md
103
+ - LICENSE.md
104
+ - README.md
34
105
  - examples/actions.rb
35
106
  - examples/automatic_key_presses.rb
36
107
  - examples/formatting.rb
@@ -39,13 +110,22 @@ files:
39
110
  - examples/scrolling.rb
40
111
  - examples/several_items.rb
41
112
  - examples/sub_menus.rb
113
+ - examples/utf_8.rb
42
114
  - lib/curses_menu.rb
43
115
  - lib/curses_menu/curses_row.rb
44
- homepage: http://x-aeon.com
116
+ - lib/curses_menu/version.rb
117
+ - spec/curses_menu_test.rb
118
+ - spec/curses_menu_test/actions_spec.rb
119
+ - spec/curses_menu_test/formatting_spec.rb
120
+ - spec/curses_menu_test/rubocop_spec.rb
121
+ - spec/curses_menu_test/scrolling_spec.rb
122
+ - spec/curses_menu_test/simple_navigation_spec.rb
123
+ - spec/spec_helper.rb
124
+ homepage: https://github.com/Muriel-Salvan/curses_menu
45
125
  licenses:
46
126
  - BSD-3-Clause
47
127
  metadata:
48
- homepage_uri: http://x-aeon.com
128
+ homepage_uri: https://github.com/Muriel-Salvan/curses_menu
49
129
  post_install_message:
50
130
  rdoc_options: []
51
131
  require_paths:
@@ -54,15 +134,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
134
  requirements:
55
135
  - - ">="
56
136
  - !ruby/object:Gem::Version
57
- version: '0'
137
+ version: '2.6'
58
138
  required_rubygems_version: !ruby/object:Gem::Requirement
59
139
  requirements:
60
140
  - - ">="
61
141
  - !ruby/object:Gem::Version
62
142
  version: '0'
63
143
  requirements: []
64
- rubyforge_project:
65
- rubygems_version: 2.7.6
144
+ rubygems_version: 3.1.6
66
145
  signing_key:
67
146
  specification_version: 4
68
147
  summary: Simple menu offering choices with navigation keys using curses