jshint 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.1
4
+
5
+ * Fixes [#23](https://github.com/damian/jshint/pull/23) - Broken Rake task
6
+ * [Upgraded to RSpec 3](https://github.com/damian/jshint/pull/22)
7
+
3
8
  ## 1.3.0
4
9
 
5
10
  * Fixes [#18](https://github.com/damian/jshint/pull/18) - Ensure the default Rake task runs the test suite
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "bundler", "~> 1.3"
26
26
  spec.add_development_dependency "railties", ">= 3.2.0"
27
27
  spec.add_development_dependency "rake"
28
- spec.add_development_dependency "rspec", "~> 2.14"
28
+ spec.add_development_dependency "rspec", "~> 3.1.0"
29
29
  spec.add_development_dependency "yard"
30
30
  end
@@ -6,8 +6,8 @@ namespace :jshint do
6
6
  desc "Runs JSHint, the JavaScript lint tool over this project's JavaScript assets"
7
7
  task :lint => :environment do |_, args|
8
8
  # Our own argument parsing, since rake jshint will push extra nil's.
9
- reporter_name = args.extras[0] if args.extras.length >= 1
10
- result_file = args.extras[1] if args.extras.length >= 2
9
+ reporter_name = args.extras[0] || :Default
10
+ result_file = args.extras[1]
11
11
 
12
12
  linter = Jshint::Cli::run(reporter_name, result_file)
13
13
  fail if linter.errors.any? { |_, errors| errors.any? }
@@ -1,4 +1,4 @@
1
1
  module Jshint
2
2
  # Our gem version
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
@@ -4,7 +4,7 @@ require 'jshint'
4
4
  describe Jshint do
5
5
  describe ".class methods" do
6
6
  it "should return the root path of the gem" do
7
- described_class.root.should == File.expand_path('../..', __FILE__)
7
+ expect(described_class.root).to eq(File.expand_path('../..', __FILE__))
8
8
  end
9
9
  end
10
10
  end
@@ -6,47 +6,51 @@ describe Jshint::Configuration do
6
6
 
7
7
  describe "core behaviour" do
8
8
  before do
9
- described_class.any_instance.stub(:default_config_path).and_return('/foo/bar.yml')
10
- described_class.any_instance.stub(:parse_yaml_config).and_return(YAML.load_file(config))
9
+ allow_any_instance_of(described_class).
10
+ to receive(:default_config_path).and_return('/foo/bar.yml')
11
+ allow_any_instance_of(described_class).
12
+ to receive(:parse_yaml_config).and_return(YAML.load_file(config))
11
13
  end
12
14
 
13
15
  it "should allow the developer to index in to config options" do
14
16
  config = described_class.new
15
- config[:boss].should be_true
16
- config[:browser].should be_true
17
+ expect(config[:boss]).to be_truthy
18
+ expect(config[:browser]).to be_truthy
17
19
  end
18
20
 
19
21
  it "should return a Hash of the global variables declared" do
20
22
  config = described_class.new
21
- config.global_variables.should == { "jQuery" => true, "$" => true }
23
+ expect(config.global_variables).to eq({ "jQuery" => true, "$" => true })
22
24
  end
23
25
 
24
26
  it "should return a Hash of the lint options declared" do
25
27
  config = described_class.new
26
- config.lint_options.should == config.options["options"].reject { |key| key == "globals" }
28
+ expect(config.lint_options).
29
+ to eq(config.options["options"].reject { |key| key == "globals" })
27
30
  end
28
31
 
29
32
  it "should return an array of files" do
30
33
  config = described_class.new
31
- config.files.should == ["**/*.js"]
34
+ expect(config.files).to eq(["**/*.js"])
32
35
  end
33
36
 
34
37
  context "search paths" do
35
38
  subject { described_class.new }
36
39
 
37
40
  it "should default the exclusion paths to an empty array" do
38
- subject.excluded_search_paths.should == []
41
+ expect(subject.excluded_search_paths).to eq([])
39
42
  end
40
43
 
41
44
  it "should set the exclusion paths to those in the config" do
42
45
  subject.options["exclude_paths"] << 'vendor/assets/javascripts'
43
- subject.excluded_search_paths.should == ["vendor/assets/javascripts"]
46
+ expect(subject.excluded_search_paths).to eq(["vendor/assets/javascripts"])
44
47
  end
45
48
 
46
49
  it "should be the default search paths minus the exclude paths" do
47
- subject.search_paths.should == subject.default_search_paths
50
+ expect(subject.search_paths).to eq(subject.default_search_paths)
48
51
  subject.options["exclude_paths"] << 'vendor/assets/javascripts'
49
- subject.search_paths.should == ['app/assets/javascripts', 'lib/assets/javascripts']
52
+ expect(subject.search_paths).
53
+ to eq(['app/assets/javascripts', 'lib/assets/javascripts'])
50
54
  end
51
55
  end
52
56
  end
@@ -9,72 +9,74 @@ describe Jshint::Lint do
9
9
  let(:globals) { MultiJson.dump({ :jquery => true, :app => true }) }
10
10
 
11
11
  subject do
12
- Jshint::Configuration.stub(:new).and_return(configuration)
12
+ allow(Jshint::Configuration).to receive(:new).and_return(configuration)
13
13
  described_class.new
14
14
  end
15
15
 
16
16
  it "should initialize errors to an empty Hash" do
17
- subject.errors.should be_a Hash
17
+ expect(subject.errors).to be_a Hash
18
18
  end
19
19
 
20
20
  it "should assing the Configration object to config" do
21
- subject.config.should == configuration
21
+ expect(subject.config).to eq(configuration)
22
22
  end
23
23
 
24
24
  it "should respond to get_json" do
25
25
  hash = { :hello => 'world' }
26
- MultiJson.should_receive(:dump).with(hash)
26
+ expect(MultiJson).to receive(:dump).with(hash)
27
27
  subject.get_json(hash)
28
28
  end
29
29
 
30
- describe :lint do
30
+ describe "lint" do
31
31
  before do
32
- subject.stub(:javascript_files).and_return(files)
33
- subject.stub(:jshint_options).and_return(opts)
34
- subject.stub(:jshint_globals).and_return(globals)
32
+ allow(subject).to receive(:javascript_files).and_return(files)
33
+ allow(subject).to receive(:jshint_options).and_return(opts)
34
+ allow(subject).to receive(:jshint_globals).and_return(globals)
35
35
  end
36
36
 
37
37
  context "invalid file" do
38
38
  before do
39
- subject.stub(:get_file_content_as_json).and_return(subject.get_json(<<-eos
40
- var foo = "bar",
41
- baz = "qux",
42
- bat;
39
+ allow(subject).to receive(:get_file_content_as_json).
40
+ and_return(subject.get_json(<<-eos
41
+ var foo = "bar",
42
+ baz = "qux",
43
+ bat;
43
44
 
44
- if (foo == baz) bat = "gorge" // no semicolon and single line
45
- eos
46
- ))
45
+ if (foo == baz) bat = "gorge" // no semicolon and single line
46
+ eos
47
+ ))
47
48
  subject.lint
48
49
  end
49
50
 
50
51
  it "should add two error messages to the errors Hash" do
51
- subject.errors[file].length.should == 2
52
+ expect(subject.errors[file].length).to eq(2)
52
53
  end
53
54
  end
54
55
 
55
56
  context "valid file" do
56
57
  before do
57
- subject.stub(:get_file_content_as_json).and_return(subject.get_json(<<-eos
58
- var foo = "bar",
59
- baz = "qux",
60
- bat;
58
+ allow(subject).to receive(:get_file_content_as_json).
59
+ and_return(subject.get_json(<<-eos
60
+ var foo = "bar",
61
+ baz = "qux",
62
+ bat;
61
63
 
62
- if (foo == baz) {
63
- bat = "gorge";
64
- var x = "foo"; // jshint ignore:line
65
- }
66
- eos
67
- ))
64
+ if (foo == baz) {
65
+ bat = "gorge";
66
+ var x = "foo"; // jshint ignore:line
67
+ }
68
+ eos
69
+ ))
68
70
  subject.lint
69
71
  end
70
72
 
71
73
  it "should retrieve the files content" do
72
- subject.should_receive(:get_file_content_as_json).with(file)
74
+ expect(subject).to receive(:get_file_content_as_json).with(file)
73
75
  subject.lint
74
76
  end
75
77
 
76
78
  it "should add two error messages to the errors Hash" do
77
- subject.errors[file].length.should == 0
79
+ expect(subject.errors[file].length).to eq(0)
78
80
  end
79
81
  end
80
82
  end
@@ -46,67 +46,67 @@ describe Jshint::Reporters::Default do
46
46
  subject { described_class.new(results) }
47
47
 
48
48
  it "should initialize output to be an empty string" do
49
- subject.output.should == ''
49
+ expect(subject.output).to eq('')
50
50
  end
51
51
 
52
- describe :print_footer do
52
+ describe "print_footer" do
53
53
  it "should output a footer starting with a new line feed" do
54
- subject.print_footer(3).start_with?("\n").should be_true
54
+ expect(subject.print_footer(3)).to start_with("\n")
55
55
  end
56
56
 
57
57
  it "should output a footer containing '3 errors'" do
58
- subject.print_footer(3).should include "3 errors"
58
+ expect(subject.print_footer(3)).to include("3 errors")
59
59
  end
60
60
 
61
61
  it "should output a footer containing '1 error'" do
62
- subject.print_footer(1).should include "1 error"
62
+ expect(subject.print_footer(1)).to include("1 error")
63
63
  end
64
64
  end
65
65
 
66
- describe :print_errors_for_file do
66
+ describe "print_errors_for_file" do
67
67
  before do
68
68
  subject.print_errors_for_file("app/assets/javascripts/angular/controllers/feeds_controller.js", results["app/assets/javascripts/angular/controllers/feeds_controller.js"])
69
69
  end
70
70
 
71
71
  it "should add 3 entries in to the error output" do
72
- subject.output.split(/\r?\n/).length.should == 3
72
+ expect(subject.output.split(/\r?\n/).length).to eq(3)
73
73
  end
74
74
 
75
75
  it "should contain the line number in to the error output" do
76
- subject.output.should include "line 1"
76
+ expect(subject.output).to include("line 1")
77
77
  end
78
78
 
79
79
  it "should contain the column number in to the error output" do
80
- subject.output.should include "col 1"
80
+ expect(subject.output).to include("col 1")
81
81
  end
82
82
 
83
83
  it "should contain the filename in to the error output" do
84
- subject.output.should include "app/assets/javascripts/angular/controllers/feeds_controller.js"
84
+ expect(subject.output).to include("app/assets/javascripts/angular/controllers/feeds_controller.js")
85
85
  end
86
86
 
87
87
  it "should contain the nature of the error in to the error output" do
88
- subject.output.should include "'app' is not defined"
88
+ expect(subject.output).to include("'app' is not defined")
89
89
  end
90
90
  end
91
91
 
92
- describe :report do
92
+ describe "report" do
93
93
  it "should call print errors for file 1 time" do
94
- subject.should_receive(:print_errors_for_file)
94
+ expect(subject).to receive(:print_errors_for_file)
95
95
  subject.report
96
96
  end
97
97
 
98
98
  it "should print the report footer" do
99
- subject.should_receive(:print_footer).with(3)
99
+ expect(subject).to receive(:print_footer).with(3)
100
100
  subject.report
101
101
  end
102
102
 
103
103
  it "should return a thorough report" do
104
- subject.report.length.should >= 10
104
+ expect(subject.report.length).to be >= 10
105
105
  end
106
106
 
107
107
  it "should return 0 errors when it has no results" do
108
108
  subject.instance_variable_set(:@results, {})
109
- subject.report.should include "0 errors"
109
+ expect(subject.report).to include "0 errors"
110
110
  end
111
111
  end
112
112
  end
@@ -2,7 +2,6 @@ require 'coveralls'
2
2
  Coveralls.wear!
3
3
 
4
4
  RSpec.configure do |config|
5
- config.treat_symbols_as_metadata_keys_with_true_values = true
6
5
  config.run_all_when_everything_filtered = true
7
6
  config.filter_run :focus
8
7
 
@@ -11,4 +10,9 @@ RSpec.configure do |config|
11
10
  # the seed, which is printed after each run.
12
11
  # --seed 1234
13
12
  config.order = 'random'
13
+
14
+ # Require the RSpec 3 "expect()" syntax
15
+ config.expect_with :rspec do |c|
16
+ c.syntax = :expect
17
+ end
14
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jshint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: '2.14'
117
+ version: 3.1.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: '2.14'
125
+ version: 3.1.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: yard
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -191,7 +191,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  segments:
193
193
  - 0
194
- hash: 326365264524046677
194
+ hash: 3701102366372032400
195
195
  required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  none: false
197
197
  requirements:
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  segments:
202
202
  - 0
203
- hash: 326365264524046677
203
+ hash: 3701102366372032400
204
204
  requirements: []
205
205
  rubyforge_project:
206
206
  rubygems_version: 1.8.23