Sha256: dd5f52bffa978e61f779a9be94d0924840213c1028207c1982f7936eb797478f
Contents?: true
Size: 1.67 KB
Versions: 14
Compression:
Stored size: 1.67 KB
Contents
require 'test_helper' module Gemdiff class RepoFinderTest < MiniTest::Spec describe ".github_url" do it "returns github url from local gemspec" do RepoFinder.stubs find_local_gemspec: "homepage: http://github.com/rails/arel" RepoFinder.stubs last_shell_command_success?: true assert_equal "http://github.com/rails/arel", RepoFinder.github_url("arel") end it "returns github url from remote gemspec" do RepoFinder.stubs find_local_gemspec: "" RepoFinder.stubs last_shell_command_success?: false RepoFinder.stubs find_remote_gemspec: "homepage: http://github.com/rails/arel" assert_equal "http://github.com/rails/arel", RepoFinder.github_url("arel") end it "returns github url from github search" do RepoFinder.stubs octokit_client: mock_octokit("haml/haml") RepoFinder.stubs gemspec: "" assert_equal "http://github.com/haml/haml", RepoFinder.github_url("haml") end it "returns nil when not found" do RepoFinder.stubs octokit_client: mock_octokit(nil) RepoFinder.stubs gemspec: "" assert_nil RepoFinder.github_url("not_found") end it "returns exception url" do assert_equal "http://github.com/rails/rails", RepoFinder.github_url('activerecord') end end private def mock_octokit(full_name) mock_items = if full_name.nil? mock { stubs items: [] } else mock_item = mock { stubs full_name: full_name } mock { stubs items: [mock_item] } end mock { stubs search_repositories: mock_items } end end end
Version data entries
14 entries across 14 versions & 1 rubygems