forked from RiverGlide/CukeSalad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
190 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.0 | ||
0.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
##!/usr/bin/env ruby | ||
require 'optparse' | ||
require 'cuke_salad/cli' | ||
|
||
OptionParser.new do |opts| | ||
opts.banner = "Usage: cuke_salad [new | configure] project_name" | ||
|
||
begin | ||
opts.parse!(ARGV) | ||
rescue OptionParser::ParseError => e | ||
warn e.message | ||
puts opts | ||
exit 1 | ||
end | ||
end | ||
|
||
if ARGV.empty? | ||
abort "Usage: cuke_salad new <project name>\nOr: cuke_salad configure" | ||
elsif ARGV.first == 'new' | ||
project = ARGV[1] | ||
puts "Creating project #{project}..." | ||
CukeSalad::CLI.create_new_project project | ||
puts "Done!" | ||
elsif ARGV.first == 'configure' | ||
CukeSalad::CLI.configure_existing_project | ||
puts "Done!" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,13 @@ Gem::Specification.new do |s| | |
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["RiverGlide"] | ||
s.date = %q{2011-04-14} | ||
s.date = %q{2011-04-15} | ||
s.default_executable = %q{cuke_salad} | ||
s.description = %q{CukeSalad allows you to focus on the task at hand - expressing examples, the roles involved in those examples and what those roles can do with the product under development.} | ||
s.email = %q{[email protected]} | ||
s.executables = ["cuke_salad"] | ||
s.extra_rdoc_files = [ | ||
"LICENSE", | ||
"README.md" | ||
] | ||
s.files = [ | ||
|
@@ -41,7 +44,10 @@ Gem::Specification.new do |s| | |
"Gemfile", | ||
"Gemfile.lock", | ||
"README.md", | ||
"Rakefile", | ||
"VERSION", | ||
"cucumber.yml", | ||
"cuke_salad.gemspec", | ||
"features/a_new_cuke_salad_project.feature", | ||
"features/define_a_role.feature", | ||
"features/define_a_task.feature", | ||
|
@@ -61,6 +67,7 @@ Gem::Specification.new do |s| | |
"lib/actor.rb", | ||
"lib/codify/const_name.rb", | ||
"lib/cuke_salad.rb", | ||
"lib/cuke_salad/cli.rb", | ||
"lib/director.rb", | ||
"lib/specifics.rb", | ||
"lib/task_author.rb", | ||
|
@@ -92,6 +99,7 @@ Gem::Specification.new do |s| | |
"examples/Calculator/spec/web_calculator_spec.rb", | ||
"spec/actor_spec.rb", | ||
"spec/codify/as_const_name_spec.rb", | ||
"spec/cuke_salad/cli_spec.rb", | ||
"spec/director_spec.rb", | ||
"spec/spec_helper.rb", | ||
"spec/specifics_spec.rb", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
require 'aruba/api' | ||
module CukeSalad | ||
class CLI | ||
|
||
def self.create_new_project project | ||
structure = Structure.new | ||
structure.setup project | ||
end | ||
|
||
def self.configure_existing_project project=nil | ||
`cd #{project}` if project | ||
structure = Structure.new | ||
structure.setup_cucumber_with_cuke_salad | ||
end | ||
|
||
class Structure | ||
include Aruba::Api | ||
|
||
def initialize | ||
set_aruba_path_to_current | ||
end | ||
|
||
def setup project | ||
create_and_navigate_to project | ||
setup_cucumber_with_cuke_salad | ||
end | ||
|
||
def setup_cucumber_with_cuke_salad | ||
create_dir_structure | ||
configure | ||
end | ||
|
||
private | ||
def set_aruba_path_to_current | ||
@dirs = ["./"] | ||
end | ||
|
||
def create_dir_structure | ||
create_cucumber_structure | ||
create_cuke_salad_structure | ||
end | ||
|
||
def create_cucumber_structure | ||
create_and_navigate_to "features" | ||
create_dir "support" | ||
end | ||
|
||
def create_cuke_salad_structure | ||
create_and_navigate_to "lib" | ||
create_and_navigate_to "default" | ||
create_dir "roles" | ||
create_dir "tasks" | ||
cd "../../../" | ||
end | ||
|
||
def configure | ||
cd "features/support" | ||
content = "require 'cuke_salad'\n begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end" | ||
append_to_file "env.rb",content | ||
end | ||
|
||
def create_and_navigate_to directory | ||
create_dir directory | ||
cd directory | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
$:.unshift(File.dirname(__FILE__), ".") | ||
require 'spec_helper' | ||
require 'cuke_salad/cli' | ||
|
||
describe CukeSalad::CLI do | ||
let(:project) { 'Foobar' } | ||
let(:features) { project+'/features'} | ||
|
||
shared_examples_for "setup cuke_salad and cucumber" do | ||
it 'Can create features directory' do | ||
dir_exists?(features).should be_true | ||
end | ||
|
||
it 'can create features/support directory' do | ||
dir_exists?(features+'/support').should be_true | ||
end | ||
|
||
context 'in cuke_salad/features/support' do | ||
let(:file) { features+'/support/env.rb' } | ||
|
||
it 'can create a file env.rb' do | ||
File.exists?(file).should be_true | ||
end | ||
|
||
it 'with a given content' do | ||
content = "require 'cuke_salad'\n begin require 'rspec/expectations'; rescue LoadError; require 'spec/expectations'; end" | ||
IO.read(file).should == content | ||
end | ||
end | ||
|
||
it 'can create lib directory' do | ||
dir_exists?(features+'/lib').should be_true | ||
end | ||
|
||
it 'can create lib/default directory' do | ||
dir_exists?(features+'/lib/default').should be_true | ||
end | ||
|
||
it 'can create features/lib/roles directory' do | ||
dir_exists?(features+'/lib/default/roles').should be_true | ||
end | ||
|
||
it 'can create tasks directory' do | ||
dir_exists?(features+'/lib/default/tasks').should be_true | ||
end | ||
end | ||
|
||
|
||
context 'Create new project Foobar' do | ||
|
||
before(:all) do | ||
cli = CukeSalad::CLI.create_new_project(project) | ||
end | ||
|
||
it "Can create the project directory" do | ||
dir_exists?(project).should be_true | ||
end | ||
|
||
it_should_behave_like "setup cuke_salad and cucumber" | ||
end | ||
|
||
context 'Setup existing project' do | ||
before(:all) do | ||
`cd Foobar` | ||
CukeSalad::CLI.configure_existing_project | ||
end | ||
it_should_behave_like "setup cuke_salad and cucumber" | ||
end | ||
|
||
|
||
def dir_exists? file | ||
File.exists?(file) | ||
end | ||
|
||
after(:all) do | ||
FileUtils.rm_rf project | ||
end | ||
end |