capybara-remote-viewer 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: 4366c063b7cea76765fec03f548f0e3e037aec84
4
- data.tar.gz: 54726e9078cfa0e27e4d6917872ef51a9277cf2a
3
+ metadata.gz: 7481e305e57c4553c4528fae954fd7aaf87e07fa
4
+ data.tar.gz: d91558cc88b0079ce48de9d47ea83b1aae839a0b
5
5
  SHA512:
6
- metadata.gz: ba8289e4502a9c6f9faf1b2a9ca0b5cf42540f2dfbf66c4539d9fe58b0ed28204cc124122c289d5951d4d4f2225df3118121791c5234e1b506e12d3f51e181e3
7
- data.tar.gz: 1980572a2817a26cf4069f58ef8233b08506c52f33c1ad6a09894848ee246c3ea5165053a66b76f55fd4ffc393d5725f3069107389258df44100d3387479fe29
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: file_name(file), url: file_path(file) }
57
+ { name: file_date(file), url: file_path(file) }
45
58
  end
46
59
 
47
60
  { files: list }.to_json
@@ -1,7 +1,7 @@
1
1
  module Capybara
2
2
  module Remote
3
3
  module Viewer
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -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
 
@@ -5,7 +5,6 @@
5
5
  %script{ type: 'text/javascript', src: '/application.js' }
6
6
 
7
7
  %style
8
- ul { display: inline }
9
8
  iframe { width: 100%; height: 100% }
10
9
 
11
10
  %body
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-remote-viewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Kastner