I've got a rails project that's using Mongoid as the "database" and I'm getting odd coverage results. Here's a snippet of a good example of the behavior I'm seeing:
Class:
class Source::TwitterFeed < Source
field :hash_tags, :type => Array, :default => []
field :users, :type => Array, :default => []
attr_accessible :users, :hash_tags
validate :validate_empty_feed
def validate_empty_feed
if (self.users.empty? && self.hash_tags.empty?)
errors.add(:users, "must have at least one username or hash_tag")
end
end
Test
context "twitter feed with empty hash_tags and users validation" do
setup do
Source::TwitterFeed.delete_all
@twitter_feed = Source::TwitterFeed.create(:users => [], :hash_tags => [])
end
should "be invalid" do
assert(@twitter_feed.invalid?, "twitter_feed was not invalid")
end
end
The test passes. Yet, only the def line of validate_empty_feed is considered covered. For reference, this is with cover_me 1.0.0, rails 3.0.7 and a cover_me config (That's really just empty) after a require in the test helper. I see this behavior all over the coverage report, where I have tests that I'm sure execute lines but are not considered covered. I looked around at the other issues and googled around but was unable to find anything on cover_me and mongoid.
I've got a rails project that's using Mongoid as the "database" and I'm getting odd coverage results. Here's a snippet of a good example of the behavior I'm seeing:
Class:
Test
The test passes. Yet, only the def line of validate_empty_feed is considered covered. For reference, this is with cover_me 1.0.0, rails 3.0.7 and a cover_me config (That's really just empty) after a require in the test helper. I see this behavior all over the coverage report, where I have tests that I'm sure execute lines but are not considered covered. I looked around at the other issues and googled around but was unable to find anything on cover_me and mongoid.