Sha256: 82cc30a8bb877d6ae2c29b9f56f3b2ca216f68da98dfb9435d38e673cabf0682

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 KB

Contents

require File.expand_path("../src/myrurema", File.dirname(__FILE__))

class MyRurema
  def sh(cmd, opt={})
    @cmds ||= []
    @cmds << cmd
  end
  attr_reader :cmds

  def exit; end
end

CASES = {
  "rurema --init" => [
    %r{svn co .*doctree},
    %r{svn co .*bitclust},
    %r{bitclust.*init},
    %r{bitclust.*update},
  ],

  "rurema --init --rubyver=1.8.7" => [
    %r{bitclust.*init version=1.8.7}
  ],

  "rurema --init --ruremadir=/tmp" => [
    %r{svn co .*/tmp}
  ],

  "rurema --update" => [
    %r{svn up},
    %r{bitclust.*update}
  ],

  "rurema Array" => [
    %r{refe.*Array},
  ],

  "rurema --server" => [
    %r{standalone},
  ],

  "rurema --server --port=9898" => [
    %r{standalone.*--port=9898},
  ],

  "rurema --server --browser" => [
    %r{standalone},
    %r{(start|open) http://localhost:}
  ],

  "rurema --preview" => [
    %r{cd .*doctree/refm/api/src},
  ],

  "rurema --preview _builtin/Array" => [
    %r{bc-tohtml.*_builtin/Array .*rurema_preview.html},
  ],

  "rurema --preview _builtin/Array Array#pop" => [
    %r{bc-tohtml.*_builtin/Array --target=Array#pop.*rurema_preview.html},
  ],

  "rurema --preview Array --browser" => [
    %r{bc-tohtml},
    %r{(start|open) .*rurema_preview.html}
  ],
  "rurema --list" => [
    %r{refe.*-l},
  ],
}

describe MyRurema do
  it "should execute expected commands" do
    CASES.each do |command, expects|
      opt = Options.new(command.split[1..-1])
      my = MyRurema.new(opt)
      my.run

      cmds = my.cmds
      i = 0
      expects.each do |pattern|
        pattern.should satisfy{
          i = cmds[i..-1].index{|cmd| pattern =~ cmd}
          not i.nil?
        }
        i += 1
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
myrurema-0.2.0 spec/commands.rb