boojs 0.0.25 → 0.0.26

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
  SHA1:
3
- metadata.gz: 193292e66911d83904cd410eebf9404518ca2758
4
- data.tar.gz: 35c56fa2c34e3224de29e58582dd4873c5f3df66
3
+ metadata.gz: db230cbf699816c58332b402c9323cc8a2247dbd
4
+ data.tar.gz: 832c8f6043bfc99893297a9d321d1d8ff27337f9
5
5
  SHA512:
6
- metadata.gz: e7c16d778e4f3392408a2f9605541ddf7b100b2dfce723443c262d6233185f13141f1b9a456b527d01ac666947ca4ac9f0ee3ddb8d56a759488dbd6171b2a7a2
7
- data.tar.gz: 4580513131b33187c4a8d2f8e489a353a4b7d89ccb72bb7dc62aba7737c2adbb947c228f75f533ffaf638d1cd77cdd85f5fcb595a791c69a225e5b04013b0b75
6
+ metadata.gz: ad5ca9aad30b0632ea9aed44e8ed5dfb09bbde16b570af4f08c0adecfe3389ea9b5355ace6a19aeb87061806f838b6a5149d647f81a44bfb2555c2e9ac9d1f48
7
+ data.tar.gz: ffcedb596fc53da6bf9d3a96e3a685226dd715d08cea17e93912efef2c89517705124328680a245c7e136f545019ceb83c898460628f28053a6314caa5ff69fa
data/README.md CHANGED
@@ -15,14 +15,14 @@
15
15
  **BooJS** was purpose built for our continuous integration infrastructure at [Fittr®](http://www.fittr.com).
16
16
 
17
17
  # Setup
18
- ```sh
18
+ ```js
19
19
  #Setup
20
20
  gem install boojs
21
21
  ```
22
22
 
23
23
  # Usage
24
24
  #### SYNOPSIS
25
- ```sh
25
+ ```js
26
26
  boojs [-e statement] [-t timeout] [-v file] [file]
27
27
  ```
28
28
 
@@ -34,27 +34,31 @@ The following options are available:
34
34
 
35
35
  #### EXAMPLES
36
36
  Open a javascript pipe that reads from stdin, writes via console.log to stdout, prints exceptions via stderr, and exits with a return code of 1 if there are errors.
37
- ```sh
37
+ ```js
38
38
  (sh)>boojs
39
+ console.log("Hello world!"); //Output to $stdout
40
+ console.error("Goodbye cruel world!"); //Output to $stderr
39
41
  ```
40
42
 
41
43
  Same as `boojs` but read the javascript file before reading from stdin. (i.e. preload a javascript file into your environment)
42
- ```sh
43
- (sh)>boojs code.js
44
+ ```js
45
+ (sh)>boojs jquery.js
46
+ $("body").html("<h1>Hello</h1>");
47
+ console.log($("body").html())
44
48
  ```
45
49
 
46
50
  Execute a javascript statement, and then immediately exit. Exceptions will return 1.
47
- ```sh
51
+ ```js
48
52
  (sh)>boojs -e "console.log(document);"
49
53
  ```
50
54
 
51
55
  Execute a javascript statement, and then wait 4 seconds before exiting. Exceptions will return 1 and end execution early.
52
- ```sh
56
+ ```js
53
57
  (sh)>boojs -e "console.log(document);" -t 4
54
58
  ```
55
59
 
56
60
  Verify that a file contains no javascript runtime initialization errors
57
- ```sh
61
+ ```js
58
62
  (sh)>boojs -v code.js
59
63
  (sh)>echo $?
60
64
  0
@@ -62,7 +66,7 @@ Verify that a file contains no javascript runtime initialization errors
62
66
 
63
67
  #### NOTES
64
68
  * Calling `booPing()` will immediately return `"pong"` to `stdout`. You may use this to know when boo has started up fully.
65
- * `console.error(msg)` will output to stderr. `console.log(msg) will output to stodut`
69
+ * `console.error(msg)` will output to `$stderr`. `console.log(msg)` will output to `$stdout`.
66
70
 
67
71
  ## Requirements
68
72
 
@@ -76,7 +80,7 @@ Verify that a file contains no javascript runtime initialization errors
76
80
 
77
81
  ---
78
82
 
79
- ## FAQ
83
+ ## FAQ & Rants
80
84
 
81
85
  ### Wait, isn't this just NodeJS?
82
86
  No, they are for different things. BooJS gives you the full DOM, you can call `document` in BooJS and import arbitrary browser javascript libraries.
@@ -86,13 +90,24 @@ There are a myriad issues with the *PhantomJS repl*; most notably, the *PhantomJ
86
90
  * Outputs special format characters even when not attached to a `tty`
87
91
  * Does not have well defined behavior which makes it a nightmare to integrate with
88
92
  * **Has no support for asynchronous stdin**
93
+ * Does not output `console.error` to `stderr`
89
94
  * Changes what it considers a newline based on the attached terminal (A QT quirk)
90
95
  * Is not a unix tool in any sense
91
96
 
92
97
  I don't think any of this is the `PhantomJS`'s team fault; it's just not their focus or target.
93
98
 
94
- ### When should I use boojs?
99
+ ### Why would I use BooJS over my browser console?
100
+ You wouldn't, if you preferred that. *BooJS* was designed for continuous integration environments and has evolved into fun for shell scripting (i.e. `netcatesque`) and even dynamic website page analysis. Some users also prefer CLI over GUI.
101
+
102
+ ### ...Capistrano?
103
+ Capistrano is great for integration tests for behaviors; many users prefer to use both `BooJS` for the javascript layer and then `Capistrano` for behavioral testing, especially with frameworks like `cucumber`. `BooJS` is faster to boot and and more determinant than `Capistrano` while `Capistrano` is able to verify behavior across browsers and visuals. They go well togeather.
104
+
105
+ ### Why Ruby?
106
+ Ruby has many shortcomings; Nonetheless, ruby is an excellent language for writing tools in. Ruby has a culture of testing, a mature gem database that contains many *js* parsers, increadible syntax that includes N-embeddable strings within strings without ugly escape sequences, and good support for `POSIX` interfaces.
95
107
 
108
+ Did you know that *WebKit* uses *Ruby* to pre-compile it's **Javascript** bytecode interpreter *LLInt*? https://trac.webkit.org/browser/releases/Apple/Safari%206.0.2/JavaScriptCore/offlineasm
109
+
110
+ ### When should I use boojs?
96
111
  When you need to test javascript code that needs to run in a browser but don't necessarily need to test the UI components.
97
112
 
98
113
  ### What's Fittr?
data/lib/boojs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BooJS
2
- VERSION = '0.0.25'
2
+ VERSION = '0.0.26'
3
3
  end
data/lib/boojs.rb CHANGED
@@ -88,6 +88,7 @@ module BooJS
88
88
  phantom.exit(1);
89
89
  }
90
90
 
91
+ //@maboiteaspam (https://github.com/ariya/phantomjs/issues/11961)
91
92
  console.error = function(msg) {
92
93
  system.stderr.writeLine(msg)
93
94
  };
@@ -37,6 +37,40 @@ RSpec.describe "JS Functions" do
37
37
  end
38
38
  end
39
39
 
40
+ it "console.log writes to stdout" do
41
+ @err = StringIO.new
42
+ @out = StringIO.new
43
+
44
+ pipe = Open3.popen3("ruby -Ilib ./bin/boojs") do |i, o, e, t|
45
+ begin
46
+ Timeout::timeout(5) do
47
+ i.puts "console.log('hello world')"
48
+ loop do
49
+ res = select [o, e], []
50
+
51
+ if res[0].include? e
52
+ @err.write e.readline
53
+ end
54
+
55
+ if res[0].include? o
56
+ @out.write o.readline
57
+ end
58
+ end
59
+ end
60
+ rescue Timeout::Error
61
+ rescue EOFError
62
+ ensure
63
+ begin
64
+ Process.kill(:KILL, t[:pid])
65
+ rescue Errno::ESRCH
66
+ end
67
+ end
68
+
69
+ expect(@out.string.strip).to eq("hello world")
70
+ expect(@err.string.strip).to eq("")
71
+ end
72
+ end
73
+
40
74
  it "booPing writes 'pong' to stdout" do
41
75
  @out = StringIO.new
42
76
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boojs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 0.0.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - seo