merb_stories 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Daniel Neighman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,55 @@
1
+ merb_stories
2
+ =================
3
+
4
+ A plugin for the Merb framework that provides generators for rSpec Text Stories.
5
+
6
+ This is currently only very basic support. It supports the same helper methods that are available
7
+ in Merbs current spec helpers.
8
+
9
+ SETUP:
10
+ in config/dependencies.rb include this line
11
+
12
+ dependency "merb_stories"
13
+
14
+ USAGE:
15
+
16
+ -- Generating Stories
17
+
18
+ ruby script/generate story my_story
19
+
20
+ OR for more organised stories
21
+
22
+ ruby script/generate story group/sub_group/my_story
23
+
24
+ This allows you to divide your stories up into different directories. You can have as many or few
25
+ sub directories as you like
26
+
27
+ -- Running the stories
28
+
29
+ merb_stories includes a rake file that allows you to run you stories
30
+
31
+ EXAMPLE
32
+ rake story[my_story]
33
+
34
+ or
35
+
36
+ rake story[group/sub_group/my_story]
37
+
38
+ or to run all stories
39
+
40
+ rake story[all]
41
+
42
+ EXTENDING THE FUNCTIONALITY
43
+
44
+ To make your own custom modules available to the stories you write you need to include them in the MerbStory class.
45
+ Any methods you define on your MerbStory class will be available.
46
+
47
+ EXAMPLE
48
+ In stories/helper.rb
49
+
50
+ class MerbStory
51
+ include MyExtraHelper
52
+ end
53
+
54
+
55
+
@@ -0,0 +1,58 @@
1
+ require "rake"
2
+ require "rake/clean"
3
+ require "rake/gempackagetask"
4
+ require "rake/rdoctask"
5
+ require "rake/testtask"
6
+ require "spec/rake/spectask"
7
+ require "fileutils"
8
+ include FileUtils
9
+
10
+ PLUGIN = "merb_stories"
11
+ NAME = "merb_stories"
12
+ VERSION = "0.1.0"
13
+ AUTHOR = "Daniel Neighman"
14
+ EMAIL = "has.sox@gmail.com"
15
+ HOMEPAGE = "http://merb-plugins.rubyforge.org/merb_stories/"
16
+ SUMMARY = "Merb plugin that provides basic support for rSpec text stories"
17
+
18
+ CLEAN.include ["**/.*.sw?", "*.gem", ".config"]
19
+
20
+ windows = (PLATFORM =~ /win32|cygwin/)
21
+ SUDO = windows ? "" : "sudo"
22
+
23
+
24
+ spec = Gem::Specification.new do |s|
25
+ s.name = NAME
26
+ s.version = VERSION
27
+ s.platform = Gem::Platform::RUBY
28
+ s.has_rdoc = true
29
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
30
+ s.summary = SUMMARY
31
+ s.description = s.summary
32
+ s.author = AUTHOR
33
+ s.email = EMAIL
34
+ s.homepage = HOMEPAGE
35
+ s.add_dependency('merb', '>= 0.4.0')
36
+ s.require_path = 'lib'
37
+ s.autorequire = PLUGIN
38
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs,rspec_generators}/**/*")
39
+ end
40
+
41
+
42
+
43
+ Rake::GemPackageTask.new(spec) do |pkg|
44
+ pkg.gem_spec = spec
45
+ end
46
+
47
+ task :install => [:package, :uninstall] do
48
+ sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
49
+ end
50
+
51
+ desc "Run :clean and uninstall the .gem"
52
+ task :uninstall => :clean do
53
+ begin
54
+ sh %{#{SUDO} gem uninstall #{NAME}}
55
+ rescue
56
+ puts "#{NAME} gem not found"
57
+ end
58
+ end
data/TODO ADDED
@@ -0,0 +1,2 @@
1
+ TODO:
2
+ Get tasks inclusion fixed in Merb so that you don't need to have this as a dependency
@@ -0,0 +1,12 @@
1
+ # make sure we're running inside Merb
2
+ if defined?(Merb::Plugins)
3
+ # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
4
+ Merb::Plugins.add_rakefiles "merb_stories/merbtasks"
5
+ end
6
+
7
+ # Don't inlcude anything if we're not in the test environment
8
+ if Merb.environment == "test"
9
+ Merb::BootLoader.after_app_loads do
10
+ require File.join(File.dirname(__FILE__), "merb_stories", "merb_story" )
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ class MerbStory
2
+ include Merb::Test::Helper
3
+ include Merb::Test::RspecMatchers
4
+ end
@@ -0,0 +1,4 @@
1
+ desc "Run the given story. rake story[story_name]"
2
+ task :story, :story_name do |t,args|
3
+ sh %{ruby stories/stories/#{args.story_name}.rb}
4
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,64 @@
1
+ class StoryGenerator < RubiGen::Base
2
+
3
+ attr_reader :story_name, :story_path, :step_name, :path_levels
4
+
5
+ def initialize(runtime_args, runtime_options = {})
6
+ super
7
+ usage if args.empty?
8
+ name = args.shift.split "/"
9
+ @story_name = name.pop
10
+ @story_path = name.empty? ? nil : name.join("/")
11
+ @step_name = @story_path.nil? ? @story_name : (@story_path.gsub("/", "_") + "_" + @story_name)
12
+ @path_levels = @story_path.nil? ? 0 : @story_path.split("/").size
13
+ extract_options
14
+ end
15
+
16
+ def manifest
17
+ record do |m|
18
+ m.directory 'stories'
19
+
20
+ m.template "helper.rb", File.join("stories", "helper.rb")
21
+
22
+ m.directory 'stories/steps'
23
+ m.directory File.join('stories/stories', "#{@story_path}")
24
+
25
+ if( !File.exists?('stories/stories/all.rb') ) # So it doesn't get destroyed when you do a destroy script
26
+ m.template 'all.rb', "stories/stories/all.rb"
27
+ end
28
+ m.template 'step.rb', File.join('stories', 'steps', "#{@step_name}.rb")
29
+ m.template 'story.rb', File.join('stories/stories', "#{@story_path}", "#{@story_name}.rb")
30
+ m.template 'story', File.join('stories/stories', "#{@story_path}", "#{@story_name}")
31
+ end
32
+ end
33
+
34
+ protected
35
+ def banner
36
+ <<-EOS
37
+ Creates a stub for a rSpec text story spec in merb.
38
+
39
+ USAGE: #{$0} #{spec.name} my_story"
40
+
41
+ EXAMPLE:
42
+ #{$0} #{spec.name} my_story
43
+ #{$0} #{spec.name} story_group/specific_story
44
+ EOS
45
+ end
46
+
47
+ def add_options!(opts)
48
+ # opts.separator ''
49
+ # opts.separator 'Options:'
50
+ # For each option below, place the default
51
+ # at the top of the file next to "default_options"
52
+ # opts.on("-a", "--author=\"Your Name\"", String,
53
+ # "Some comment about this option",
54
+ # "Default: none") { |options[:author]| }
55
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
56
+ end
57
+
58
+ def extract_options
59
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
60
+ # Templates can access these value via the attr_reader-generated methods, but not the
61
+ # raw instance variable value.
62
+ # @author = options[:author]
63
+ end
64
+ end
@@ -0,0 +1,4 @@
1
+ dir = File.dirname(__FILE__)
2
+ Dir[File.expand_path("#{dir}/**/*.rb")].uniq.each do |file|
3
+ require file
4
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'spec/rake/spectask'
3
+ require File.join(File.dirname(__FILE__), "..", "spec", "spec_helper")
4
+ require 'spec/mocks'
5
+ require 'spec/story'
6
+
7
+ require 'merb_stories'
8
+
9
+ class MerbStory
10
+ # Include your custom helpers here
11
+ end
12
+
13
+ Dir['stories/steps/**/*.rb'].each do |steps_file|
14
+ require steps_file
15
+ end
@@ -0,0 +1,3 @@
1
+ steps_for(:<%= step_name %>) do
2
+
3
+ end
@@ -0,0 +1,7 @@
1
+ Story: Some story about <%= story_name %>
2
+
3
+ As a ...
4
+ I want to ...
5
+ So that ...
6
+
7
+ Scenario: ...
@@ -0,0 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), "../<%= "../" * path_levels %>helper")
2
+
3
+ with_steps_for :<%= step_name %> do
4
+ run File.expand_path(__FILE__).gsub(".rb",""), :type => MerbStory
5
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: merb_stories
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Neighman
8
+ autorequire: merb_stories
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-01-28 00:00:00 +11:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: merb
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.4.0
23
+ version:
24
+ description: Merb plugin that provides basic support for rSpec text stories
25
+ email: has.sox@gmail.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - README
32
+ - LICENSE
33
+ - TODO
34
+ files:
35
+ - LICENSE
36
+ - README
37
+ - Rakefile
38
+ - TODO
39
+ - lib/merb_stories
40
+ - lib/merb_stories/merb_story.rb
41
+ - lib/merb_stories/merbtasks.rb
42
+ - lib/merb_stories.rb
43
+ - rspec_generators/story
44
+ - rspec_generators/story/story_generator.rb
45
+ - rspec_generators/story/templates
46
+ - rspec_generators/story/templates/all.rb
47
+ - rspec_generators/story/templates/helper.rb
48
+ - rspec_generators/story/templates/step.rb
49
+ - rspec_generators/story/templates/story
50
+ - rspec_generators/story/templates/story.rb
51
+ - rspec_generators/story/USAGE
52
+ has_rdoc: true
53
+ homepage: http://merb-plugins.rubyforge.org/merb_stories/
54
+ post_install_message:
55
+ rdoc_options: []
56
+
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ requirements: []
72
+
73
+ rubyforge_project:
74
+ rubygems_version: 1.0.1
75
+ signing_key:
76
+ specification_version: 2
77
+ summary: Merb plugin that provides basic support for rSpec text stories
78
+ test_files: []
79
+