rspec / rspec-core

RSpec runner and formatters
http://rspec.info
MIT License
1.23k stars 765 forks source link

Raise ArgumentError when doc_string is neither string nor nil #3081

Closed eisukeyeongjo closed 2 months ago

eisukeyeongjo commented 7 months ago

Related issue: rspec/rspec#40

To keep the first argument a string object, it raises ArgumentError when non string object were given as doc_string.

ArgumentError:
  `:pending` is not acceptable for doc_string.
  it must be a string.

Currently example recognize its first argument as doc_string even if it is not a string object. For example,

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

In the example above, :pending does not work and fails like below

  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)>'

I suppose that if this PR is beneficial for RSpec, this breaking change will be released for upcoming new major version 4.0 or later. For preparing the change I created another PR rspec/rspec-core#3073 to output deprecation warning in the same condition.