-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from sleepingkingstudios/fix/wrap-deferred
Fix/Pass #wrap_deferred block to example group.
- Loading branch information
Showing
6 changed files
with
224 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
spec/integration/deferred/wrapped_contexts_spec.fixture.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'support/integration/deferred/wrapped_contexts' | ||
|
||
RSpec.describe Spec::Models::Rocket do | ||
include RSpec::SleepingKingStudios::Deferred::Consumer | ||
include Spec::Integration::Deferred::WrappedContexts | ||
|
||
subject(:rocket) { described_class.new('Imp IV') } | ||
|
||
wrap_deferred 'when the rocket has been launched' do | ||
it { expect(rocket.launched?).to be true } | ||
|
||
wrap_deferred 'when the payload includes a booster' do | ||
let(:expected_payload) { { booster: true } } | ||
|
||
it { expect(rocket.payload).to be == expected_payload } | ||
end | ||
|
||
wrap_deferred 'when the payload includes a satellite' do | ||
let(:expected_payload) { { satellite: true } } | ||
|
||
it { expect(rocket.payload).to be == expected_payload } | ||
end | ||
|
||
context 'when the rocket has multiple payloads' do | ||
include_deferred 'when the payload includes a booster' | ||
include_deferred 'when the payload includes a satellite' | ||
|
||
let(:expected_payload) { { booster: true, satellite: true } } | ||
|
||
it { expect(rocket.payload).to be == expected_payload } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rspec/sleeping_king_studios/deferred/examples' | ||
|
||
require 'support/sandbox' | ||
|
||
RSpec.describe RSpec::SleepingKingStudios::Deferred::Examples do | ||
let(:fixture_file) do | ||
%w[spec/integration/deferred/wrapped_contexts_spec.fixture.rb] | ||
end | ||
let(:result) do | ||
Spec::Support::Sandbox.run(fixture_file) | ||
end | ||
let(:expected_examples) do | ||
<<~EXAMPLES.lines.map(&:strip) | ||
Spec::Models::Rocket when the rocket has been launched is expected to equal true | ||
Spec::Models::Rocket when the rocket has been launched when the payload includes a booster is expected to be == {:booster=>true} | ||
Spec::Models::Rocket when the rocket has been launched when the payload includes a satellite is expected to be == {:satellite=>true} | ||
Spec::Models::Rocket when the rocket has been launched when the rocket has multiple payloads is expected to be == {:booster=>true, :satellite=>true} | ||
EXAMPLES | ||
end | ||
|
||
it 'should apply the deferred examples', :aggregate_failures do | ||
expect(result.summary).to be == '4 examples, 0 failures' | ||
|
||
expect(result.example_descriptions).to be == expected_examples | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rspec/sleeping_king_studios' | ||
|
||
require 'support/integration/deferred' | ||
|
||
module Spec::Integration::Deferred | ||
module WrappedContexts | ||
include RSpec::SleepingKingStudios::Deferred::Provider | ||
|
||
module WhenTheRocketHasBeenLaunchedContext | ||
include RSpec::SleepingKingStudios::Deferred::Examples | ||
|
||
let?(:launch_site) { 'KSC' } | ||
let?(:payload) { {} } | ||
|
||
before(:example) do | ||
subject.launch(launch_site:, payload:) | ||
end | ||
end | ||
|
||
deferred_context 'when the payload includes a booster' do | ||
let(:payload) { super().merge(booster: true) } | ||
end | ||
|
||
deferred_context 'when the payload includes a satellite' do | ||
let(:payload) { super().merge(satellite: true) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters