ticketmaster-github 0.6.9 → 0.6.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.rbenv-gemsets ADDED
@@ -0,0 +1 @@
1
+ ticketmaster-github
data/.rbenv-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.2-p290
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+ gem "ticketmaster", "0.6.7"
3
+ gem "octokit", "0.6.5"
4
+ gem "jeweler", "1.6.4"
5
+ group :development do
6
+ gem "rspec", "1.3.0"
7
+ gem "fakeweb", "~> 1.3.0"
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,56 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.1.3)
5
+ activesupport (= 3.1.3)
6
+ builder (~> 3.0.0)
7
+ i18n (~> 0.6)
8
+ activeresource (3.1.3)
9
+ activemodel (= 3.1.3)
10
+ activesupport (= 3.1.3)
11
+ activesupport (3.1.3)
12
+ multi_json (~> 1.0)
13
+ addressable (2.2.6)
14
+ builder (3.0.0)
15
+ fakeweb (1.3.0)
16
+ faraday (0.7.5)
17
+ addressable (~> 2.2.6)
18
+ multipart-post (~> 1.1.3)
19
+ rack (>= 1.1.0, < 2)
20
+ faraday_middleware (0.7.0)
21
+ faraday (~> 0.7.3)
22
+ git (1.2.5)
23
+ hashie (1.2.0)
24
+ i18n (0.6.0)
25
+ jeweler (1.6.4)
26
+ bundler (~> 1.0)
27
+ git (>= 1.2.5)
28
+ rake
29
+ multi_json (1.0.4)
30
+ multipart-post (1.1.4)
31
+ octokit (0.6.5)
32
+ addressable (~> 2.2.6)
33
+ faraday (~> 0.7.4)
34
+ faraday_middleware (~> 0.7.0)
35
+ hashie (~> 1.2.0)
36
+ multi_json (~> 1.0.2)
37
+ rack (1.3.5)
38
+ rake (0.9.2.2)
39
+ rspec (1.3.0)
40
+ ticketmaster (0.6.7)
41
+ activeresource
42
+ activeresource (>= 2.3.2)
43
+ activesupport
44
+ activesupport (>= 2.3.2)
45
+ hashie (= 1.2.0)
46
+ jeweler
47
+
48
+ PLATFORMS
49
+ ruby
50
+
51
+ DEPENDENCIES
52
+ fakeweb (~> 1.3.0)
53
+ jeweler (= 1.6.4)
54
+ octokit (= 0.6.5)
55
+ rspec (= 1.3.0)
56
+ ticketmaster (= 0.6.7)
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+ # Capybara request specs
17
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
18
+ end
19
+
data/Rakefile CHANGED
@@ -10,9 +10,6 @@ begin
10
10
  gem.email = "hong.quach@abigfisch.com"
11
11
  gem.homepage = "http://github.com/kiafaldorius/ticketmaster-github"
