3
3
describe FoodCritic::Review do
4
4
it "is instantiable with no warnings" do
5
FoodCritic::Review.new('example', [], false)
5
FoodCritic::Review.new('example', [])
7
7
describe "#cookbook_paths" do
8
8
it "returns the cookbook paths provided" do
9
FoodCritic::Review.new(['example'], [], false).cookbook_paths.must_equal ['example']
9
FoodCritic::Review.new(['example'], []).cookbook_paths.must_equal ['example']
11
11
it "returns the cookbook paths provided when there are multiple" do
12
FoodCritic::Review.new(['example', 'example2'], [], false).cookbook_paths.must_equal ['example', 'example2']
12
FoodCritic::Review.new(['example', 'example2'], []).cookbook_paths.must_equal ['example', 'example2']
15
15
describe "#warnings" do
16
16
it "returns empty when there are no warnings" do
17
FoodCritic::Review.new('example', [], false).warnings.must_be_empty
17
FoodCritic::Review.new('example', []).warnings.must_be_empty
19
19
it "makes the warnings available" do
20
20
warning = 'Danger Will Robinson'
21
FoodCritic::Review.new('example', [warning], false).warnings.must_equal [warning]
21
FoodCritic::Review.new('example', [warning]).warnings.must_equal [warning]
26
describe FoodCritic::Rule do
27
let(:rule) { FoodCritic::Rule.new('FCTEST001', 'Test rule') }
29
describe '#matches_tags?' do
30
it "matches the rule's code" do
31
rule.matches_tags?(['FCTEST001']).must_equal true
34
it "doesn't match an unrelated code" do
35
rule.matches_tags?(['FCTEST999']).must_equal false
40
it "returns any + the rule's code" do
41
rule.tags.must_equal ['any', 'FCTEST001']
46
describe FoodCritic::Warning do
47
let(:rule) { FoodCritic::Rule.new('FCTEST001', 'Test rule') }
48
let(:match_opts) { {:filename => 'foo/recipes.default.rb', :line => 5, :column=> 40} }
50
describe "failure indication" do
51
it 'is false if no fail_tags match' do
52
FoodCritic::Warning.new(rule, match_opts, {:fail_tags => []}).failed?.must_equal false
55
it 'is true if fail_tags do match' do
56
FoodCritic::Warning.new(rule, match_opts, {:fail_tags => ['any']}).failed?.must_equal true