spec/file_spec.rb in templater-0.1.3 vs spec/file_spec.rb in templater-0.1.4
- old
+ new
@@ -1,69 +1,69 @@
require File.dirname(__FILE__) + '/spec_helper'
-describe Templater::File, '.new' do
+describe Templater::Actions::File, '.new' do
it "should set name, source and destination" do
- file = Templater::File.new(:monkey, '/path/to/source', '/path/to/destination')
+ file = Templater::Actions::File.new(:monkey, '/path/to/source', '/path/to/destination')
file.name.should == :monkey
file.source.should == '/path/to/source'
file.destination.should == '/path/to/destination'
end
end
-describe Templater::File, '#relative_destination' do
+describe Templater::Actions::File, '#relative_destination' do
it "should get the destination relative to the pwd" do
Dir.stub!(:pwd).and_return('/path/to')
- file = Templater::File.new(:monkey, '/path/to/source', '/path/to/destination/with/some/more/subdirs')
+ file = Templater::Actions::File.new(:monkey, '/path/to/source', '/path/to/destination/with/some/more/subdirs')
file.relative_destination.should == 'destination/with/some/more/subdirs'
end
end
-describe Templater::File, '#render' do
+describe Templater::Actions::File, '#render' do
it "should output the file" do
- file = Templater::File.new(:monkey, template_path('simple_erb.rbt'), '/path/to/destination')
+ file = Templater::Actions::File.new(:monkey, template_path('simple_erb.rbt'), '/path/to/destination')
file.render.should == "test<%= 1+1 %>test"
end
end
-describe Templater::File, '#exists?' do
+describe Templater::Actions::File, '#exists?' do
it "should exist if the destination file exists" do
- file = Templater::File.new(:monkey, template_path('simple.rbt'), result_path('erb.rbs'))
+ file = Templater::Actions::File.new(:monkey, template_path('simple.rbt'), result_path('erb.rbs'))
file.should be_exists
end
it "should not exist if the destination file does not exist" do
- file = Templater::File.new(:monkey, template_path('simple.rbt'), result_path('some_weird_file.rbs'))
+ file = Templater::Actions::File.new(:monkey, template_path('simple.rbt'), result_path('some_weird_file.rbs'))
file.should_not be_exists
end
end
-describe Templater::File, '#identical' do
+describe Templater::Actions::File, '#identical' do
it "should not be identical if the destination file doesn't exist" do
- file = Templater::File.new(:monkey, template_path('simple_erb.rbt'), result_path('some_weird_file.rbs'))
+ file = Templater::Actions::File.new(:monkey, template_path('simple_erb.rbt'), result_path('some_weird_file.rbs'))
file.should_not be_identical
end
it "should not be identical if the destination file is not identical to the source file" do
- file = Templater::File.new(:monkey, template_path('simple_erb.rbt'), result_path('simple_erb.rbs'))
+ file = Templater::Actions::File.new(:monkey, template_path('simple_erb.rbt'), result_path('simple_erb.rbs'))
file.should be_exists
file.should_not be_identical
end
it "should be identical if the destination file is identical to the source file" do
- file= Templater::File.new(:monkey, template_path('simple_erb.rbt'), result_path('file.rbs'))
+ file= Templater::Actions::File.new(:monkey, template_path('simple_erb.rbt'), result_path('file.rbs'))
file.should be_exists
file.should be_identical
end
end
-describe Templater::File, '#invoke!' do
+describe Templater::Actions::File, '#invoke!' do
it "should copy the source file to the destination" do
- file = Templater::File.new(:monkey, template_path('simple_erb.rbt'), result_path('path/to/subdir/test2.rbs'))
+ file = Templater::Actions::File.new(:monkey, template_path('simple_erb.rbt'), result_path('path/to/subdir/test2.rbs'))
file.invoke!
File.exists?(result_path('path/to/subdir/test2.rbs')).should be_true
FileUtils.identical?(template_path('simple_erb.rbt'), result_path('path/to/subdir/test2.rbs')).should be_true
@@ -71,13 +71,13 @@
# cleanup
FileUtils.rm_rf(result_path('path'))
end
end
-describe Templater::File, '#revoke!' do
+describe Templater::Actions::File, '#revoke!' do
it "should remove the destination file" do
- file = Templater::File.new(:monkey, template_path('simple_erb.rbt'), result_path('path/to/subdir/test2.rbs'))
+ file = Templater::Actions::File.new(:monkey, template_path('simple_erb.rbt'), result_path('path/to/subdir/test2.rbs'))
file.invoke!
File.exists?(result_path('path/to/subdir/test2.rbs')).should be_true
FileUtils.identical?(template_path('simple_erb.rbt'), result_path('path/to/subdir/test2.rbs')).should be_true