Last active
January 4, 2016 01:29
-
-
Save jrab89/8548631 to your computer and use it in GitHub Desktop.
Is there a way I can write the second context more concisely by referencing the first?
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
describe MyClass | |
let(:instance){MyClass.new} | |
describe '#myMethod' do | |
let(:input){ [1] } | |
context 'with input' do | |
it 'does stuff' do | |
instance.should_receive(:foo) | |
instance.should_receive(:bar) | |
instance.myMethod(input).should eql true | |
end | |
end | |
context 'with slightly different input' do | |
before do | |
input << 2 | |
end | |
it 'does more stuff' do | |
instance.should_receive(:foo) | |
instance.should_receive(:bar) | |
instance.should_receive(:otherMethod) | |
instance.myMethod(input).should eql true | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A few things:
input
across contexts. The reason is they are not meant to be the exact sameinput
. They represent contextually different values; thus I do not view them as extractable beyond each context's specs.