browserio 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,59 +0,0 @@
1
- var page = require('webpage').create();
2
- page.settings.localToRemoteUrlAccessEnabled = true;
3
- page.settings.resourceTimeout = 1000;
4
- // page.content = "<!doctype html>\n<html>\n<head>\new<script type=\"text/javascript\" src=\"https://code.jquery.com/jquery-1.11.2.min.js\"></script>\n</head>\n<body>\n<div id=\"foo\">bar<div>\n</body>\n</html>";
5
- var content = '<!doctype html>';
6
- content += '<html><head>';
7
- content += '<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script>';
8
- content += '</head><body>';
9
- content += '<h1 id="foo">bar</h1>';
10
- content += '</body></html>';
11
-
12
- // page.content = "<div id='foo'>bar</div>";
13
-
14
- page.onConsoleMessage = function(msg) {
15
- console.log(msg);
16
- };
17
-
18
- page.onResourceTimeout = function(a) {
19
- phantom.exit(1);
20
- };
21
-
22
- page.onError = function(msg, trace) {
23
-
24
- var msgStack = ['ERROR: ' + msg];
25
-
26
- if (trace && trace.length) {
27
- msgStack.push('TRACE:');
28
- trace.forEach(function(t) {
29
- msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : ''));
30
- });
31
- }
32
-
33
- console.log(msgStack.join('\n'));
34
- phantom.exit();
35
- };
36
-
37
- phantom.onError = function(msg, trace) {
38
- var msgStack = ['PHANTOM ERROR: ' + msg];
39
- if (trace && trace.length) {
40
- msgStack.push('TRACE:');
41
- trace.forEach(function(t) {
42
- msgStack.push(' -> ' + (t.file || t.sourceURL) + ': ' + t.line + (t.function ? ' (in function ' + t.function +')' : ''));
43
- });
44
- }
45
- console.log(msgStack.join('\n'));
46
- phantom.exit();
47
- };
48
-
49
- page.content = content
50
-
51
- page.onLoadFinished = function() {
52
- page.evaluate(function() {
53
- console.log($('#foo').html());
54
- });
55
- phantom.exit();
56
- };
57
-
58
- // page.includeJs("http://code.jquery.com/jquery-1.11.2.min.js", function(){
59
- // });
@@ -1,34 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- class BasicComponent < BrowserIO::Component
4
- config.name :basic
5
- config.html <<-HTML
6
- <!DOCTYPE html>
7
- <html>
8
- <body>
9
- <div id='foo'>bar</div>
10
- </body>
11
- </html>
12
- HTML
13
- config.dom do
14
- tmpl :foo, dom.find('#foo')
15
- end
16
-
17
- def foo
18
- 'bar'
19
- end
20
- end
21
-
22
- class TestComponent < Minitest::Test
23
- def test_calling_basic_component
24
- assert_equal 'bar', bio(:basic).foo
25
- end
26
-
27
- def test_parsing_html
28
- assert_equal '<div id="foo">bar</div>', bio(:basic).tmpl(:foo).to_html
29
- end
30
-
31
- def test_returning_js
32
- assert bio(:basic, :js).foo[/Opal/]
33
- end
34
- end
@@ -1,13 +0,0 @@
1
- require 'phantomjs'
2
- require_relative 'test_helper'
3
-
4
- class TestBrowserIO < Minitest::Test
5
- def test_javascript_and_source_maps
6
- assert BrowserIO.javascript[/Opal/]
7
- assert BrowserIO.source_map[/mappings/]
8
- end
9
-
10
- # def test_moo
11
- # Phantomjs.run('./test/test.js')
12
- # end
13
- end
@@ -1,38 +0,0 @@
1
- require 'bundler'
2
- Bundler.setup :default, ENV.fetch('RACK_ENV') { 'development' }
3
-
4
- require 'minitest/autorun'
5
- require 'minitest/reporters'
6
- require 'browserio'
7
-
8
- require 'pry'
9
- require 'awesome_print'
10
-
11
- Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new # spec-like progress
12
-
13
- module Minitest
14
- class Test
15
- extend Minitest::Spec::DSL
16
-
17
- def session
18
- @_session ||= OpenStruct.new
19
- end
20
-
21
- def bio(*args)
22
- BrowserIO[*args]
23
- end
24
-
25
- # def app(*args)
26
- # a = Class.new(PropertyLink).new
27
- #
28
- # a.instance_variable_set(:@_request, OpenStruct.new(
29
- # session: session,
30
- # env: {
31
- # 'rack.session' => {}
32
- # }
33
- # ))
34
- #
35
- # a.component(*args)
36
- # end
37
- end
38
- end