Sha256: 22f188a894b187789a9a7a899e68d1fcace5e743fc2886849171f131b1351ff3

Contents?: true

Size: 865 Bytes

Versions: 3

Compression:

Stored size: 865 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[#{example.path}]", :on_blue)
        example.results.each{|result| say(result, :on_black)}
        i += example.results.size
      end
      say("\nfound #{i} example(s) on #{results.size}/#{examples.size} spec(s)", :on_red)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspex-0.0.4 lib/rspex/cli.rb
rspex-0.0.2 lib/rspex/cli.rb
rspex-0.0.1 lib/rspex/cli.rb