Permalink
Browse files

Implement the story generator.

  • Loading branch information...
1 parent 2813a28 commit 13fef58292448fbe98c6c0f238fd451a528e1527 @avh4 avh4 committed Jul 5, 2008
@@ -2,25 +2,27 @@ class StoryGenerator < RubiGen::Base
default_options :author => nil
- attr_reader :name
+ attr_reader :name, :class_name
def initialize(runtime_args, runtime_options = {})
super
usage if args.empty?
@name = args.shift
+ @class_name = @name.camelcase
extract_options
end
def manifest
record do |m|
# Ensure appropriate folder(s) exists
- m.directory 'some_folder'
+ m.directory 'stories'
+ m.directory 'stories/steps'
# Create stubs
- # m.template "template.rb", "some_file_after_erb.rb"
- # m.template_copy_each ["template.rb", "template2.rb"]
- # m.file "file", "some_file_copied"
- # m.file_copy_each ["path/to/file", "path/to/file2"]
+ m.file "story_helper.rb", "stories/story_helper.rb"
+ m.template "story", "stories/#{name}_story"
+ m.template "story.rb", "stories/#{name}_story.rb"
+ m.template "steps.rb", "stories/steps/#{name}_steps.rb"
end
end
@@ -0,0 +1,8 @@
+require "<%= class_name %>.bundle"
+OSX::ns_import :<%= class_name %>
+
+steps_for(:<%= name %>) do
+ Given "a <%= class_name %> instance" do
+ @tame = OSX::<%= class_name %>.alloc.init
+ end
+end
@@ -0,0 +1,13 @@
+Story: <%= name %>
+ As a ___
+ I want ___
+ So that ___
+
+ Scenario: <%= name %>
+ Given a <%= class_name => instance
+ And ___
+
+ When ___
+
+ Then ___
+
@@ -0,0 +1,5 @@
+require File.dirname(__FILE__) + "/story_helper"
+
+with_steps_for(:<%= name =>) do
+ run_local_story "<%= name =>_story"
+end
@@ -0,0 +1,15 @@
+require "rubygems"
+require "spec/story"
+require "ruby-debug"
+
+require "osx/cocoa"
+$:.unshift File.dirname(__FILE__) + "/../build/bundles"
+
+dir = File.dirname(__FILE__)
+Dir[File.expand_path("#{dir}/steps/*.rb")].uniq.each do |file|
+ require file
+end
+
+def run_local_story(filename, options={})
+ run File.join(File.dirname(__FILE__), filename), options
+end

0 comments on commit 13fef58

Please sign in to comment.