ttytest2 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9eaa16f80b9604b9b174e0e7cba8fe5552c453d928d7f543dbf0d1498726516
4
- data.tar.gz: a8b0cad547df8948c71951817ad7c9fbaa74a8d1a17e7e0bf61c94911c4a6d13
3
+ metadata.gz: d3f08a4827e337de7e9124c7c0daf929922f9c6dfb573a03e88ee5e23b243cf9
4
+ data.tar.gz: 1f4ae48c6dff1ce25ea0a22c6f29c188b98caee3efa2a512132e4c416a522185
5
5
  SHA512:
6
- metadata.gz: 6b64fa53f510b203ea188a715e76ea524564dab12e5718d3c93e57c2182d8a192c263511492667703a155e3b8b8d68293ffa8ab835f606117b603696c92e0159
7
- data.tar.gz: 1f16083d91f27ccc16064a5d23bff87e03b18b5185ce206ad3efe8efeec0e1b0c6a32d947b4078f49b929c31e4be13f311bd6fd3dacf8af7e03bdf86e7873d5f
6
+ metadata.gz: edc7cb24ffec16991743b8dd104050f594f78a68ed44b88df91e2ce3ba52045dd0d37548b978a1bc47e0bd424d3dd8b1b75b9cce231f323bb6f860e2fb6ef7e4
7
+ data.tar.gz: 8d7e3f220552cc6485fa848e046eb6711e18117f43d6fb99d1fdc1751391da3e0aa719cc5c50b34dd3a4256eb89e17fec5a3868d32084074909af68110570283
data/README.md CHANGED
@@ -6,7 +6,7 @@ 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/ttytest.svg)](https://rubygems.org/gems/ttytest)
9
+ [![Gem Version](https://badge.fury.io/rb/ttytest2.svg)](https://rubygems.org/gems/ttytest2)
10
10
 
11
11
  ## Minimum Requirements
12
12
 
@@ -18,6 +18,8 @@ It works by running commands inside a tmux session, capturing the pane, and comp
18
18
  ### Example
19
19
 
20
20
  ``` ruby
21
+ require 'ttytest'
22
+
21
23
  @tty = TTYtest.new_terminal(%{PS1='$ ' /bin/sh}, width: 80, height: 24)
22
24
  @tty.assert_row(0, '$')
23
25
  @tty.assert_cursor_position(x: 2, y: 0)
@@ -41,6 +43,8 @@ The main way to use TTYtest is through assertions. When called on a `TTYtest::Te
41
43
  Available assertions:
42
44
  * `assert_row(row_number, expected_text)`
43
45
  * `assert_row_like(row_number, expected_text)`
46
+ * `assert_row_starts_with(row_number, expected_text)`
47
+ * `assert_row_ends_with(row_number, expected_text)`
44
48
  * `assert_cursor_position(x: x, y: y)`
45
49
  * `assert_cursor_visible`
46
50
  * `assert_cursor_hidden`
@@ -1,4 +1,5 @@
1
1
  module TTYtest
2
+ # Assertions for ttytest2.
2
3
  module Matchers
3
4
  # Asserts the contents of a single row
4
5
  # @param [Integer] row_number the row (starting from 0) to test against
@@ -7,15 +8,15 @@ module TTYtest
7
8
  def assert_row(row_number, expected)
8
9
  expected = expected.rstrip
9
10
  actual = row(row_number)
10
- return unless actual != expected
11
+ return if actual == expected
11
12
 
12
13
  raise MatchError,
13
14
  "expected row #{row_number} to be #{expected.inspect} but got #{actual.inspect}\nEntire screen:\n#{self}"
14
15
  end
15
16
 
16
- # Asserts the contents of a single row
17
+ # Asserts the contents of a single row contains expected
17
18
  # @param [Integer] row_number the row (starting from 0) to test against
18
- # @param [String] expected the expected value of the row. Any trailing whitespace is ignored
19
+ # @param [String] expected the expected value contained in the row. Any trailing whitespace is ignored
19
20
  # @raise [MatchError] if the row doesn't match
20
21
  def assert_row_like(row_number, expected)
21
22
  expected = expected.rstrip
@@ -26,6 +27,32 @@ module TTYtest
26
27
  "expected row #{row_number} to be like #{expected.inspect} but got #{actual.inspect}\nEntire screen:\n#{self}"
27
28
  end
28
29
 
30
+ # Asserts the contents of a single row start with expected
31
+ # @param [Integer] row_number the row (starting from 0) to test against
32
+ # @param [String] expected the expected value that the row starts with. Any trailing whitespace is ignored
33
+ # @raise [MatchError] if the row doesn't match
34
+ def assert_row_starts_with(row_number, expected)
35
+ expected = expected.rstrip
36
+ actual = row(row_number)
37
+ return if actual.start_with?(expected)
38
+
39
+ raise MatchError,
40
+ "expected row #{row_number} to start with #{expected.inspect} and got #{actual.inspect}\nEntire screen:\n#{self}"
41
+ end
42
+
43
+ # Asserts the contents of a single row end with expected
44
+ # @param [Integer] row_number the row (starting from 0) to test against
45
+ # @param [String] expected the expected value that the row starts with. Any trailing whitespace is ignored
46
+ # @raise [MatchError] if the row doesn't match
47
+ def assert_row_ends_with(row_number, expected)
48
+ expected = expected.rstrip
49
+ actual = row(row_number)
50
+ return if actual.end_with?(expected)
51
+
52
+ raise MatchError,
53
+ "expected row #{row_number} to end with #{expected.inspect} and got #{actual.inspect}\nEntire screen:\n#{self}"
54
+ end
55
+
29
56
  # Asserts that the cursor is in the expected position
30
57
  # @param [Integer] x cursor x (row) position, starting from 0
31
58
  # @param [Integer] y cursor y (column) position, starting from 0
@@ -33,7 +60,7 @@ module TTYtest
33
60
  def assert_cursor_position(x, y)
34
61
  expected = [x, y]
35
62
  actual = [cursor_x, cursor_y]
36
- return unless actual != expected
63
+ return if actual == expected
37
64
 
38
65
  raise MatchError,
39
66
  "expected cursor to be at #{expected.inspect} but was at #{actual.inspect}\nEntire screen:\n#{self}"
@@ -1,3 +1,3 @@
1
1
  module TTYtest
2
- VERSION = '0.7.1'.freeze
2
+ VERSION = '0.8.0'.freeze
3
3
  end
data/notes.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  to push new version to github,
2
- git tag v0.7.0
2
+ git tag v0.8.0
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.7.0.gem
7
+ gem push ttytest2-0.8.0.gem
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.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Eski