Skip to content

Conversation

@voxik
Copy link
Contributor

@voxik voxik commented Nov 1, 2024

This prevents test error such as:

  Scenario: specify a method does not throw an expection                                               # features/its.feature:145
    Given a file named "example_spec.rb" with:                                                         # aruba-2.2.0/lib/aruba/cucumber/file.rb:26
      """
      class Klass; end

      describe Klass do
        subject { Klass.new }
        its(:foo) { will_not raise_error }
      end
      """
    When I run rspec                                                                                   # features/step_definitions/additional_cli_steps.rb:1
    Then the example should fail                                                                       # features/step_definitions/additional_cli_steps.rb:23
    And the output should contain "Failure/Error: its(:foo) { will_not raise_error }"                  # aruba-2.2.0/lib/aruba/cucumber/command.rb:123
    And the output should contain "expected no Exception, got #<NoMethodError: undefined method `foo'" # aruba-2.2.0/lib/aruba/cucumber/command.rb:123
      expected "F\n\nFailures:\n\n  1) Klass foo is expected not to raise Exception\n     Failure/Error: its(:foo) {...e\n\nFailed examples:\n\nrspec ./example_spec.rb:5 # Klass foo is expected not to raise Exception\n" to string includes: "expected no Exception, got #<NoMethodError: undefined method `foo'"
      Diff:
      @@ -1,17 +1,33 @@
      -expected no Exception, got #<NoMethodError: undefined method `foo'
      +F
      +
      +Failures:
      +
      +  1) Klass foo is expected not to raise Exception
      +     Failure/Error: its(:foo) { will_not raise_error }
      +
      +       expected no Exception, got #<NoMethodError: undefined method 'foo' for an instance of Klass> with backtrace:
      +         # ./example_spec.rb:5:in 'block (2 levels) in <top (required)>'
      +     # ./example_spec.rb:5:in 'block (2 levels) in <top (required)>'
      +
      +Finished in 0.01104 seconds (files took 0.05894 seconds to load)
      +1 example, 1 failure
      +
      +Failed examples:
      +
      +rspec ./example_spec.rb:5 # Klass foo is expected not to raise Exception
       (RSpec::Expectations::ExpectationNotMetError)
      <internal:array>:42:in 'Array#each'
      features/its.feature:158:in `the output should contain "expected no Exception, got #<NoMethodError: undefined method `foo'"'

Ruby upstream ticket:

https://bugs.ruby-lang.org/issues/16495

This prevents test error such as:

~~~cucumber
  Scenario: specify a method does not throw an expection                                               # features/its.feature:145
    Given a file named "example_spec.rb" with:                                                         # aruba-2.2.0/lib/aruba/cucumber/file.rb:26
      """
      class Klass; end

      describe Klass do
        subject { Klass.new }
        its(:foo) { will_not raise_error }
      end
      """
    When I run rspec                                                                                   # features/step_definitions/additional_cli_steps.rb:1
    Then the example should fail                                                                       # features/step_definitions/additional_cli_steps.rb:23
    And the output should contain "Failure/Error: its(:foo) { will_not raise_error }"                  # aruba-2.2.0/lib/aruba/cucumber/command.rb:123
    And the output should contain "expected no Exception, got #<NoMethodError: undefined method `foo'" # aruba-2.2.0/lib/aruba/cucumber/command.rb:123
      expected "F\n\nFailures:\n\n  1) Klass foo is expected not to raise Exception\n     Failure/Error: its(:foo) {...e\n\nFailed examples:\n\nrspec ./example_spec.rb:5 # Klass foo is expected not to raise Exception\n" to string includes: "expected no Exception, got #<NoMethodError: undefined method `foo'"
      Diff:
      @@ -1,17 +1,33 @@
      -expected no Exception, got #<NoMethodError: undefined method `foo'
      +F
      +
      +Failures:
      +
      +  1) Klass foo is expected not to raise Exception
      +     Failure/Error: its(:foo) { will_not raise_error }
      +
      +       expected no Exception, got #<NoMethodError: undefined method 'foo' for an instance of Klass> with backtrace:
      +         # ./example_spec.rb:5:in 'block (2 levels) in <top (required)>'
      +     # ./example_spec.rb:5:in 'block (2 levels) in <top (required)>'
      +
      +Finished in 0.01104 seconds (files took 0.05894 seconds to load)
      +1 example, 1 failure
      +
      +Failed examples:
      +
      +rspec ./example_spec.rb:5 # Klass foo is expected not to raise Exception
       (RSpec::Expectations::ExpectationNotMetError)
      <internal:array>:42:in 'Array#each'
      features/its.feature:158:in `the output should contain "expected no Exception, got #<NoMethodError: undefined method `foo'"'
~~~

Ruby upstream ticket:

https://bugs.ruby-lang.org/issues/16495
@JonRowe JonRowe changed the base branch from main to add-ruby-34 November 4, 2024 00:06
@JonRowe JonRowe merged commit 38955ea into rspec:add-ruby-34 Nov 4, 2024
28 checks passed
@JonRowe
Copy link
Member

JonRowe commented Nov 4, 2024

Thanks, verified this fixes the build by adding Ruby 3.4 to the build and our cucumber monkey patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants