Sha256: de0a62e5a69503b7389254ab4d0091b012603853b6b6d34347017dfc46256ad2

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

require 'test_helper'

class OctopiTest < Test::Unit::TestCase
  include Octopi
  
  # TODO: Those tests are obviously brittle. Need to stub/mock it.
  
  def assert_find_all(cls, check_method, repo, user)
    repo_method = cls.resource_name(:plural)
    
    item1 = cls.find_all(user.login, repo.name).first
    item2 = cls.find_all(repo).first
    item3 = repo.send(repo_method).first
    
    assert_equal item1.send(check_method), item2.send(check_method)
    assert_equal item1.send(check_method), item3.send(check_method)
  end
  
  def setup
    @user = User.find("fcoury")
    @repo = @user.repository("octopi")
    @issue = @repo.issues.first
  end
  
  context Issue do
    should "return the correct issue by number" do
      assert_equal @issue.number, Issue.find(@repo, @issue.number).number
      assert_equal @issue.number, Issue.find(@user, @repo, @issue.number).number
      assert_equal @issue.number, Issue.find(@repo.owner, @repo.name, @issue.number).number
    end

    should "return the correct issue by using repo.issue number" do
      assert_equal @issue.number, @repo.issue(@issue.number).number
    end
    
    should "fetch the same issue using different but equivalent find_all params" do
      assert_find_all Issue, :number, @repo, @user
    end
  end

  context Commit do
    should "fetch the same commit using different but equivalent find_all params" do
      assert_find_all Commit, :id, @repo, @user
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
fcoury-octopi-0.0.6 test/octopi_test.rb
fcoury-octopi-0.0.7 test/octopi_test.rb
fcoury-octopi-0.0.8 test/octopi_test.rb
fcoury-octopi-0.0.9 test/octopi_test.rb
octopi-0.0.9 test/octopi_test.rb