ttytest2 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a35421907aa8999c90ba5e18959aa659bf6a9b14248ae46acddb7d18f1db0f5
4
- data.tar.gz: bbf9762f20e681e29861f9f04090afa03c238fccee3ea6e3d2e8314fb6fa88c1
3
+ metadata.gz: 000e855fe9017a84a4041ff693e8037d7ce134231699fb5e4440be428d7f068b
4
+ data.tar.gz: fac1531d712a1f276a3b861fc9f3cb1a21b6a3849433bf4bfff76ec852b39637
5
5
  SHA512:
6
- metadata.gz: 978ca3331442680de64cd74fdd9e7167526c4a521dc9ed41fdbd8e08d89d9caebb617d6427edb58b5bc79b1b0a522cbb4a54d0854a5f8a3953f22777adebc0d9
7
- data.tar.gz: 4115b6301cba03d98b92a6b40f9264b3a0630f28421fae34d402bbfef941f6704895e6b73fee83ddde511b2523f602a16d351434366392a75a1e61457164432d
6
+ metadata.gz: 93ee5ba6fad1d8f44f000de98a2acd17fa7cb4d19e96dec87f2ea83a718d95db2eaf59b98d9430f8c4009d6f2808a066da31027d28b6005dd97e1906da16a783
7
+ data.tar.gz: 1d9de87f136ae70629a67e21570f325f1cd18e6ce243a0cd000b0f5217efc4222144e52ae1eaa2ba6658d2434c8a3293be83d407adda6e23e6e403432df1f94f
data/README.md CHANGED
@@ -6,7 +6,10 @@ Forked from https://github.com/jhawthorn/ttytest, because I had some features I
6
6
 
7
7
  It works by running commands inside a tmux session, capturing the pane, and comparing the content. The assertions will wait a specified amount of time (default 2 seconds) for the expected content to appear.
8
8
 
9
- [![Gem Version](https://badge.fury.io/rb/ttytest2.svg)](https://rubygems.org/gems/ttytest2)
9
+ [![Gem Version](https://badge.fury.io/rb/ttytest2.svg)](https://badge.fury.io/rb/ttytest2)
10
+
11
+ ## Gem at RubyGems.org
12
+ https://rubygems.org/gems/ttytest2
10
13
 
11
14
  ## Minimum Requirements
12
15
 
@@ -15,7 +18,8 @@ It works by running commands inside a tmux session, capturing the pane, and comp
15
18
 
16
19
  ## Usage
17
20
 
18
- ### Example
21
+ ### Example Canonical CLI/Shell
22
+ Most people should use send_keys, if you are writing or working with a noncanonical shell/CLI, you will probably know it. Most are canonical.
19
23
 
20
24
  ``` ruby
21
25
  require 'ttytest'
@@ -36,6 +40,21 @@ TTY
36
40
  p @tty.rows # => ["$ echo \"Hello, world\"", "Hello, world", "$", "", "", "", ...]
37
41
  ```
38
42
 
43
+ ### Example Noncanonical CLI/Shell
44
+ If you are working with a noncanonical shell, you need to use send_keys_one_at_a_time to have your shell/CLI process the input correctly.
45
+
46
+ ``` ruby
47
+ require 'ttytest'
48
+
49
+ @tty = TTYtest.new_terminal(%{PS1='$ ' /bin/noncanonical-sh}, width: 80, height: 24)
50
+ @tty.assert_row_starts_with(0, ENV['USER'])
51
+ @tty.assert_row_ends_with(0, '$')
52
+
53
+ @tty.send_keys_one_at_a_time('ls')
54
+ @tty.assert_row_ends_with(0, 'ls')
55
+ @tty.send_keys_one_at_a_time(%(\n))
56
+ ```
57
+
39
58
  ### Assertions
40
59
 
41
60
  The main way to use TTYtest is through assertions. When called on a `TTYtest::Terminal`, each of these will be retried (for up to 2 seconds by default).
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rake/testtask'
3
5
  require 'yard'
@@ -19,12 +19,15 @@ module TTYtest
19
19
  end
20
20
 
21
21
  # @!method send_keys(*keys)
22
- # Simulate typing keys into the terminal
22
+ # Simulate typing keys into the terminal. For canonical cli's/shells which read line by line.
23
+ # @param [String] keys keys to send to the terminal
24
+ # @!method send_keys_one_at_a_time(*keys)
25
+ # Simulate typing keys into the terminal. For noncanonical cli's/shells which read character by character.
23
26
  # @param [String] keys keys to send to the terminal
24
27
  # @!method capture
25
28
  # Capture the current state of the terminal
26
29
  # @return [Capture] instantaneous state of the terminal when called
27
- def_delegators :@driver_terminal, :send_keys, :capture
30
+ def_delegators :@driver_terminal, :send_keys, :send_keys_one_at_a_time, :capture
28
31
 
29
32
  # @!method rows
30
33
  # @return [Array<String>]
@@ -8,6 +8,7 @@ require 'ttytest/tmux/session'
8
8
 
9
9
  module TTYtest
10
10
  module Tmux
11
+ # tmux driver
11
12
  class Driver
12
13
  COMMAND = 'tmux'
13
14
  SOCKET_NAME = 'ttytest'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module TTYtest
4
4
  module Tmux
5
- # tmux session manager
5
+ # represents a tmux session and how to send output to the current tmux session
6
6
  class Session
7
7
  # @api private
8
8
  def initialize(driver, name)
@@ -42,6 +42,12 @@ module TTYtest
42
42
  driver.tmux(*%W[send-keys -t #{name} -l], *keys)
43
43
  end
44
44
 
45
+ def send_keys_one_at_a_time(*keys)
46
+ keys.each do |key|
47
+ driver.tmux(*%W[send-keys -t #{name} -l], key)
48
+ end
49
+ end
50
+
45
51
  private
46
52
 
47
53
  attr_reader :driver, :name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TTYtest
4
- VERSION = '0.8.1'
4
+ VERSION = '0.8.2'
5
5
  end
data/notes.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  to push new version to github,
2
- git tag v0.8.1
2
+ git tag v0.8.2
3
3
  git push origin --tags
4
4
 
5
5
  to push new version to rubygems.org
6
6
  gem build ttytest2.gemspec
7
- gem push ttytest2-0.8.1.gem
7
+ gem push ttytest2-0.8.2.gem
data/ttytest2.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'ttytest/version'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ttytest2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Eski