Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
user stories for test unit
module Test::Unit::UserStory
class UserStoryTestCase < ActionController::IntegrationTest
class << self
attr_accessor :description
alias :it :test
def criteria(name, options = {}, &block)
klass = create_class(name, self, &block)
helper_klass = options[:js] ? CapybaraJavascriptTestHelper : CapybaraTestHelper
klass.send(:include, helper_klass)
klass
end
def background(&block)
define_method(:setup, &block)
end
end
end
def story(name, description, options = {}, &block)
klass = create_class(name, UserStoryTestCase, &block)
klass.description = description
klass
end
def create_class(name, superclass, &block)
klass = Class.new(superclass, &block)
name = name.gsub(/(^\d*|\W)/, ' ').lstrip
klass_name = name.gsub(/(^[a-z]|\s+[a-zA-Z])/).each do |match|
match.lstrip.upcase
end
Object.const_set klass_name, klass
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.