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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
|
require 'spec_helper'
describe user("itamae") do
it { should exist }
it { should have_uid 1234 }
it { should have_home_directory '/home/itamae' }
it { should have_login_shell '/bin/dash' }
end
describe file('/tmp/included_recipe') do
it { should be_file }
end
describe package('jq') do
it { should be_installed }
end
describe package('sl') do
it { should be_installed }
end
describe package('resolvconf') do
it { should_not be_installed }
end
%w!/tmp/remote_file /tmp/remote_file_auto!.each do |f|
describe file(f) do
it { should be_file }
its(:content) { should match(/Hello Itamae/) }
end
end
describe file('/tmp/directory') do
it { should be_directory }
it { should be_mode 700 }
it { should be_owned_by "itamae" }
it { should be_grouped_into "itamae" }
end
describe file('/tmp/directory_never_exist1') do
it { should_not be_directory }
end
%w!/tmp/template /tmp/template_auto!.each do |f|
describe file(f) do
it { should be_file }
its(:content) { should match(/Hello/) }
its(:content) { should match(/Good bye/) }
its(:content) { should match(/^total memory: \d+kB$/) }
its(:content) { should match(/^uninitialized node key: $/) }
end
end
describe file('/tmp/file') do
it { should be_file }
its(:content) { should match(/Hello World/) }
it { should be_mode 777 }
end
describe file('/tmp/file_with_suid') do
it { should be_file }
it { should be_mode 4755 }
it { should be_owned_by "itamae" }
it { should be_grouped_into "itamae" }
end
describe file('/tmp/execute') do
it { should be_file }
its(:content) { should match(/Hello Execute/) }
end
describe file('/tmp/never_exist1') do
it { should_not be_file }
end
describe file('/tmp/never_exist2') do
it { should_not be_file }
end
describe file('/tmp/http_request.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
it { should be_file }
its(:content) { should match(/"from":\s*"itamae"/) }
end
describe file('/tmp/http_request_delete.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
it { should be_file }
its(:content) { should match(/"from":\s*"itamae"/) }
end
describe file('/tmp/http_request_post.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
it { should be_file }
its(:content) { should match(/"from":\s*"itamae"/) }
its(:content) { should match(/"love":\s*"sushi"/) }
end
describe file('/tmp/http_request_put.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
it { should be_file }
its(:content) { should match(/"from":\s*"itamae"/) }
its(:content) { should match(/"love":\s*"sushi"/) }
end
describe file('/tmp/http_request_headers.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
it { should be_file }
its(:content) { should match(/"User-Agent":\s*"Itamae"/) }
end
xdescribe file('/tmp/http_request_redirect.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
it { should be_file }
its(:content) { should match(/"from":\s*"itamae"/) }
end
describe file('/tmp/notifies') do
it { should be_file }
its(:content) { should eq("2431") }
end
describe file('/tmp/subscribes') do
it { should be_file }
its(:content) { should eq("2431") }
end
describe file('/tmp-link') do
it { should be_linked_to '/tmp' }
its(:content) do
expect(subject.content.lines.size).to eq 0
end
end
describe file('/tmp-link-force') do
it { should be_linked_to '/tmp' }
end
describe file('/tmp/link-force-no-dereference') do
it { should be_linked_to 'link-force-no-dereference2' }
end
describe file('/tmp/link-force-no-dereference/link-force-no-dereference2') do
it { should_not exist }
end
describe command('cd /tmp/git_repo && git rev-parse HEAD') do
its(:stdout) { should match(/3116e170b89dc0f7315b69c1c1e1fd7fab23ac0d/) }
end
describe command('cd /tmp/git_repo_submodule/empty_repo && cat README.md') do
its(:stdout) { should match(/Empty Repo/) }
end
describe command('cd /tmp/git_repo_depth_1 && git rev-list --count HEAD') do
its(:stdout) { should eq "1\n" }
end
describe file('/tmp/created_by_itamae_user') do
it { should be_file }
it { should be_owned_by 'itamae' }
its(:content) { should eq("/home/itamae\n/home/itamae") }
end
describe file('/tmp/created_in_default2') do
it { should be_file }
end
describe file('/tmp/never_exist3') do
it { should_not be_file }
end
describe file('/tmp/never_exist4') do
it { should_not be_file }
end
describe file('/tmp/created_in_redefine') do
it { should be_file }
its(:content) { should match(/first/) }
end
describe command('gem list') do
its(:stdout) { should include('tzinfo (1.2.2, 1.1.0)') }
end
describe command('gem list') do
its(:stdout) { should match(/^rake \(.*11.1.0.*\)/) }
end
describe command('gem list') do
its(:stdout) { should_not include('test-unit') }
end
describe command('gem list') do
its(:stdout) { should include('ast (2.0.0)') }
end
describe command('ri AST') do
its(:stderr) { should eq("Nothing known about AST\n") }
end
describe file('/tmp/created_by_definition') do
it { should be_file }
its(:content) { should eq("name:name,key:value,message:Hello, Itamae\n") }
end
describe file('/tmp/remote_file_in_definition') do
it { should be_file }
its(:content) { should eq("definition_example\n") }
end
describe file('/tmp/created_by_definition_2_created') do
it { should be_file }
its(:content) { should eq("name:created,key:value2,message:Hello, Itamae\n") }
end
describe file('/tmp/remote_file_in_definition_2_created') do
it { should be_file }
its(:content) { should eq("definition_example_2\n") }
end
describe file('/tmp/created_by_definition_2_not_created') do
it { should_not exist }
end
describe file('/tmp/remote_file_in_definition_2_not_created') do
it { should_not exist }
end
describe file('/tmp/created_by_definition_3_created') do
it { should be_file }
its(:content) { should eq("name:created,key:value3,message:Hello, Itamae\n") }
end
describe file('/tmp/remote_file_in_definition_3_created') do
it { should be_file }
its(:content) { should eq("definition_example_3\n") }
end
describe file('/tmp/created_by_definition_3_not_created') do
it { should_not exist }
end
describe file('/tmp/remote_file_in_definition_3_not_created') do
it { should_not exist }
end
describe file('/tmp/multi_delayed_notifies') do
it { should be_file }
its(:content) { should eq("1\n2\n3\n4\n") }
end
describe file('/tmp/multi_immediately_notifies') do
it { should be_file }
its(:content) { should eq("1\n2\n3\n4\n") }
end
describe file('/tmp/file_edit_sample') do
it { should be_file }
its(:content) { should eq("Hello, Itamae") }
it { should be_mode 400 }
it { should be_owned_by "itamae2" }
it { should be_grouped_into "itamae2" }
end
describe file('/tmp/file_edit_with_suid') do
it { should be_file }
it { should be_mode 4755 }
it { should be_owned_by "itamae2" }
it { should be_grouped_into "itamae2" }
end
describe file('/tmp/file_edit_keeping_mode_owner') do
it { should be_file }
its(:content) { should eq("Hello, Itamae") }
it { should be_mode 444 }
it { should be_owned_by "itamae" }
it { should be_grouped_into "itamae" }
end
describe file('/tmp/file_edit_with_content_change_updates_timestamp') do
its(:mtime) { should be > DateTime.iso8601("2016-05-02T01:23:45Z") }
its(:content) { should eq "Hello, Itamae\n" }
end
describe file('/tmp/file_edit_without_content_change_keeping_timestamp') do
its(:mtime) { should eq(DateTime.iso8601("2016-05-02T12:34:56Z")) }
its(:content) { should eq "" }
end
describe file('/home/itamae2') do
it { should be_directory }
it { should be_owned_by "itamae2" }
it { should be_grouped_into "itamae2" }
end
describe file('/tmp/file_create_without_content') do
its(:content) { should eq("Hello, World") }
it { should be_mode 600 }
it { should be_owned_by "itamae" }
it { should be_grouped_into "itamae" }
end
describe file('/tmp/file_edit_notifies') do
its(:content) { should eq("1") }
end
describe file('/tmp/file_without_content_change_updates_mode_and_owner') do
its(:content) { should eq("Hello, world") }
it { should be_mode 666 }
it { should be_owned_by "itamae2" }
it { should be_grouped_into "itamae2" }
end
describe file('/tmp/file_with_content_change_updates_timestamp') do
its(:mtime) { should be > DateTime.iso8601("2016-05-01T01:23:45Z") }
its(:content) { should eq "Hello, world" }
end
describe file('/tmp/file_without_content_change_keeping_timestamp') do
its(:mtime) { should eq(DateTime.iso8601("2016-05-01T12:34:56Z")) }
its(:content) { should eq "Hello, world\n" }
end
describe file('/tmp/subscribed_from_parent') do
it { should be_file }
end
describe file('/tmp/empty_file1') do
it { should exist }
it { should be_file }
its(:content) { should eq "" }
end
describe file('/tmp/empty_file2') do
it { should exist }
it { should be_file }
its(:content) { should eq "" }
end
describe file('/tmp/empty_file3') do
it { should exist }
it { should be_file }
its(:content) { should eq "" }
end
describe file('/tmp/toplevel_module') do
it { should exist }
it { should be_file }
its(:content) { should eq "helper" }
end
describe file('/tmp/local_variables') do
it { should exist }
it { should be_file }
its(:content) { should eq "[]" }
end
describe file('/tmp/instance_variables') do
it { should exist }
it { should be_file }
its(:content) { should eq "[:@recipe]" } # backward compatibility
end
|