On Sun, May 1, 2011 at 4:57 AM, Frederick Cheung <[email protected]
> wrote:

>
>
> On 1 May 2011, at 03:20, Gustavo de Sá Carvalho Honorato<
> [email protected]> wrote:
>
> Hi,
>
> I'm starting to use Test::Unit to create unit tests for my Rails
> Applications/Plugins. I don't have much experience in Ruby Unit Testing. The
> problem is that the output report is very simple and it is very difficult to
> discover where is the error. Test::Unit does not show the line number of the
> error and the Stack Trace printed using the --trace option does not help
> either.
>
> That's not the normal failing test output - it looks to me like things are
> blowing up before your test even gets run. Do you have any idea where this
> score= problem could be coming from?
>

Yes. The problem is inside the test. I'm testing an Rails plugin I'm
developing. I've created I fake 'Report' class to test my 'acts_as' method.
Here is the Report class:

class Report

  include SeoAuditor

  declare_auditor do
    category 'Server' do
      criteria 'Response time', :max_score => 5 do

      end
    end

    category 'Title Tag' do
      analyzed_text { 'Texto Fake' }

      criteria 'Title Tag found', :max_score => 5 do

      end

      criteria 'Title Tag has text', :max_score => 5 do

      end
    end
  end
end

declare_auditor is the 'acts_as' method and this is my test case:

  test "Categories order" do
    report = Report.new
    result = report.audit

    categories = result.categories

    assert_equal categories[0].name, 'Server'
    assert_equal categories[1].name, 'Title Tag'
  end

I have discovered where the error is: it occurs when I call the audit method
(in 3rd line), which is created in Report class by using declare_auditor
method, but the real problem is the lacking of information of the errors in
the output of the Test::Unit.

Any help would be appreciated.

Thanks,
Gustavo


>
>
> Fred
>
> Here is the output of my test:
>
> /home/gustavo/.rvm/rubies/ruby-1.9.2-p180/bin/ruby -e
> $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)
> /home/gustavo/.rvm/rubies/ruby-1.9.2-p180/bin/rake test:plugins --trace
> Testing started at 23:18 ...
> (in /home/gustavo/Projetos/seo_apps)
> ** Invoke test:plugins (first_time)
> ** Invoke environment (first_time)
> ** Execute environment
> ** Execute test:plugins
>
> NoMethodError: undefined method `score=' for #<Report:0xa1f269c>
> 1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0
> notifications
> Test suite finished: 0.132010162 seconds
> rake aborted!
> Command failed with status (1):
> [/home/gustavo/.rvm/rubies/ruby-1.9.2-p180/...]
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:995:in
> `block in sh'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1010:in
> `call'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1010:in
> `sh'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1094:in
> `sh'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1029:in
> `ruby'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1094:in
> `ruby'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/test_unit/testing.rake:26:in
> `block (2 levels) in define'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1112:in
> `verbose'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/test_unit/testing.rake:11:in
> `block in define'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:636:in
> `call'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:636:in
> `block in execute'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:631:in
> `each'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:631:in
> `execute'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:597:in
> `block in invoke_with_call_chain'
> /home/gustavo/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/monitor.rb:201:in
> `mon_synchronize'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:590:in
> `invoke_with_call_chain'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:583:in
> `invoke'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2051:in
> `invoke_task'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in
> `block (2 levels) in top_level'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in
> `each'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2029:in
> `block in top_level'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:in
> `standard_exception_handling'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2023:in
> `top_level'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2001:in
> `block in run'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:2068:in
> `standard_exception_handling'
> /home/gustavo/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake.rb:1998:in
> `run'
> /home/gustavo/.rvm/rubies/ruby-1.9.2-p180/bin/rake:35:in `<top (required)>'
> -e:1:in `load'
> -e:1:in `<main>'
>
> Process finished with exit code 1
>
>
> Please, anyone have an idea of how to improve this error output??
>
> Thanks in advance,
> Gustavo
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to