require 'spec_helper' describe 'traversal' do context 'when first step' do before(:all){ @controller = Base::StepOneController.new } describe 'current_step methods' do describe '#current_step' do it 'should be "Step 1"' do get :show expect(subject.current_step.label).to eq 'Step 1' end end describe '#current_step_index' do it 'should be 0' do get :show expect(subject.current_step_index).to eq 0 end end describe '#current_step_name' do it 'should be :step_one' do get :show expect(subject.current_step_name).to eq :step_one end end end describe 'previous_step methods' do describe '#previous_step' do it 'should be nil' do get :show expect(subject.previous_step).to be_nil end end describe '#previous_step_index' do it 'should be nil' do get :show expect(subject.previous_step_index).to be_nil end end describe '#previous_step_name' do it 'should be nil' do get :show expect(subject.previous_step_name).to be_nil end end end describe 'next_step methods' do describe '#next_step' do it 'should "Step 2"' do get :show expect(subject.next_step.label).to eq 'Step 2' end end describe '#next_step_index' do it 'should be 1' do get :show expect(subject.next_step_index).to eq 1 end end describe '#next_step_name' do it 'should be :step_two' do get :show expect(subject.next_step_name).to eq :step_two end end end end context 'when middle step' do before(:all){ @controller = Base::StepTwoController.new } describe 'current_step methods' do describe '#current_step' do it 'should be "Step 2"' do get :show expect(subject.current_step.label).to eq 'Step 2' end end describe '#current_step_index' do it 'should be 1' do get :show expect(subject.current_step_index).to eq 1 end end describe '#current_step_name' do it 'should be :step_one' do get :show expect(subject.current_step_name).to eq :step_two end end end describe 'previous_step methods' do describe '#previous_step' do it 'should be "Step 1"' do get :show expect(subject.previous_step.label).to eq 'Step 1' end end describe '#previous_step_index' do it 'should be 0' do get :show expect(subject.previous_step_index).to eq 0 end end describe '#previous_step_name' do it 'should be :step_one' do get :show expect(subject.previous_step_name).to eq :step_one end end end describe 'next_step methods' do describe 'next_step' do it 'should "Step 3"' do get :show expect(subject.next_step.label).to eq 'Step 3' end end describe 'next_step_index' do it 'should be 2' do get :show expect(subject.next_step_index).to eq 2 end end describe '#next_step_name' do it 'should be :step_three' do get :show expect(subject.next_step_name).to eq :step_three end end end end context 'when last step' do before(:all){ @controller = Base::StepThreeController.new } describe 'current_step methods' do describe 'current_step' do it 'should be "Step 3"' do get :show expect(subject.current_step.label).to eq 'Step 3' end end describe '#current_step_index' do it 'should be 2' do get :show expect(subject.current_step_index).to eq 2 end end describe '#current_step_name' do it 'should be :step_three' do get :show expect(subject.current_step_name).to eq :step_three end end end describe 'previous_step methods' do describe 'previous_step' do it 'should be "Step 2"' do get :show expect(subject.previous_step.label).to eq 'Step 2' end end describe '#previous_step_index' do it 'should be 1' do get :show expect(subject.previous_step_index).to eq 1 end end describe '#previous_step_name' do it 'should be :step_two' do get :show expect(subject.previous_step_name).to eq :step_two end end end describe 'next_step methods' do describe 'next_step' do it 'should be nil' do get :show expect(subject.next_step).to be_nil end end describe 'next_step_index' do it 'should be nil' do get :show expect(subject.next_step_index).to be_nil end end describe '#next_step_name' do it 'should be nil' do get :show expect(subject.next_step_name).to be_nil end end end end end