capybara-java_script_lint 0.0.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.
@@ -0,0 +1,46 @@
1
+ module Capybara
2
+ module JavaScriptLint
3
+ class TestCase < ActionDispatch::IntegrationTest
4
+ include ActionView::Helpers::JavaScriptHelper
5
+ setup do
6
+ Capybara.current_driver = :webkit
7
+ end
8
+
9
+ def self.check(path)
10
+ options = @options || {}
11
+ source = self.jslint_source
12
+ test "JSLINT #{path}" do
13
+ assert_jslint(path, options, source)
14
+ end
15
+ end
16
+
17
+ def self.options(options)
18
+ @options = options
19
+ end
20
+
21
+ private
22
+ def self.jslint_source
23
+ @jslint_source ||= File.read(File.join(File.dirname(__FILE__), '..', '..', '..', 'jslint.js'))
24
+ end
25
+
26
+ def assert_jslint(path, options, jslint)
27
+ path = "/assets/#{path}"
28
+ visit path
29
+
30
+ doc = Nokogiri::HTML(page.body)
31
+ source = doc.css('pre').first.content
32
+
33
+ visit 'about:blank'
34
+ page.execute_script jslint
35
+
36
+ if !page.evaluate_script %{JSLINT("#{escape_javascript source}", #{options.to_json})}
37
+ page.evaluate_script(%{JSLINT.errors}).each do |error|
38
+ puts %{\n#{path}:#{error['line']}@#{error['character']}: #{error['reason']}\n#{error['evidence']}}
39
+ end
40
+ flunk 'JSLINT Errors'
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+
@@ -0,0 +1,5 @@
1
+ module Capybara
2
+ module JavaScriptLint
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "capybara/java_script_lint/version"
2
+
3
+ module Capybara
4
+ module JavaScriptLint
5
+ autoload :TestCase, 'capybara/java_script_lint/test_case'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capybara-java_script_lint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nick Gauthier
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capybara-webkit
16
+ requirement: &15191480 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *15191480
25
+ description: Run JSLint on Rails JavaScript assets through the asset pipeline with
26
+ Capybara Webkit
27
+ email:
28
+ - ngauthier@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - Gemfile
35
+ - LICENSE
36
+ - MIT-LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - capybara-java_script_lint.gemspec
40
+ - jslint.js
41
+ - lib/capybara-java_script_lint.rb
42
+ - lib/capybara/java_script_lint/test_case.rb
43
+ - lib/capybara/java_script_lint/version.rb
44
+ homepage: http://github.com/ngauthier/capybara-java_script_lint
45
+ licenses: []
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.11
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Run JSLint on Rails JavaScript assets through the asset pipeline with Capybara
68
+ Webkit
69
+ test_files: []