Sha256: 7b334b8745f1426f517aa39cde31410be2d78613498eaed0545cb0a274957f4d

Contents?: true

Size: 1.42 KB

Versions: 6

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(repo.name,user.login).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

6 entries across 6 versions & 4 rubygems

Version Path
ddollar-octopi-0.0.13 test/octopi_test.rb
fcoury-octopi-0.0.11 test/octopi_test.rb
fcoury-octopi-0.1.0 test/octopi_test.rb
philnash-octopi-0.0.11 test/octopi_test.rb
philnash-octopi-0.0.12 test/octopi_test.rb
octopi-0.1.0 test/octopi_test.rb