capybara-remote-viewer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +70 -0
  6. data/Rakefile +1 -0
  7. data/bin/capy-remote +9 -0
  8. data/capybara-remote-viewer.gemspec +29 -0
  9. data/lib/capybara/remote/viewer/cli.rb +27 -0
  10. data/lib/capybara/remote/viewer/server.rb +56 -0
  11. data/lib/capybara/remote/viewer/version.rb +7 -0
  12. data/lib/capybara/remote/viewer.rb +9 -0
  13. data/spec/capybara/remote/viewer/server_spec.rb +38 -0
  14. data/spec/dummy/Gemfile +47 -0
  15. data/spec/dummy/README.rdoc +28 -0
  16. data/spec/dummy/Rakefile +6 -0
  17. data/spec/dummy/app/assets/images/.keep +0 -0
  18. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  19. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  20. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  21. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  22. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  23. data/spec/dummy/app/mailers/.keep +0 -0
  24. data/spec/dummy/app/models/.keep +0 -0
  25. data/spec/dummy/app/models/concerns/.keep +0 -0
  26. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  27. data/spec/dummy/bin/bundle +3 -0
  28. data/spec/dummy/bin/rails +4 -0
  29. data/spec/dummy/bin/rake +4 -0
  30. data/spec/dummy/config/application.rb +23 -0
  31. data/spec/dummy/config/boot.rb +4 -0
  32. data/spec/dummy/config/cucumber.yml +8 -0
  33. data/spec/dummy/config/database.yml +28 -0
  34. data/spec/dummy/config/environment.rb +5 -0
  35. data/spec/dummy/config/environments/development.rb +29 -0
  36. data/spec/dummy/config/environments/production.rb +80 -0
  37. data/spec/dummy/config/environments/test.rb +36 -0
  38. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  40. data/spec/dummy/config/initializers/inflections.rb +16 -0
  41. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  42. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  43. data/spec/dummy/config/initializers/session_store.rb +3 -0
  44. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  45. data/spec/dummy/config/locales/en.yml +23 -0
  46. data/spec/dummy/config/routes.rb +56 -0
  47. data/spec/dummy/config.ru +4 -0
  48. data/spec/dummy/db/seeds.rb +7 -0
  49. data/spec/dummy/features/support/env.rb +58 -0
  50. data/spec/dummy/lib/assets/.keep +0 -0
  51. data/spec/dummy/lib/tasks/.keep +0 -0
  52. data/spec/dummy/lib/tasks/cucumber.rake +65 -0
  53. data/spec/dummy/log/.keep +0 -0
  54. data/spec/dummy/log/development.log +0 -0
  55. data/spec/dummy/public/404.html +58 -0
  56. data/spec/dummy/public/422.html +58 -0
  57. data/spec/dummy/public/500.html +57 -0
  58. data/spec/dummy/public/favicon.ico +0 -0
  59. data/spec/dummy/public/robots.txt +5 -0
  60. data/spec/dummy/script/cucumber +10 -0
  61. data/spec/dummy/test/controllers/.keep +0 -0
  62. data/spec/dummy/test/fixtures/.keep +0 -0
  63. data/spec/dummy/test/helpers/.keep +0 -0
  64. data/spec/dummy/test/integration/.keep +0 -0
  65. data/spec/dummy/test/mailers/.keep +0 -0
  66. data/spec/dummy/test/models/.keep +0 -0
  67. data/spec/dummy/test/test_helper.rb +15 -0
  68. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  69. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  70. data/spec/spec_helper.rb +6 -0
  71. data/static/application.js +18 -0
  72. data/views/index.haml +17 -0
  73. metadata +274 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: 4366c063b7cea76765fec03f548f0e3e037aec84
