This repository has been archived by the owner on Mar 1, 2019. It is now read-only.
forked from cucumber/aruba
-
Notifications
You must be signed in to change notification settings - Fork 1
/
have_file_size.feature
107 lines (82 loc) · 2.68 KB
/
have_file_size.feature
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
Feature: Check if path has size
If you need to check if a given path has file size, you can use the
`have_file_size`-matcher. It fails if the file does not exist.
```ruby
require 'spec_helper'
RSpec.describe 'Check if file has size', :type => :aruba do
let(:file) { 'file.txt' }
let(:size) { 1 }
before(:each) { write_fixed_size_file(file, size) }
it { expect(file).to have_file_size size }
end
```
Background:
Given I use a fixture named "cli-app"
Scenario: Expect file of given size
Given a file named "spec/file_of_size_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file has size', :type => :aruba do
let(:file) { 'file.txt' }
let(:size) { 1 }
before(:each) { write_fixed_size_file(file, size) }
it { expect(file).to have_file_size size }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect multiple files of given size
Given a file named "spec/file_of_size_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file has size', :type => :aruba do
let(:files) { %w(file1.txt file2.txt) }
let(:size) { 1 }
before :each do
files.each { |f| write_fixed_size_file(f, size) }
end
it { expect(files).to all have_file_size size }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Expect a least one file of size
Given a file named "spec/file_of_size_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file has size', :type => :aruba do
let(:files) { %w(file1.txt file2.txt) }
let(:size) { 1 }
before :each do
write_fixed_size_file(files.first, size)
end
it { expect(files).to include a_file_of_size size }
end
"""
When I run `rspec`
Then the specs should all pass
Scenario: Fails because file has different size than expected
Given a file named "spec/file_of_size_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file has size', :type => :aruba do
let(:file) { 'file.txt' }
let(:size) { 1 }
before(:each) { write_fixed_size_file(file, size) }
it { expect(file).to have_file_size 2 }
end
"""
When I run `rspec`
Then the specs should not all pass
Scenario: Fails if file does not exist
Given a file named "spec/file_of_size_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file has size', :type => :aruba do
let(:file) { 'file.txt' }
let(:size) { 1 }
it { expect(file).to have_file_size size }
end
"""
When I run `rspec`
Then the specs should not all pass