ttytest2 0.7.0 → 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: 3c87da11ef189a8f5c57cb248f6b141d00d43a64d27f62a2b5d00fb40974c765
4
- data.tar.gz: 4dbc8af44a477b2c755c9653eb9411946447a295c1186f6f12a709b84dec3ee9
3
+ metadata.gz: d3f08a4827e337de7e9124c7c0daf929922f9c6dfb573a03e88ee5e23b243cf9
4
+ data.tar.gz: 1f4ae48c6dff1ce25ea0a22c6f29c188b98caee3efa2a512132e4c416a522185
5
5
  SHA512:
6
- metadata.gz: 15737416cb6956c0dc04c07d77ba8970f06a38da74321bb888bb3565d60ef04e28b8b1bf1bf7304af3452a3c480ff32998ffcf339f00848782c5251ad0c3b606
7
- data.tar.gz: c969a721dc64fec69889482759664b3c7fdba5585292663b470a8903b39336f2e12b6da353f3c40b6080d1c4f1b59e7e35b0c8deb046097dfe59ef5ce1179bc4
6
+ metadata.gz: edc7cb24ffec16991743b8dd104050f594f78a68ed44b88df91e2ce3ba52045dd0d37548b978a1bc47e0bd424d3dd8b1b75b9cce231f323bb6f860e2fb6ef7e4
7
+ data.tar.gz: 8d7e3f220552cc6485fa848e046eb6711e18117f43d6fb99d1fdc1751391da3e0aa719cc5c50b34dd3a4256eb89e17fec5a3868d32084074909af68110570283
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ Gemfile.lock
2
2
  pkg/
3
3
  .yardoc/
4
4
  doc/
5
+ *.gem
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,19 +8,17 @@ 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
- raise MatchError, "expected a value for 'expected' but recieved nil" if actual.nil?
22
-
23
22
  expected = expected.rstrip
24
23
  actual = row(row_number)
25
24
  return if actual.include?(expected)
@@ -28,6 +27,32 @@ module TTYtest
28
27
  "expected row #{row_number} to be like #{expected.inspect} but got #{actual.inspect}\nEntire screen:\n#{self}"
29
28
  end
30
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
+
31
56
  # Asserts that the cursor is in the expected position
32
57
  # @param [Integer] x cursor x (row) position, starting from 0
33
58
  # @param [Integer] y cursor y (column) position, starting from 0
@@ -35,7 +60,7 @@ module TTYtest
35
60
  def assert_cursor_position(x, y)
36
61
  expected = [x, y]
37
62
  actual = [cursor_x, cursor_y]
38
- return unless actual != expected
63
+ return if actual == expected
39
64
 
40
65
  raise MatchError,
41
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.0'.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.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Eski