simplecov-ruby / simplecov

Code coverage for Ruby with a powerful configuration library and automatic merging of coverage across test suites

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

not working with riot correctly?

thepixelmonk opened this issue · comments

simplecov results: http://stuff.saikonet.org/images/misc/2011-09-18-150129_1024x768_scrot.png

my tests:

context 'New user visits web site' do
    base_uri 'http://localhost:3001'
    get '/'
    asserts_status.equals(200)
end
context 'Authentication' do
    context 'User signs up' do
      base_uri 'http://localhost:3001'
      post '/site/authenticate', body: { user: { email: 'saiko_chriskun@shortmail.com', password: 'my_pass' } }
      asserts_status.equals(200)
      asserts('display tasks') { response.body.match(/New Task/) != nil }
    end

    context 'User signs in' do
       base_uri 'http://localhost:3001'
       post '/site/authenticate', body: { user: { email: 'saiko_chriskun@shortmail.com', password: 'my_pass' } }
       asserts_status.equals(200)
       asserts('display tasks') { response.body.match(/New Task/) != nil }
     end
    context 'User tries to signup with existing email' do
       base_uri 'http://localhost:3001'
       post '/site/authenticate', body: { user: { email: 'saiko_chriskun@shortmail.com', password: 'incorrect_pass' } }
       asserts_status.equals(200)
       asserts('display flash message') { response.body.match(/taken!/) != nil }
     end
end

I haven't tried SimpleCov with riot yet, but there's no reason it shouldn't work. I'll try it out. Maybe this is related to the bug in the Coverage lib as figured out in #60.

yeah I think it's the Coverage lib as cover_me is churning out the same results :P

@saiko-chriskun Could you please edit your issue description to hold the code sample you had posted on StackOverflow as it seems the question is no longer present there and I wanted to provide Ruby core maintainers with this example on my already filed bug report on this: http://redmine.ruby-lang.org/issues/5333

updated

not sure what changed exactly but it's not catching any of my controller code now (it doesn't detect any files under the controller tab) although the models seem to be fine.

Thanks for the report. I'm not using riot so I didn't realize the problem yet.

It would be great if you could create a cucumber feature and example that tests usage with the riot framework similar to those already existing and submit it as a Pull Request so I could go about fixing those.

Also, this might be related to #60.

I'm not having any trouble using it with Riot... Although, I was.

I'm trying to remember how I fixed it. I think what I actually ended up with was this: https://gist.github.com/1814276

Again, I'm fuzzy on the whole "fix". But I think it's the rand(99999) part that is the key. Somehow it allows the results to accumulate, otherwise each set of tests overwrites the previous set of results. Using a random name prevents the overwriting. (Well it actually just makes the odds 1:99999.) What you're probably encountering is your model tests being run after your controller tests, so the controller test coverage results get overwritten.

And yeah I'm pretty sure it's related to #60

Closing as stale. Please reopen if this is still an issue. (And take a look at #340 )