Skip to content

Commit

Permalink
updating to rubyspec head
Browse files Browse the repository at this point in the history
  • Loading branch information
jredville committed Aug 4, 2008
2 parents e125a7a + de768fc commit 4fdd80b
Show file tree
Hide file tree
Showing 19 changed files with 1,304 additions and 604 deletions.
35 changes: 17 additions & 18 deletions lib/mspec/commands/mkspec.rb
Expand Up @@ -3,9 +3,9 @@
MSPEC_HOME = File.expand_path(File.dirname(__FILE__) + '/../../..')

require 'fileutils'
require 'optparse'
require 'rbconfig'
require 'mspec/version'
require 'mspec/utils/options'
require 'mspec/utils/name_map'


Expand All @@ -22,35 +22,34 @@ def initialize
end

def options(argv=ARGV)
options = OptionParser.new
options.version = MSpec::VERSION
options.banner = "mkspec [options]"
options.separator ""
options = MSpecOptions.new "mkspec [options]"

options.on("-c", "--constant CONSTANT", String,
options.on("-c", "--constant", "CONSTANT",
"Class or Module to generate spec stubs for") do |name|
config[:constants] << name
end
options.on("-b", "--base DIR", String,
options.on("-b", "--base", "DIR",
"Directory to generate specs into") do |directory|
config[:base] = File.expand_path directory
end
options.on("-r", "--require LIBRARY", String,
options.on("-r", "--require", "LIBRARY",
"A library to require") do |file|
config[:requires] << file
end

options.separator "\n How might this work in the real world?\n"
options.separator " 1. To create spec stubs for every class or module in Object\n"
options.separator " $ mkspec\n"
options.separator " 2. To create spec stubs for Fixnum\n"
options.separator " $ mkspec -c Fixnum\n"
options.separator " 3. To create spec stubs for Complex in 'superspec/complex'\n"
options.separator " $ mkspec -c Complex -rcomplex -b superspec"
options.separator ""
options.version MSpec::VERSION
options.help

options.doc "\n How might this work in the real world?\n"
options.doc " 1. To create spec stubs for every class or module in Object\n"
options.doc " $ mkspec\n"
options.doc " 2. To create spec stubs for Fixnum\n"
options.doc " $ mkspec -c Fixnum\n"
options.doc " 3. To create spec stubs for Complex in 'superspec/complex'\n"
options.doc " $ mkspec -c Complex -rcomplex -b superspec"
options.doc ""

options.parse argv
rescue OptionParser::ParseError => e
rescue MSpecOptions::ParseError => e
puts options
puts
puts e
Expand Down
60 changes: 30 additions & 30 deletions lib/mspec/commands/mspec-ci.rb
Expand Up @@ -2,49 +2,49 @@

$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'optparse'
require 'mspec/version'
require 'mspec/utils/options'
require 'mspec/utils/script'


class MSpecCI < MSpecScript
def options(argv=ARGV)
options = MSpecOptions.new config, "ci", "", 28, " "
options = MSpecOptions.new "mspec ci [options] (FILE|DIRECTORY|GLOB)+", 30, config

options.separator " Ask yourself:"
options.separator " 1. How to run the specs?"
options.separator " 2. How to display the output?"
options.separator " 3. What action to perform?"
options.separator " 4. When to perform it?"
options.doc " Ask yourself:"
options.doc " 1. How to run the specs?"
options.doc " 2. How to display the output?"
options.doc " 3. What action to perform?"
options.doc " 4. When to perform it?"

options.separator "\n How to run the specs"
options.add_config { |f| load f }
options.add_name
options.add_pretend
options.add_interrupt
options.doc "\n How to run the specs"
options.configure { |f| load f }
options.name
options.pretend
options.interrupt

options.separator "\n How to display their output"
options.add_formatters
options.add_verbose
options.doc "\n How to display their output"
options.formatters
options.verbose

options.separator "\n What action to perform"
options.add_actions
options.doc "\n What action to perform"
options.actions

options.separator "\n When to perform it"
options.add_action_filters
options.doc "\n When to perform it"
options.action_filters

options.separator "\n Help!"
options.add_version
options.add_help
options.doc "\n Help!"
options.version MSpec::VERSION
options.help

options.separator "\n How might this work in the real world?"
options.separator "\n 1. To simply run the known good specs"
options.separator "\n $ mspec ci"
options.separator "\n 2. To run a subset of the known good specs"
options.separator "\n $ mspec ci path/to/specs"
options.separator "\n 3. To start the debugger before the spec matching 'this crashes'"
options.separator "\n $ mspec ci --spec-debug -S 'this crashes'"
options.separator ""
options.doc "\n How might this work in the real world?"
options.doc "\n 1. To simply run the known good specs"
options.doc "\n $ mspec ci"
options.doc "\n 2. To run a subset of the known good specs"
options.doc "\n $ mspec ci path/to/specs"
options.doc "\n 3. To start the debugger before the spec matching 'this crashes'"
options.doc "\n $ mspec ci --spec-debug -S 'this crashes'"
options.doc ""

@patterns = options.parse argv
@patterns = config[:ci_files] if @patterns.empty?
Expand Down
90 changes: 45 additions & 45 deletions lib/mspec/commands/mspec-run.rb
Expand Up @@ -2,60 +2,60 @@

$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')

require 'optparse'
require 'mspec/version'
require 'mspec/utils/options'
require 'mspec/utils/script'


class MSpecRun < MSpecScript
def options(argv=ARGV)
options = MSpecOptions.new config, "run", "", 28, " "

options.separator " Ask yourself:"
options.separator " 1. What specs to run?"
options.separator " 2. How to modify the execution?"
options.separator " 3. How to display the output?"
options.separator " 4. What action to perform?"
options.separator " 5. When to perform it?"

options.separator "\n What specs to run"
options.add_filters

options.separator "\n How to modify the execution"
options.add_config { |f| load f }
options.add_name
options.add_randomize
options.add_pretend
options.add_interrupt

options.separator "\n How to display their output"
options.add_formatters
options.add_verbose

options.separator "\n What action to perform"
options.add_actions
options.add_verify

options.separator "\n When to perform it"
options.add_action_filters

options.separator "\n Help!"
options.add_version
options.add_help

options.separator "\n How might this work in the real world?"
options.separator "\n 1. To simply run some specs"
options.separator "\n $ mspec path/to/the/specs"
options.separator " mspec path/to/the_file_spec.rb"
options.separator "\n 2. To run specs tagged with 'fails'"
options.separator "\n $ mspec -g fails path/to/the_file_spec.rb"
options.separator "\n 3. To start the debugger before the spec matching 'this crashes'"
options.separator "\n $ mspec --spec-debug -S 'this crashes' path/to/the_file_spec.rb"
options.separator ""
options = MSpecOptions.new "mspec run [options] (FILE|DIRECTORY|GLOB)+", 30, config

options.doc " Ask yourself:"
options.doc " 1. What specs to run?"
options.doc " 2. How to modify the execution?"
options.doc " 3. How to display the output?"
options.doc " 4. What action to perform?"
options.doc " 5. When to perform it?"

options.doc "\n What specs to run"
options.filters

options.doc "\n How to modify the execution"
options.configure { |f| load f }
options.name
options.randomize
options.pretend
options.interrupt

options.doc "\n How to display their output"
options.formatters
options.verbose

options.doc "\n What action to perform"
options.actions
options.verify

options.doc "\n When to perform it"
options.action_filters

options.doc "\n Help!"
options.version MSpec::VERSION
options.help

options.doc "\n How might this work in the real world?"
options.doc "\n 1. To simply run some specs"
options.doc "\n $ mspec path/to/the/specs"
options.doc " mspec path/to/the_file_spec.rb"
options.doc "\n 2. To run specs tagged with 'fails'"
options.doc "\n $ mspec -g fails path/to/the_file_spec.rb"
options.doc "\n 3. To start the debugger before the spec matching 'this crashes'"
options.doc "\n $ mspec --spec-debug -S 'this crashes' path/to/the_file_spec.rb"
options.doc ""

@patterns = options.parse argv
if @patterns.empty?
puts options.parser
puts options
puts "No files specified."
exit 1
end
Expand Down
74 changes: 37 additions & 37 deletions lib/mspec/commands/mspec-tag.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby

require 'optparse'
require 'mspec/version'
require 'mspec/utils/options'
require 'mspec/utils/script'

Expand All @@ -15,45 +15,45 @@ def initialize
end

def options(argv=ARGV)
options = MSpecOptions.new config, "tag", "", 28, " "

options.separator " Ask yourself:"
options.separator " 1. What specs to run?"
options.separator " 2. How to modify the execution?"
options.separator " 3. How to display the output?"
options.separator " 4. What tag action to perform?"
options.separator " 5. When to perform it?"

options.separator "\n What specs to run"
options.add_filters

options.separator "\n How to modify the execution"
options.add_config { |f| load f }
options.add_name
options.add_pretend
options.add_interrupt

options.separator "\n How to display their output"
options.add_formatters
options.add_verbose

options.separator "\n What action to perform and when to perform it"
options.add_tagging

options.separator "\n Help!"
options.add_version
options.add_help

options.separator "\n How might this work in the real world?"
options.separator "\n 1. To add the 'fails' tag to failing specs"
options.separator "\n $ mspec tag path/to/the_file_spec.rb"
options.separator "\n 2. To remove the 'fails' tag from passing specs"
options.separator "\n $ mspec tag --del fails path/to/the_file_spec.rb"
options.separator ""
options = MSpecOptions.new "mspec tag [options] (FILE|DIRECTORY|GLOB)+", 30, config

options.doc " Ask yourself:"
options.doc " 1. What specs to run?"
options.doc " 2. How to modify the execution?"
options.doc " 3. How to display the output?"
options.doc " 4. What tag action to perform?"
options.doc " 5. When to perform it?"

options.doc "\n What specs to run"
options.filters

options.doc "\n How to modify the execution"
options.configure { |f| load f }
options.name
options.pretend
options.interrupt

options.doc "\n How to display their output"
options.formatters
options.verbose

options.doc "\n What action to perform and when to perform it"
options.tagging

options.doc "\n Help!"
options.version MSpec::VERSION
options.help

options.doc "\n How might this work in the real world?"
options.doc "\n 1. To add the 'fails' tag to failing specs"
options.doc "\n $ mspec tag path/to/the_file_spec.rb"
options.doc "\n 2. To remove the 'fails' tag from passing specs"
options.doc "\n $ mspec tag --del fails path/to/the_file_spec.rb"
options.doc ""

@patterns = options.parse argv
if @patterns.empty?
puts options.parser
puts options
puts "No files specified."
exit 1
end
Expand Down

0 comments on commit 4fdd80b

Please sign in to comment.