File: file_spec.rb

package info (click to toggle)
ruby-serverspec 2.42.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 980 kB
  • sloc: ruby: 4,835; makefile: 4
file content (127 lines) | stat: -rw-r--r-- 2,935 bytes parent folder | download | duplicates (5)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
require 'spec_helper'

set :backend, :cmd

set :os, :family => 'windows'

describe file('/some/valid/file') do
  it { should be_file }
end

describe file('/some/valid/folder') do
  it { should be_directory }
end

describe file('/some/file') do
  it { should contain 'search text' }
end

describe file('/some/file') do
  it { should contain /^search text/ }
end

describe file('Gemfile') do
  it { should contain('rspec').from(/^group :test do/).to(/^end/) }
end

describe file('Gemfile') do
  it { should contain('rspec').after(/^group :test do/) }
end

describe file('Gemfile') do
  it { should contain('rspec').before(/end/) }
end

describe file('/some/file') do
  it { should be_readable }
end

describe file('/some/file') do
  it "should raise error if trying to check access by 'owner' or 'group' or 'others'" do
   ['owner', 'group', 'others'].each do |access|
     expect { should be_readable.by(access) }.to raise_error(RuntimeError)
   end
 end
end

describe file('/some/file') do
  it { should be_readable.by('test.identity') }
end

describe file('/some/file') do
  it { should be_readable.by_user('test.identity') }
end

describe file('/some/file') do
  it { should be_writable }
end

describe file('/some/file') do
  it "should raise error if trying to check access by 'owner' or 'group' or 'others'" do
   ['owner', 'group', 'others'].each do |access|
     expect { should be_writable.by(access) }.to raise_error(RuntimeError)
   end
 end
end

describe file('/some/file') do
  it { should be_writable.by('test.identity') }
end

describe file('/some/file') do
  it { should be_writable.by_user('test.identity') }
end

describe file('/some/file') do
  it { should be_executable }
end

describe file('/some/file') do
  it "should raise error if trying to check access by 'owner' or 'group' or 'others'" do
   ['owner', 'group', 'others'].each do |access|
     expect { should be_executable.by(access) }.to raise_error(RuntimeError)
   end
 end
end

describe file('/some/file') do
  it { should be_executable.by('test.identity') }
end

describe file('/some/file') do
  it { should be_executable.by_user('test.identity') }
end

describe file('/some/file') do
  it { should be_version 1 }
end

describe file('/some/test/file') do
  it "should raise error if command is not implemented" do
    {
      :be_socket => [],
      :be_mode => 644,
      :be_grouped_into => 'root',
      :be_linked_to => '/some/other/file',
      :be_mounted => []
    }.each do |method, args|
      expect { should self.send(method, *args) }.to raise_error(NotImplementedError)
    end
  end

  it "should raise error if command is not defined" do
    {
      :match_md5checksum => '35435ea447c19f0ea5ef971837ab9ced',
      :match_sha256checksum => '0c3feee1353a8459f8c7d84885e6bc602ef853751ffdbce3e3b6dfa1d345fc7a'
    }.each do |method, args|
      expect { should self.send(method, *args) }.to raise_error(NoMethodError)
    end
  end
end