You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
I have noticed the same problem as well. For example, for a particular method that I'm sure is being run, but does not show as covered, I'll throw a raise statement somewhere in that method and get errors all over the place when I run my tests. When I remove it, though, it still shows as not being covered.
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.
The text was updated successfully, but these errors were encountered: