Bugs: Browse | Submit New | Admin

[#13448] Attribute access without self gives error.

Date:
2007-08-28 02:08
Priority:
3
Submitted By:
Curtis Miller (curtm95)
Assigned To:
Eric Hodel (drbrain)
Category:
heckle
State:
Open
Summary:
Attribute access without self gives error.

Detailed description
With this test code:

# models/tester.rb
class Tester < ActiveRecord::Base
  def test1
    self.some_attr.nil?
  end

  def test2
    some_attr.nil?
  end
end

And this test:

# spec/models/tester_spec.rb
require File.dirname(__FILE__) + '/../spec_helper'

describe Tester, "a tester" do
  it "should pass a test" do
  end
end

I get the following output with Heckle:

Finished in 0.056968 seconds
1 example, 0 failures
**********************************************************************
***  Tester#test1 loaded with 2 possible mutations
**********************************************************************

2 mutations remaining...
1 mutations remaining...

The following mutations didn't cause test failures:

--- original
+++ mutation
 def test1
-  self.some_attr.nil?
+  nil.nil?
 end

--- original
+++ mutation
 def test1
-  self.some_attr.nil?
+  # do nothing
 end


Finished in 0.064995 seconds
1 example, 0 failures
**********************************************************************
***  Tester#test2 loaded with 1 possible mutations
**********************************************************************

1 mutations remaining...
/usr/local/lib/ruby/gems/1.8/gems/ruby2ruby-1.1.7/lib/ruby2ruby.rb:243:in `process_call': You have a nil object when
you didn't expect it! (NoMethodError)
You might have expected an instance of Array.
The error occurred while evaluating nil.first   from
/usr/local/lib/ruby/gems/1.8/gems/ParseTree-2.0.1/lib/sexp_processor.rb:241:in `send'
        from /usr/local/lib/ruby/gems/1.8/gems/ParseTree-2.0.1/lib/sexp_processor.rb:241:in `process'
        from /usr/local/lib/ruby/gems/1.8/gems/ParseTree-2.0.1/lib/sexp_processor.rb:299:in `error_handler'
        from /usr/local/lib/ruby/gems/1.8/gems/ParseTree-2.0.1/lib/sexp_processor.rb:240:in `process'
        from /usr/local/lib/ruby/gems/1.8/gems/ruby2ruby-1.1.7/lib/ruby2ruby.rb:52:in `process'
        from /usr/local/lib/ruby/gems/1.8/gems/ruby2ruby-1.1.7/lib/ruby2ruby.rb:244:in `process_call'
        from /usr/local/lib/ruby/gems/1.8/gems/ParseTree-2.0.1/lib/sexp_processor.rb:241:in `send'
        from /usr/local/lib/ruby/gems/1.8/gems/ParseTree-2.0.1/lib/sexp_processor.rb:241:in `process'
         ... 30 levels...
        from /Users/curtis/work/test_project/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:114:in `heckle'
        from /Users/curtis/work/test_project/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:31:in `run'
        from /Users/curtis/work/test_project/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in `run'
        from /Users/curtis/work/test_project/vendor/plugins/rspec/bin/spec:3



I also tried it with standard Test::Unit test case and running heckle directly - same result.  May be related to 13267?

Add A Comment: Notepad

Please login


Followup

Message
Date: 2012-06-04 21:03
Sender: Ryan Davis

Believe it or not, we've moved to github! If you think this issue
is still relevant, please re-file it under our project on github
(
https://github.com/seattlerb/$projectname ) and provide a link 
back to this ticket (if there is any comment stream). If not, 
please close this ticket.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_tokevinclark2007-09-19 23:18zenspider