described_class behavior doesn't make sense when inner block is not a Class
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 117
- Forks
- 51
- Avg merge
- 59m
- Merged PRs (30d)
- 3
Description
Gemfile:
gem 'rspec', '= 3.0.0'
spec/described_class_spec.rb:
describe Array do
describe 'a string' do
it { expect(described_class).to eq(Array) }
end
describe :a_symbol do
it { expect(described_class).to eq(Array) }
end
describe Hash do
it { expect(described_class).to eq(Hash) }
end
describe Hash.new do
it { expect(described_class).to eq(Hash) }
end
end
This results in two errors--one on :a_symbol and one on Hash.new. IMO this behavior is non-intuitive. rspec/rspec-core#1114 seems to have made an exception for when the inner describe is an instance of String, which makes sense, because described_class.should be_a(Class). However, I argue that this should be consistent for all cases where the inner describe is not a Class. Either take its class, or skip it and move to the outer describe block, but don't return an instance.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with spec/described_class_spec.rb and reproduce the failures for the symbol and Hash.new nested descriptions. Read the existing described_class behavior and related examples to determine the intended consistent handling of non-Class inner descriptions. Done means the chosen behavior is covered by passing focused specs without returning an instance unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100