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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78021e6870947818ac2d9be3fe3d83fe5070662d
4
- data.tar.gz: d3cc412b912956ef3ea44948f6a656b3bfca644f
3
+ metadata.gz: d0175fa2266c1f56f709051162f3419862a24355
4
+ data.tar.gz: 949439a6f922cd8b71c8c92e10a9721161c152b7
5
5
  SHA512:
6
- metadata.gz: 6fc3b334c3c43bbe3fe518f74ca5be4b262f60014f564443433a41fb2b503905264ff2df725379cd173729ce5fdca7638848a991a78ee6056f36c75c8c838669
7
- data.tar.gz: 371818454cdc7df5cd7d6ceef162ddf0075ad5f6bd425122457fb0ef1e4c02e99d776c9eda2faf3adf31a01530fdbe57e04905a31f52fc216c76b6359c589df3
6
+ metadata.gz: 8af22aa0fb0f3896c113c7e5cb5d929c82e642c44d93e03f5b75729fc3d1e2a2eb5f796f6e09300f6d21bc4d5bc1b70e6a7c3676e0dd0f5bc4ff7d6e91a52c8d
7
+ data.tar.gz: 7871021b99ebef74812db882e8ada619135697c114c6df31c19ed282dec13a155237d6162c467cab6f440887ebbf76d43a93eedd9812d3eef139ca47acf00c65
data/Rakefile CHANGED
@@ -7,4 +7,8 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList['test/**/*_test.rb']
8
8
  end
9
9
 
10
+ task :console do
11
+ system 'irb -Ilib -rttytest'
12
+ end
13
+
10
14
  task :default => :test
@@ -16,10 +16,6 @@ module TTYtest
16
16
  @cursor_visible = cursor_visible
17
17
  end
18
18
 
19
- def cursor_position
20
- [@cursor_x, @cursor_y]
21
- end
22
-
23
19
  def rows
24
20
  @rows
25
21
  end
data/lib/ttytest/dummy.rb CHANGED
@@ -1,15 +1,13 @@
1
1
  module TTYtest
2
2
  class Dummy
3
- attr_accessor :contents, :cursor_position
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
- x, y = cursor_position
12
- Capture.new(contents, cursor_x: x, cursor_y: y)
10
+ Capture.new(contents)
13
11
  end
14
12
  end
15
13
  end
@@ -9,7 +9,7 @@ module TTYtest
9
9
 
10
10
  def assert_cursor_position(x:, y:)
11
11
  expected = [x, y]
12
- actual = cursor_position
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
@@ -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, :cursor_position, :width, :height, :cursor_visible?, :cursor_hidden?
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|
@@ -24,7 +24,7 @@ module TTYtest
24
24
  end
25
25
 
26
26
  def new_terminal(cmd, width: 80, height: 24)
27
- cmd = "#{cmd};#{SLEEP_INFINITY}"
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}])
@@ -1,3 +1,3 @@
1
1
  module TTYtest
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
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.3.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-29 00:00:00.000000000 Z
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: '0'
90
+ version: 2.1.0
91
91
  required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="