tomykaira / rspec-parameterized

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

TableSyntax is failed with Ruby 3.0.2 #73

Closed ryogift closed 2 years ago

ryogift commented 2 years ago

Hello.

https://github.com/tomykaira/rspec-parameterized/issues/69 It looks like it's closed, but it's not resolved.

I validated TableSyntax in Ruby 3.0.2 but it fails. I verified it in the following environment.

$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [aarch64-linux]
require "rails_helper"

RSpec.describe "Sample" do
  describe "plus" do
    using RSpec::Parameterized::TableSyntax

    where(:a, :b, :answer) do
      1 | 2 | 3
      5 | 8 | 13
      0 | 0 | 0
    end

    with_them do
      it "should do additions" do
        expect(a + b).to eq answer
      end
    end
  end
end

$ bundle exec rspec

An error occurred while loading ./spec/sample_spec.rb.
Failure/Error:
  with_them do
    it "should do additions" do
      expect(a + b).to eq answer
    end
  end

NoMethodError:
  undefined method `to_params' for 0:Integer
  Did you mean?  to_param
# /usr/local/bundle/gems/rspec-parameterized-0.5.0/lib/rspec/parameterized.rb:107:in `define_cases'
# /usr/local/bundle/gems/rspec-parameterized-0.5.0/lib/rspec/parameterized.rb:84:in `with_them'
# ./spec/sample_spec.rb:13:in `block (2 levels) in <top (required)>'
# ./spec/sample_spec.rb:4:in `block in <top (required)>'
# ./spec/sample_spec.rb:3:in `<top (required)>'
No examples found.

Finished in 0.00003 seconds (files took 2.74 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
ryogift commented 2 years ago

After verifying with Ruby 3.1.0, it passed.

$ ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [aarch64-linux]
$ bundle exec rspec spec/sample_spec.rb 
...

Finished in 0.049 seconds (files took 3.17 seconds to load)
3 examples, 0 failures

This issue has been solved with the latest Ruby, so I will close it.