rspec/rspec-core — Issue #576: shared context and 'its' runs 'before' twice
Author: Ragmaanir
Created: 2012-02-25 00:12:04+00:00
State: open

Hi, from my understanding this is a bug:

Running (https://gist.github.com/1904749):

```ruby
describe 'shared context and its' do
shared_context :shared => :ctx do
before{ puts 'before';raise if @x; @x = true }
end

describe 'failing', :shared => :ctx do
its(:length){}
it(:ok){}
end
end
```

Prints:

```
RSpec::Issue
shared context and its
failing
before
ok
length
before
before
(FAILED - 1)

Failures:

1) RSpec::Issue shared context and its failing length
Failure/Error: before{ puts 'before';raise if @x; @x = true }
RuntimeError:
# ./spec/rspec/issue_spec.rb:8:in `block (4 levels) in '

Finished in 0.0777 seconds
2 examples, 1 failure

Failed examples:

rspec ./spec/rspec/issue_spec.rb:12 # RSpec::Issue shared context and its failing length
```

So the before-hook is run once for the it-example, but twice for the its-example. From my understanding it should only be run once in both.