sugar-high 0.4.0 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/VERSION +1 -1
  2. data/lib/sugar-high/array.rb +58 -7
  3. data/lib/sugar-high/class_ext.rb +11 -0
  4. data/lib/sugar-high/enumerable.rb +67 -0
  5. data/lib/sugar-high/file.rb +24 -76
  6. data/lib/sugar-high/file_ext.rb +65 -0
  7. data/lib/sugar-high/file_mutate.rb +45 -192
  8. data/lib/sugar-high/file_mutate/append_content.rb +17 -0
  9. data/lib/sugar-high/file_mutate/delete.rb +29 -0
  10. data/lib/sugar-high/file_mutate/insert_content.rb +62 -0
  11. data/lib/sugar-high/file_mutate/mutate.rb +58 -0
  12. data/lib/sugar-high/file_mutate/overwrite_content.rb +17 -0
  13. data/lib/sugar-high/file_mutate/remove_content.rb +33 -0
  14. data/lib/sugar-high/file_mutate/replace_content.rb +45 -0
  15. data/lib/sugar-high/kind_of.rb +8 -43
  16. data/lib/sugar-high/string.rb +5 -0
  17. data/spec/fixtures/application_file.rb +1 -0
  18. data/spec/fixtures/class_file.rb +15 -0
  19. data/spec/fixtures/content_file.txt +1 -0
  20. data/spec/fixtures/file.txt +1 -0
  21. data/spec/fixtures/routes_file.rb +16 -0
  22. data/spec/sugar-high/array_spec.rb +44 -3
  23. data/spec/sugar-high/file/file_dsl_spec.rb +4 -0
  24. data/spec/sugar-high/file_mutate/append_content_spec.rb +60 -0
  25. data/spec/sugar-high/file_mutate/delete_spec.rb +47 -0
  26. data/spec/sugar-high/file_mutate/insert_before_last_spec.rb +56 -0
  27. data/spec/sugar-high/file_mutate/insert_content_spec.rb +111 -0
  28. data/spec/sugar-high/file_mutate/overwrite_content_spec.rb +80 -0
  29. data/spec/sugar-high/file_mutate/remove_content_spec.rb +109 -0
  30. data/spec/sugar-high/file_mutate/replace_content_spec.rb +33 -0
  31. data/spec/sugar-high/{file/file_spec.rb → file_spec.rb} +1 -0
  32. data/sugar-high.gemspec +26 -27
  33. metadata +27 -28
  34. data/spec/sugar-high/file/file_mutate_spec.rb +0 -325
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+ require 'sugar-high/file_mutate'
3
+ File.mutate_ext :all
4
+
5
+ describe "SugarHigh::File" do
6
+ let(:empty_file) { fixture_file 'empty.txt' }
7
+ let(:non_empty_file) { fixture_file 'non-empty.txt'}
8
+ let(:class_file) { fixture_file 'class_file.rb'}
9
+ let(:replace_file) { fixture_file 'file.txt' }
10
+ let(:file_to_delete) { fixture_file 'file_to_delete.txt' }
11
+ let(:routes_file) { fixture_file 'routes_file.rb' }
12
+ let(:app_file) { fixture_file 'application_file.rb' }
13
+
14
+ describe '#replace_content_from' do
15
+ let(:replace_file) { fixture_file 'file.txt' }
16
+
17
+ it "should replace content from existing file - class method" do
18
+ File.overwrite(replace_file) do
19
+ 'Hello You'
20
+ end
21
+ File.replace_content_from replace_file, :where => 'You', :with => 'Me'
22
+ File.read(replace_file).should_not match /You/
23
+ end
24
+
25
+ it 'should remove content from existing file - instance method #replace_content' do
26
+ File.overwrite(replace_file) do
27
+ 'Hello You'
28
+ end
29
+ File.new(replace_file).replace_content :where => 'You', :with => 'Me'
30
+ File.read(replace_file).should_not match /You/
31
+ end
32
+ end
33
+ end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'sugar-high/file'
3
3
  require 'sugar-high/file_mutate'
4
+ File.mutate_ext :all
4
5
 
5
6
  describe "SugarHigh" do
6
7
  describe "File" do
data/sugar-high.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sugar-high}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2011-03-02}
11
+ s.authors = [%q{Kristian Mandrup}]
12
+ s.date = %q{2011-06-01}
13
13
  s.description = %q{More Ruby sugar - inspired by the 'zuker' project}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -28,8 +28,18 @@ Gem::Specification.new do |s|
28
28
  "lib/sugar-high/arguments.rb",
29
29
  "lib/sugar-high/array.rb",
30
30
  "lib/sugar-high/blank.rb",
31
+ "lib/sugar-high/class_ext.rb",
32
+ "lib/sugar-high/enumerable.rb",
31
33
  "lib/sugar-high/file.rb",
34
+ "lib/sugar-high/file_ext.rb",
32
35
  "lib/sugar-high/file_mutate.rb",
36
+ "lib/sugar-high/file_mutate/append_content.rb",
37
+ "lib/sugar-high/file_mutate/delete.rb",
38
+ "lib/sugar-high/file_mutate/insert_content.rb",
39
+ "lib/sugar-high/file_mutate/mutate.rb",
40
+ "lib/sugar-high/file_mutate/overwrite_content.rb",
41
+ "lib/sugar-high/file_mutate/remove_content.rb",
42
+ "lib/sugar-high/file_mutate/replace_content.rb",
33
43
  "lib/sugar-high/hash.rb",
34
44
  "lib/sugar-high/includes.rb",
35
45
  "lib/sugar-high/kind_of.rb",
@@ -46,7 +56,9 @@ Gem::Specification.new do |s|
46
56
  "spec/fixtures/application_file.rb",
47
57
  "spec/fixtures/class_file.rb",
48
58
  "spec/fixtures/class_file.txt",
59
+ "spec/fixtures/content_file.txt",
49
60
  "spec/fixtures/empty.txt",
61
+ "spec/fixtures/file.txt",
50
62
  "spec/fixtures/non-empty.txt",
51
63
  "spec/fixtures/routes_file.rb",
52
64
  "spec/fixtures/search_file.txt",
@@ -55,8 +67,15 @@ Gem::Specification.new do |s|
55
67
  "spec/sugar-high/arguments_spec.rb",
56
68
  "spec/sugar-high/array_spec.rb",
57
69
  "spec/sugar-high/blank_spec.rb",
58
- "spec/sugar-high/file/file_mutate_spec.rb",
59
- "spec/sugar-high/file/file_spec.rb",
70
+ "spec/sugar-high/file/file_dsl_spec.rb",
71
+ "spec/sugar-high/file_mutate/append_content_spec.rb",
72
+ "spec/sugar-high/file_mutate/delete_spec.rb",
73
+ "spec/sugar-high/file_mutate/insert_before_last_spec.rb",
74
+ "spec/sugar-high/file_mutate/insert_content_spec.rb",
75
+ "spec/sugar-high/file_mutate/overwrite_content_spec.rb",
76
+ "spec/sugar-high/file_mutate/remove_content_spec.rb",
77
+ "spec/sugar-high/file_mutate/replace_content_spec.rb",
78
+ "spec/sugar-high/file_spec.rb",
60
79
  "spec/sugar-high/hash_spec.rb",
61
80
  "spec/sugar-high/includes_spec.rb",
62
81
  "spec/sugar-high/kind_of_spec.rb",
@@ -68,29 +87,9 @@ Gem::Specification.new do |s|
68
87
  "sugar-high.gemspec"
69
88
  ]
70
89
  s.homepage = %q{http://github.com/kristianmandrup/sugar-high}
71
- s.require_paths = ["lib"]
72
- s.rubygems_version = %q{1.5.3}
90
+ s.require_paths = [%q{lib}]
91
+ s.rubygems_version = %q{1.8.3}
73
92
  s.summary = %q{Ruby convenience sugar packs!}
74
- s.test_files = [
75
- "spec/fixtures/application_file.rb",
76
- "spec/fixtures/class_file.rb",
77
- "spec/fixtures/routes_file.rb",
78
- "spec/spec_helper.rb",
79
- "spec/sugar-high/alias_spec.rb",
80
- "spec/sugar-high/arguments_spec.rb",
81
- "spec/sugar-high/array_spec.rb",
82
- "spec/sugar-high/blank_spec.rb",
83
- "spec/sugar-high/file/file_mutate_spec.rb",
84
- "spec/sugar-high/file/file_spec.rb",
85
- "spec/sugar-high/hash_spec.rb",
86
- "spec/sugar-high/includes_spec.rb",
87
- "spec/sugar-high/kind_of_spec.rb",
88
- "spec/sugar-high/methods_spec.rb",
89
- "spec/sugar-high/module_spec.rb",
90
- "spec/sugar-high/path_spec.rb",
91
- "spec/sugar-high/regexp_spec.rb",
92
- "spec/sugar-high/string_spec.rb"
93
- ]
94
93
 
95
94
  if s.respond_to? :specification_version then
96
95
  s.specification_version = 3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugar-high
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-03-02 00:00:00.000000000 +01:00
13
- default_executable:
12
+ date: 2011-06-01 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
- requirement: &2164404920 !ruby/object:Gem::Requirement
16
+ requirement: &2154101200 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ! '>='
@@ -22,7 +21,7 @@ dependencies:
22
21
  version: 2.4.1
23
22
  type: :development
24
23
  prerelease: false
25
- version_requirements: *2164404920
24
+ version_requirements: *2154101200
26
25
  description: More Ruby sugar - inspired by the 'zuker' project
27
26
  email: kmandrup@gmail.com
28
27
  executables: []
@@ -42,8 +41,18 @@ files:
42
41
  - lib/sugar-high/arguments.rb
43
42
  - lib/sugar-high/array.rb
44
43
  - lib/sugar-high/blank.rb
44
+ - lib/sugar-high/class_ext.rb
45
+ - lib/sugar-high/enumerable.rb
45
46
  - lib/sugar-high/file.rb
47
+ - lib/sugar-high/file_ext.rb
46
48
  - lib/sugar-high/file_mutate.rb
49
+ - lib/sugar-high/file_mutate/append_content.rb
50
+ - lib/sugar-high/file_mutate/delete.rb
51
+ - lib/sugar-high/file_mutate/insert_content.rb
52
+ - lib/sugar-high/file_mutate/mutate.rb
53
+ - lib/sugar-high/file_mutate/overwrite_content.rb
54
+ - lib/sugar-high/file_mutate/remove_content.rb
55
+ - lib/sugar-high/file_mutate/replace_content.rb
47
56
  - lib/sugar-high/hash.rb
48
57
  - lib/sugar-high/includes.rb
49
58
  - lib/sugar-high/kind_of.rb
@@ -60,7 +69,9 @@ files:
60
69
  - spec/fixtures/application_file.rb
61
70
  - spec/fixtures/class_file.rb
62
71
  - spec/fixtures/class_file.txt
72
+ - spec/fixtures/content_file.txt
63
73
  - spec/fixtures/empty.txt
74
+ - spec/fixtures/file.txt
64
75
  - spec/fixtures/non-empty.txt
65
76
  - spec/fixtures/routes_file.rb
66
77
  - spec/fixtures/search_file.txt
@@ -69,8 +80,15 @@ files:
69
80
  - spec/sugar-high/arguments_spec.rb
70
81
  - spec/sugar-high/array_spec.rb
71
82
  - spec/sugar-high/blank_spec.rb
72
- - spec/sugar-high/file/file_mutate_spec.rb
73
- - spec/sugar-high/file/file_spec.rb
83
+ - spec/sugar-high/file/file_dsl_spec.rb
84
+ - spec/sugar-high/file_mutate/append_content_spec.rb
85
+ - spec/sugar-high/file_mutate/delete_spec.rb
86
+ - spec/sugar-high/file_mutate/insert_before_last_spec.rb
87
+ - spec/sugar-high/file_mutate/insert_content_spec.rb
88
+ - spec/sugar-high/file_mutate/overwrite_content_spec.rb
89
+ - spec/sugar-high/file_mutate/remove_content_spec.rb
90
+ - spec/sugar-high/file_mutate/replace_content_spec.rb
91
+ - spec/sugar-high/file_spec.rb
74
92
  - spec/sugar-high/hash_spec.rb
75
93
  - spec/sugar-high/includes_spec.rb
76
94
  - spec/sugar-high/kind_of_spec.rb
@@ -80,7 +98,6 @@ files:
80
98
  - spec/sugar-high/regexp_spec.rb
81
99
  - spec/sugar-high/string_spec.rb
82
100
  - sugar-high.gemspec
83
- has_rdoc: true
84
101
  homepage: http://github.com/kristianmandrup/sugar-high
85
102
  licenses: []
86
103
  post_install_message:
@@ -101,26 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
118
  version: '0'
102
119
  requirements: []
103
120
  rubyforge_project:
104
- rubygems_version: 1.5.3
121
+ rubygems_version: 1.8.3
105
122
  signing_key:
106
123
  specification_version: 3
107
124
  summary: Ruby convenience sugar packs!
108
- test_files:
109
- - spec/fixtures/application_file.rb
110
- - spec/fixtures/class_file.rb
111
- - spec/fixtures/routes_file.rb
112
- - spec/spec_helper.rb
113
- - spec/sugar-high/alias_spec.rb
114
- - spec/sugar-high/arguments_spec.rb
115
- - spec/sugar-high/array_spec.rb
116
- - spec/sugar-high/blank_spec.rb
117
- - spec/sugar-high/file/file_mutate_spec.rb
118
- - spec/sugar-high/file/file_spec.rb
119
- - spec/sugar-high/hash_spec.rb
120
- - spec/sugar-high/includes_spec.rb
121
- - spec/sugar-high/kind_of_spec.rb
122
- - spec/sugar-high/methods_spec.rb
123
- - spec/sugar-high/module_spec.rb
124
- - spec/sugar-high/path_spec.rb
125
- - spec/sugar-high/regexp_spec.rb
126
- - spec/sugar-high/string_spec.rb
125
+ test_files: []
@@ -1,325 +0,0 @@
1
- require 'spec_helper'
2
- require 'sugar-high/file_mutate'
3
-
4
- describe "SugarHigh::File" do
5
- let(:empty_file) { fixture_file 'empty.txt' }
6
- let(:non_empty_file) { fixture_file 'non-empty.txt'}
7
- let(:class_file) { fixture_file 'class_file.rb'}
8
- let(:replace_file) { fixture_file 'file.txt' }
9
- let(:file_to_delete) { fixture_file 'file_to_delete.txt' }
10
- let(:routes_file) { fixture_file 'routes_file.rb' }
11
- let(:app_file) { fixture_file 'application_file.rb' }
12
-
13
- after do
14
- File.overwrite class_file do
15
- %q{class Abc
16
- def begin
17
- end
18
- end}
19
- end
20
-
21
- File.overwrite app_file do
22
- %q{# Load the rails application
23
- require File.expand_path('../application', __FILE__)
24
-
25
- # Initialize the rails application
26
- Fixtures::Application.initialize!
27
- }
28
- end
29
- end
30
-
31
- before :each do
32
- File.delete replace_file if File.file?(replace_file)
33
- end
34
-
35
- describe '#delete! (class)' do
36
- it 'should delete file' do
37
- File.overwrite(file_to_delete) do
38
- 'Delete this!'
39
- end
40
- File.delete! file_to_delete
41
- File.exist?(file_to_delete).should be_false
42
- end
43
- end
44
-
45
- describe '#delete_file! (class)' do
46
- it 'should delete file' do
47
- File.overwrite(file_to_delete) do
48
- 'Delete this!'
49
- end
50
- File.delete_file! file_to_delete
51
- File.exist?(file_to_delete).should be_false
52
- end
53
- end
54
-
55
- describe '#delete! (instance)' do
56
- it 'should delete file' do
57
- File.overwrite(file_to_delete) do
58
- 'Delete this!'
59
- end
60
- File.new(file_to_delete).delete!
61
- File.exist?(file_to_delete).should be_false
62
- end
63
- end
64
-
65
- describe '#delete_file! (instance)' do
66
- it 'should delete file' do
67
- File.overwrite(file_to_delete) do
68
- 'Delete this!'
69
- end
70
- File.new(file_to_delete).delete_file!
71
- File.exist?(file_to_delete).should be_false
72
- end
73
- end
74
-
75
- describe '#append with :content option' do
76
- let(:append_file) { fixture_file 'file.txt' }
77
-
78
- it 'should append content to existing file - class method' do
79
- File.overwrite(append_file) do
80
- 'Hello You'
81
- end
82
- File.append append_file, :content => 'Appended'
83
- content = File.read(append_file)
84
- content.should match /Hello You/
85
- content.should match /Appended/
86
- end
87
-
88
- it 'should append content to existing file - instance method' do
89
- File.overwrite(append_file) do
90
- 'Hello You'
91
- end
92
- File.new(append_file).append :content => 'Appended'
93
- content = File.read(append_file)
94
- content.should match /Hello You/
95
- content.should match /Appended/
96
- end
97
- end
98
-
99
- describe '#append with block' do
100
- let(:append_file) { fixture_file 'file.txt' }
101
-
102
- it "should append content to existing file using block arg - class method" do
103
- File.overwrite(append_file) do
104
- 'Hello You'
105
- end
106
- File.append append_file do
107
- 'Appended'
108
- end
109
- content = File.read(replace_file)
110
- content.should match /Hello You/
111
- content.should match /Appended/
112
- end
113
-
114
- it "should append content to existing file using block arg - instance method" do
115
- File.overwrite(append_file) do
116
- 'Hello You'
117
- end
118
- File.new(append_file).append do
119
- 'Appended'
120
- end
121
- content = File.read(replace_file)
122
- content.should match /Hello You/
123
- content.should match /Appended/
124
- end
125
- end
126
-
127
-
128
- describe '#replace_content_from' do
129
- let(:replace_file) { fixture_file 'file.txt' }
130
-
131
- it "should replace content from existing file - class method" do
132
- File.overwrite(replace_file) do
133
- 'Hello You'
134
- end
135
- File.replace_content_from replace_file, :where => 'You', :with => 'Me'
136
- File.read(replace_file).should_not match /You/
137
- end
138
-
139
- it 'should remove content from existing file - instance method #replace_content' do
140
- File.overwrite(replace_file) do
141
- 'Hello You'
142
- end
143
- File.new(replace_file).replace_content :where => 'You', :with => 'Me'
144
- File.read(replace_file).should_not match /You/
145
- end
146
- end
147
-
148
- describe '#remove_content_from with :where option' do
149
- let(:replace_file) { fixture_file 'file.txt' }
150
-
151
- it "should remove content from existing file - class method" do
152
- File.overwrite(replace_file) do
153
- 'Hello You'
154
- end
155
- File.remove_content_from replace_file, :where => 'You'
156
- File.read(replace_file).should_not match /You/
157
- end
158
-
159
- it "should remove content from existing file - instance method #remove_content" do
160
- File.overwrite(replace_file) do
161
- 'Hello You'
162
- end
163
- File.new(replace_file).remove_content :where => 'You'
164
- File.read(replace_file).should_not match /You/
165
- end
166
-
167
- end
168
-
169
- describe '#remove_content_from with :content option' do
170
- let(:replace_file) { fixture_file 'file.txt' }
171
-
172
- it "should remove content from existing file - class method" do
173
- File.overwrite(replace_file) do
174
- 'Hello You'
175
- end
176
- File.remove_content_from replace_file, :content => 'You'
177
- File.read(replace_file).should_not match /You/
178
- end
179
-
180
- it "should remove content from existing file - instance method #remove_content" do
181
- File.overwrite(replace_file) do
182
- 'Hello You'
183
- end
184
- File.new(replace_file).remove_content 'You'
185
- File.read(replace_file).should_not match /You/
186
- end
187
- end
188
-
189
- describe '#remove_from with String/Regexp argument that is content to remove' do
190
- let(:replace_file) { fixture_file 'file.txt' }
191
-
192
- it "should remove content from existing file - class method" do
193
- File.overwrite(replace_file) do
194
- 'Hello You'
195
- end
196
- File.remove_from replace_file, 'You'
197
- File.read(replace_file).should_not match /You/
198
- end
199
-
200
- it "should remove content from existing file - instance method #remove" do
201
- File.overwrite(replace_file) do
202
- 'Hello You'
203
- end
204
- File.new(replace_file).remove_content 'You'
205
- File.read(replace_file).should_not match /You/
206
- end
207
- end
208
-
209
- describe '#remove_from with block argument that is content to remove' do
210
- let(:replace_file) { fixture_file 'file.txt' }
211
-
212
- it "should remove content from existing file - class method" do
213
- File.overwrite(replace_file) do
214
- 'Hello You'
215
- end
216
- File.remove_from replace_file do
217
- 'You'
218
- end
219
- File.read(replace_file).should_not match /You/
220
- end
221
-
222
- it "should remove content from existing file - instance method #remove" do
223
- File.overwrite(replace_file) do
224
- 'Hello You'
225
- end
226
- File.new(replace_file).remove do
227
- 'You'
228
- end
229
- File.read(replace_file).should_not match /You/
230
- end
231
- end
232
-
233
-
234
- describe '#insert_into' do
235
- let(:insertion_file) { fixture_file 'insertion.txt' }
236
-
237
- before :each do
238
- File.overwrite(insertion_file) do
239
- 'Goodbye'
240
- end
241
- end
242
-
243
- after :each do
244
- File.delete insertion_file if File.file?(insertion_file)
245
- end
246
-
247
- it "should insert Hello before Goodbye using a block as content" do
248
- File.insert_into insertion_file, :before => 'Goodbye' do
249
- 'Hello'
250
- end
251
- File.read(insertion_file).should match /Hello\s+Goodbye/
252
- end
253
-
254
- it "should insert Hello before Goodbye using a block as content - instance method #insert" do
255
- File.new(insertion_file).insert :before => 'Goodbye' do
256
- 'Hello'
257
- end
258
- File.read(insertion_file).should match /Hello\s+Goodbye/
259
- end
260
-
261
-
262
- it "should insert Hello before Goodbye using a content string arg" do
263
- File.insert_into insertion_file, "Hello ", :before => 'Goodbye'
264
- File.read(insertion_file).should match /Hello\s+Goodbye/
265
- end
266
-
267
- it "should insert Hello before Goodbye using a :content option" do
268
- File.insert_into insertion_file, :content => 'Hello', :before => 'Goodbye'
269
- File.read(insertion_file).should match /Hello\s+Goodbye/
270
- end
271
-
272
- it "should insert Hello before Goodbye using a block as content to insert" do
273
- File.insert_into insertion_file, :before => 'Goodbye' do
274
- 'Hello'
275
- end
276
- File.read(insertion_file).should match /Hello\s+Goodbye/
277
- end
278
-
279
- it "should insert Hello after Goodbye using a :with option and a Regexp for the after expression" do
280
- File.insert_into insertion_file, :content => ' Hello', :after => /Goodbye/
281
- File.read(insertion_file).should match /Goodbye\s+Hello/
282
- end
283
-
284
- it "should insert Hello after Goodbye using a :with option and a Regexp for the after expression" do
285
-
286
- pattern = Regexp.escape('::Application.initialize!')
287
- File.insert_into app_file, :after => /\w+#{pattern}/ do
288
- 'hello'
289
- end
290
- File.read(app_file).should match /hello/
291
- end
292
-
293
- it "should insert Hello before last end statement" do
294
- File.insert_into class_file, :content => ' # Hello', :before_last => 'end'
295
- puts File.read(class_file)
296
- File.read(class_file).should match /end\s+# Hello\s+end/
297
- File.remove_content_from class_file, :content => ' # Hello'
298
- end
299
-
300
- it "should insert Hello before last end statement but don't repeat" do
301
- File.insert_into class_file, :content => ' # Hello', :before_last => 'end', :repeat => true
302
- puts File.read(class_file)
303
- File.read(class_file).should match /end\s+# Hello\s+end/
304
- File.remove_content_from class_file, :content => ' # Hello'
305
- end
306
-
307
- it "should insert Hello before last end statement - block" do
308
- File.insert_into class_file, :before_last => 'end' do
309
- ' # Hello'
310
- end
311
- puts File.read(class_file)
312
- File.read(class_file).should match /end\s+# Hello\s+end/
313
- File.remove_content_from class_file, :content => ' # Hello'
314
- end
315
-
316
- it "should insert devise routes statement as first route statement" do
317
- File.insert_into routes_file, :after => 'routes.draw do' do
318
- 'devise :users'
319
- end
320
- puts File.read(routes_file)
321
- File.read(routes_file).should match /routes.draw\s+do\s+devise :users/
322
- File.remove_content_from routes_file, :content => 'devise :users'
323
- end
324
- end
325
- end