1# 2# Randomly taken from https://github.com/rspec/rspec-core 3# https://github.com/rspec/rspec-core/blob/master/LICENSE.md 4# 5 6RSpec.describe Order do 7 context "with no items" do 8 it "behaves one way" do 9 # ... 10 end 11 end 12 13 context "with one item" do 14 it "behaves another way" do 15 # ... 16 end 17 end 18end 19 20RSpec.describe Calculator do 21 describe '#add' do 22 it 'returns the sum of its arguments' do 23 expect(Calculator.new.add(1, 2)).to eq(3) 24 end 25 end 26end 27 28# Taken from rspec-core/spec/rspec/core/example_group_spec.rb 29module RSpec::Core 30 RSpec.describe ExampleGroup do 31 %w[ describe context let before it it_behaves_like ].each do |method| 32 context "when calling `#{method}`, an example group API, from within an example" do 33 it "tells the user they are in the wrong scope for that API" do 34 ex = nil 35 36 RSpec.describe do 37 ex = example { __send__(method, "foo") } 38 end.run 39 40 expect(ex).to fail_with(ExampleGroup::WrongScopeError) 41 end 42 end 43 end 44 45 describe Object, "describing nested example_groups", :little_less_nested => 'yep' do 46 end 47 end 48end 49