Browse files

Made event log tests less dependent on terminal width

Change-Id: I374e68cdd8bb2379856174c4ad0489ecf0923b8f
  • Loading branch information...
1 parent b8311e7 commit 45ef7bb4711a8896a8fbccc7a78067ac8e3a7d05 @olegshaldybin olegshaldybin committed Aug 18, 2011
Showing with 8 additions and 9 deletions.
  1. +1 −1 cli/lib/cli/event_log_renderer.rb
  2. +7 −8 cli/spec/unit/event_log_renderer_spec.rb
View
2 cli/lib/cli/event_log_renderer.rb
@@ -291,7 +291,7 @@ def clear_line
end
def calculate_terminal_width
- if ENV["TERM"]
+ if !ENV["TERM"].blank?
width = `tput cols`
$?.exitstatus == 0 ? [ width.to_i, 100 ].min : 80
else
View
15 cli/spec/unit/event_log_renderer_spec.rb
@@ -64,23 +64,22 @@ def make_renderer(*args)
lines.count.should == 3
lines[1].should == "Preparing"
lines[2].should =~ /Binding release/
- lines[2].should =~ /\|\s{24}\| 0\/9/
+ lines[2].should =~ /\|\s+\| 0\/9/
renderer.add_event(make_event("Preparing", "Moving stuff", 2, 9))
lines = renderer.render.split("\n")
lines.count.should == 1
lines[0].should =~ /Binding release/
- lines[0].should =~ /Moving stuff/
- lines[0].should =~ /\|\s{24}\| 0\/9/
+ lines[0].should =~ /\|\s+\| 0\/9/
renderer.add_event(make_event("Preparing", "Moving stuff", 2, 9, "finished"))
lines = renderer.render.split("\n")
lines.count.should == 2
lines[0].should =~ /moving stuff/
lines[1].should =~ /Binding release/
- lines[1].should =~ /\|o{2}\s{22}\| 1\/9/
+ lines[1].should =~ /\|o+\s+\| 1\/9/
# throwing in out-of-order event
renderer.add_event(make_event("Preparing", "Binding release", 1, 9, "finished"))
@@ -92,7 +91,7 @@ def make_renderer(*args)
lines = renderer.render.split("\n")
lines.count.should == 9
- lines[-1].should =~ /\|o{24}\| 9\/9/
+ lines[-1].should =~ /\|o+\| 9\/9/
renderer.add_event(make_event("Updating", "prepare update", 1, 2, "started", ["stuff", "thing"]))
@@ -118,21 +117,21 @@ def make_renderer(*args)
lines = renderer.render.split("\n")
lines[1].should =~ /Preparing/
- lines[2].should =~ /\|o{3}\s{21}\| 0\/2/
+ lines[2].should =~ /\|o+\s+\| 0\/2/
lines[2].should =~ /Binding release/
renderer.add_event(make_event("Preparing", "Binding release", 1, 2, "in_progress", [], 50))
lines = renderer.render.split("\n")
- lines[0].should =~ /\|o{6}\s{18}\| 0\/2/
+ lines[0].should =~ /\|o+\s+\| 0\/2/
lines[0].should =~ /Binding release/
renderer.add_event(make_event("Preparing", "Binding release", 1, 2, "finished", []))
lines = renderer.render.split("\n")
lines[1].should_not =~ /Binding release/
- lines[1].should =~ /\|o{12}\s{12}\| 1\/2/
+ lines[1].should =~ /\|o+\s+\| 1\/2/
end
end

0 comments on commit 45ef7bb

Please sign in to comment.