mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-05 21:15:20 +00:00
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:
@@ -2,6 +2,7 @@
|
||||
class CMockFileWriter
|
||||
|
||||
require 'ftools'
|
||||
attr_reader :config
|
||||
|
||||
def initialize(config)
|
||||
@config = config
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user