spec/overapp_spec.rb in overapp-0.2.0 vs spec/overapp_spec.rb in overapp-0.3.0
- old
+ new
@@ -55,16 +55,18 @@
f = combined.files.find { |x| x.path == ".abc" }
f.body.should == 'stuff'
end
end
-describe "combine - append" do
+
+
+describe "combine - append format2" do
include_context "setup"
base_file "a.txt","stuff"
base_file "b.txt","here"
- on_top_file "b.txt","FSTMODE:append\nother"
+ on_top_file "b.txt","<overapp>append</overapp>\nother"
it 'combined size' do
combined.size.should == 2
end
@@ -72,75 +74,87 @@
f = combined.files.find { |x| x.path == "b.txt" }
f.body.should == "here\nother"
end
end
-describe "combine - append format2" do
+describe "combine - insert after" do
include_context "setup"
base_file "a.txt","stuff"
- base_file "b.txt","here"
- on_top_file "b.txt","<overapp>append</overapp>\nother"
+ base_file "b.txt","123\n456\n789"
+ on_top_file "b.txt","<overapp>action: insert\nafter: 456</overapp>\nabc"
it 'combined size' do
combined.size.should == 2
end
it 'combined file should overwrite' do
f = combined.files.find { |x| x.path == "b.txt" }
- f.body.should == "here\nother"
+ f.body.should == "123\n456\nabc\n789"
end
end
-describe "combine - insert" do
+describe "combine - insert after with colon" do
include_context "setup"
base_file "a.txt","stuff"
- base_file "b.txt","a\nb\nc\nd"
- on_top_file "b.txt","FSTMODE:insert:line:2\nother\n"
+ base_file "b.txt","123\n45: 6\n789"
+ on_top_file "b.txt","<overapp>action: insert\nafter: 45: 6</overapp>\nabc"
it 'combined size' do
combined.size.should == 2
end
it 'combined file should overwrite' do
f = combined.files.find { |x| x.path == "b.txt" }
- f.body.should == "a\nother\nb\nc\nd"
+ f.body.should == "123\n45: 6\nabc\n789"
end
end
-describe "combine - insert after" do
+describe "combine - insert before" do
include_context "setup"
base_file "a.txt","stuff"
base_file "b.txt","123\n456\n789"
- on_top_file "b.txt","<overapp>action: insert\nafter: 456</overapp>\nabc"
+ on_top_file "b.txt","<overapp>action: insert\nbefore: 456</overapp>abc\n"
it 'combined size' do
combined.size.should == 2
end
it 'combined file should overwrite' do
f = combined.files.find { |x| x.path == "b.txt" }
- f.body.should == "123\n456\nabc\n789"
+ f.body.should == "123\nabc\n456\n789"
end
end
-describe "combine - insert before" do
+describe "combine - delete" do
include_context "setup"
base_file "a.txt","stuff"
base_file "b.txt","123\n456\n789"
- on_top_file "b.txt","<overapp>action: insert\nbefore: 456</overapp>abc\n"
+ on_top_file "b.txt","<overapp>action: delete\n</overapp>abc\n"
it 'combined size' do
+ combined.size.should == 1
+ end
+end
+
+describe "combine - multiple directives" do
+ include_context "setup"
+
+ base_file "a.txt","stuff"
+ base_file "b.txt","123\n456\n789"
+ on_top_file "b.txt","<overapp>action: replace\nbase: 123\n</overapp>abc<overapp>action: replace\nbase: 456\n</overapp>def"
+
+ it 'combined size' do
combined.size.should == 2
end
it 'combined file should overwrite' do
f = combined.files.find { |x| x.path == "b.txt" }
- f.body.should == "123\nabc\n456\n789"
+ f.body.should == "abc\ndef\n789"
end
end
describe "combine - replace" do
include_context "setup"
@@ -169,15 +183,15 @@
it 'combined size' do
combined.size.should == 2
end
end
-describe "combine - error" do
+describe "combine - insert to nothing" do
include_context "setup"
- base_file "a.txt","stuff"
- on_top_file "a.txt","FSTMODE:fgdfgdfg\nstuff"
+ on_top_file "b.txt","<overapp>action: insert\nafter: 456</overapp>abc"
- it 'combined size' do
+ it 'errors' do
lambda { combined.size }.should raise_error
end
end
+