tomykaira / rspec-parameterized

RSpec::Parameterized supports simple parameterized test syntax in rspec.
MIT License
417 stars 28 forks source link

rspec is failed with binding_ninja v0.2.0 #45

Closed sue445 closed 7 years ago

sue445 commented 7 years ago

When using binding_ninja v0.2.0, rspec is failed πŸ’” https://travis-ci.org/sue445/rspec-parameterized/builds/287121332

/home/travis/build/sue445/rspec-parameterized/spec/parametarized_spec.rb:174:in `|': uninitialized class variable @@__auto_inject_binding_options in String (NameError)
    from /home/travis/build/sue445/rspec-parameterized/spec/parametarized_spec.rb:174:in `block (4 levels) in <top (required)>'
    from /home/travis/build/sue445/rspec-parameterized/lib/rspec/parameterized.rb:104:in `instance_eval'
    from /home/travis/build/sue445/rspec-parameterized/lib/rspec/parameterized.rb:104:in `define_cases'
    from /home/travis/build/sue445/rspec-parameterized/lib/rspec/parameterized.rb:83:in `with_them'
    from /home/travis/build/sue445/rspec-parameterized/spec/parametarized_spec.rb:180:in `block (3 levels) in <top (required)>'
    from /home/travis/build/sue445/rspec-parameterized/gemfiles/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:385:in `module_exec'
    from /home/travis/build/sue445/rspec-parameterized/gemfiles/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:385:in `subclass'
    from /home/travis/build/sue445/rspec-parameterized/gemfiles/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:255:in `block in define_example_group_method'
    from /home/travis/build/sue445/rspec-parameterized/spec/parametarized_spec.rb:170:in `block (2 levels) in <top (required)>'

But when downgrade binding_ninja to v0.1.0, rspec is successful πŸ’š

https://travis-ci.org/sue445/rspec-parameterized/builds/287123622

changes: https://github.com/sue445/rspec-parameterized/commit/dd6cb424cc16ea65d5b9aa23cce0ab116a7db65a

@joker1007 Can you fix this problem?

joker1007 commented 7 years ago

I inspected this probrem. It is caused by Refinements behavior. Current Refinements cannot refer to class variables.

class Foo
  @@hoge = 1
  @class_instance_var = 2

  def hoge1
    p @@hoge
  end

  def bar1
    p self.class.instance_variable_get("@class_instance_var")
  end
end

module Ext
  refine Foo do
    def hoge2
      p @@hoge
    end

    def bar2
      p self.class.instance_variable_get("@class_instance_var")
    end
  end
end

using Ext

Foo.new.bar1
Foo.new.bar2

Foo.new.hoge1
Foo.new.hoge2 # => NameError

I will submit bug ticket to bugs.ruby-lang.org

sue445 commented 7 years ago

@joker1007 I see.

I think rspec-parameterized should be locked with binding_ninja v0.1.0. How do you think?

joker1007 commented 7 years ago

LGTM. Let's do so until I have fixed binding_ninja

joker1007 commented 7 years ago

I fixed binding_ninja and released v0.2.1