pt-flow 0.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +5 -0
  3. data/lib/pt-flow/ui.rb +21 -13
  4. data/lib/pt-flow/version.rb +1 -1
  5. data/pt-flow.gemspec +1 -0
  6. data/spec/fixtures/activity.xml +177 -0
  7. data/spec/fixtures/backup_stories.xml +270 -0
  8. data/spec/fixtures/bugs.xml +279 -0
  9. data/spec/fixtures/created_note.xml +14 -0
  10. data/spec/fixtures/created_story.xml +14 -0
  11. data/spec/fixtures/features.xml +293 -0
  12. data/spec/fixtures/global_config.yml +1 -1
  13. data/spec/fixtures/iterations_all.xml +243 -0
  14. data/spec/fixtures/iterations_backlog.xml +166 -0
  15. data/spec/fixtures/iterations_current.xml +48 -0
  16. data/spec/fixtures/iterations_current_backlog.xml +211 -0
  17. data/spec/fixtures/iterations_done.xml +34 -0
  18. data/spec/fixtures/local_config.yml +5 -5
  19. data/spec/fixtures/memberships.xml +42 -0
  20. data/spec/fixtures/notes.xml +33 -0
  21. data/spec/fixtures/project.xml +53 -0
  22. data/spec/fixtures/project_activity.xml +177 -0
  23. data/spec/fixtures/projects.xml +107 -0
  24. data/spec/fixtures/stories.xml +270 -0
  25. data/spec/fixtures/story-4459994.xml +14 -0
  26. data/spec/fixtures/story-4460038.xml +46 -0
  27. data/spec/fixtures/story-4460598.xml +32 -0
  28. data/spec/fixtures/story-4473735.xml +48 -0
  29. data/spec/fixtures/story.xml +14 -0
  30. data/spec/fixtures/tasks.xml +24 -0
  31. data/spec/fixtures/update_tasks.xml +8 -0
  32. data/spec/lib/pt-flow/ui_spec.rb +79 -28
  33. data/spec/spec_helper.rb +2 -1
  34. data/spec/support/dummy.rb +14 -0
  35. data/spec/support/fixture_macros.rb +13 -0
  36. data/spec/support/git_macros.rb +9 -0
  37. data/spec/support/webmock.rb +5 -0
  38. metadata +104 -12
@@ -1,43 +1,94 @@
1
1
  require 'spec_helper'
2
2
 
3
- module PT::Flow
4
- describe UI do
3
+ describe PT::Flow::UI do
5
4
 
6
- let(:project) { double('Project', id: 1, use_https: false) }
7
- let(:task) { double('Task', id: 1, name: 'Do this', current_state: 'Unscheduled', estimate: 1, errors: []) }
8
- let(:prompt) { double('HighLine') }
5
+ let(:endpoint) { "http://www.pivotaltracker.com/services/v3" }
6
+ let(:prompt) { double('HighLine') }
9
7
 
10
- before do
11
- PivotalTracker::Project.stub(all: [], find: project)
12
- PivotalTracker::Story.stub(find: task)
13
- HighLine.stub(new: prompt)
8
+ before do
9
+ HighLine.stub(new: prompt)
10
+ stub_request(:get, /projects$/).to_return(body: fixture_file('projects.xml'))
11
+ stub_request(:get, /stories\?/).to_return(body: fixture_file('stories.xml'))
12
+ stub_request(:any, /stories\/\d+/).to_return(body: fixture_file('story.xml'))
13
+ end
14
+
15
+ describe '#start' do
16
+ context 'given an unestimated story' do
17
+ it "shows lists of stories - choosing one asks you to estimate, starts/assigns the story on pt and checks out a new branch." do
18
+ prompt.should_receive(:ask).with("Please select a task to start working on (1-14, 'q' to exit)".bold).and_return('2')
19
+ prompt.should_receive(:ask).with("How many points do you estimate for it? (0,1,2,3)".bold).and_return('3')
20
+
21
+ PT::Flow::UI.new %w{ start }
22
+
23
+ WebMock.should have_requested(:get, "#{endpoint}/projects/102622/stories?filter=current_state:unscheduled,unstarted,started")
24
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<estimate>3<\/estimate>/)
25
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<owned_by>Jon Mischo<\/owned_by>/)
26
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<current_state>started<\/current_state>/)
27
+
28
+ current_branch.should == 'master-4459994'
29
+ end
14
30
  end
15
31
 
16
- describe '#start' do
17
- before do
18
- project.stub(stories: double('stories', all: [task]))
32
+ context 'given an already estimated story' do
33
+ it "does not prompt to estimate" do
34
+ prompt.should_receive(:ask).once.with("Please select a task to start working on (1-14, 'q' to exit)".bold).and_return('3')
35
+ PT::Flow::UI.new %w{ start }
19
36
  end
37
+ end
20
38
 
21
- context 'given no args' do
22
- it "shows lists of tasks - choosing one starts/assigns the task on pt and checks out a new branch." do
23
- prompt.should_receive(:ask).with("Please select a task to start working on (1-1, 'q' to exit)".bold).and_return('1')
24
- task.should_receive(:update).with(owned_by: 'Jens Balvig').and_return(task)
25
- task.should_receive(:update).with(current_state: 'started').and_return(task)
26
- UI.any_instance.should_receive(:`).with('git checkout -B 1')
39
+ context 'when run from a feature branch' do
40
+ before { system('git checkout -B new_feature') }
27
41
 
28
- ui = UI.new %w{ start }
29
- end
42
+ it "creates an appropriately namespaced branch" do
43
+ prompt.should_receive(:ask).and_return('3')
44
+ PT::Flow::UI.new %w{ start }
45
+ current_branch.should == 'new_feature-4460038'
30
46
  end
31
- context 'given a number' do
32
- it "starts/assigns the task on pt and checks out a new branch." do
33
- task.should_receive(:update).with(owned_by: 'Jens Balvig').and_return(task)
34
- task.should_receive(:update).with(current_state: 'started').and_return(task)
35
- UI.any_instance.should_receive(:`).with('git checkout -B 1')
36
-
37
- ui = UI.new %w{ start 1 }
38
- end
47
+ end
48
+
49
+ context 'when run from an existing story branch' do
50
+ before { system('git checkout -B new_feature-12345') }
51
+
52
+ it "creates a branch within the same namespace" do
53
+ prompt.should_receive(:ask).and_return('3')
54
+ PT::Flow::UI.new %w{ start }
55
+ current_branch.should == 'new_feature-4460038'
39
56
  end
40
57
  end
58
+ end
41
59
 
60
+ describe '#finish' do
61
+ before do
62
+ #TODO: Stubbed endpoint ALWAYS returns story 4459994, need a way to check it is actually getting the right id from the branch
63
+ system('git checkout -B new_feature-4459994')
64
+ system('git remote add origin git@github.com:balvig/pt-flow.git')
65
+ end
66
+
67
+ it "pushes the current branch to origin, flags the story as finished, and opens a github pull request" do
68
+ PT::Flow::UI.any_instance.should_receive(:run).with('git push origin new_feature-4459994')
69
+ PT::Flow::UI.any_instance.should_receive(:run).with("open 'https://github.com/balvig/pt-flow/pull/new/new_feature...new_feature-4459994?title=Unestimated Feature [#4459994]&body=http://www.pivotaltracker.com/story/show/4459994'")
70
+ PT::Flow::UI.new %w{ finish }
71
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<current_state>finished<\/current_state>/)
72
+ end
73
+ end
74
+
75
+ describe '#deliver' do
76
+ before do
77
+ #TODO: Stubbed endpoint ALWAYS returns story 4459994, need a way to check it is actually getting the right id from the branch
78
+ system('git checkout -B new_feature-4459994')
79
+ end
80
+
81
+ it "pushes the current branch to origin, flags the story as finished, and opens a github pull request" do
82
+ PT::Flow::UI.any_instance.should_receive(:run).with('git fetch')
83
+ PT::Flow::UI.any_instance.should_receive(:run).with('git checkout new_feature')
84
+ PT::Flow::UI.any_instance.should_receive(:run).with('git pull --rebase origin new_feature')
85
+ PT::Flow::UI.any_instance.should_receive(:run).with('git merge new_feature-4459994')
86
+ PT::Flow::UI.any_instance.should_receive(:run).with('git push origin new_feature')
87
+ PT::Flow::UI.any_instance.should_receive(:run).with('git push origin :new_feature-4459994')
88
+ PT::Flow::UI.any_instance.should_receive(:run).with('git branch -d new_feature-4459994')
89
+
90
+ PT::Flow::UI.new %w{ deliver }
91
+ WebMock.should have_requested(:put, "#{endpoint}/projects/102622/stories/4459994").with(body: /<current_state>delivered<\/current_state>/)
92
+ end
42
93
  end
