File: unsatisfiable_graph_spec.rb

package info (click to toggle)
ruby-semantic-puppet 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 292 kB
  • sloc: ruby: 2,898; makefile: 6
file content (44 lines) | stat: -rw-r--r-- 1,101 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'spec_helper'
require 'semantic_puppet/dependency/unsatisfiable_graph'

describe SemanticPuppet::Dependency::UnsatisfiableGraph do

  let(:modules) { %w[ foo bar baz ] }
  let(:graph) { double('Graph', :modules => modules) }
  let(:instance) { described_class.new(graph, ['a']) }

  subject { instance }

  describe '#message' do
    subject { instance.message }

    it { should match /#{instance.send(:sentence_from_list, modules)}/ }
  end

  describe '#sentence_from_list' do

    subject { instance.send(:sentence_from_list, modules) }

    context 'with a list of one item' do
      let(:modules) { %w[ foo ] }
      it { should eql 'foo' }
    end

    context 'with a list of two items' do
      let(:modules) { %w[ foo bar ] }
      it { should eql 'foo and bar' }
    end

    context 'with a list of three items' do
      let(:modules) { %w[ foo bar baz ] }
      it { should eql 'foo, bar, and baz' }
    end

    context 'with a list of more than three items' do
      let(:modules) { %w[ foo bar baz quux ] }
      it { should eql 'foo, bar, baz, and quux' }
    end

  end

end