diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-05-22 13:06:54 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-05-22 13:07:48 +0100 |
commit | 5589b75b247cce161ba71f1e62c0a3bd4f98e932 (patch) | |
tree | de88efb908153b6aa3c2036b5f759fc5b5994c13 | |
parent | dd289908964c8d60e33ce71724dc9e36c3beb765 (diff) |
Cleanup specs
Don't call load_raw_emails for all specs - only needed for one.
Don't call update_display_size! explicitly - the point of the
test is that body= should set it as a side effect.
-rw-r--r-- | spec/models/foi_attachment_spec.rb | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/spec/models/foi_attachment_spec.rb b/spec/models/foi_attachment_spec.rb index 88afc24a4..5b5db3dbf 100644 --- a/spec/models/foi_attachment_spec.rb +++ b/spec/models/foi_attachment_spec.rb @@ -18,45 +18,47 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe FoiAttachment do - before(:each) do - load_raw_emails_data - end + describe :body= do - it "sets the body" do - attachment = FoiAttachment.new - attachment.body = "baz" - attachment.body.should == "baz" - end - it "sets the size" do - attachment = FoiAttachment.new - attachment.body = "baz" - attachment.body.should == "baz" - attachment.update_display_size! - attachment.display_size.should == "0K" - end - it "reparses the body if it disappears" do - im = incoming_messages(:useless_incoming_message) - im.extract_attachments! - main = im.get_main_body_text_part - orig_body = main.body - main.delete_cached_file! - lambda { - im.get_main_body_text_part.body - }.should_not raise_error(Errno::ENOENT) - main.delete_cached_file! - main = im.get_main_body_text_part - main.body.should == orig_body + it "sets the body" do + attachment = FoiAttachment.new + attachment.body = "baz" + attachment.body.should == "baz" + end + + it "sets the size" do + attachment = FoiAttachment.new + attachment.body = "baz" + attachment.body.should == "baz" + attachment.display_size.should == "0K" + end + + it "reparses the body if it disappears" do + load_raw_emails_data + im = incoming_messages(:useless_incoming_message) + im.extract_attachments! + main = im.get_main_body_text_part + orig_body = main.body + main.delete_cached_file! + lambda { + im.get_main_body_text_part.body + }.should_not raise_error(Errno::ENOENT) + main.delete_cached_file! + main = im.get_main_body_text_part + main.body.should == orig_body + end end -end -describe FoiAttachment, "when ensuring a filename is present" do + describe :ensure_filename! do + + it 'should create a filename for an instance with a blank filename' do + attachment = FoiAttachment.new + attachment.filename = '' + attachment.ensure_filename! + attachment.filename.should == 'attachment.bin' + end - it 'should create a filename for an instance with a blank filename' do - attachment = FoiAttachment.new - attachment.filename = '' - attachment.ensure_filename! - attachment.filename.should == 'attachment.bin' end end |