spec/file_spec.rb in ach_builder-0.0.1.1 vs spec/file_spec.rb in ach_builder-0.0.2
- old
+ new
@@ -12,10 +12,11 @@
@invalid_attributes = {:foo => 'bar'}
@file = ACH::File.new(@attributes)
@file_with_batch = ACH::File.new(@attributes) do
batch :entry_class_code => 'WEB'
end
+ @sample_file = ACH.sample_file
end
it "should correctly assign attributes" do
@file.company_id.should == '11-11111'
end
@@ -66,8 +67,24 @@
end
it "should assign attributes to a batch" do
batch = @file_with_batch.batch(0)
batch.attributes.should include(@file_with_batch.attributes)
+ end
+
+ it "should have correct record count" do
+ @sample_file.record_count.should == 8
+ end
+
+ it "should have header record with length of 94" do
+ @sample_file.header.to_s!.length.should == ACH::Constants::RECORD_SIZE
+ end
+
+ it "should have control record with length of 94" do
+ @sample_file.control.to_s!.length.should == ACH::Constants::RECORD_SIZE
+ end
+
+ it "should have length devisible by 94 (record size)" do
+ (@sample_file.to_s!.gsub("\r\n", '').length % ACH::Constants::RECORD_SIZE).should be_zero
end
end