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

Weird error when refinement is used in rspec #2977

Closed
jirutka opened this issue May 22, 2015 · 5 comments
Closed

Weird error when refinement is used in rspec #2977

jirutka opened this issue May 22, 2015 · 5 comments

Comments

@jirutka
Copy link

@jirutka jirutka commented May 22, 2015

Sorry for such bad title, but I don’t know how to properly described what’s going on here. Let me show you:

module Refin
  refine String do
    def foo
    end
  end
end

describe "foo" do
  using Refin

  shared_examples :okay do
    it { expect( 1 ).to eq 1 }
  end

  shared_examples :failing do |arg|
    it { expect( arg ).to_not be_nil }
  end

  context "include example without arguments" do
    include_examples :okay  # <-- THIS IS OK
  end

  context "include example with an argument" do
    include_examples :failing, :foo  # <-- THIS FAILS
  end
end
$ rspec some_spec.rb
ArgumentError: wrong number of arguments (0 for 1)
   include_examples at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/example_group.rb:24
    block in (root) at /Users/jimmy/Temp/jruby/some_spec.rb:24
        module_exec at org/jruby/RubyModule.java:2669
           subclass at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/example_group.rb:363
   block in context at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/example_group.rb:253
    block in (root) at /Users/jimmy/Temp/jruby/some_spec.rb:23
        module_exec at org/jruby/RubyModule.java:2669
           subclass at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/example_group.rb:363
  block in describe at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/example_group.rb:253
  block in describe at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/dsl.rb:43
  block in describe at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/dsl.rb:82
              <top> at /Users/jimmy/Temp/jruby/some_spec.rb:8
               load at org/jruby/RubyKernel.java:984
    block in (root) at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1
               each at org/jruby/RubyArray.java:1571
    load_spec_files at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226
    load_spec_files at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224
              setup at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97
                run at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85
                run at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70
              <top> at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38
               load at org/jruby/RubyKernel.java:984
              <top> at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/bin/rspec:23

When you remove the line using Refin, then it runs without problem.

I ran into this problem with corefines, you can see similar log here on Travis with jruby-head.


rspec 3.2.3

@jirutka
Copy link
Author

@jirutka jirutka commented May 22, 2015

Another weird issue:

module Refin
  refine String do
    def foo
    end
  end
end

describe 'foo' do
  using Refin

  subject { 42 }

  it { is_expected.to eq 42 }
end
$ rspec second_spec.rb
RuntimeError: #let or #subject called without a block
                let at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/memoized_helpers.rb:234
            subject at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/memoized_helpers.rb:347
    block in (root) at /Users/jimmy/Temp/jruby/second_spec.rb:11
        module_exec at org/jruby/RubyModule.java:2669
           subclass at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/example_group.rb:363
  block in describe at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/example_group.rb:253
  block in describe at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/dsl.rb:43
  block in describe at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/dsl.rb:82
              <top> at /Users/jimmy/Temp/jruby/second_spec.rb:8
               load at org/jruby/RubyKernel.java:984
    block in (root) at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1
               each at org/jruby/RubyArray.java:1571
    load_spec_files at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1226
    load_spec_files at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1224
              setup at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:97
                run at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85
                run at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70
              <top> at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/lib/ruby/gems/shared/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38
               load at org/jruby/RubyKernel.java:984
              <top> at /Users/jimmy/.rbenv/versions/jruby-9.0.0.0.pre2/bin/rspec:23

And again, when you remove the using Refin line, then it runs without problem.

@jirutka
Copy link
Author

@jirutka jirutka commented May 23, 2015

I’ve just tested it on the current master (2015-05-23) and the problem persists.

/cc @enebo

@headius
Copy link
Member

@headius headius commented Jun 2, 2015

We plan to fix this for final but probably not for RC1.

@headius headius added this to the JRuby 9.0.0.0 milestone Jun 2, 2015
@enebo enebo added the JRuby 9000 label Jul 14, 2015
@enebo enebo modified the milestone: JRuby 9.0.0.0 Jul 14, 2015
@headius
Copy link
Member

@headius headius commented Dec 22, 2015

Still fails in current JRuby master. Bumping priority.

@headius
Copy link
Member

@headius headius commented Apr 22, 2016

The issue with mismatched arities and missing blocks is very likely fixed by 02d4f4f in 9.1. Still other issues, though.

@headius headius closed this Apr 22, 2016
headius added a commit that referenced this issue Apr 22, 2016
Fixes #3796. Fixes #2977. Fixes #3820. Fixes part of #3733.

See also 02d4f4f.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.