<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path("../command_helper", __FILE__)

describe "github search" do
  include CommandHelper
  
  specify "search finds multiple results" do
    running :search, "github-gem" do
      # @command.should_receive(:open).with("https://api.github.com/search/repositories?q=github-gem&sort=stars&order=desc")
      stdout.should =~ "defunkt/github-gem\npjhyett/github-gem-builder\n"
    end
  end

  specify "search finds no results" do
    running :search, "xxxxxxxxxx" do
      # @command.should_receive(:open).with("https://api.github.com/search/repositories?q=xxxxxxxxxx&sort=stars&order=desc")
      stdout.should == "No results found\n"
    end
  end

  specify "search shows usage if no arguments given" do
    running :search do
      @command.should_receive(:die).with("Usage: github search [query]").and_return { raise "Died" }
      self.should raise_error(RuntimeError)
    end
  end
end<commit_msg>Update search spec for terminal helper<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require File.expand_path("../command_helper", __FILE__)

describe "github search" do
  include CommandHelper

  specify "search displays on terminal" do
    running :search, "github-gem" do
      @helper.should_receive(:terminal_display)
    end
  end
  
  specify "search finds multiple results" do
    running :search, "github-gem" do
      json = StringIO.new <<-JSON
      {
        "total_count": 211,
        "items": [
          { 
            "id": 1653,
            "full_name": "rlqualls/github-gem",
            "description": "command-line helper"
          },
          { 
            "id": 1,
            "full_name": "octocat/some-gem",
            "description": "some other gem"
          }
        ]
      } 
      JSON

      @command.should_receive(:open).with("https://api.github.com/search/repositories?q=github-gem&sort=stars&order=desc").and_return(json)
      @helper.should_receive(:terminal_display)
    end
  end

  specify "search finds no results" do
    running :search, "xxxxxxxxxxsdfgdfgklj4345" do
      # @command.should_receive(:open).with("https://api.github.com/search/repositories?q=xxxxxxxxxx&sort=stars&order=desc")
      stdout.should == "No results found\n"
    end
  end

  specify "search shows usage if no arguments given" do
    running :search do
      @command.should_receive(:die).with("Usage: github search [query]").and_return { raise "Died" }
      self.should raise_error(RuntimeError)
    end
  end
end
{'fraction_non_alphanumeric': 0.12582268679829656, 'fraction_numerical': 0.004645760743321719, 'mean_word_length': 3.147672552166934, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4806676', 'n_tokens_mistral': 831, 'n_tokens_neox': 783, 'n_words': 172}