tested file writer

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@26 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
mvandervoord
2008-10-05 19:11:10 +00:00
parent 303586e5b1
commit d58c6e408d
2 changed files with 38 additions and 0 deletions
+1
View File
@@ -2,6 +2,7 @@
class CMockFileWriter
require 'ftools'
attr_reader :config
def initialize(config)
@config = config
+37
View File
@@ -0,0 +1,37 @@
require File.expand_path(File.dirname(__FILE__)) + "/../test_helper"
require File.expand_path(File.dirname(__FILE__)) + "/../../lib/cmock_file_writer"
class CMockFileWriterTest < Test::Unit::TestCase
def setup
create_mocks :config
@cmock_file_writer = CMockFileWriter.new(@config)
end
def teardown
end
should "have set up internal accessors correctly on init" do
assert_equal(@config, @cmock_file_writer.config)
end
should "complain if a block was not specified when calling create" do
begin
@cmock_file_writer.create_file("test.txt")
assert false, "Should Have Thrown An Error When Calling Without A Block"
rescue
end
end
should "create a file when requested and put a block of data in it" do
@config.expect.mock_path.returns("C:\\")
@config.expect.mock_path.returns("C:\\")
@cmock_file_writer.create_file("test.txt") do |file, filename|
file << "VICTORY!"
end
retval = File.open("C:\\test.txt", 'r').readlines[0]
assert_equal "VICTORY!", retval
end
end