Sha256: 17f56b74d84154057545d6886de9833ea6808d5f0841e290fae36af7bd59ab2f

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module CukeTest
	module CucumberMatchers
		class PassCuke
			def matches?(target)
				@target = target
				!!target.match(/[0-9]+ scenarios? \([0-9]+ passed\)/)
			end
			
			def failure_message
				message('to pass')
			end
			
			def negative_failure_message
				message('not to pass')
			end
			
			private
			
			def message(infinitive)
				"Expected Cucumber scenario(s) #{infinitive}. Cucumber output:\n\n" + @target
			end
		end
		
		def pass_cuke
			PassCuke.new
		end
		
		class FailCuke
			def initialize(step = nil)
				@step = step
			end
			
			def matches?(target)
				@target = target
				target.match(/[0-9]+ scenarios? \([0-9]+ failed(, [0-9]+ passed)?\)/) and
					(@step.nil? or target.match(/in `#{@step}'/))
			end
			
			def failure_message
				message('to fail')
			end
			
			def negative_failure_message
				message('not to fail')
			end
			
			private
			
			def message(infinitive)
				"Expected Cucumber scenario(s) #{infinitive}#{step_message}. Cucumber output:\n\n" + @target
			end
			
			def step_message
				@step ? %Q{ on step "#{@step}"} : nil
			end
		end
		
		def fail_cuke(step = nil)
			FailCuke.new(step)
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cuke-test-0.0.1 lib/cuke-test/cucumber_matchers.rb