|
23 | 23 | File.open(tmpfile, 'w') do |fh| |
24 | 24 | fh.write('foo') |
25 | 25 | end |
26 | | - provider.exists?.should be_true |
| 26 | + expect(provider.exists?).to be_truthy |
27 | 27 | end |
28 | 28 | it 'should detect if the line does not exist in the file' do |
29 | 29 | File.open(tmpfile, 'w') do |fh| |
30 | 30 | fh.write('foo1') |
31 | 31 | end |
32 | | - provider.exists?.should be_nil |
| 32 | + expect(provider.exists?).to be_nil |
33 | 33 | end |
34 | 34 | it 'should append to an existing file when creating' do |
35 | 35 | provider.create |
36 | | - File.read(tmpfile).chomp.should == 'foo' |
| 36 | + expect(File.read(tmpfile).chomp).to eq('foo') |
37 | 37 | end |
38 | 38 | end |
39 | 39 |
|
|
61 | 61 | File.open(@tmpfile, 'w') do |fh| |
62 | 62 | fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") |
63 | 63 | end |
64 | | - @provider.exists?.should be_nil |
| 64 | + expect(@provider.exists?).to be_nil |
65 | 65 | expect { @provider.create }.to raise_error(Puppet::Error, /More than one line.*matches/) |
66 | | - File.read(@tmpfile).should eql("foo1\nfoo=blah\nfoo2\nfoo=baz") |
| 66 | + expect(File.read(@tmpfile)).to eql("foo1\nfoo=blah\nfoo2\nfoo=baz") |
67 | 67 | end |
68 | 68 |
|
69 | 69 | it 'should replace all lines that matches' do |
|
80 | 80 | File.open(@tmpfile, 'w') do |fh| |
81 | 81 | fh.write("foo1\nfoo=blah\nfoo2\nfoo=baz") |
82 | 82 | end |
83 | | - @provider.exists?.should be_nil |
| 83 | + expect(@provider.exists?).to be_nil |
84 | 84 | @provider.create |
85 | | - File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2\nfoo = bar") |
| 85 | + expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2\nfoo = bar") |
86 | 86 | end |
87 | 87 |
|
88 | 88 | it 'should raise an error with invalid values' do |
|
103 | 103 | File.open(@tmpfile, 'w') do |fh| |
104 | 104 | fh.write("foo1\nfoo=blah\nfoo2") |
105 | 105 | end |
106 | | - @provider.exists?.should be_nil |
| 106 | + expect(@provider.exists?).to be_nil |
107 | 107 | @provider.create |
108 | | - File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2") |
| 108 | + expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") |
109 | 109 | end |
110 | 110 | it 'should add a new line if no lines match' do |
111 | 111 | File.open(@tmpfile, 'w') do |fh| |
112 | 112 | fh.write("foo1\nfoo2") |
113 | 113 | end |
114 | | - @provider.exists?.should be_nil |
| 114 | + expect(@provider.exists?).to be_nil |
115 | 115 | @provider.create |
116 | | - File.read(@tmpfile).should eql("foo1\nfoo2\nfoo = bar\n") |
| 116 | + expect(File.read(@tmpfile)).to eql("foo1\nfoo2\nfoo = bar\n") |
117 | 117 | end |
118 | 118 | it 'should do nothing if the exact line already exists' do |
119 | 119 | File.open(@tmpfile, 'w') do |fh| |
120 | 120 | fh.write("foo1\nfoo = bar\nfoo2") |
121 | 121 | end |
122 | | - @provider.exists?.should be_true |
| 122 | + expect(@provider.exists?).to be_truthy |
123 | 123 | @provider.create |
124 | | - File.read(@tmpfile).chomp.should eql("foo1\nfoo = bar\nfoo2") |
| 124 | + expect(File.read(@tmpfile).chomp).to eql("foo1\nfoo = bar\nfoo2") |
125 | 125 | end |
126 | 126 | end |
127 | 127 |
|
|
150 | 150 |
|
151 | 151 | it 'inserts the specified line after the line matching the "after" expression' do |
152 | 152 | provider.create |
153 | | - File.read(@tmpfile).chomp.should eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz") |
| 153 | + expect(File.read(@tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo = baz") |
154 | 154 | end |
155 | 155 | end |
156 | 156 |
|
|
179 | 179 |
|
180 | 180 | it 'appends the specified line to the file' do |
181 | 181 | provider.create |
182 | | - File.read(@tmpfile).should eq(content << resource[:line] << "\n") |
| 182 | + expect(File.read(@tmpfile)).to eq(content << resource[:line] << "\n") |
183 | 183 | end |
184 | 184 | end |
185 | 185 | end |
|
203 | 203 | fh.write("foo1\nfoo\nfoo2") |
204 | 204 | end |
205 | 205 | @provider.destroy |
206 | | - File.read(@tmpfile).should eql("foo1\nfoo2") |
| 206 | + expect(File.read(@tmpfile)).to eql("foo1\nfoo2") |
207 | 207 | end |
208 | 208 |
|
209 | 209 | it 'should remove the line without touching the last new line' do |
210 | 210 | File.open(@tmpfile, 'w') do |fh| |
211 | 211 | fh.write("foo1\nfoo\nfoo2\n") |
212 | 212 | end |
213 | 213 | @provider.destroy |
214 | | - File.read(@tmpfile).should eql("foo1\nfoo2\n") |
| 214 | + expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n") |
215 | 215 | end |
216 | 216 |
|
217 | 217 | it 'should remove any occurence of the line' do |
218 | 218 | File.open(@tmpfile, 'w') do |fh| |
219 | 219 | fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") |
220 | 220 | end |
221 | 221 | @provider.destroy |
222 | | - File.read(@tmpfile).should eql("foo1\nfoo2\n") |
| 222 | + expect(File.read(@tmpfile)).to eql("foo1\nfoo2\n") |
223 | 223 | end |
224 | 224 | end |
225 | 225 | end |
0 commit comments