checkcheckit 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -5
- data/lib/checkcheckit/console.rb +18 -13
- data/lib/checkcheckit/version.rb +1 -1
- data/test/start_test.rb +45 -6
- metadata +3 -3
data/README.md
CHANGED
data/lib/checkcheckit/console.rb
CHANGED
@@ -44,14 +44,19 @@ class CheckCheckIt::Console
|
|
44
44
|
list = List.new(list_name)
|
45
45
|
if (emails = @options['email']) || @options['live']
|
46
46
|
@list_id = list_id = notify_server_of_start(emails, list)
|
47
|
-
|
47
|
+
url = URI.join(web_service_url, list_id)
|
48
|
+
puts "Live at URL: #{url}"
|
49
|
+
|
50
|
+
if @options['open'] || @options['O']
|
51
|
+
Process.detach fork{ exec("open #{url}") }
|
52
|
+
end
|
48
53
|
|
49
54
|
begin
|
50
55
|
@client = web_socket.connect(web_service_url, sync: true) do
|
51
56
|
after_start { emit('register', {list_id: list_id}) }
|
52
57
|
end
|
53
58
|
rescue Errno::ECONNREFUSED, WebSocket::Error, RuntimeError => e
|
54
|
-
|
59
|
+
$stderr.puts "Websocket refused connection - using POST"
|
55
60
|
@use_post = true
|
56
61
|
end
|
57
62
|
end
|
@@ -103,15 +108,8 @@ class CheckCheckIt::Console
|
|
103
108
|
return
|
104
109
|
end
|
105
110
|
|
106
|
-
if
|
107
|
-
|
108
|
-
list_id: @list_id,
|
109
|
-
step_id: i
|
110
|
-
}
|
111
|
-
end
|
112
|
-
|
113
|
-
if @use_post
|
114
|
-
post_check(@list_id, i)
|
111
|
+
if check
|
112
|
+
update_server_with_step(i)
|
115
113
|
end
|
116
114
|
|
117
115
|
results[i] = {
|
@@ -164,7 +162,6 @@ class CheckCheckIt::Console
|
|
164
162
|
def post_check(list_id, step_id)
|
165
163
|
begin
|
166
164
|
url = URI.join(web_service_url, "/#{list_id}/check/#{step_id}").to_s
|
167
|
-
STDERR.puts url
|
168
165
|
Excon.post(url)
|
169
166
|
rescue Excon::Errors::SocketError, ArgumentError => e
|
170
167
|
puts "Error POSTing to #{url}"
|
@@ -181,10 +178,18 @@ class CheckCheckIt::Console
|
|
181
178
|
:headers => {
|
182
179
|
'Content-Type' => 'application/json'
|
183
180
|
})
|
184
|
-
|
181
|
+
$stderr.puts response if @options['d'] || @options['debug']
|
185
182
|
return response.body.gsub('"','')
|
186
183
|
rescue Excon::Errors::SocketError => e
|
187
184
|
puts "Error connecting to #{web_service_url}"
|
188
185
|
end
|
189
186
|
end
|
187
|
+
|
188
|
+
def update_server_with_step(i)
|
189
|
+
if @client
|
190
|
+
@client.emit 'check', {list_id: @list_id, step_id: i}
|
191
|
+
elsif @use_post
|
192
|
+
post_check(@list_id, i)
|
193
|
+
end
|
194
|
+
end
|
190
195
|
end
|
data/lib/checkcheckit/version.rb
CHANGED
data/test/start_test.rb
CHANGED
@@ -9,6 +9,12 @@ class StartTest < CheckCheckIt::TestCase
|
|
9
9
|
console.web_socket = MiniTest::Mock.new
|
10
10
|
end
|
11
11
|
|
12
|
+
def mock_web_socket
|
13
|
+
client = MiniTest::Mock.new
|
14
|
+
console.web_socket.expect :connect, client, [String, {sync: true}]
|
15
|
+
client
|
16
|
+
end
|
17
|
+
|
12
18
|
def test_list_parses_steps
|
13
19
|
3.times { console.in_stream.expect :gets, "y" }
|
14
20
|
result = check "start groceries"
|
@@ -23,15 +29,28 @@ class StartTest < CheckCheckIt::TestCase
|
|
23
29
|
|
24
30
|
# When you do
|
25
31
|
#
|
26
|
-
# check start deploy --
|
32
|
+
# check start deploy --live
|
33
|
+
#
|
34
|
+
# we setup the POST with the list data
|
35
|
+
def test_live_flag_triggers_live_mode
|
36
|
+
client = mock_web_socket
|
37
|
+
3.times { client.expect :emit, true, ['check', Hash] }
|
38
|
+
Excon.stub({:method => :post, :body => {
|
39
|
+
emails: nil,
|
40
|
+
list: List.new(home + '/personal/groceries').to_h
|
41
|
+
}.to_json}, {:status => 200})
|
42
|
+
3.times { console.in_stream.expect :gets, "y" }
|
43
|
+
check "start groceries --live"
|
44
|
+
end
|
45
|
+
|
46
|
+
# When you do
|
27
47
|
#
|
28
|
-
#
|
48
|
+
# check start deploy --email csquared@heroku.com
|
29
49
|
#
|
30
50
|
# The webservice sends you an email with a link to the list so
|
31
51
|
# you can run it on the web.
|
32
52
|
def test_email_flag_triggers_live_mode
|
33
|
-
client =
|
34
|
-
console.web_socket.expect :connect, client, [String, {sync: true}]
|
53
|
+
client = mock_web_socket
|
35
54
|
3.times { client.expect :emit, true, ['check', Hash] }
|
36
55
|
Excon.stub({:method => :post, :body => {
|
37
56
|
emails: "csquared@heroku.com,thea.lamkin@gmail.com",
|
@@ -44,8 +63,7 @@ class StartTest < CheckCheckIt::TestCase
|
|
44
63
|
# Same as above but with env set
|
45
64
|
def test_reads_email_from_env
|
46
65
|
set_env 'CHECKCHECKIT_EMAIL', "csquared@heroku.com,thea.lamkin@gmail.com"
|
47
|
-
client =
|
48
|
-
console.web_socket.expect :connect, client, [String, {sync: true}]
|
66
|
+
client = mock_web_socket
|
49
67
|
3.times { client.expect :emit, true, ['check', Hash] }
|
50
68
|
Excon.stub({:method => :post, :body => {
|
51
69
|
emails: "csquared@heroku.com,thea.lamkin@gmail.com",
|
@@ -55,7 +73,28 @@ class StartTest < CheckCheckIt::TestCase
|
|
55
73
|
check "start groceries"
|
56
74
|
end
|
57
75
|
|
76
|
+
def test_live_only_sends_on_success
|
77
|
+
client = mock_web_socket
|
78
|
+
1.times { client.expect :emit, true, ['check', Hash] }
|
79
|
+
Excon.stub({:method => :post}, {:status => 200})
|
80
|
+
2.times { console.in_stream.expect :gets, "n" }
|
81
|
+
1.times { console.in_stream.expect :gets, "y" }
|
82
|
+
check "start groceries --live"
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_live_falls_back_to_post
|
86
|
+
# stub it the old way
|
87
|
+
ws = console.web_socket
|
88
|
+
def ws.connect(*args); raise WebSocket::Error; end
|
89
|
+
4.times { Excon.stub({:method => :post}, {:status => 200}) }
|
90
|
+
3.times { console.in_stream.expect :gets, "y" }
|
91
|
+
assert_output(//,/POST/) do
|
92
|
+
check "start groceries --live"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
58
96
|
def test_reads_url_from_env
|
97
|
+
#skip "too lazy to implement"
|
59
98
|
end
|
60
99
|
end
|
61
100
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkcheckit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
segments:
|
116
116
|
- 0
|
117
|
-
hash:
|
117
|
+
hash: -2207512465125543391
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
none: false
|
120
120
|
requirements:
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
segments:
|
125
125
|
- 0
|
126
|
-
hash:
|
126
|
+
hash: -2207512465125543391
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
129
|
rubygems_version: 1.8.23
|