ttytest 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -0
- data/lib/ttytest/capture.rb +0 -4
- data/lib/ttytest/dummy.rb +2 -4
- data/lib/ttytest/matchers.rb +21 -1
- data/lib/ttytest/terminal.rb +1 -1
- data/lib/ttytest/tmux/driver.rb +1 -1
- data/lib/ttytest/version.rb +1 -1
- data/ttytest.gemspec +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0175fa2266c1f56f709051162f3419862a24355
|
4
|
+
data.tar.gz: 949439a6f922cd8b71c8c92e10a9721161c152b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8af22aa0fb0f3896c113c7e5cb5d929c82e642c44d93e03f5b75729fc3d1e2a2eb5f796f6e09300f6d21bc4d5bc1b70e6a7c3676e0dd0f5bc4ff7d6e91a52c8d
|
7
|
+
data.tar.gz: 7871021b99ebef74812db882e8ada619135697c114c6df31c19ed282dec13a155237d6162c467cab6f440887ebbf76d43a93eedd9812d3eef139ca47acf00c65
|
data/Rakefile
CHANGED
data/lib/ttytest/capture.rb
CHANGED
data/lib/ttytest/dummy.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
module TTYtest
|
2
2
|
class Dummy
|
3
|
-
attr_accessor :contents
|
3
|
+
attr_accessor :contents
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@contents = "\n"*23
|
7
|
-
@cursor_position = [0,0]
|
8
7
|
end
|
9
8
|
|
10
9
|
def capture
|
11
|
-
|
12
|
-
Capture.new(contents, cursor_x: x, cursor_y: y)
|
10
|
+
Capture.new(contents)
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
data/lib/ttytest/matchers.rb
CHANGED
@@ -9,7 +9,7 @@ module TTYtest
|
|
9
9
|
|
10
10
|
def assert_cursor_position(x:, y:)
|
11
11
|
expected = [x, y]
|
12
|
-
actual =
|
12
|
+
actual = [cursor_x, cursor_y]
|
13
13
|
if actual != expected
|
14
14
|
raise MatchError, "expected cursor to be at #{expected.inspect} but was at #{actual.inspect}\nEntire screen:\n#{to_s}"
|
15
15
|
end
|
@@ -27,6 +27,26 @@ module TTYtest
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def assert_matches(expected)
|
31
|
+
expected_rows = expected.split("\n")
|
32
|
+
diff = []
|
33
|
+
matched = true
|
34
|
+
rows.each_with_index do |actual_row, index|
|
35
|
+
expected_row = (expected_rows[index] || "").rstrip
|
36
|
+
if actual_row != expected_row
|
37
|
+
diff << "-#{expected_row}"
|
38
|
+
diff << "+#{actual_row}"
|
39
|
+
matched = false
|
40
|
+
else
|
41
|
+
diff << " #{actual_row}".rstrip
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
if !matched
|
46
|
+
raise MatchError, "screen did not match expected content:\n--- expected\n+++ actual\n#{diff.join("\n")}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
30
50
|
METHODS = public_instance_methods
|
31
51
|
end
|
32
52
|
end
|
data/lib/ttytest/terminal.rb
CHANGED
@@ -16,7 +16,7 @@ module TTYtest
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def_delegators :@driver_terminal, :send_keys, :send_raw, :capture
|
19
|
-
def_delegators :capture, :rows, :row, :
|
19
|
+
def_delegators :capture, :rows, :row, :width, :height, :cursor_visible?, :cursor_hidden?
|
20
20
|
|
21
21
|
TTYtest::Matchers::METHODS.each do |matcher_name|
|
22
22
|
define_method matcher_name do |*args|
|
data/lib/ttytest/tmux/driver.rb
CHANGED
@@ -24,7 +24,7 @@ module TTYtest
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def new_terminal(cmd, width: 80, height: 24)
|
27
|
-
cmd = "#{cmd}
|
27
|
+
cmd = "#{cmd}\n#{SLEEP_INFINITY}"
|
28
28
|
|
29
29
|
session_name = "ttytest-#{SecureRandom.uuid}"
|
30
30
|
tmux(*%W[-f #{CONF_PATH} new-session -s #{session_name} -d -x #{width} -y #{height} #{cmd}])
|
data/lib/ttytest/version.rb
CHANGED
data/ttytest.gemspec
CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
+
spec.required_ruby_version = '>= 2.1.0'
|
25
|
+
|
24
26
|
spec.add_development_dependency "bundler", "~> 1.7"
|
25
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
28
|
spec.add_development_dependency "minitest", "~> 5.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ttytest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: 2.1.0
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - ">="
|