command_line_reporter 3.3.6 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- $: << File.join(File.dirname(__FILE__), '..', 'lib')
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
2
2
 
3
3
  require 'command_line_reporter'
4
4
 
@@ -2,16 +2,4 @@ RSpec::Matchers.define :accepts_argument do |expected|
2
2
  match do
3
3
  expected.call.should raise_exception ArgumentError
4
4
  end
5
-
6
- # failure_message_for_should do |actual|
7
- # 'should raise an ArgumentError'
8
- # end
9
-
10
- # failure_message_for_should_not do |actual|
11
- # 'should not raise ArgumentError'
12
- # end
13
-
14
- # description do
15
- # 'validates options argument'
16
- # end
17
5
  end
@@ -1,68 +1,95 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CommandLineReporter::Table do
4
+ subject { CommandLineReporter::Table }
5
+ let(:row_subject) { CommandLineReporter::Row }
6
+ let(:col_subject) { CommandLineReporter::Column }
7
+
4
8
  context 'creation' do
5
9
  it 'defaults options hash' do
6
- expect {
7
- CommandLineReporter::Table.new
8
- }.to_not raise_error
10
+ expect do
11
+ subject.new
12
+ end.to_not raise_error Exception
9
13
  end
10
14
 
11
15
  it 'defaults the border' do
12
- expect(CommandLineReporter::Table.new.border).to be false
16
+ t = subject.new
17
+ expect(t.border).to be false
13
18
  end
14
19
 
15
20
  it 'accepts the border' do
16
- expect(CommandLineReporter::Table.new(:border => true).border).to eq(true)
21
+ t = subject.new(border: true)
22
+ expect(t.border).to eq(true)
17
23
  end
18
24
 
19
25
  it 'output encoding should be ascii' do
20
- expect(CommandLineReporter::Table.new(:encoding => :ascii).encoding).to eq(:ascii)
26
+ t = subject.new(encoding: :ascii)
27
+ expect(t.encoding).to eq(:ascii)
21
28
  end
22
29
 
23
30
  it 'output encoding should be unicode' do
24
- expect(CommandLineReporter::Table.new.encoding).to eq(:unicode)
31
+ t = subject.new
32
+ expect(t.encoding).to eq(:unicode)
25
33
  end
26
34
  end
27
35
 
28
36
  context 'rows' do
29
37
  it 'allows addition' do
30
- cols = [CommandLineReporter::Column.new('test1'), CommandLineReporter::Column.new('test2')]
31
- row = CommandLineReporter::Row.new
32
- cols.each {|c| row.add(c)}
33
- expect {
34
- CommandLineReporter::Table.new.add(row)
35
- }.to_not raise_error
38
+ cols = [col_subject.new('test1'), col_subject.new('test2')]
39
+ row = row_subject.new
40
+ cols.each { |c| row.add(c) }
41
+ expect do
42
+ subject.new.add(row)
43
+ end.to_not raise_error Exception
36
44
  end
37
45
 
38
46
  context 'inherits' do
39
47
  before :each do
40
- @table = CommandLineReporter::Table.new
41
- row = CommandLineReporter::Row.new(:color => 'red')
48
+ @table = subject.new
49
+ row = row_subject.new(color: 'red')
42
50
  (
43
51
  @cols1 = [
44
- CommandLineReporter::Column.new('asdf', :width => 5),
45
- CommandLineReporter::Column.new('qwer', :align => 'right', :color => 'purple'),
46
- CommandLineReporter::Column.new('tutu', :color => 'green'),
47
- CommandLineReporter::Column.new('uiui', :bold => true),
52
+ col_subject.new('asdf', width: 5),
53
+ col_subject.new('qwer', align: 'right', color: 'purple'),
54
+ col_subject.new('tutu', color: 'green'),
55
+ col_subject.new('uiui', bold: true)
48
56
  ]
49
- ).each {|c| row.add(c)}
57
+ ).each { |c| row.add(c) }
50
58
  @table.add(row)
