rspec/rspec-expectations — Issue #111: `should` should warn when used in `describe`, outside `it`
Author: gioele
Created: 2012-01-24 10:12:46+00:00
State: open

RSpec crashes with the attached backtrace in this rspec example

```ruby
describe "#exclude" do
list = FilePathList.new(%w{a.foo b.bar c.foo d.foo b.bar})
refined = list.exclude(/bar$/)

refined.should be_a FilePathList ### <<< this crashes rspec
refined.each { |path| path.extension.should == 'foo' }
end
```

The problem with in this code is that the example is not surrounded by `it "..." do ... end`. This test was running fine until I added the `be_a` test. This generated the attached backtrace. It took me a while and a pair of fresh eyes to realise that the problem was the use of `should` outside an `it` example.

Could you add some warnings so that uses of `should` outside `it` blocks can easily be catch more easily?

The backtrace:

spec/filepathlist_spec.rb:43: undefined method `be_a' for # (NoMethodError)
from .../rspec-core-2.8.0/lib/rspec/core/example_group.rb:201:in `module_eval'
from .../rspec-core-2.8.0/lib/rspec/core/example_group.rb:201:in `subclass'
from .../rspec-core-2.8.0/lib/rspec/core/example_group.rb:187:in `describe'
from /home/gioele/Projects/filepath/spec/filepathlist_spec.rb:39
from .../rspec-core-2.8.0/lib/rspec/core/example_group.rb:201:in `module_eval'
from .../rspec-core-2.8.0/lib/rspec/core/example_group.rb:201:in `subclass'
from .../rspec-core-2.8.0/lib/rspec/core/example_group.rb:187:in `describe'
from .../rspec-core-2.8.0/lib/rspec/core/dsl.rb:18:in `describe'
from /home/gioele/Projects/filepath/spec/filepathlist_spec.rb:6
from .../rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load'
from .../rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
from .../rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map'
from .../rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
from .../rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run'
from .../rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
from .../rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
from .../rspec-core-2.8.0/lib/rspec/core/runner.rb:10
from /home/gioele/Applications/ruby/gems/bin/rspec:19
rake aborted!
/usr/bin/ruby1.8 -w -S rspec spec/filepath_spec.rb spec/filepathlist_spec.rb failed

The rspec file is .