Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #552 from binford2k/dLobatog-code_outside_class_block
Updates PR for #223
- Loading branch information
Showing
4 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
"test" # lint:ignore:double_quoted_strings for a good reason | ||
# test::ignore_reason | ||
class test::ignore_reason { | ||
$foo = "test" # lint:ignore:double_quoted_strings for a good reason | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
spec/puppet-lint/plugins/check_classes/code_on_top_scope_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require 'spec_helper' | ||
|
||
describe 'code_on_top_scope' do | ||
describe 'comments outside class block' do | ||
let(:code) { " | ||
# Baz | ||
class foo:bar { | ||
}" | ||
} | ||
|
||
its(:problems) { should be_empty } | ||
end | ||
|
||
describe 'new lines outside of class-define block' do | ||
let(:code) { " | ||
class foo:bar { | ||
} | ||
" | ||
} | ||
|
||
its(:problems) { should be_empty } | ||
end | ||
describe 'code outside class block' do | ||
let(:code) { " | ||
include('something') | ||
# Baz | ||
class foo:bar { | ||
} | ||
define whatever { | ||
}" | ||
} | ||
|
||
its(:problems) { | ||
should contain_warning("code outside of class or define block - include") | ||
should have(4).problems | ||
} | ||
end | ||
end |