# Bizarr problem with rake

**URL:** <https://www.ruby-forum.com/t/bizarr-problem-with-rake/159555>\
**Category:** Rails\
**Created:** [February 5, 2009, 6:18pm UTC](https://www.ruby-forum.com/t/bizarr-problem-with-rake/159555 "2009-02-05T18:18:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [February 5, 2009, 6:18pm UTC](https://www.ruby-forum.com/t/bizarr-problem-with-rake/159555/1 "2009-02-05T18:18:47Z")

</div>

I hope that someone here can identify what is going on as I am  
completely frustrated at the moment.

I am writing a custom rake task for rcov. The intent is top produce  
three variants of a test, each using slightly different options. This  
is the basic code:

R\_RCOV\_AGGREG\_FILE = ‘coverage.data’

# Use single quotes here so that regexp argument is not munged.

R\_RCOV\_EXCLUDE\_DIR = ‘lib/ruby,lib64/ruby’

R\_RCOV\_OUTPUT\_DIR = ‘test\_coverage’

R\_RCOV\_AGGREG\_OPTS = "–aggregate #{R\_RCOV\_AGGREG\_FILE} " +  
"–text-summary --no-html "

R\_RCOV\_BASIC\_OPTS = [ " --rails ", " --exclude  
#{R\_RCOV\_EXCLUDE\_DIR} " ]

R\_RCOV\_FINAL\_OPTS = " --aggregate #{R\_RCOV\_AGGREG\_FILE} "

R\_RCOV\_BROWSER = ‘firefox’

# make the output directory an array.

r\_rcov\_dir = R\_RCOV\_OUTPUT\_DIR.scan(/\w+/)

[‘single’, ‘aggregate’, ‘final’].each do |reptype|

```
# Set the rcov options variables according to report type
r_rcov_opta = nil if reptype == 'single'
r_rcov_opta = R_RCOV_AGGREG_OPTS if reptype == 'aggregate'
r_rcov_opta = R_RCOV_FINAL_OPTS if reptype == 'final'

# builds task int_testunit_X
Rcov::RcovTask.new("int_testunit_#{reptype}") do |t|
  t.test_files = FileList['test/**/test*.rb']
  t.libs << "test"
  t.output_dir = r_rcov_dir
  t.rcov_opts = R_RCOV_BASIC_OPTS
  t.rcov_opts << r_rcov_opta
  puts "testunit #{reptype} opts: #{R_RCOV_BASIC_OPTS} size " +
        "#{R_RCOV_BASIC_OPTS.size}"
  puts " "
  puts "testunit #{reptype} opta: #{r_rcov_opta}"
  puts " "
  puts "testunit #{reptype} options: #{t.rcov_opts}"
  puts " "
  t.verbose = true
end

```

end

The problem is this. Somewhere the constant value R\_RCOV\_BASIC\_OPTS is  
being changed. A rake run using puts and displaying  
R\_RCOV\_BASIC\_OPTS.size gives this output:

testunit single opts: --rails --exclude lib/ruby,lib64/ruby size  
5

testunit single opta:

testunit single options: --rails --exclude lib/ruby,lib64/ruby

testunit aggregate opts: --rails --exclude lib/ruby,lib64/ruby  
–aggregate coverage.data --text-summary --no-html --aggregate  
coverage.data --text-summary --no-html --aggregate coverage.data  
–text-summary --no-html size 8

testunit aggregate opta: --aggregate coverage.data --text-summary  
–no-html

testunit aggregate options: --rails --exclude lib/ruby,lib64/ruby  
–aggregate coverage.data --text-summary --no-html --aggregate  
coverage.data --text-summary --no-html --aggregate coverage.data  
–text-summary --no-html

testunit final opts: --rails --exclude lib/ruby,lib64/ruby  
–aggregate coverage.data --text-summary --no-html --aggregate  
coverage.data --text-summary --no-html --aggregate coverage.data  
–text-summary --no-html --aggregate coverage.data --aggregate  
coverage.data --aggregate coverage.data size 11

testunit final opta: --aggregate coverage.data

testunit final options: --rails --exclude lib/ruby,lib64/ruby  
–aggregate coverage.data --text-summary --no-html --aggregate  
coverage.data --text-summary --no-html --aggregate coverage.data  
–text-summary --no-html --aggregate coverage.data --aggregate  
coverage.data --aggregate coverage.data

Checking my rake task lists only these places where R-RCOV\_BASIC\_OPTS is  
referenced:

22 R\_RCOV\_BASIC\_OPTS = [ " --rails ", " --exclude  
#{R\_RCOV\_EXCLUDE\_DIR} " ]  
57 t.rcov\_opts = R\_RCOV\_BASIC\_OPTS  
68 t.rcov\_opts = R\_RCOV\_BASIC\_OPTS  
77 t.rcov\_opts = R\_RCOV\_BASIC\_OPTS  
79 puts "testunit #{reptype} opts: #{R\_RCOV\_BASIC\_OPTS} size  
" +  
80 “#{R\_RCOV\_BASIC\_OPTS.size}”

How is constant getting its value changed?