43
94
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'bundler'
2
1
  require 'pt-flow'
3
2
 
4
3
  PT::UI.send(:remove_const, :GLOBAL_CONFIG_PATH)
@@ -6,6 +5,8 @@ PT::UI.send(:remove_const, :LOCAL_CONFIG_PATH)
6
5
  PT::UI::GLOBAL_CONFIG_PATH = File.join(File.dirname(__FILE__), 'fixtures', 'global_config.yml')
7
6
  PT::UI::LOCAL_CONFIG_PATH = File.join(File.dirname(__FILE__), 'fixtures', 'local_config.yml')
8
7
 
8
+ Dir[File.join(File.dirname(__FILE__),'support', '**', '*.rb')].each {|f| require f}
9
+
9
10
  RSpec.configure do |config|
10
11
  config.mock_with :rspec
11
12
  end
@@ -0,0 +1,14 @@
1
+ RSpec.configure do |config|
2
+ dummy_path = File.join(File.dirname(__FILE__), '..', 'fixtures', 'dummy')
3
+
4
+ config.before(:each) do
5
+ FileUtils.rm_rf(dummy_path) if Dir.exists?(dummy_path)
6
+ Dir.mkdir(dummy_path)
7
+ Dir.chdir(dummy_path)
8
+ system('git init .')
9
+ system('touch dummy.txt')
10
+ system('git add .')
11
+ system('git commit -m"init commit"')
12
+ end
13
+
14
+ end
@@ -0,0 +1,13 @@
1
+ module FixtureMacros
2
+ def fixture_file(filename)
3
+ File.new(fixture_file_path(filename))
4
+ end
5
+
6
+ def fixture_file_path(filename)
7
+ File.join(File.dirname(__FILE__), '..', 'fixtures', filename)
8
+ end
9
+ end
10
+
11
+ RSpec.configure do |config|
12
+ config.include(FixtureMacros)
13
+ end
@@ -0,0 +1,9 @@
1
+ module GitMacros
2
+ def current_branch
3
+ `git rev-parse --abbrev-ref HEAD`.strip
4
+ end
5
+ end
6
+
7
+ RSpec.configure do |config|
8
+ config.include(GitMacros)
9
+ end
@@ -0,0 +1,5 @@
1
+ require 'webmock/rspec'
2
+
3
+ class Pivotal
4
+
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pt-flow
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pt
16
- requirement: &70237517292560 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70237517292560
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &70237509107220 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,31 @@ dependencies:
32
37
  version: '2.9'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70237509107220
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.9'
46
+ - !ruby/object:Gem::Dependency
47
+ name: webmock
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
36
62
  - !ruby/object:Gem::Dependency
37
63
  name: guard
38
- requirement: &70237509108900 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
39
65
  none: false
40
66
  requirements:
41
67
  - - ! '>='
@@ -43,10 +69,15 @@ dependencies:
43
69
  version: '0'
44
70
  type: :development
45
71
  prerelease: false
46
- version_requirements: *70237509108900
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
47
78
  - !ruby/object:Gem::Dependency
48
79
  name: guard-rspec
49
- requirement: &70237513253180 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
50
81
  none: false
51
82
  requirements:
52
83
  - - ! '>='
@@ -54,7 +85,12 @@ dependencies:
54
85
  version: '0'
55
86
  type: :development
56
87
  prerelease: false
57
- version_requirements: *70237513253180
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
58
94
  description: Some extra methods for the pt gem to use in our dev flow.
59
95
  email:
60
96
  - jens@balvig.com
@@ -74,10 +110,38 @@ files:
74
110
  - lib/pt-flow/ui.rb
75
111
  - lib/pt-flow/version.rb
76
112
  - pt-flow.gemspec
