Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add specs for subject/its in a shared context.

  • Loading branch information...
commit 3a4470f8bb5d498977843c54ebbfb5e3a6a766cf 1 parent f430278
@myronmarston myronmarston authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 spec/rspec/core/shared_context_spec.rb
View
27 spec/rspec/core/shared_context_spec.rb
@@ -46,6 +46,33 @@
expect(group.new.foo).to eq('foo')
end
+ it 'supports explicit subjects' do
+ shared = Module.new do
+ extend RSpec::SharedContext
+ subject { 17 }
+ end
+
+ group = RSpec::Core::ExampleGroup.describe do
+ include shared
+ end
+
+ expect(group.new.subject).to eq(17)
+ end
+
+ it 'supports `its` with an implicit subject' do
+ shared = Module.new do
+ extend RSpec::SharedContext
+ its(:size) { should eq 0 }
+ end
+
+ group = RSpec::Core::ExampleGroup.describe(Array) do
+ include shared
+ end
+
+ group.run
+ expect(group.children.first.examples.first.execution_result).to include(:status => "passed")
+ end
+
%w[describe context].each do |method_name|
it "supports nested example groups using #{method_name}" do
shared = Module.new do
Please sign in to comment.
Something went wrong with that request. Please try again.