Skip to content

Commit

Permalink
support let in SharedContext
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Oct 29, 2011
1 parent edc2901 commit 5fd8dab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -4,6 +4,7 @@
* --order (Justin Ko)
* Run your examples in random order: `--order rand`
* Pass a seed: `--order random:123`
* SharedContext supports `let` (David Chelimsky)

* Bug fixes
* Make sure the `bar` in `--tag foo:bar` makes it to DRb (Aaron Gibralter)
Expand Down
1 change: 1 addition & 0 deletions lib/rspec/core/shared_context.rb
Expand Up @@ -2,6 +2,7 @@ module RSpec
module Core
module SharedContext
include Hooks
include Let::ClassMethods

def included(group)
[:before, :after].each do |type|
Expand Down
18 changes: 17 additions & 1 deletion spec/rspec/core/shared_context_spec.rb
Expand Up @@ -9,7 +9,7 @@
RSpec::SharedContext
end

it "expose before and after hooks" do
it "supports before and after hooks" do
before_all_hook = false
before_each_hook = false
after_each_hook = false
Expand All @@ -33,4 +33,20 @@
after_each_hook.should be_true
after_all_hook.should be_true
end

it "supports let" do
whatever = nil
shared = Module.new do
extend RSpec::SharedContext
let(:foo) { 'foo' }
end
group = RSpec::Core::ExampleGroup.describe do
include shared
example { whatever = foo }
end

group.run

whatever.should eq('foo')
end
end

0 comments on commit 5fd8dab

Please sign in to comment.