code school testing with spec(4)

####SHARED EXAMPLE before:

shared_examples_for 'the brianless' do 
end

describe Zombie do 
  let(:zombie) { Zombie.new }
  subject { zombie }
  it { should be_dummy }
  it { should_not be_genius }
end

describe Plant do 
  let(:plant) { Plant.new }
  subject { plant }
  it { should be_dummy }
  it { should_not be_genius }
end

after:

shared_examples_for 'the brainless' do 
  it { should be_dummy }
  it { should_not be_genius }
end

describe Zombie do 
  let(:zombie) { Zombie.new }
  subject { zombie }
  it_behaves_like "the brainless"
end

describe Plant do 
  let(:plant) { Plant.new }
  subject { plant }
  it_behaves_like "the brainless"
end

####METADATA WITH FILTER rspec --tag focus(Add the focus tag to the ‘with a smart zombie’ context block. This way we can run $ rspec –tag focus and just run these examples.)显示出达到达到的状态。 before:

describe Zombie do
  let(:zombie) { Zombie.new }
  subject { zombie }

  context 'with a dummy zombie' do
    before { zombie.iq = 0 }
    it { should be_dummy }
  end

  context 'with a smart zombie' do
    before { zombie.iq = 3 }
    it { should_not be_dummy }
  end
end

after:

describe Zombie do
  let(:zombie) { Zombie.new }
  subject { zombie }

  context 'with a dummy zombie' do
    before { zombie.iq = 0 }
    it { should be_dummy }
  end

  context 'with a smart zombie' , focus: true do 
    before { zombie.iq = 3 }
    it { should_not be_dummy }
  end
end