Skip to content

Commit

Permalink
Add BugTracker and its tests
Browse files Browse the repository at this point in the history
Used for communicating with Pivotal Tracker.
  • Loading branch information
tubbo committed Nov 18, 2012
1 parent d0d3351 commit 8e93914
Show file tree
Hide file tree
Showing 9 changed files with 642 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in pv.gemspec
gemspec

group :test do
gem 'rspec'
gem 'vcr'
gem 'webmock', '~> 1.8'
end
19 changes: 19 additions & 0 deletions lib/pv/bug_tracker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'pivotal_tracker'

module Pv
class BugTracker
def initialize with_username, and_password
PivotalTracker::Client.use_ssl = true
@token = PivotalTracker::Client.token(with_username, and_password)
end

def connected?
@token != nil
end

def stories for_project_id, and_full_name
project = PivotalTracker::Project.all.select { |p| p.id == for_project_id }.first
project.stories.all(owned_by: and_full_name)
end
end
end
4 changes: 0 additions & 4 deletions pv.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]

gem.add_development_dependency 'rspec'
gem.add_development_dependency 'vcr'
gem.add_development_dependency 'webmock'

gem.add_dependency 'pivotal-tracker'
end
22 changes: 22 additions & 0 deletions spec/bug_tracker_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'spec_helper'
require 'pv/bug_tracker'

module Pv
describe BugTracker do
subject do
VCR.use_cassette :pivotal_client_connection do
Pv::BugTracker.new("john@doe.com", "password")
end
end

it "connects to pivotal tracker" do
subject.should be_connected
end

it "gathers the list of stories this user has to accomplish" do
VCR.use_cassette :pivotal_project_stories_search do
subject.stories(461255, "Tom Scott").should_not be_empty
end
end
end
end
2 changes: 1 addition & 1 deletion spec/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Pv
it "reads from ~/.pv YAML" do
subject.should be_present
subject.attributes.should_not be_empty
subject.attributes.count.should == 2
subject.attributes.count.should == 3
end

it "parses a username" do
Expand Down
74 changes: 74 additions & 0 deletions spec/fixtures/cassettes/pivotal_client_connection.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8e93914

Please sign in to comment.