I have a text file which I intend to convert to a CSV (in this case) format. How do I create a proper RSpec test to see if the output will be in the proper format for the following scenario?
This is my code:
class ProcessLog
@@log = Array.new
def read_log(log)
if File.exists?(log)
f = File.open(log, "r")
f.each_line { |line| @@log << line.strip }
end
end
def process_log
result = Array.new
@@log.each do |line|
<convert to csv>
result << <converted to csv>
end
result
end
end
describe ProcessLog do
before do
@pl = ProcessLog.new
<help>
end
it 'should pass first format' do
text = "Item X has a price of $ per gram" # just as an example
<help>
@pl.read_log("file.log")
@pl.should == 'X,$,gram'
end
end