Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

start an initial cuke-set.

  • Loading branch information...
commit 44617a532bef6771e674af62c40e06eac2959c58 1 parent 1b6f4a1
@cowboyd authored
View
92 features/create-new-plugin.feature
@@ -5,86 +5,14 @@ Creating a new Ruby plugin for Jenkins needs to be as simple as running a single
that will generate a project skeleton. This skeleton will come complete with git repository and all
the goodies that you need to do your plugin develompent.
-Background: Creating a brand new Jenkins Ruby Plugin
- Given I've run "jenkins-plugin create newplugin"
-
Scenario: The directory skeleton is generated
- Then I should see this structure
- """
- [-] newplugin
- | [+] .git
- | .gitignore
- | Gemfile
- | Rakefile
- | [-] lib
- | [-] newplugin
- | | | version.rb
- | | newplugin.rb
- | [-] spec
- | | spec_helper.rb
- | [-] plugin
- | | [+] models
- | | [+] views
- """
-
-Scenario: The .gitignore contents
- When I open ".gitignore"
- Then I should see
- """
-.bundle
-.rvmrc
-.rspec
- """
-
-Scenario: The Gemfile contents
- When I open "Gemfile"
- Then I should see
- """
-source :rubygems
-
-gem "jenkins-war"
-gem "jenkins-plugins"
- """
-
-Scenario: The Rakefile contents
- When I open "Rakefile"
- Then I should see
- """
-require 'jenkins/rake'
-Jenkins::Rake.install_tasks
- """
-
-Scenario: The plugin module contents
- When I open "lib/newplugin.rb"
- Then I should see
- """
-module Newplugin
-
- def self.start
- #do any startup when this plugin initializes
- end
-
- def self.stop
- #perform any necessary cleanup when this plugin is shut down.
- end
-end
- """
-
-Scenario: The version file is generated
- When I open "lib/newplugin/version.rb"
- Then I should see
- """
-
-module Newplugin
- VERSION = 0.0.1
-end
- """
-
-Scenario: The spec_helper is created
- When I open "spec/spec_helper.rb"
- Then I should see
- """
- $:.unshift(Pathname(__FILE__).dirname.join('../lib'))
- require 'newplugin'
- """
-
+ When I run "jpi new newplugin"
+ # Then I should see this structure
+ # """
+ # [-] newplugin
+ # | [+] .git
+ # | .gitignore
+ # | Gemfile
+ # | Rakefile
+ # | newplugin.pluginspec
+ # """
View
7 features/support/create_new_plugin_steps.rb
@@ -0,0 +1,7 @@
+When /^I run "([^"]*)"$/ do |cmd|
+ run cmd
+end
+
+Then /^I should see this structure$/ do |structure|
+ fail "no match" unless DirectoryStructure.new(structure).matches? work_dir
+end
View
49 features/support/directory_structure.rb
@@ -0,0 +1,49 @@
+
+class DirectoryStructure
+ def initialize(structure)
+
+ @root = context = DirChild.new('.')
+
+ structure.each_line do |line|
+ if line =~ /(\[[-+]\]|\|)?\s+(\.?\w+)$/
+ op, name = $1, $2
+ case op
+ when "[+]"
+ context.add(DirChild.new name)
+ when "[-]"
+ new_context = DirChild.new name
+ context.add(new_context)
+ context = new_context
+ when "|"
+ context.add(FileChild.new name)
+ end
+ end
+ end
+ end
+
+ def matches?(dir)
+ @root.matches?(dir)
+ end
+
+ Entry = Struct.new(:name)
+
+ class DirChild < Entry
+ def initialize(name)
+ super(name)
+ @entries = []
+ end
+
+ def add(entry)
+ @entries << entries
+ end
+
+ def matches?(realdir)
+ entries = Dir.new(realdir).entries
+ !@entries.detect {|e| !entries.map{|e| File.basename(e)}.member?(e)}
+ end
+ end
+
+ class FileChild < Entry
+
+ end
+end
View
20 features/support/work.rb
@@ -0,0 +1,20 @@
+module Work
+ def run cmd
+ Dir.chdir(work_dir) do
+ root = Pathname(__FILE__).join('..', '..', '..')
+ full_cmd = "ruby -rubygems -I #{root.join('lib')} -S #{root.join('bin',cmd)}"
+ system(full_cmd) or fail "failed to run command #{cmd}"
+ end
+ end
+
+ def work_dir
+ @work_dir ||= File.expand_path("tmp/work")
+ end
+end
+
+Before do
+ FileUtils.rm_rf work_dir
+ FileUtils.mkdir_p work_dir
+end
+
+World(Work)
Please sign in to comment.
Something went wrong with that request. Please try again.