4
+ data.tar.gz: 54726e9078cfa0e27e4d6917872ef51a9277cf2a
5
+ SHA512:
6
+ metadata.gz: ba8289e4502a9c6f9faf1b2a9ca0b5cf42540f2dfbf66c4539d9fe58b0ed28204cc124122c289d5951d4d4f2225df3118121791c5234e1b506e12d3f51e181e3
7
+ data.tar.gz: 1980572a2817a26cf4069f58ef8233b08506c52f33c1ad6a09894848ee246c3ea5165053a66b76f55fd4ffc393d5725f3069107389258df44100d3387479fe29
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capybara-remote-viewer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Derek Kastner
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # Capybara::Remote::Viewer
2
+
3
+ Capybara remote viewer runs a server that provides a navigable browser interface
4
+ to the HTML dumps generated by capybara's `save_page` helper. It is especially
5
+ useful if you're developing an app on a remote machine or working within a shell
6
+ that can't open a browser window on your desktop.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'capybara-remote-viewer'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install capybara-remote-viewer
21
+
22
+ ## Usage
23
+
24
+ ### As a stand-alone binary
25
+
26
+ Start a server with:
27
+ $ capy-remote
28
+
29
+ It will start on port 3000 by default and look in the current working directory
30
+ (and all subdirectories) for any .html files to serve.
31
+
32
+ You can specify a path to a directory containing .html files with the -t option.
33
+
34
+ You can also specify the port with the -p option.
35
+
36
+ ### With foreman
37
+
38
+ Add a binstub
39
+
40
+ $ bundle binstub capybara-remote-viewer
41
+
42
+ Add a line to your Procfile
43
+
44
+ capy: bin/capy-remote -t tmp -p $PORT
45
+
46
+ ### Interface
47
+
48
+ All files dumped by capybara with the `save_page` method will automatically
49
+ appear in the viewer interface as they are generated. No need to refresh!
50
+
51
+ ### Optional capybara configuration
52
+
53
+ Capybara does not clean up after itself when it dumps html files, so as these
54
+ files appear, they will fill up remote viewer's interface with old junk. You can
55
+ tell cucumber to clean these up before each run.
56
+
57
+ In features/support/capybara.rb:
58
+
59
+ AfterConfiguration do |config|
60
+ Dir.glob(File.expand_path('../../../tmp/capybara/*', __FILE__)).
61
+ each { |f| FileUtils.rm_f f }
62
+ end
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/capy-remote ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+
5
+ $:.unshift File.expand_path('../../lib', __FILE__)
6
+
7
+ require 'capybara/remote/viewer/cli'
8
+
9
+ Capybara::Remote::Viewer::CLI.start(ARGV)
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capybara/remote/viewer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capybara-remote-viewer"
8
+ spec.version = Capybara::Remote::Viewer::VERSION
9
+ spec.authors = ["Derek Kastner"]
10
+ spec.email = ["dkastner@gmail.com"]
11
+ spec.description = %q{View capybara page dumps remotely}
12
+ spec.summary = %q{A web server that looks for capybara's saved output and makes them available to remotely connected developers}
13
+ spec.homepage = "http://github.com/dkastner/capybara-remote-viewer"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'haml'
22
+ spec.add_dependency 'sinatra'
23
+ spec.add_dependency 'thor'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rack-test"
28
+ spec.add_development_dependency "rspec"
29
+ end
@@ -0,0 +1,27 @@
1
+ require 'thor'
2
+
3
+ module Capybara
4
+ module Remote
5
+ module Viewer
6
+ class CLI < Thor
7
+
8
+ desc 'serve', 'Run the web server'
9
+ method_option :path, type: :string, default: nil, aliases: '-t',
10
+ desc: "Path to your app's tmp directory, or any directory containing html files"
11
+ method_option :port, type: :numeric, default: 3000, aliases: '-p',
12
+ desc: "Port for the server to listen on"
13
+ def serve
14
+ path = options.path || File.join(Dir.pwd, 'tmp')
15
+
16
+ require 'capybara/remote/viewer/server'
17
+
18
+ Capybara::Remote::Viewer::Server.path = path
19
+ Capybara::Remote::Viewer::Server.set :port, options.port
20
+ Capybara::Remote::Viewer::Server.run!
21
+ end
22
+
23
+ default_task :serve
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,56 @@
1
+ require 'sinatra/base'
2
+ require 'haml'
3
+ require 'json'
4
+
5
+ module Capybara
6
+ module Remote
7
+ module Viewer
8
+ class Server < Sinatra::Base
9
+
10
+ def self.path
11
+ @path
12
+ end
13
+ def self.path=(val)
14
+ @path = val
15
+ end
16
+
17
+ set :views, File.expand_path('../../../../../views', __FILE__)
18
+ set :public_folder, File.expand_path('../../../../../static', __FILE__)
19
+
20
+ def files
21
+ Dir.glob File.join(Server.path, '**/*.html')
22
+ end
23
+
24
+ def file(id)
25
+ files.find { |f| f =~ /#{id}.html$/ }
26
+ end
27
+
28
+ def file_path(str)
29
+ "/files/#{file_name(str)}"
30
+ end
31
+
32
+ def file_name(str)
33
+ File.basename(str, '.html')
34
+ end
35
+
36
+ get '/' do
37
+ haml :index, locals: { dir: Server.path, files: files }
38
+ end
39
+
40
+ get '/files' do
41
+ headers 'Content-Type' => 'application/json'
42
+
43
+ list = files.map do |file|
44
+ { name: file_name(file), url: file_path(file) }
45
+ end
46
+
47
+ { files: list }.to_json
48
+ end
49
+
50
+ get '/files/:id' do
51
+ File.read file(params['id'])
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,7 @@
1
+ module Capybara
2
+ module Remote
3
+ module Viewer
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require "capybara/remote/viewer/version"
2
+
3
+ module Capybara
4
+ module Remote
5
+ module Viewer
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+ require 'rack/test'
3
+ require 'capybara/remote/viewer/server'
4
+
5
+ describe Capybara::Remote::Viewer::Server do
6
+ include Rack::Test::Methods
7
+
8
+ before(:all) do
9
+ Capybara::Remote::Viewer::Server.
10
+ set :path, File.expand_path('../../../../dummy', __FILE__)
11
+ end
12
+
13
+ def app
14
+ Capybara::Remote::Viewer::Server
15
+ end
16
+
17
+ describe 'GET /' do
18
+
19
+ it 'links to existing files' do
20
+ get '/'
21
+
22
+ last_response.body.should =~ %r{<a href='/files/1'>1</a>}
23
+ end
24
+
25
+ end
26
+
27
+ describe 'GET /files/1' do
28
+
29
+ it 'displays the content of a capybara dump' do
30
+ get '/files/1'
31
+
32
+ last_response.body.should =~ %r{First dump}
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
@@ -0,0 +1,47 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '4.0.1'
5
+
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3'
8
+
9
+ # Use SCSS for stylesheets
10
+ gem 'sass-rails', '~> 4.0.0'
11
+
12
+ # Use Uglifier as compressor for JavaScript assets
13
+ gem 'uglifier', '>= 1.3.0'
14
+
15
+ # Use CoffeeScript for .js.coffee assets and views
16
+ gem 'coffee-rails', '~> 4.0.0'
17
+
18
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
19
+ # gem 'therubyracer', platforms: :ruby
20
+
21
+ # Use jquery as the JavaScript library
22
+ gem 'jquery-rails'
23
+
24
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
25
+ gem 'turbolinks'
26
+
27
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
28
+ gem 'jbuilder', '~> 1.2'
29
+
30
+ group :doc do
31
+ # bundle exec rake doc:rails generates the API under doc/api.
32
+ gem 'sdoc', require: false
33
+ end
34
+
35
+ # Use ActiveModel has_secure_password
36
+ # gem 'bcrypt-ruby', '~> 3.1.2'
37
+
38
+ # Use unicorn as the app server
39
+ # gem 'unicorn'
40
+
41
+ # Use Capistrano for deployment
42
+ # gem 'capistrano', group: :development
43
+
44
+ # Use debugger
45
+ # gem 'debugger', group: [:development, :test]
46
+
47
+ gem 'cucumber-rails'
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
File without changes
@@ -0,0 +1,16 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end