Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Raise ArgumentError when doc_string is neither string nor nil #3081

Conversation

eisukeyeongjo
Copy link

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 #3073 to output deprecation warning in the same condition.

@JonRowe JonRowe merged commit d8c5e3e into rspec:4-0-dev Sep 5, 2024
0 of 16 checks passed
JonRowe added a commit to rspec/rspec that referenced this pull request Nov 27, 2024
…gument_error_when_doc_string_is_not_nil_or_stirng

Raise ArgumentError when doc_string is neither string nor nil

---
This commit was imported from rspec/rspec-core@d8c5e3e.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants