diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-02-03 18:40:51 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-02-03 18:40:51 +0000 |
commit | c5b957e91c9a1c974c7725deb7914058b0fd334d (patch) | |
tree | 760d269b249494feec5d49546b108900100773f0 | |
parent | bf4bbc351dae8e97d09b87434cef4f44eea4d73a (diff) |
Better test assertions
Change the test assertions so they give more informative errors
when they fail -- as they sometimes do: see issue #408.
-rw-r--r-- | spec/models/incoming_message_spec.rb | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index b6fee7898..6cfd2eb64 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -362,6 +362,7 @@ describe IncomingMessage, " when uudecoding bad messages" do im = incoming_messages(:useless_incoming_message) im.stub!(:mail).and_return(mail) im.extract_attachments! + attachments = im.foi_attachments attachments.size.should == 2 attachments[1].filename.should == 'moo.txt' @@ -385,9 +386,9 @@ describe IncomingMessage, " when uudecoding bad messages" do ir.censor_rules << @censor_rule im.extract_attachments! - attachments = im.get_attachments_for_display - attachments.size.should == 1 - attachments[0].display_filename.should == 'bah.txt' + im.get_attachments_for_display.map(&:display_filename).should == [ + 'bah.txt', + ] end end @@ -409,10 +410,11 @@ describe IncomingMessage, "when messages are attached to messages" do im.extract_attachments! attachments = im.get_attachments_for_display - attachments.size.should == 3 - attachments[0].display_filename.should == 'Same attachment twice.txt' - attachments[1].display_filename.should == 'hello.txt' - attachments[2].display_filename.should == 'hello.txt' + attachments.map(&:display_filename).should == [ + 'Same attachment twice.txt', + 'hello.txt', + 'hello.txt', + ] end end @@ -431,10 +433,10 @@ describe IncomingMessage, "when Outlook messages are attached to messages" do im.stub!(:mail).and_return(mail) im.extract_attachments! - attachments = im.get_attachments_for_display - attachments.size.should == 2 - attachments[0].display_filename.should == 'test.html' # picks HTML rather than text by default, as likely to render better - attachments[1].display_filename.should == 'attach.txt' + im.get_attachments_for_display.map(&:display_filename).should == [ + 'test.html', # picks HTML rather than text by default, as likely to render better + 'attach.txt', + ] end end @@ -453,12 +455,10 @@ describe IncomingMessage, "when TNEF attachments are attached to messages" do im.stub!(:mail).and_return(mail) im.extract_attachments! - attachments = im.get_attachments_for_display - attachments.size.should == 2 - attachments[0].display_filename.should == 'FOI 09 02976i.doc' - attachments[1].display_filename.should == 'FOI 09 02976iii.doc' + im.get_attachments_for_display.map(&:display_filename).should == [ + 'FOI 09 02976i.doc', + 'FOI 09 02976iii.doc', + ] end end - - |