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

Add deprecate warning when example doc string is not a string object #3073

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eisukeyeongjo
Copy link

Preparing for upcoming new specification mentioned #3072 , added deprecated warning when example doc string is not a string object

What is changed

When execute rspec below

context do
  it :pending do
    # Only pending option without reason
    expect(true).to eq false
  end

  it pending: 'only pending option' do
    expect(true).to eq false   
  end  

  it 'description with option', pending: 'some reason' do
    expect(true).to eq false
  end
end

Output deprecate warning like

Deprecation Warnings:

Hash object `{:pending=>"only pending option"}` as example doc string is deprecated. Use a string instead. Called from /home/username/test.rb:7:in `block in <top (required)>'.

Symbol object `:pending` as example doc string is deprecated. Use a string instead. Called from /home/username/test.rb:2:in `block in <top (required)>'.
Entire output is here
$ bundle exec rspec test.rb --format documentation


  pending (FAILED - 1)
  {:pending=>"only pending option"} (FAILED - 2)
  description with option (PENDING: some reason)

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) description with option
     # some reason
     Failure/Error: expect(true).to eq false
     
       expected: false
            got: true
     
       (compared using ==)
     
       Diff:
       @@ -1 +1 @@
       -false
       +true
       
     # ./test.rb:12:in `block (2 levels) in <top (required)>'

Failures:

  1) pending
     Failure/Error: expect(true).to eq false
     
       expected: false
            got: true
     
       (compared using ==)
     
       Diff:
       @@ -1 +1 @@
       -false
       +true
       
     # ./test.rb:4:in `block (2 levels) in <top (required)>'

  2) {:pending=>"only pending option"}
     Failure/Error: expect(true).to eq false
     
       expected: false
            got: true
     
       (compared using ==)
     
       Diff:
       @@ -1 +1 @@
       -false
       +true
       
     # ./test.rb:8:in `block (2 levels) in <top (required)>'

Deprecation Warnings:

Hash object `{:pending=>"only pending option"}` as example doc string is deprecated. Use a string instead. Called from /home/username/test.rb:7:in `block in <top (required)>'.

Symbol object `:pending` as example doc string is deprecated. Use a string instead. Called from /home/username/test.rb:2:in `block in <top (required)>'.


If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.

2 deprecation warnings total

Finished in 0.01384 seconds (files took 0.08949 seconds to load)
3 examples, 2 failures, 1 pending

Failed examples:

rspec ./test.rb:2 # pending
rspec ./test.rb:7 # {:pending=>"only pending option"}

@pirj pirj added this to the 3.99 milestone Mar 20, 2024
Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you
Can you please add a couple of specs for deprecation messages like eg here?

@eisukeyeongjo
Copy link
Author

eisukeyeongjo commented Mar 20, 2024

@pirj Sorry, I just added rspec for the deprecation warning 🙇

@eisukeyeongjo eisukeyeongjo requested a review from pirj March 20, 2024 15:28
@eisukeyeongjo eisukeyeongjo changed the title Output deprecate warning when example doc string is not a string object Add deprecate warning when example doc string is not a string object Mar 20, 2024
@eisukeyeongjo
Copy link
Author

Sorry, I think it is a wrong place to put rspec in...
I'll fix it

@eisukeyeongjo eisukeyeongjo marked this pull request as draft March 20, 2024 22:55
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