Sha256: 3b790b9f9f22024cc9c65832ba35e4aa123a92d21330738d6929177ad28226fd
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require 'spec_helper' module RSpec::Core::SharedExampleGroup describe Collection do # this represents: # # shared_examples "top level group" # # context do # shared_examples "nested level one" # end # # context do # shared_examples "nested level two" # end # let(:examples) do Hash.new { |hash,k| hash[k] = Hash.new }.tap do |hash| hash["main"] = { "top level group" => example_1 } hash["nested 1"] = { "nested level one" => example_2 } hash["nested 2"] = { "nested level two" => example_3 } end end (1..3).each { |num| let("example_#{num}") { double "example #{num}" } } context 'setup with one source, which is the top level' do let(:collection) { Collection.new ['main'], examples } it 'fetches examples from the top level' do expect(collection['top level group']).to eq example_1 end it 'wont fetches examples across the nested context' do expect(collection['nested level two']).to eq nil end end context 'setup with multiple sources' do let(:collection) { Collection.new ['main','nested 1'], examples } it 'fetches examples from the context' do expect(collection['nested level one']).to eq example_2 end it 'fetches examples from main' do expect(collection['top level group']).to eq example_1 end it 'wont fetch examples across the nested context' do expect(collection['nested level two']).to eq nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rspec-core-3.0.0.beta1 | spec/rspec/core/shared_example_group/collection_spec.rb |