51
- row = CommandLineReporter::Row.new
52
- (@cols2 = [
53
- CommandLineReporter::Column.new('test'),
54
- CommandLineReporter::Column.new('test'),
55
- CommandLineReporter::Column.new('test', :color => 'blue'),
56
- CommandLineReporter::Column.new('test'),
59
+ row = row_subject.new
60
+ (
61
+ @cols2 = [
62
+ col_subject.new('test'),
63
+ col_subject.new('test'),
64
+ col_subject.new('test', color: 'blue'),
65
+ col_subject.new('test')
57
66
  ]
58
- ).each {|c| row.add(c)}
67
+ ).each { |c| row.add(c) }
59
68
  @table.add(row)
60
69
  end
61
70
 
62
- it 'positional attributes' do
63
- [:align, :width, :size, :padding].each do |m|
71
+ context 'positional attributes' do
72
+ it 'should inherit alignment' do
73
+ 4.times do |i|
74
+ expect(@table.rows[1].columns[i].align).to eq(@table.rows[0].columns[i].align)
75
+ end
76
+ end
77
+
78
+ it 'should inherit width' do
64
79
  4.times do |i|
65
- expect(@table.rows[1].columns[i].send(m)).to eq(@table.rows[0].columns[i].send(m))
80
+ expect(@table.rows[1].columns[i].width).to eq(@table.rows[0].columns[i].width)
81
+ end
82
+ end
83
+
84
+ it 'should inherit size' do
85
+ 4.times do |i|
86
+ expect(@table.rows[1].columns[i].size).to eq(@table.rows[0].columns[i].size)
87
+ end
88
+ end
89
+
90
+ it 'should inherit padding' do
91
+ 4.times do |i|
92
+ expect(@table.rows[1].columns[i].padding).to eq(@table.rows[0].columns[i].padding)
66
93
  end
67
94
  end
68
95
  end
@@ -85,12 +112,12 @@ describe CommandLineReporter::Table do
85
112
 
86
113
  context 'with header row' do
87
114
  before :each do
88
- @table = CommandLineReporter::Table.new
89
- row = CommandLineReporter::Row.new(:header => true)
90
- @cols1.each {|c| row.add(c)}
115
+ @table = subject.new
116
+ row = row_subject.new(header: true)
117
+ @cols1.each { |c| row.add(c) }
91
118
  @table.add(row)
92
- row = CommandLineReporter::Row.new
93
- @cols2.each {|c| row.add(c)}
119
+ row = row_subject.new
120
+ @cols2.each { |c| row.add(c) }
94
121
  @table.add(row)
95
122
  end
96
123
 
@@ -114,20 +141,20 @@ describe CommandLineReporter::Table do
114
141
 
115
142
  describe '#auto_adjust_widths' do
116
143
  it 'sets the widths of each column in each row to the maximum required width for that column' do
117
- table = CommandLineReporter::Table.new.tap do |t|
144
+ table = subject.new.tap do |t|
118
145
  t.add(
119
- CommandLineReporter::Row.new.tap do |r|
120
- r.add CommandLineReporter::Column.new('medium length')
121
- r.add CommandLineReporter::Column.new('i am pretty long') # longest column
122
- r.add CommandLineReporter::Column.new('short', :padding => 100)
146
+ row_subject.new.tap do |r|
147
+ r.add col_subject.new('medium length')
148
+ r.add col_subject.new('i am pretty long') # longest column
149
+ r.add col_subject.new('short', padding: 100)
123
150
  end
124
151
  )
125
152
 
126
153
  t.add(
127
- CommandLineReporter::Row.new.tap do |r|
128
- r.add CommandLineReporter::Column.new('longer than medium length') # longest column
129
- r.add CommandLineReporter::Column.new('shorter')
130
- r.add CommandLineReporter::Column.new('longer than short') # longest column (inherits padding)
154
+ row_subject.new.tap do |r|
155
+ r.add col_subject.new('longer than medium length') # longest column
156
+ r.add col_subject.new('shorter')
157
+ r.add col_subject.new('longer than short') # longest column (inherits padding)
131
158
  end
132
159
  )
133
160
  end
@@ -135,11 +162,10 @@ describe CommandLineReporter::Table do
135
162
  table.auto_adjust_widths
136
163
 
137
164
  table.rows.each do |row|
138
- expect(row.columns[0].width).to eq(CommandLineReporter::Column.new('longer than medium length').required_width)
139
- expect(row.columns[1].width).to eq(CommandLineReporter::Column.new('i am pretty long').required_width)
140
- expect(row.columns[2].width).to eq(CommandLineReporter::Column.new('longer than short', :padding => 100).required_width)
165
+ expect(row.columns[0].width).to eq(col_subject.new('longer than medium length').required_width)
166
+ expect(row.columns[1].width).to eq(col_subject.new('i am pretty long').required_width)
167
+ expect(row.columns[2].width).to eq(col_subject.new('longer than short', padding: 100).required_width)
141
168
  end
142
169
  end
143
170
  end
144
-
145
171
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_line_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.6
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-22 00:00:00.000000000 Z
12
+ date: 2017-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  version: '0'
85
85
  requirements: []
86
86
  rubyforge_project:
87
- rubygems_version: 2.4.8
87
+ rubygems_version: 2.6.12
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: A tool for providing interactive command line applications