12
12
  gem.authors = ["HybridGroup"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.add_dependency "ticketmaster", ">= 0.6.0"
15
- gem.add_dependency "octokit", ">= 0.6.4"
16
13
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
14
  end
18
15
  Jeweler::GemcutterTasks.new
@@ -32,8 +29,6 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
32
29
  spec.rcov = true
33
30
  end
34
31
 
35
- task :spec => :check_dependencies
36
-
37
32
  task :default => :spec
38
33
 
39
34
  require 'rake/rdoctask'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.9
1
+ 0.6.10
@@ -8,6 +8,22 @@ module TicketMaster::Provider
8
8
  class Comment < TicketMaster::Provider::Base::Comment
9
9
  attr_accessor :prefix_options
10
10
 
11
+ def initialize(*object)
12
+ if object.first
13
+ object = object.first
14
+ unless object.is_a? Hash
15
+ hash = {:id => object.id,
16
+ :body => object.body,
17
+ :created_at => object.created_at,
18
+ :author => object.user.login}
19
+
20
+ else
21
+ hash = object
22
+ end
23
+ super hash
24
+ end
25
+ end
26
+
11
27
  def author
12
28
  self.user.login
13
29
  end
@@ -30,18 +46,22 @@ module TicketMaster::Provider
30
46
 
31
47
  # declare needed overloaded methods here
32
48
 
33
- def self.find(project_id, ticket_id)
34
- TicketMaster::Provider::Github.api.issue_comments(project_id, ticket_id).collect do |comment|
35
- comment.merge!(:project_id => project_id, :ticket_id => ticket_id)
36
- self.new comment
37
- end
38
- end
49
+ def self.find_by_attributes(project_id, ticket_id, attributes = {})
50
+ search_by_attribute(self.find_all(project_id, ticket_id), attributes)
51
+ end
39
52
 
40
- def self.create(project_id, ticket_id, comment)
41
- github_comment = TicketMaster::Provider::Github.api.add_comment(project_id, ticket_id, comment)
42
- github_comment.merge!(:project_id => project_id, :ticket_id => ticket_id)
43
- self.new github_comment
44
- end
53
+ def self.find_all(project_id, ticket_id)
54
+ TicketMaster::Provider::Github.api.issue_comments(project_id, ticket_id).collect do |comment|
55
+ comment.merge!(:project_id => project_id, :ticket_id => ticket_id)
56
+ self.new comment
57
+ end
58
+ end
59
+
60
+ def self.create(project_id, ticket_id, comment)
61
+ github_comment = TicketMaster::Provider::Github.api.add_comment(project_id, ticket_id, comment)
62
+ github_comment.merge!(:project_id => project_id, :ticket_id => ticket_id)
63
+ self.new github_comment
64
+ end
45
65
 
46
66
  end
47
67
  end
@@ -43,15 +43,7 @@ module TicketMaster::Provider
43
43
  end
44
44
 
45
45
  def projects(*options)
46
- if options.empty?
47
- Project.find_all(options)
48
- elsif options.first.is_a? Array
49
- options.first.collect { |name| Project.find_by_id(name) }
50
- elsif options.first.is_a? String
51
- Project.find_by_id(options.first)
52
- elsif options.first.is_a? Hash
53
- Project.find_by_attributes(options.first)
54
- end
46
+ Project.find(options)
55
47
  end
56
48
 
57
49
  def project(*project)
@@ -41,7 +41,7 @@ module TicketMaster::Provider
41
41
  end
42
42
 
43
43
  def id
44
- "#{self[:owner]}/#{self[:name]}"
44
+ "#{self.owner.login}/#{self[:name]}"
45
45
  end
46
46
 
47
47
  # copy from this.copy(that) copies that into this
@@ -55,27 +55,38 @@ module TicketMaster::Provider
55
55
  end
56
56
  end
57
57
 
58
+ def self.find(*options)
59
+ if options[0].empty?
60
+ projects = self.find_all
61
+ elsif options[0].first.is_a? Array
62
+ options[0].first.collect { |name| self.find_by_id(name) }
63
+ elsif options[0].first.is_a? String
64
+ self.find_by_id(options[0].first)
65
+ elsif options[0].first.is_a? Hash
66
+ self.find_by_attributes(options[0].first)
67
+ end
68
+ end
69
+
58
70
  def self.find_by_attributes(attributes = {})
59
- projects = find_all
60
- search_by_attribute(projects, attributes).collect { |project| self.new project }
71
+ search_by_attribute(self.find_all, attributes)
61
72
  end
62
73
 
63
74
  def self.find_by_id(id)
64
75
  id = "#{TicketMaster::Provider::Github.login}/#{id}" unless id.include?("/")
65
- self.new TicketMaster::Provider::Github.api.repository(id)
76
+ self.new TicketMaster::Provider::Github.api.repository(id)
66
77
  end
67
78
 
68
- def self.find_all(*options)
79
+ def self.find_all
69
80
  repos = []
70
81
  user_repos = TicketMaster::Provider::Github.api.repositories(TicketMaster::Provider::Github.login).collect { |repository|
71
82
  self.new repository }
72
- repos = repos + user_repos
73
- if TicketMaster::Provider::Github.valid_user
74
- org_repos = TicketMaster::Provider::Github.api.organization_repositories.collect { |repository|
75
- self.new repository }
76
- repos = repos + org_repos
77
- end
78
- repos
83
+ repos = repos + user_repos
84
+ if TicketMaster::Provider::Github.valid_user
85
+ org_repos = TicketMaster::Provider::Github.api.organization_repositories.collect { |repository|
86
+ self.new repository }
87
+ repos = repos + org_repos
88
+ end
89
+ repos
79
90
  end
80
91
 
81
92
  def tickets(*options)
@@ -8,6 +8,22 @@ module TicketMaster::Provider
8
8
  attr_accessor :prefix_options
9
9
  # declare needed overloaded methods here
10
10
 
11
+ def initialize(*object)
12
+ if object.first
13
+ object = object.first
14
+ unless object.is_a? Hash
15
+ hash = {:id => object.id,
16
+ :status => object.state,
17
+ :description => object.body,
18
+ :user => object.user,
19
+ :project_id => object.project_id}
20
+ else
21
+ hash = object
22
+ end
23
+ super hash
24
+ end
25
+ end
26
+
11
27
  def id
12
28
  self.number
13
29
  end
@@ -35,15 +51,14 @@ module TicketMaster::Provider
35
51
  def self.find_by_id(project_id, number)
36
52
  issue = TicketMaster::Provider::Github.api.issue(project_id, number)
37
53
  issue.merge!(:project_id => project_id)
38
- puts issue.inspect
39
54
  self.new issue
40
55
  end
41
56
 
42
57
  def self.find(project_id, *options)
43
- if options.first.empty?
58
+ if options[0].empty?
44
59
  self.find_all(project_id)
45
60
  elsif options[0].first.is_a? Array
46
- options.first.collect { |number| self.find_by_id(project_id, number) }
61
+ options[0].first.collect { |number| self.find_by_id(project_id, number) }
47
62
  elsif options[0].first.is_a? Hash
48
63
  self.find_by_attributes(project_id, options[0].first)
49
64
  end
@@ -57,8 +72,7 @@ module TicketMaster::Provider
57
72
  def self.find_all(project_id)
58
73
  issues = []
59
74
  issues += TicketMaster::Provider::Github.api.issues(project_id)
60
- state = 'closed'
61
- issues += TicketMaster::Provider::Github.api.issues(project_id, state)
75
+ issues += TicketMaster::Provider::Github.api.issues(project_id, {:state => "closed"})
62
76
  issues.collect do |issue|
63
77
  issue.merge!(:project_id => project_id)
64
78
  Ticket.new issue
@@ -102,10 +116,6 @@ module TicketMaster::Provider
102
116
  Ticket.new(project_id, TicketMaster::Provider::Github.api.close_issue(project_id, number))
103
117
  end
104
118
 
105
- def comments
106
- Comment.find(project_id, number)
107
- end
108
-
109
119
  def comment!(comment)
110
120
  Comment.create(project_id, number, comment)
111
121
  end
data/spec/comment_spec.rb CHANGED
@@ -3,17 +3,25 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe "Ticketmaster::Provider::Github::Comment" do
4
4
 
5
5
  before(:each) do
6
- @github = TicketMaster.new(:github, {:login => 'cored', :token => 'kdkdkd'})
6
+ @github = TicketMaster.new(:github, {:login => 'ticketmaster-user', :password => 'Tm123456'})
7
+ stub_get('https://ticketmaster-user:Tm123456@api.github.com/users/ticketmaster-user/repos', 'projects.json')
8
+ stub_get('https://ticketmaster-user:Tm123456@api.github.com/repos/ticketmaster-user/tmtest-repo/issues','issues.json')
9
+ stub_get('https://ticketmaster-user:Tm123456@api.github.com/repos/ticketmaster-user/tmtest-repo/issues?state=closed','closed_issues.json')
10
+ @project = @github.projects.first
11
+ @ticket = @project.tickets.first
7
12
  @klass = TicketMaster::Provider::Github::Comment
8
13
  @api = Octokit::Client
9
14
  end
10
15
 
11
16
  it "should be able to load all comments" do
12
- pending
17
+ stub_get('https://ticketmaster-user:Tm123456@api.github.com/repos/ticketmaster-user/tmtest-repo/issues/1/comments', 'comments.json')
18
+ @comments = @ticket.comments
19
+ @comments.should be_an_instance_of(Array)
20
+ @comments.first.should be_an_instance_of(@klass)
13
21
  end
14
22
 
15
- it "should be able to create a new comment" do
16
- pending
23
+ it "should be able to create a new comment" do
24
+ pending
17
25
  end
18
26
 
19
27
  end
@@ -0,0 +1,3 @@
1
+ [
2
+
3
+ ]
@@ -0,0 +1,16 @@
1
+ [
2
+ {
3
+ "url": "https://api.github.com/repos/ticketmaster-user/tmtest-repo/issues/comments/3951282",
4
+ "created_at": "2012-02-13T22:49:55Z",
5
+ "body": "for testing",
6
+ "updated_at": "2012-02-13T22:49:55Z",
7
+ "id": 3951282,
8
+ "user": {
9
+ "url": "https://api.github.com/users/ticketmaster-user",
10
+ "gravatar_id": "42bd18419413dfbd6e7ec4fefdec94ae",
11
+ "login": "ticketmaster-user",
12
+ "avatar_url": "https://secure.gravatar.com/avatar/42bd18419413dfbd6e7ec4fefdec94ae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
13
+ "id": 1434902
14
+ }
15
+ }
16
+ ]
@@ -0,0 +1 @@
1
+ {"issue":{"comments":1,"position":1.0,"number":1,"state":"open","updated_at":"2012/02/13 14:49:55 -0800","labels":[],"user":"ticketmaster-user","body":"","title":"for testing","html_url":"https://github.com/ticketmaster-user/tmtest-repo/issues/1","created_at":"2012/02/13 14:45:27 -0800","votes":0,"gravatar_id":"42bd18419413dfbd6e7ec4fefdec94ae"}}
@@ -0,0 +1,32 @@
1
+ [
2
+ {
3
+ "title": "for testing",
4
+ "url": "https://api.github.com/repos/ticketmaster-user/tmtest-repo/issues/1",
5
+ "closed_at": null,
6
+ "created_at": "2012-02-13T22:45:27Z",
7
+ "milestone": null,
8
+ "labels": [
9
+
10
+ ],
11
+ "number": 1,
12
+ "body": "",
13
+ "html_url": "https://github.com/ticketmaster-user/tmtest-repo/issues/1",
14
+ "updated_at": "2012-02-13T22:49:55Z",
15
+ "comments": 1,
16
+ "state": "open",
17
+ "pull_request": {
18
+ "diff_url": null,
19
+ "patch_url": null,
20
+ "html_url": null
21
+ },
22
+ "assignee": null,
23
+ "id": 3210729,
24
+ "user": {
25
+ "url": "https://api.github.com/users/ticketmaster-user",
26
+ "gravatar_id": "42bd18419413dfbd6e7ec4fefdec94ae",
27
+ "login": "ticketmaster-user",
28
+ "avatar_url": "https://secure.gravatar.com/avatar/42bd18419413dfbd6e7ec4fefdec94ae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
29
+ "id": 1434902
30
+ }
31
+ }
32
+ ]
@@ -0,0 +1,34 @@
1
+ {
2
+ "watchers": 1,
3
+ "url": "https://api.github.com/repos/ticketmaster-user/tmtest-repo",
4
+ "master_branch": null,
5
+ "created_at": "2012-02-13T22:20:10Z",
6
+ "html_url": "https://github.com/ticketmaster-user/tmtest-repo",
7
+ "ssh_url": "git@github.com:ticketmaster-user/tmtest-repo.git",
8
+ "description": "",
9
+ "has_wiki": true,
10
+ "clone_url": "https://github.com/ticketmaster-user/tmtest-repo.git",
11
+ "forks": 1,
12
+ "fork": false,
13
+ "pushed_at": null,
14
+ "git_url": "git://github.com/ticketmaster-user/tmtest-repo.git",
15
+ "mirror_url": null,
16
+ "open_issues": 1,
17
+ "private": false,
18
+ "svn_url": "https://github.com/ticketmaster-user/tmtest-repo",
19
+ "homepage": "",
20
+ "size": 0,
21
+ "has_issues": true,
22
+ "updated_at": "2012-02-13T22:20:10Z",
23
+ "owner": {
24
+ "url": "https://api.github.com/users/ticketmaster-user",
25
+ "gravatar_id": "42bd18419413dfbd6e7ec4fefdec94ae",
26
+ "login": "ticketmaster-user",
27
+ "avatar_url": "https://secure.gravatar.com/avatar/42bd18419413dfbd6e7ec4fefdec94ae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
28
+ "id": 1434902
29
+ },
30
+ "name": "tmtest-repo",
31
+ "id": 3434734,
32
+ "has_downloads": true,
33
+ "language": null
34
+ }
@@ -0,0 +1,34 @@
1
+ [{
2
+ "watchers":"1",
3
+ "url":"https://api.github.com/repos/ticketmaster-user/tmtest-repo",
4
+ "created_at":"2012-02-13T22:20:10Z",
5
+ "mirror_url":"null",
6
+ "has_wiki":"true",
7
+ "html_url":"https://github.com/ticketmaster-user/tmtest-repo",
8
+ "ssh_url":"git@github.com:ticketmaster-user/tmtest-repo.git",
9
+ "description":"",
10
+ "forks":"1",
11
+ "clone_url":"https://github.com/ticketmaster-user/tmtest-repo.git",
12
+ "fork":false,
13
+ "open_issues":"1",
14
+ "private":false,
15
+ "homepage":"",
16
+ "size":"0",
17
+ "has_issues":true,
18
+ "master_branch":"null",
19
+ "pushed_at":"null",
20
+ "updated_at":"2012-02-13T22:20:10Z",
21
+ "owner": {
22
+ "url":"https://api.github.com/users/ticketmaster-user",
23
+ "avatar_url":"https://secure.gravatar.com/avatar/42bd18419413dfbd6e7ec4fefdec94ae?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
24
+ "gravatar_id":"42bd18419413dfbd6e7ec4fefdec94ae",
25
+ "login":"ticketmaster-user",
26
+ "id":"1434902"
27
+ },
28
+ "name":"tmtest-repo",
29
+ "has_downloads":true,
30
+ "id":"3434734",
31
+ "git_url":"git://github.com/ticketmaster-user/tmtest-repo.git",
32
+ "svn_url":"https://github.com/ticketmaster-user/tmtest-repo",
33
+ "language":"null"
34
+ }]
@@ -0,0 +1 @@
1
+ {"repositories":[]}
data/spec/project_spec.rb CHANGED
@@ -2,46 +2,48 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Ticketmaster::Provider::Github::Project" do
4
4
 
5
- before(:each) do
6
- @repo_name = "deadprogrammer/flying_robot"
5
+ before(:all) do
6
+ @repo_name = "tmtest-repo"
7
+ @returned_repo = "ticketmaster-user/tmtest-repo"
7
8
  @klass = TicketMaster::Provider::Github::Project
8
- @github = TicketMaster.new(:github, {:login => 'cored'})
9
+ end
10
+
11
+ before(:each) do
12
+ @github = TicketMaster.new(:github, :login => 'ticketmaster-user', :password => 'Tm123456')
9
13
  end
10
14
 
11
15
  it "should be able to load all projects" do
12
- @github.projects.should be_an_instance_of(Array)
13
- @github.projects.first.should be_an_instance_of(@klass)
16
+ stub_get('https://ticketmaster-user:Tm123456@api.github.com/users/ticketmaster-user/repos', 'projects.json')
17
+ stub_get('https://ticketmaster-user:Tm123456@github.com/api/v2/json/organizations/repositories', 'repositories.json')
18
+ @projects = @github.projects
19
+ @projects.should be_an_instance_of(Array)
20
+ @projects.first.should be_an_instance_of(@klass)
14
21
  end
15
22
 
16
23
  it "should be able to load all projects based on an array of name(id)" do
17
- projects = @github.projects([@repo_name])
18
- projects.should be_an_instance_of(Array)
19
- projects.first.should be_an_instance_of(@klass)
20
- projects.first.id.should == @repo_name
24
+ stub_get('https://ticketmaster-user:Tm123456@api.github.com/repos/ticketmaster-user/tmtest-repo', 'project.json')
25
+ @projects = @github.projects([@repo_name])
26
+ @projects.should be_an_instance_of(Array)
27
+ @projects.first.should be_an_instance_of(@klass)
28
+ @projects.first.id.should == @returned_repo
21
29
  end
22
30
 
23
31
  it "should be able to load a single project based on a single name(id)" do
24
- project = @github.projects(@repo_name)
25
- project.should be_an_instance_of(@klass)
26
- project.id.should be_eql(@repo_name)
32
+ @project = @github.projects(@repo_name)
33
+ @project.should be_an_instance_of(@klass)
34
+ @project.id.should == @returned_repo
27
35
  end
28
36
 
29
37
  it "should be able to find by name(id)" do
30
- p = @github.project(@repo_name)
31
- p.should be_an_instance_of(@klass)
32
- p.id.should be_eql(@repo_name)
33
- end
34
-
35
- it "should be able to find by name(id) with the find method" do
36
- p = @github.project.find(@repo_name)
37
- p.should be_an_instance_of(@klass)
38
- p.id.should be_eql(@repo_name)
38
+ @project = @github.project(@repo_name)
39
+ @project.should be_an_instance_of(@klass)
40
+ @project.id.should == @returned_repo
39
41
  end
40
42
 
41
43
  it "should be able to find by attributes" do
42
- projects = @github.projects(:name => 'translator')
43
- projects.should be_an_instance_of(Array)
44
- projects.first.id.should be_eql('cored/translator')
44
+ @projects = @github.projects(:name => 'tmtest-repo')
45
+ @projects.should be_an_instance_of(Array)
46
+ @projects.first.id.should be_eql(@returned_repo)
45
47
  end
46
48
  end
47
49
 
data/spec/spec_helper.rb CHANGED
@@ -5,9 +5,27 @@ require 'rubygems'
5
5
  require 'ticketmaster'
6
6
  require 'active_support/core_ext/string'
7
7
  require 'spec'
8
- require 'factory_girl'
9
8
  require 'ticketmaster-github'
9
+ require 'fakeweb'
10
10
 
11
- Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each {|f| require f}
12
- Spec::Runner.configure do |config|
11
+ FakeWeb.allow_net_connect = false
12
+
13
+ def fixture_file(filename)
14
+ return '' if filename == ''
15
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
16
+ File.read(file_path)
17
+ end
18
+
19
+
20
+ def stub_request(method, url, filename, status=nil)
21
+ options = {:body => ""}
22
+ options.merge!({:body => fixture_file(filename)}) if filename
23
+ options.merge!({:body => status.last}) if status
24
+ options.merge!({:status => status}) if status
25
+
26
+ FakeWeb.register_uri(method, url, options)
13
27
  end
28
+
29
+ def stub_get(*args); stub_request(:get, *args) end
30
+ def stub_post(*args); stub_request(:post, *args) end
31
+ def stub_delete(*args); stub_request(:delete, *args) end
data/spec/ticket_spec.rb CHANGED
@@ -2,45 +2,42 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Ticketmaster::Provider::Github::Ticket" do
4
4
  before(:each) do
5
- @github = TicketMaster.new(:github, {:login => 'cored'})
6
- @project = @github.project('jquery/jquery-mobile')
5
+ @github = TicketMaster.new(:github, {:login => 'ticketmaster-user', :password => 'Tm123456'})
6
+ stub_get('https://ticketmaster-user:Tm123456@api.github.com/repos/ticketmaster-user/tmtest-repo', 'project.json')
7
+ @project = @github.project('tmtest-repo')
7
8
  @ticket_id = 1
8
- @ticket = {:body => 'Creating a ticket from API', :title => 'Ticket for jquery', :number => 1}
9
9
  @klass = TicketMaster::Provider::Github::Ticket
10
- @api = Octokit::Client
11
10
  end
12
-
11
+
13
12
  it "should be able to load all tickets" do
14
- @project.tickets.should be_an_instance_of(Array)
15
- @project.tickets.first.should be_an_instance_of(@klass)
13
+ stub_get('https://ticketmaster-user:Tm123456@api.github.com/repos/ticketmaster-user/tmtest-repo/issues', 'issues.json')
14
+ stub_get('https://ticketmaster-user:Tm123456@api.github.com/repos/ticketmaster-user/tmtest-repo/issues?state=closed', 'closed_issues.json')
15
+ @tickets = @project.tickets
16
+ @tickets.should be_an_instance_of(Array)
17
+ @tickets.first.should be_an_instance_of(@klass)
16
18
  end
17
19
 
18
20
  it "should be able to load tickets from an array of ids" do
19
- tickets = @project.tickets([@ticket_id])
20
- tickets.should be_an_instance_of(Array)
21
- tickets.first.should be_an_instance_of(@klass)
21
+ stub_get('https://ticketmaster-user:Tm123456@github.com/api/v2/json/issues/show/ticketmaster-user/tmtest-repo/1', 'issues/1.json')
22
+ @tickets = @project.tickets([@ticket_id])
23
+ @tickets.should be_an_instance_of(Array)
24
+ @tickets.first.should be_an_instance_of(@klass)
22
25
  end
23
26
 
24
27
  it "should be able to find tickets based on attributes" do
25
- pending
26
- tickets = @project.tickets(:id => @ticket_id)
27
- tickets.should be_an_instance_of(Array)
28
- tickets.first.should be_an_instance_of(@klass)
29
- end
30
-
31
- it "should find a ticket by id(number)" do
32
- ticket = @project.ticket(@ticket_id)
33
- ticket.should be_an_instance_of(@klass)
34
- ticket.title.should be_eql('Move Ajax Test to Core')
28
+ @tickets = @project.tickets(:id => @ticket_id)
29
+ @tickets.should be_an_instance_of(Array)
30
+ @tickets.first.should be_an_instance_of(@klass)
35
31
  end
36
32
 
37
- it "should return author in ticket"
33
+ it "should retrieve tickets from a private repo" do
38
34
 
39
- it "should be able to open a new ticket"
40
-
41
- it "should be able to update a existing ticket"
35
+ end
42
36
 
43
- it "should be able to reopen a ticket"
37
+ it "should find a ticket by id(number)" do
38
+ @ticket = @project.ticket(@ticket_id)
39
+ @ticket.should be_an_instance_of(@klass)
40
+ @ticket.title.should be_eql('for testing')
41
+ end
44
42
 
45
- it "should be able to close a ticket"
46
43
  end
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe "Ticketmaster::Provider::Github" do
4
4
 
5
5
  before(:each) do
6
- @github = TicketMaster.new(:github, {:login => 'juanespinosa', :password => 'asdfghk'})
6
+ @github = TicketMaster.new(:github, :login => 'cored')
7
7
  end
8
8
 
9
9
  it "should be able to instantiate a new instance" do
@@ -1,76 +1,80 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{ticketmaster-github}
8
- s.version = "0.6.9"
7
+ s.name = "ticketmaster-github"
8
+ s.version = "0.6.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["HybridGroup"]
12
- s.date = %q{2011-07-20}
13
- s.description = %q{This provides an interface with github through the ticketmaster gem.}
14
- s.email = %q{hong.quach@abigfisch.com}
12
+ s.date = "2012-03-06"
13
+ s.description = "This provides an interface with github through the ticketmaster gem."
14
+ s.email = "hong.quach@abigfisch.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.md"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.md",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/provider/comment.rb",
27
- "lib/provider/github.rb",
28
- "lib/provider/project.rb",
29
- "lib/provider/ticket.rb",
30
- "lib/ticketmaster-github.rb",
31
- "spec/comment_spec.rb",
32
- "spec/factories/comment.rb",
33
- "spec/factories/issue.rb",
34
- "spec/factories/repository.rb",
35
- "spec/project_spec.rb",
36
- "spec/spec.opts",
37
- "spec/spec_helper.rb",
38
- "spec/ticket_spec.rb",
39
- "spec/ticketmaster-github_spec.rb",
40
- "ticketmaster-github.gemspec"
41
- ]
42
- s.homepage = %q{http://github.com/kiafaldorius/ticketmaster-github}
43
- s.rdoc_options = ["--charset=UTF-8"]
44
- s.require_paths = ["lib"]
45
- s.rubygems_version = %q{1.3.7}
46
- s.summary = %q{The github provider for ticketmaster}
47
- s.test_files = [
21
+ ".rbenv-gemsets",
22
+ ".rbenv-version",
23
+ ".travis.yml",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "Guardfile",
27
+ "LICENSE",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "lib/provider/comment.rb",
32
+ "lib/provider/github.rb",
33
+ "lib/provider/project.rb",
34
+ "lib/provider/ticket.rb",
35
+ "lib/ticketmaster-github.rb",
36
+ "spec/comment_spec.rb",
37
+ "spec/fixtures/closed_issues.json",
38
+ "spec/fixtures/comments.json",
39
+ "spec/fixtures/issues.json",
40
+ "spec/fixtures/issues/1.json",
41
+ "spec/fixtures/project.json",
42
+ "spec/fixtures/projects.json",
43
+ "spec/fixtures/repositories.json",
44
+ "spec/project_spec.rb",
45
+ "spec/spec.opts",
48
46
  "spec/spec_helper.rb",
49
- "spec/comment_spec.rb",
50
- "spec/ticketmaster-github_spec.rb",
51
- "spec/factories/issue.rb",
52
- "spec/factories/comment.rb",
53
- "spec/factories/repository.rb",
54
- "spec/project_spec.rb",
55
- "spec/ticket_spec.rb"
47
+ "spec/ticket_spec.rb",
48
+ "spec/ticketmaster-github_spec.rb",
49
+ "ticketmaster-github.gemspec"
56
50
  ]
51
+ s.homepage = "http://github.com/kiafaldorius/ticketmaster-github"
52
+ s.require_paths = ["lib"]
53
+ s.rubygems_version = "1.8.15"
54
+ s.summary = "The github provider for ticketmaster"
57
55
 
58
56
  if s.respond_to? :specification_version then
59
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
60
57
  s.specification_version = 3
61
58
 
62
59
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
- s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
64
- s.add_runtime_dependency(%q<ticketmaster>, [">= 0.6.0"])
65
- s.add_runtime_dependency(%q<octokit>, [">= 0.6.4"])
60
+ s.add_runtime_dependency(%q<ticketmaster>, ["= 0.6.7"])
61
+ s.add_runtime_dependency(%q<octokit>, ["= 0.6.5"])
62
+ s.add_runtime_dependency(%q<jeweler>, ["= 1.6.4"])
63
+ s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
64
+ s.add_development_dependency(%q<fakeweb>, ["~> 1.3.0"])
66
65
  else
67
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
68
- s.add_dependency(%q<ticketmaster>, [">= 0.6.0"])
69
- s.add_dependency(%q<octokit>, [">= 0.6.4"])
66
+ s.add_dependency(%q<ticketmaster>, ["= 0.6.7"])
67
+ s.add_dependency(%q<octokit>, ["= 0.6.5"])
68
+ s.add_dependency(%q<jeweler>, ["= 1.6.4"])
69
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
70
+ s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
70
71
  end
71
72
  else
72
- s.add_dependency(%q<rspec>, [">= 1.2.9"])
73
- s.add_dependency(%q<ticketmaster>, [">= 0.6.0"])
74
- s.add_dependency(%q<octokit>, [">= 0.6.4"])
73
+ s.add_dependency(%q<ticketmaster>, ["= 0.6.7"])
74
+ s.add_dependency(%q<octokit>, ["= 0.6.5"])
75
+ s.add_dependency(%q<jeweler>, ["= 1.6.4"])
76
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
77
+ s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
75
78
  end
76
79
  end
80
+
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ticketmaster-github
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 19
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 6
8
- - 9
9
- version: 0.6.9
9
+ - 10
10
+ version: 0.6.10
10
11
  platform: ruby
11
12
  authors:
12
13
  - HybridGroup
@@ -14,54 +15,88 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-07-20 00:00:00 -04:00
18
- default_executable:
18
+ date: 2012-03-06 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: rspec
22
- prerelease: false
23
21
  requirement: &id001 !ruby/object:Gem::Requirement
24
22
  none: false
25
23
  requirements:
26
- - - ">="
24
+ - - "="
27
25
  - !ruby/object:Gem::Version
26
+ hash: 9
28
27
  segments:
29
- - 1
30
- - 2
31
- - 9
32
- version: 1.2.9
33
- type: :development
28
+ - 0
29
+ - 6
30
+ - 7
31
+ version: 0.6.7
34
32
  version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
33
  name: ticketmaster
37
34
  prerelease: false
35
+ type: :runtime
36
+ - !ruby/object:Gem::Dependency
38
37
  requirement: &id002 !ruby/object:Gem::Requirement
39
38
  none: false
40
39
  requirements:
41
- - - ">="
40
+ - - "="
42
41
  - !ruby/object:Gem::Version
42
+ hash: 13
43
43
  segments:
44
44
  - 0
45
45
  - 6
46
- - 0
47
- version: 0.6.0
48
- type: :runtime
46
+ - 5
47
+ version: 0.6.5
49
48
  version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
49
  name: octokit
52
50
  prerelease: false
51
+ type: :runtime
52
+ - !ruby/object:Gem::Dependency
53
53
  requirement: &id003 !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
56
- - - ">="
56
+ - - "="
57
57
  - !ruby/object:Gem::Version
58
+ hash: 7
58
59
  segments:
59
- - 0
60
+ - 1
60
61
  - 6
61
62
  - 4
62
- version: 0.6.4
63
- type: :runtime
63
+ version: 1.6.4
64
64
  version_requirements: *id003
65
+ name: jeweler
66
+ prerelease: false
67
+ type: :runtime
68
+ - !ruby/object:Gem::Dependency
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - "="
73
+ - !ruby/object:Gem::Version
74
+ hash: 27
75
+ segments:
76
+ - 1
77
+ - 3
78
+ - 0
79
+ version: 1.3.0
80
+ version_requirements: *id004
81
+ name: rspec
82
+ prerelease: false
83
+ type: :development
84
+ - !ruby/object:Gem::Dependency
85
+ requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ hash: 27
91
+ segments:
92
+ - 1
93
+ - 3
94
+ - 0
95
+ version: 1.3.0
96
+ version_requirements: *id005
97
+ name: fakeweb
98
+ prerelease: false
99
+ type: :development
65
100
  description: This provides an interface with github through the ticketmaster gem.
66
101
  email: hong.quach@abigfisch.com
67
102
  executables: []
@@ -73,7 +108,12 @@ extra_rdoc_files:
73
108
  - README.md
74
109
  files:
75
110
  - .document
76
- - .gitignore
111
+ - .rbenv-gemsets
112
+ - .rbenv-version
113
+ - .travis.yml
114
+ - Gemfile
115
+ - Gemfile.lock
116
+ - Guardfile
77
117
  - LICENSE
78
118
  - README.md
79
119
  - Rakefile
@@ -84,22 +124,25 @@ files:
84
124
  - lib/provider/ticket.rb
85
125
  - lib/ticketmaster-github.rb
86
126
  - spec/comment_spec.rb
87
- - spec/factories/comment.rb
88
- - spec/factories/issue.rb
89
- - spec/factories/repository.rb
127
+ - spec/fixtures/closed_issues.json
128
+ - spec/fixtures/comments.json
129
+ - spec/fixtures/issues.json
130
+ - spec/fixtures/issues/1.json
131
+ - spec/fixtures/project.json
132
+ - spec/fixtures/projects.json
133
+ - spec/fixtures/repositories.json
90
134
  - spec/project_spec.rb
91
135
  - spec/spec.opts
92
136
  - spec/spec_helper.rb
93
137
  - spec/ticket_spec.rb
94
138
  - spec/ticketmaster-github_spec.rb
95
139
  - ticketmaster-github.gemspec
96
- has_rdoc: true
97
140
  homepage: http://github.com/kiafaldorius/ticketmaster-github
98
141
  licenses: []
99
142
 
100
143
  post_install_message:
101
- rdoc_options:
102
- - --charset=UTF-8
144
+ rdoc_options: []
145
+
103
146
  require_paths:
104
147
  - lib
105
148
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -107,6 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
150
  requirements:
108
151
  - - ">="
109
152
  - !ruby/object:Gem::Version
153
+ hash: 3
110
154
  segments:
111
155
  - 0
112
156
  version: "0"
@@ -115,22 +159,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
159
  requirements:
116
160
  - - ">="
117
161
  - !ruby/object:Gem::Version
162
+ hash: 3
118
163
  segments:
119
164
  - 0
120
165
  version: "0"
121
166
  requirements: []
122
167
 
123
168
  rubyforge_project:
124
- rubygems_version: 1.3.7
169
+ rubygems_version: 1.8.15
125
170
  signing_key:
126
171
  specification_version: 3
127
172
  summary: The github provider for ticketmaster
128
- test_files:
129
- - spec/spec_helper.rb
130
- - spec/comment_spec.rb
131
- - spec/ticketmaster-github_spec.rb
132
- - spec/factories/issue.rb
133
- - spec/factories/comment.rb
134
- - spec/factories/repository.rb
135
- - spec/project_spec.rb
136
- - spec/ticket_spec.rb
173
+ test_files: []
174
+
data/.gitignore DELETED
@@ -1,25 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- nbproject/
23
-
24
- ## RVM
25
- .rvmrc
@@ -1,7 +0,0 @@
1
- Factory.define :comment do |p|
2
- p.body 'Body message'
3
- p.id '335287'
4
- p.created_at '2010/07/30 13:50:42'
5
- p.updated_at '2010/07/30 13:50:42'
6
- p.user 'juanespinosa'
7
- end
@@ -1,13 +0,0 @@
1
- Factory.define :issue do |p|
2
- p.repository 'test-juange'
3
- p.user 'juanespinosa'
4
- p.updated_at ''
5
- p.votes ''
6
- p.number '1'
7
- p.title 'test'
8
- p.body 'test ticket body'
9
- p.closed_at ''
10
- p.labels ''
11
- p.state 'open'
12
- p.created_at ''
13
- end
@@ -1,22 +0,0 @@
1
- Factory.define :repository do |p|
2
- p.description ''
3
- p.url ''
4
- p.forks ''
5
- p.name 'test-juange'
6
- p.homepage ''
7
- p.watchers ''
8
- p.private ''
9
- p.fork ''
10
- p.open_issues ''
11
- p.pledgie ''
12
- p.size ''
13
- p.actions ''
14
- p.score ''
15
- p.language ''
16
- p.followers ''
17
- p.type ''
18
- p.username 'juanespinosa'
19
- p.id ''
20
- p.pushed ''
21
- p.created ''
22
- end