require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe CukeTest do include CukeTest def spec_dir File.expand_path(File.dirname(__FILE__)) end def features_path(filename) File.join(spec_dir, 'features', filename) end describe '#feature and #pass_cuke' do it 'matches a passing feature' do feature(features_path('success.feature')).should pass_cuke end it 'does not match a failing feature' do feature(features_path('failure.feature')).should_not pass_cuke end end describe '#feature and #fail_cuke' do it 'matches a failing feature' do feature(features_path('failure.feature')).should fail_cuke('And the test fails') end it 'does not match a passing feature' do feature(features_path('success.feature')).should_not fail_cuke end it 'does not match a feature that fails on the wrong step' do feature(features_path('failure_on_wrong_step.feature')).should_not fail_cuke('And the test fails') end end describe '#scenario and #pass_cuke' do it 'matches a passing scenario' do scenario(features_path('success_and_failure.feature'), 'success').should pass_cuke end it 'does not match a failing scenario' do scenario(features_path('success_and_failure.feature'), 'failure').should_not pass_cuke end end describe '#scenario and #fail_cuke' do it 'matches a failing scenario' do scenario(features_path('success_and_failure.feature'), 'failure').should fail_cuke('And the test fails') end it 'does not match a passing scenario' do scenario(features_path('success_and_failure.feature'), 'success').should_not fail_cuke end it 'does not match a scenario that fails on the wrong step' do scenario(features_path('success_and_failure.feature'), 'failure on wrong step').should_not fail_cuke('And the test fails') end end describe '.config' do it 'can set the features path' do CukeTest.config.features_path = File.join(File.expand_path(File.dirname(__FILE__)), 'features') feature('success.feature').should pass_cuke end end it 'can handle Cucumber args with spaces' do scenario(features_path('success_and_failure.feature'), 'failure on wrong step').should fail_cuke('And the test fails on the wrong step') end end