capybara-remote-viewer 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7481e305e57c4553c4528fae954fd7aaf87e07fa
|
4
|
+
data.tar.gz: d91558cc88b0079ce48de9d47ea83b1aae839a0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b3232be246a850adc91df5847025292ad2b00558da603fc9e537b0c1ffc86b21081636cc7e5c2f5824821bf00da953c122bf8a183fc39443317aef15106494b
|
7
|
+
data.tar.gz: 2134d7625f1ce862c306bd2ab130e10a2fa088884ff623395eeb10684ef48dcc7d636729e1eed0a99f3cfa89e0814e8760139175a91a49194fd297bc1237fcba
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'haml'
|
3
3
|
require 'json'
|
4
|
+
require 'time'
|
4
5
|
|
5
6
|
module Capybara
|
6
7
|
module Remote
|
@@ -33,6 +34,18 @@ module Capybara
|
|
33
34
|
File.basename(str, '.html')
|
34
35
|
end
|
35
36
|
|
37
|
+
def file_date(str)
|
38
|
+
filename = file_name(str)
|
39
|
+
prefix, date_str = filename.split('-')
|
40
|
+
if prefix == 'capybara'
|
41
|
+
time = Time.parse date_str[0..13]
|
42
|
+
ms = date_str[14..-1]
|
43
|
+
time.strftime("%Y/%m/%d - %H:%M:%S.#{ms}")
|
44
|
+
else
|
45
|
+
filename
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
36
49
|
get '/' do
|
37
50
|
haml :index, locals: { dir: Server.path, files: files }
|
38
51
|
end
|
@@ -41,7 +54,7 @@ module Capybara
|
|
41
54
|
headers 'Content-Type' => 'application/json'
|
42
55
|
|
43
56
|
list = files.map do |file|
|
44
|
-
{ name:
|
57
|
+
{ name: file_date(file), url: file_path(file) }
|
45
58
|
end
|
46
59
|
|
47
60
|
{ files: list }.to_json
|
@@ -19,7 +19,7 @@ describe Capybara::Remote::Viewer::Server do
|
|
19
19
|
it 'links to existing files' do
|
20
20
|
get '/'
|
21
21
|
|
22
|
-
last_response.body.should =~ %r{<a href='/files/1'>1</a>}
|
22
|
+
last_response.body.should =~ %r{<a href='/files/1' target='porthole'>1</a>}
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -34,5 +34,23 @@ describe Capybara::Remote::Viewer::Server do
|
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
|
+
describe '#file_date' do
|
38
|
+
|
39
|
+
let(:server) { app.new.instance_variable_get(:@instance) }
|
40
|
+
|
41
|
+
it 'parses a capybara file name as a date string' do
|
42
|
+
server.
|
43
|
+
file_date('/path/to/app/tmp/capybara/capybara-201312061034395395175534.html').
|
44
|
+
should == '2013/12/06 - 10:34:39.5395175534'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "just returns a string if it doesn't match standard capy file name" do
|
48
|
+
server.
|
49
|
+
file_date('/path/to/app/tmp/foo/bar.html').
|
50
|
+
should == 'bar'
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
37
55
|
end
|
38
56
|
|
data/views/index.haml
CHANGED