Permalink
Browse files

Merge pull request #1 from nightscape/patch-1

Be more resilient if no tmux session is running.
  • Loading branch information...
2 parents 4b0c631 + 5a15917 commit 7d391539042a828962602f66e68451b0b117e06a @juanibiapina committed Nov 9, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/tmuxbar.rb
View
@@ -10,7 +10,7 @@ def start(example_count)
def stop
super
- @session.status_bar.right.pop_widget(@bar)
+ @session.status_bar.right.pop_widget(@bar) if @session
end
def example_passed(example)
@@ -43,15 +43,16 @@ def message(message)
private
def increment_bar
- @bar.value += 1
+ @bar.value += 1 if @bar
end
def init_bar(size)
server = Tmux::Server.new
- @session = server.sessions(attached: true).first
+ if (@session = server.sessions(attached: true).first)
- @bar = Tmux::Widgets::ProgressBar.new("RSpec")
- @bar.total = size
- @session.status_bar.right.add_widget(@bar)
+ @bar = Tmux::Widgets::ProgressBar.new("RSpec")
+ @bar.total = size
+ @session.status_bar.right.add_widget(@bar)
+ end
end
end

0 comments on commit 7d39153

Please sign in to comment.