~ubuntu-branches/ubuntu/vivid/foodcritic/vivid-proposed

« back to all changes in this revision

Viewing changes to spec/foodcritic/domain_spec.rb

  • Committer: Package Import Robot
  • Author(s): Stefano Rivera
  • Date: 2014-01-16 14:49:30 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140116144930-0mgwfhgnqtohnud7
Tags: 3.0.3-1
* New upstream release.
* Refresh patches.
* Drop rak-free patch, superseded upstream.
* Drop gherkin-2.11.1 patch, and bump gherkin dependency to 2.11.7.
* Switch to stable tarballs from gemwatch.
* Update copyright years.
* FC010 is currently broken due to changes in Chef. Ignore the test failures.
* Ruby 1.8 is no longer supported in Debian, so declare XS-Ruby-Versions:
  all.
* Bump Standards-Version to 3.9.5, no changes needed.
* The manpage is now included upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
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', [])
6
6
  end
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']
10
10
    end
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']
13
13
    end
14
14
  end
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
18
18
    end
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]
 
22
    end
 
23
  end
 
24
end
 
25
 
 
26
describe FoodCritic::Rule do
 
27
  let(:rule) { FoodCritic::Rule.new('FCTEST001', 'Test rule') }
 
28
 
 
29
  describe '#matches_tags?' do
 
30
    it "matches the rule's code" do
 
31
      rule.matches_tags?(['FCTEST001']).must_equal true
 
32
    end
 
33
 
 
34
    it "doesn't match an unrelated code" do
 
35
      rule.matches_tags?(['FCTEST999']).must_equal false
 
36
    end
 
37
  end
 
38
 
 
39
  describe '#tags' do
 
40
    it "returns any + the rule's code" do
 
41
      rule.tags.must_equal ['any', 'FCTEST001']
 
42
    end
 
43
  end
 
44
end
 
45
 
 
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} }
 
49
 
 
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
 
53
    end
 
54
 
 
55
    it 'is true if fail_tags do match' do
 
56
      FoodCritic::Warning.new(rule, match_opts, {:fail_tags => ['any']}).failed?.must_equal true
22
57
    end
23
58
  end
24
59
end