Sha256: 800105e1f51cbe840280faa9fe8581264dee965eaf0950418abcbd3ed0d5cabf

Contents?: true

Size: 911 Bytes

Versions: 2

Compression:

Stored size: 911 Bytes

Contents

require "rspex"
require 'thor'

module RSpex
  class CLI < Thor
    desc "it 'keyword'", "search keyword from 'it' sentence."
    def it(word)
      search word, 'it'
    end

    desc "context 'keyword'", "search keyword from 'context' sentence."
    def context(word)
      search word, 'context'
    end
    
    desc "describe 'keyword'", "search keyword from 'describe' sentence."
    def describe(word)
      search word, 'describe'
    end

    private
    def search word, type
      i = 0
      examples = RSpex.examples
      results = examples.search(word, type)
      results.each do |example|
        say("\n", :black)
        say("[#{example.path}]", :on_blue)
        example.results.each{|result| say(result, :on_black)}
        i += example.results.size
      end
      say("\n", :black)
      say("found #{i} example(s) on #{results.size}/#{examples.size} spec(s)", :on_red)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspex-0.0.6 lib/rspex/cli.rb
rspex-0.0.5 lib/rspex/cli.rb