hubeye 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Hubeye
2
- # 0.3.0 since Dec. 4, 2011
3
- VERSION = [0,3,2]
2
+ # 0.3.3 since Jan. 28, 2012
3
+ VERSION = [0,3,3]
4
4
  end
5
5
 
@@ -5,7 +5,12 @@ require_relative 'connection'
5
5
  module Hubeye
6
6
  module Client
7
7
  class Client
8
- @@stty_save = `stty -g`
8
+
9
+ def self.testing?
10
+ ENV["HUBEYE_ENV"] == 'test'
11
+ end
12
+
13
+ @@stty_save = `stty -g` unless testing?
9
14
 
10
15
  begin
11
16
  Readline.emacs_editing_mode
@@ -21,6 +26,7 @@ module Hubeye
21
26
  @debug = debug
22
27
  end
23
28
 
29
+
24
30
  def start(host, port)
25
31
  conn = Connection.new(host, port)
26
32
  conn.receive_welcome
@@ -54,17 +60,17 @@ module Hubeye
54
60
  begin
55
61
  mesg = @s.read_all
56
62
  rescue EOFError
57
- mesg = "Bye!\n"
63
+ mesg = "Bye!"
58
64
  end
59
- if mesg.chop.strip == "Bye!"
60
- mesg[-1] == "\n" ? print(mesg) : puts(mesg)
65
+ if mesg.strip == "Bye!"
66
+ puts(mesg)
61
67
  @s.close
62
68
  exit 0
63
- elsif mesg.chop.strip.match(/shutting/i)
69
+ elsif mesg.strip.match(/shutting/i)
64
70
  @s.close
65
71
  exit 0
66
72
  else
67
- mesg[-1] == "\n" ? print(mesg) : puts(mesg)
73
+ puts(mesg)
68
74
  next
69
75
  end
70
76
  end
@@ -74,7 +80,7 @@ module Hubeye
74
80
  begin
75
81
  @input = Readline.readline('> ', true)
76
82
  rescue Interrupt => e
77
- system('stty', @@stty_save)
83
+ system('stty', @@stty_save) unless Client.testing?
78
84
  exit
79
85
  end
80
86
  end
@@ -22,6 +22,7 @@ module Hubeye
22
22
  puts mesg
23
23
  rescue SystemCallError, NoMethodError
24
24
  puts "The server's not running!"
25
+ exit 1
25
26
  rescue EOFError
26
27
  @retried ||= -1
27
28
  @retried += 1
data/test/integration.rb CHANGED
@@ -1,24 +1,38 @@
1
+ require_relative "test_helper"
2
+
1
3
  class HubeyeIntegrationTest < Test::Unit::TestCase
2
4
  include Hubeye::Environment
3
5
 
4
6
  EXECUTABLE = File.join(BINDIR, 'hubeye')
5
7
 
6
- def interact
7
- start_server
8
- sleep 0.5
9
- start_client
10
- end
11
-
12
8
  def start_server
13
9
  system "#{EXECUTABLE} -s"
14
10
  end
15
11
 
16
- def start_client
17
- IO.popen("#{EXECUTABLE} -c", "r+") do |p|
18
- p.write 'fjdksfjlsdj'
19
- p.close_write
20
- p.read.chomp
12
+ def start_client &blk
13
+ IO.popen("#{EXECUTABLE} -c", "r+") do |c|
14
+ begin
15
+ yield c if c
16
+ ensure
17
+ c.puts "shutdown"
18
+ c.close_write
19
+ c.close
20
+ end
21
+ end
22
+ end
23
+
24
+ def setup
25
+ start_server
26
+ sleep 0.5
27
+ end
28
+
29
+ def test_truth
30
+ start_client do |c|
31
+ c.puts 'hi'
32
+ @response = c.gets
21
33
  end
34
+ STDOUT.puts @response
35
+ assert @response.match /github/i
22
36
  end
23
37
 
24
38
  end
data/test/runner.rb CHANGED
@@ -1,10 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # environment file
4
- require File.join(File.expand_path(File.dirname(__FILE__) + '/..'), "lib/hubeye/config/environment")
5
-
6
- # test/unit
7
- require 'test/unit'
3
+ require_relative "test_helper"
8
4
 
9
5
  # test files
10
6
  require_relative 'environment'
@@ -0,0 +1,3 @@
1
+ require File.expand_path("../../lib/hubeye/config/environment", __FILE__)
2
+ require "test/unit"
3
+ ENV["HUBEYE_ENV"] = 'test'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubeye
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -50,6 +50,7 @@ files:
50
50
  - LICENSE
51
51
  - test/config_parser.rb
52
52
  - test/runner.rb
53
+ - test/test_helper.rb
53
54
  - test/integration.rb
54
55
  - test/environment.rb
55
56
  - test/notification.rb