113
+ - spec/fixtures/activity.xml
114
+ - spec/fixtures/backup_stories.xml
115
+ - spec/fixtures/bugs.xml
116
+ - spec/fixtures/created_note.xml
117
+ - spec/fixtures/created_story.xml
118
+ - spec/fixtures/features.xml
77
119
  - spec/fixtures/global_config.yml
120
+ - spec/fixtures/iterations_all.xml
121
+ - spec/fixtures/iterations_backlog.xml
122
+ - spec/fixtures/iterations_current.xml
123
+ - spec/fixtures/iterations_current_backlog.xml
124
+ - spec/fixtures/iterations_done.xml
78
125
  - spec/fixtures/local_config.yml
126
+ - spec/fixtures/memberships.xml
127
+ - spec/fixtures/notes.xml
128
+ - spec/fixtures/project.xml
129
+ - spec/fixtures/project_activity.xml
130
+ - spec/fixtures/projects.xml
131
+ - spec/fixtures/stories.xml
132
+ - spec/fixtures/story-4459994.xml
133
+ - spec/fixtures/story-4460038.xml
134
+ - spec/fixtures/story-4460598.xml
135
+ - spec/fixtures/story-4473735.xml
136
+ - spec/fixtures/story.xml
137
+ - spec/fixtures/tasks.xml
138
+ - spec/fixtures/update_tasks.xml
79
139
  - spec/lib/pt-flow/ui_spec.rb
80
140
  - spec/spec_helper.rb
141
+ - spec/support/dummy.rb
142
+ - spec/support/fixture_macros.rb
143
+ - spec/support/git_macros.rb
144
+ - spec/support/webmock.rb
81
145
  homepage: ''
82
146
  licenses: []
83
147
  post_install_message:
@@ -92,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
156
  version: '0'
93
157
  segments:
94
158
  - 0
95
- hash: 3947336664115380543
159
+ hash: -3508141726274605870
96
160
  required_rubygems_version: !ruby/object:Gem::Requirement
97
161
  none: false
98
162
  requirements:
@@ -101,15 +165,43 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
165
  version: '0'
102
166
  segments:
103
167
  - 0
104
- hash: 3947336664115380543
168
+ hash: -3508141726274605870
105
169
  requirements: []
106
170
  rubyforge_project:
107
- rubygems_version: 1.8.11
171
+ rubygems_version: 1.8.23
108
172
  signing_key:
109
173
  specification_version: 3
110
174
  summary: Some extra methods for the pt gem to use in our dev flow.
111
175
  test_files:
176
+ - spec/fixtures/activity.xml
177
+ - spec/fixtures/backup_stories.xml
178
+ - spec/fixtures/bugs.xml
179
+ - spec/fixtures/created_note.xml
180
+ - spec/fixtures/created_story.xml
181
+ - spec/fixtures/features.xml
112
182
  - spec/fixtures/global_config.yml
183
+ - spec/fixtures/iterations_all.xml
184
+ - spec/fixtures/iterations_backlog.xml
185
+ - spec/fixtures/iterations_current.xml
186
+ - spec/fixtures/iterations_current_backlog.xml
187
+ - spec/fixtures/iterations_done.xml
113
188
  - spec/fixtures/local_config.yml
189
+ - spec/fixtures/memberships.xml
190
+ - spec/fixtures/notes.xml
191
+ - spec/fixtures/project.xml
192
+ - spec/fixtures/project_activity.xml
193
+ - spec/fixtures/projects.xml
194
+ - spec/fixtures/stories.xml
195
+ - spec/fixtures/story-4459994.xml
196
+ - spec/fixtures/story-4460038.xml
197
+ - spec/fixtures/story-4460598.xml
198
+ - spec/fixtures/story-4473735.xml
199
+ - spec/fixtures/story.xml
200
+ - spec/fixtures/tasks.xml
201
+ - spec/fixtures/update_tasks.xml
114
202
  - spec/lib/pt-flow/ui_spec.rb
115
203
  - spec/spec_helper.rb
204
+ - spec/support/dummy.rb
205
+ - spec/support/fixture_macros.rb
206
+ - spec/support/git_macros.rb
207
+ - spec/support/webmock.rb