Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rcov not detecting a working request.xhr? test #5

Closed
ghost opened this issue May 8, 2009 · 4 comments
Closed

Rcov not detecting a working request.xhr? test #5

ghost opened this issue May 8, 2009 · 4 comments

Comments

@ghost
Copy link

ghost commented May 8, 2009

I have a method

def index
  if request.xhr?
    @users = User.find( :all )
  end
end

And then I have a test for it:

def test_index
  user = users( :foo )
  xhr :post, :index, {}, { :user_id => user.user_id }
  assert_response :success
  assert_template ’users/index’
end

The test works fine.

But then rcov produces a report that says the code block has not yet been covered with a test.

original LH ticket

@ghost
Copy link
Author

ghost commented May 8, 2009

Rcov not detecting a working request.xhr? test

Hi

What sort of rcov task are you using? Are you passing the --rails flag to rcov?

Rob

by Rob Sanheim

@ghost
Copy link
Author

ghost commented May 8, 2009

Rcov not detecting a working request.xhr? test

I am passing --rails, yes.

Here is my rake task:

namespace :test do
namespace :coverage do
desc ’Delete aggregate coverage data.’
task( :clean ){ rm_f ’coverage.data’ }
end
desc ’Aggregate code coverage for unit, functional and integration tests’
task :coverage => ’test:coverage:clean’
%w[ unit functional ].each do |target|
namespace :coverage do
Rcov::RcovTask.new( target ) do |t|
t.libs << ’test’
t.test_files = FileList[ "test/#{ target }/*_test.rb" ]
t.output_dir = "public/coverage/#{ target }"
t.verbose = true
t.rcov_opts << "--sort coverage --exclude gem,oci8 --rails --aggregate coverage.data"
end
end
task :coverage => "test:coverage:#{ target }"
end
end

by Greg Donald

@abedra
Copy link
Contributor

abedra commented Aug 8, 2009

I am going to start looking into this. Is it still an issue for you?

@abedra
Copy link
Contributor

abedra commented Aug 10, 2009

I created a sample application with your example code and it does in fact treat the code as covered.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant