web-console-pry 0.1.1

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.
Files changed (105) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.markdown +53 -0
  4. data/Rakefile +18 -0
  5. data/lib/web-console-pry.rb +1 -0
  6. data/lib/web_console/repl/pry/version.rb +7 -0
  7. data/lib/web_console/repl/pry.rb +57 -0
  8. data/lib/web_console_pry.rb +2 -0
  9. data/test/dummy/README.rdoc +28 -0
  10. data/test/dummy/Rakefile +6 -0
  11. data/test/dummy/app/assets/javascripts/application.js +13 -0
  12. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  13. data/test/dummy/app/controllers/application_controller.rb +5 -0
  14. data/test/dummy/app/helpers/application_helper.rb +2 -0
  15. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  16. data/test/dummy/bin/bundle +3 -0
  17. data/test/dummy/bin/rails +4 -0
  18. data/test/dummy/bin/rake +4 -0
  19. data/test/dummy/config/application.rb +14 -0
  20. data/test/dummy/config/boot.rb +5 -0
  21. data/test/dummy/config/database.yml +25 -0
  22. data/test/dummy/config/environment.rb +5 -0
  23. data/test/dummy/config/environments/development.rb +29 -0
  24. data/test/dummy/config/environments/production.rb +80 -0
  25. data/test/dummy/config/environments/test.rb +36 -0
  26. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  27. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  28. data/test/dummy/config/initializers/inflections.rb +16 -0
  29. data/test/dummy/config/initializers/mime_types.rb +5 -0
  30. data/test/dummy/config/initializers/secret_token.rb +12 -0
  31. data/test/dummy/config/initializers/session_store.rb +3 -0
  32. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  33. data/test/dummy/config/locales/en.yml +23 -0
  34. data/test/dummy/config/routes.rb +2 -0
  35. data/test/dummy/config.ru +4 -0
  36. data/test/dummy/db/development.sqlite3 +0 -0
  37. data/test/dummy/db/schema.rb +16 -0
  38. data/test/dummy/db/test.sqlite3 +0 -0
  39. data/test/dummy/log/development.log +2510 -0
  40. data/test/dummy/log/test.log +7423 -0
  41. data/test/dummy/public/404.html +58 -0
  42. data/test/dummy/public/422.html +58 -0
  43. data/test/dummy/public/500.html +57 -0
  44. data/test/dummy/public/favicon.ico +0 -0
  45. data/test/dummy/tmp/cache/assets/development/sprockets/013cd9dde061678035fd449602ed3dee +0 -0
  46. data/test/dummy/tmp/cache/assets/development/sprockets/0280bb38c5058cc31c4fcd8c392a5ec4 +0 -0
  47. data/test/dummy/tmp/cache/assets/development/sprockets/05bd7b24c0a86010ebb28b50ac7cad52 +0 -0
  48. data/test/dummy/tmp/cache/assets/development/sprockets/295d963a582a11a6815203dae93a7c79 +0 -0
  49. data/test/dummy/tmp/cache/assets/development/sprockets/3a37adb5ebd079cf67dae597b8c2e4f8 +0 -0
  50. data/test/dummy/tmp/cache/assets/development/sprockets/3a4877e6003e99861e71654d638a21e0 +0 -0
  51. data/test/dummy/tmp/cache/assets/development/sprockets/3d01ce5517f0c10de9cf591640b37af2 +0 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/3da4ddb876e322e73b97548fa9066914 +0 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/4d7a5a07b0f10c39da3b16d1732c5d94 +0 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/4de538f1592e73a3a96aca4a204b0664 +0 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/521d63cea37a3868ee0cc4ecce244b5b +0 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/5adcb7569cdd03204d650e285f19351f +0 -0
  57. data/test/dummy/tmp/cache/assets/development/sprockets/5b97a34a13e51ae5a7b579aba0cf3196 +0 -0
  58. data/test/dummy/tmp/cache/assets/development/sprockets/5db5650c923557311407f58df98cd166 +0 -0
  59. data/test/dummy/tmp/cache/assets/development/sprockets/654a1bde557d359b957dc0aa12b0dfa0 +0 -0
  60. data/test/dummy/tmp/cache/assets/development/sprockets/67786c573ee3131d5b7efbca2d71bf44 +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/6b0a87b6bf10ebb5d7a6617baa1ad3dc +0 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/706cd58a61621d21c7d4963305ee4cb2 +0 -0
  63. data/test/dummy/tmp/cache/assets/development/sprockets/71f57313d6c92f5483915a6c2d79a506 +0 -0
  64. data/test/dummy/tmp/cache/assets/development/sprockets/7285cfef563d125008aca55469e09ca1 +0 -0
  65. data/test/dummy/tmp/cache/assets/development/sprockets/7a52175179fd09c4064b0e33dc3dd08f +0 -0
  66. data/test/dummy/tmp/cache/assets/development/sprockets/7ec0041a47c34b44e52e836c01454a1a +0 -0
  67. data/test/dummy/tmp/cache/assets/development/sprockets/9de1a5b1420a794cf6084c393d47145e +0 -0
  68. data/test/dummy/tmp/cache/assets/development/sprockets/a01a032614d49817ab20a9171b6bb7cd +0 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/a1534e0c08b73ad82c2edb8c364caa66 +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/a33d9f5eaf160e512ebae3d6d350179b +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/a59bd8ace61285ea7939759309f8490b +0 -0
  72. data/test/dummy/tmp/cache/assets/development/sprockets/a810316ce75be3f56e46f562cbccba67 +0 -0
  73. data/test/dummy/tmp/cache/assets/development/sprockets/a841a3af20a321912acfed87036438fb +0 -0
  74. data/test/dummy/tmp/cache/assets/development/sprockets/ab9f090c432b5cbd32de0e877ec90fb2 +0 -0
  75. data/test/dummy/tmp/cache/assets/development/sprockets/ac1e35855de82d64c80076a844243604 +0 -0
  76. data/test/dummy/tmp/cache/assets/development/sprockets/b0741545b4917192ba7b5e803c2e323d +0 -0
  77. data/test/dummy/tmp/cache/assets/development/sprockets/b3159b06164dd474ff8efc3c84aefbba +0 -0
  78. data/test/dummy/tmp/cache/assets/development/sprockets/bbbe6a3ce382662666a355d708c83d2d +0 -0
  79. data/test/dummy/tmp/cache/assets/development/sprockets/c18ba3c550539f8d42db587c7f552ddf +0 -0
  80. data/test/dummy/tmp/cache/assets/development/sprockets/c52aa5859edffd7cd39a3a61dbacd79c +0 -0
  81. data/test/dummy/tmp/cache/assets/development/sprockets/c60ffedbde9e80e6794ad1bd0896feb5 +0 -0
  82. data/test/dummy/tmp/cache/assets/development/sprockets/ca53fb2717d5aac2f1c3939d9444fe3b +0 -0
  83. data/test/dummy/tmp/cache/assets/development/sprockets/d6b37d10680a997662c379d0ff7cad27 +0 -0
  84. data/test/dummy/tmp/cache/assets/development/sprockets/e1d89809967e81220dca66770c50aa67 +0 -0
  85. data/test/dummy/tmp/cache/assets/development/sprockets/e3d5cafc071e8f9a8efc88fddf721947 +0 -0
  86. data/test/dummy/tmp/cache/assets/development/sprockets/e783078d430c8e9abb61a79601230012 +0 -0
  87. data/test/dummy/tmp/cache/assets/development/sprockets/f0872fadfe4f2aecfc09b8b8cb9e0649 +0 -0
  88. data/test/dummy/tmp/cache/assets/development/sprockets/f4a21ed9cebe2c83a9d988504dc6720b +0 -0
  89. data/test/dummy/tmp/cache/assets/development/sprockets/f4d45273ff5b44879dab0a16805f4309 +0 -0
  90. data/test/dummy/tmp/cache/assets/development/sprockets/f9195f88e3e2d4e48c350ce84185809f +0 -0
  91. data/test/dummy/tmp/cache/assets/development/sprockets/f9af7b613655292da7559109cfd010cf +0 -0
  92. data/test/dummy/tmp/cache/assets/development/sprockets/f9fe1d844576802f622a9c329d4fbbdf +0 -0
  93. data/test/dummy/tmp/cache/assets/test/sprockets/0280bb38c5058cc31c4fcd8c392a5ec4 +0 -0
  94. data/test/dummy/tmp/cache/assets/test/sprockets/3a37adb5ebd079cf67dae597b8c2e4f8 +0 -0
  95. data/test/dummy/tmp/cache/assets/test/sprockets/5adcb7569cdd03204d650e285f19351f +0 -0
  96. data/test/dummy/tmp/cache/assets/test/sprockets/a841a3af20a321912acfed87036438fb +0 -0
  97. data/test/dummy/tmp/cache/assets/test/sprockets/bbbe6a3ce382662666a355d708c83d2d +0 -0
  98. data/test/dummy/tmp/cache/assets/test/sprockets/d6b37d10680a997662c379d0ff7cad27 +0 -0
  99. data/test/dummy/tmp/cache/assets/test/sprockets/e1d89809967e81220dca66770c50aa67 +0 -0
  100. data/test/dummy/tmp/cache/assets/test/sprockets/e3d5cafc071e8f9a8efc88fddf721947 +0 -0
  101. data/test/dummy/tmp/cache/assets/test/sprockets/f4a21ed9cebe2c83a9d988504dc6720b +0 -0
  102. data/test/dummy/tmp/cache/assets/test/sprockets/f4d45273ff5b44879dab0a16805f4309 +0 -0
  103. data/test/test_helper.rb +15 -0
  104. data/test/web_console/repl/pry_test.rb +77 -0
  105. metadata +301 -0
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,15 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ # Load fixtures from the engine
13
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
15
+ end
@@ -0,0 +1,77 @@
1
+ require 'test_helper'
2
+
3
+ class PryTest < ActiveSupport::TestCase
4
+ setup do
5
+ @pry1 = @pry = WebConsole::REPL::Pry.new
6
+ @pry2 = WebConsole::REPL::Pry.new
7
+ end
8
+
9
+ test 'sending input returns the result as output' do
10
+ assert_equal return_prompt(42), @pry.send_input('foo = 42')
11
+ end
12
+
13
+ test 'session preservation requires same bindings' do
14
+ assert_equal return_prompt(42), @pry1.send_input('foo = 42')
15
+ assert_equal return_prompt(42), @pry2.send_input('foo')
16
+ end
17
+
18
+ test 'session isolation requires own bindings' do
19
+ pry1 = WebConsole::REPL::Pry.new(Object.new.instance_eval('binding'))
20
+ pry2 = WebConsole::REPL::Pry.new(Object.new.instance_eval('binding'))
21
+ assert_equal return_prompt(42), pry1.send_input('foo = 42')
22
+ assert_match %r{NameError}, pry2.send_input('foo')
23
+ end
24
+
25
+ test 'multiline support' do
26
+ assert_equal '', @pry.send_input('class A')
27
+ assert_equal return_prompt(nil), @pry.send_input('end')
28
+ assert_equal return_prompt('A'), @pry.send_input('A.name')
29
+ end
30
+
31
+ test 'multiline support between threads' do
32
+ assert_equal "", @pry.send_input('class A')
33
+ Thread.new do
34
+ assert_equal return_prompt(nil), @pry.send_input('end')
35
+ assert_no_match %r{NameError}, @pry.send_input('A')
36
+ end.join
37
+ end
38
+
39
+ test 'captures direct stdout output' do
40
+ assert_equal "42\n#{return_prompt(nil)}", @pry.send_input('puts 42')
41
+ end
42
+
43
+ test 'captures direct stderr output' do
44
+ assert_equal "42\n#{return_prompt(3)}", @pry.send_input('$stderr.write("42\n")')
45
+ end
46
+
47
+ test 'captures direct output from subprocesses' do
48
+ assert_equal "42\n#{return_prompt(true)}", @pry.send_input('system "echo 42"')
49
+ end
50
+
51
+ test 'captures direct output from forks' do
52
+ assert_match %r{42\n}, @pry.send_input('Process.wait(fork { puts 42 })')
53
+ end
54
+
55
+ test 'prompt is present' do
56
+ assert_not_nil @pry.prompt
57
+ end
58
+
59
+ test 'rails helpers are available in the session' do
60
+ each_rails_console_method do |meth|
61
+ assert_equal return_prompt(true), @pry.send_input("respond_to? :#{meth}")
62
+ end
63
+ end
64
+
65
+ private
66
+ def return_prompt(value)
67
+ output = StringIO.new
68
+ ::Pry.config.print.call(output, value)
69
+ output.string
70
+ end
71
+
72
+ def each_rails_console_method(&block)
73
+ require 'rails/console/app'
74
+ require 'rails/console/helpers'
75
+ Rails::ConsoleMethods.public_instance_methods.each(&block)
76
+ end
77
+ end