rspec-lintable 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 683b97c425abfd9c6607eb0fc6e4b17b018a2d06
4
+ data.tar.gz: ea1b6b12ae34cc82dc666ff075dd9e829a1467fb
5
+ SHA512:
6
+ metadata.gz: 842c7ba842041b3f1e7e426f93a097777c7851eedc4a828dac15454c3f6a53089f081c4e6a6b30cb888055623ff801ae2e5c1db5ecc0af53e58799fba0ab00d9
7
+ data.tar.gz: 5b3ab83132fa094041e9202c918c49e44157c324d31063a163fbe07feac426072234ef7f63bbe74f94277716932038b3f48679b0100d6e04e199a61e8b21ba22
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/CONTRIBUTING.md ADDED
@@ -0,0 +1,6 @@
1
+ ## Contribution Guidelines
2
+ 1. Fork the repository
3
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
4
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
5
+ 4. Push to the branch (`git push origin my-new-feature`)
6
+ 5. Create new Pull Request
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-lintable.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ryan Sonnek
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,31 @@
1
+ # Rspec::Lintable
2
+ > Ensure your controllers are returning "valid" Javascript responses
3
+
4
+ ## Usage
5
+
6
+ ```ruby
7
+ describe "#show" do
8
+ before { get :show, format: :js }
9
+ it { should be_lintable }
10
+ end
11
+ ```
12
+
13
+ ## Installation
14
+
15
+ Add the gem to your `test` group of your `Gemfile` and it will automatically be loaded into your RSpec runtime!
16
+
17
+ ```ruby
18
+ # Gemfile
19
+ gem 'rspec-lintable', group: :test
20
+ ```
21
+
22
+ ## Configuration
23
+
24
+ All options and configuration are done via the standard [Jshint .jshintrc](http://www.jshint.com/docs/)
25
+ configuration file.
26
+
27
+ ## Contributing
28
+
29
+ Interested in contributing? Review the project [contribution guidelines](CONTRIBUTING.md) and get started!
30
+
31
+ Patches are always welcome and thank you to all [project contributors](https://github.com/wireframe/rspec-lintable/graphs/contributors)!
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Rspec
2
+ module Lintable
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,36 @@
1
+ require "rspec/lintable/version"
2
+ require 'rspec/matchers'
3
+ require 'jshintrb'
4
+ require 'json'
5
+
6
+ # ensure that response body is valid "lintable" javascript.
7
+ # this matcher should *not* be used for negative assertions (ie: should_not be_lintable)
8
+ #
9
+ # example usage:
10
+ # describe "#show" do
11
+ # before { get :show, format: :js }
12
+ # it { should be_lintable }
13
+ # end
14
+ #
15
+ # see https://gist.github.com/wireframe/1042920
16
+ RSpec::Matchers.define :be_lintable do |ability|
17
+ match do |controller|
18
+ @content = controller.response.body
19
+ @errors = Jshintrb.lint(@content, jshint_options, jshint_globals)
20
+ @errors.empty?
21
+ end
22
+
23
+ failure_message_for_should do |actual|
24
+ "expected response javascript to be lintable.\nErrors: #{@errors.inspect}\nContent: #{@content}"
25
+ end
26
+
27
+ private
28
+
29
+ def jshint_options
30
+ @jshint_options ||= JSON.load(File.read(Rails.root.join('.jshintrc')))
31
+ end
32
+
33
+ def jshint_globals
34
+ @globals ||= jshint_options.delete('globals').keys
35
+ end
36
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rspec/lintable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-lintable"
8
+ spec.version = Rspec::Lintable::VERSION
9
+ spec.authors = ["Ryan Sonnek"]
10
+ spec.email = ["ryan@codecrate.com"]
11
+ spec.summary = %q{RSpec matcher for linting javascript responses}
12
+ spec.description = %q{RSpec helper that asserts javascript responses are valid}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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 'rspec'
22
+ spec.add_dependency 'jshintrb'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.5"
25
+ spec.add_development_dependency "rake"
26
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-lintable
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Sonnek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jshintrb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: RSpec helper that asserts javascript responses are valid
70
+ email:
71
+ - ryan@codecrate.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - CONTRIBUTING.md
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/rspec/lintable.rb
83
+ - lib/rspec/lintable/version.rb
84
+ - rspec-lintable.gemspec
85
+ homepage: ''
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.2.1
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: RSpec matcher for linting javascript responses
109
+ test_files: []