stories_sync 0.0.2 → 0.0.3

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2008 Evelin Garcia and Lucas Nasif
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/bin/stories ADDED
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env ruby -rubygems
2
+
3
+ require File.join(File.dirname(__FILE__), "..", "lib", "stories_sync.rb")
4
+
5
+ if File.exists?("Thorfile")
6
+ load("Thorfile")
7
+ end
8
+
9
+ Stories.start
data/stories_sync.gemspec CHANGED
@@ -1,13 +1,17 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "stories_sync"
3
- s.version = "0.0.2"
3
+ s.version = "0.0.3"
4
4
  s.summary = "Stories Sync"
5
5
  s.description = "Manage and syncrhonize your UATs with Pivotal Tracker."
6
6
  s.authors = ["Evelin Garcia", "Lucas Nasif"]
7
7
  s.email = ["ehqhvm@gmail.com"]
8
8
 
9
+ s.executables << "stories"
10
+
9
11
  s.rubyforge_project = "stories_sync"
10
12
 
11
- s.files = ["README.markdown", "lib/pivotal.rb", "lib/stories_sync.rb", "stories_sync.gemspec"]
13
+ s.add_dependency("thor", "~> 0.11")
14
+
15
+ s.files = ["README.markdown", "lib/pivotal.rb", "bin/stories", "lib/stories_sync.rb", "stories_sync.gemspec", "LICENSE", "test/test_helper.rb", "test/stories_sync_test.rb", "templates/config/pivotal.yml", "templates/test/stories/label_1_test.rb", "templates/test/stories/label_1_test_template.rb", "templates/test/stories/label_2_test.rb", "templates/test/stories/label_2_test.rb"]
12
16
  end
13
17
 
@@ -0,0 +1,7 @@
1
+ ---
2
+ :user:
3
+ :pass: stories_sync
4
+ :token: 1f6e3f04cea980a892fa82620839db80
5
+ :name: ehqhvm@gmail.com
6
+ :project:
7
+ :id: "32613"
@@ -0,0 +1,10 @@
1
+ class FooTest < Test::Unit::TestCase
2
+ story 'a' do
3
+ scenario 'a' do
4
+ end
5
+ end
6
+ story 'b' do
7
+ scenario 'b' do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class FooTest < Test::Unit::TestCase
2
+ story 'a' do
3
+ scenario 'a' do
4
+ end
5
+ end
6
+ story 'b' do
7
+ scenario 'b' do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class BarTest < Test::Unit::TestCase
2
+ story '1' do
3
+ scenario '1' do
4
+ end
5
+ end
6
+ story '2' do
7
+ scenario '2' do
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,99 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'stories_sync.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper.rb'))
3
+
4
+ require "contest"
5
+
6
+ STORIES_ROOT = File.join("#{Dir.pwd}", "templates", "test", "stories")
7
+
8
+ class StorySyncTest < Test::Unit::TestCase
9
+ context "Synchronization" do
10
+ setup do
11
+ create_test_file("label_1")
12
+ create_test_file("label_2")
13
+ delete_all_stories
14
+ spawn_story("a", "label_1")
15
+ spawn_story("c", "label_1")
16
+ spawn_story("1", "label_2")
17
+ spawn_story("3", "label_2")
18
+ end
19
+
20
+ should "Synchronize multi-files with Pivotal" do
21
+ execute_at_root("sync")
22
+
23
+ stories = Story.find(:all).inject({}) do |result, story|
24
+ result[story.labels] ||= []
25
+ result[story.labels] << story.name
26
+ result
27
+ end
28
+
29
+ stories.each_pair do |key, value|
30
+ file = File.read("#{STORIES_ROOT}/#{key}_test.rb")
31
+ local_stories = file.scan(/\n\s*story[\s\n]*(?:"([^"]*)"|'([^']*)')/m).map(&:compact).flatten
32
+ assert_equal(value.sort, local_stories.sort)
33
+ end
34
+ end
35
+ end
36
+
37
+ context "Updating local stories" do
38
+ setup do
39
+ create_test_file("label_1")
40
+ create_test_file("label_2")
41
+ delete_all_stories
42
+ spawn_story("a", "label_1")
43
+ spawn_story("c", "label_1")
44
+ spawn_story("1", "label_2")
45
+ spawn_story("3", "label_2")
46
+ end
47
+
48
+ should "Add pending stories" do
49
+ execute_at_root("add_pending_stories")
50
+
51
+ f = File.read("#{STORIES_ROOT}/label_1_test.rb")
52
+ assert_match(/Pending stories/, f)
53
+ assert_match(/a/, f)
54
+ assert_match(/b/, f)
55
+ assert_match(/c/, f)
56
+
57
+ f = File.read("#{STORIES_ROOT}/label_2_test.rb")
58
+ assert_match(/Pending stories/, f)
59
+ assert_match(/1/, f)
60
+ assert_match(/2/, f)
61
+ assert_match(/3/, f)
62
+ end
63
+ end
64
+
65
+ context "Uploading new stories" do
66
+ setup do
67
+ create_test_file("label_1")
68
+ create_test_file("label_2")
69
+ delete_all_stories
70
+ spawn_story("a", "label_1")
71
+ spawn_story("1", "label_2")
72
+ end
73
+
74
+ should "Upload any new story to pivotal, without repeating it" do
75
+ execute_at_root("upload_new_stories")
76
+
77
+ stories = Story.find(:all).inject({}) do |result, story|
78
+ result[story.labels] ||= []
79
+ result[story.labels] << story.name
80
+ result
81
+ end
82
+
83
+ assert_equal(['a', 'b'], stories["label_1"].sort)
84
+ assert_equal(['1', '2'], stories["label_2"].sort)
85
+ end
86
+ end
87
+
88
+ context "Warning" do
89
+ setup do
90
+ delete_all_stories
91
+ spawn_story("alpha", "label_3")
92
+ end
93
+
94
+ should "Add a pending story that doesn't have any test file" do
95
+ assert_match(/The file .*label_3_test.rb. doesn't exist/, execute_at_root("add_pending_stories"))
96
+ end
97
+ end
98
+
99
+ end
@@ -0,0 +1,41 @@
1
+ require "rubygems"
2
+ require "contest"
3
+ require "fileutils"
4
+
5
+ ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..", "templates"))
6
+
7
+ $:.unshift ROOT
8
+
9
+ class Test::Unit::TestCase
10
+ def root(*args)
11
+ File.join(ROOT, *args)
12
+ end
13
+
14
+ def execute_at_root(args = nil)
15
+ Dir.chdir root do
16
+ `ruby -rubygems ../bin/stories #{args}` # 2>&1`
17
+ end
18
+ end
19
+
20
+ def delete_all_stories
21
+ Story.find(:all).each do |story|
22
+ story.destroy
23
+ end
24
+ end
25
+
26
+ def spawn_story(name, label)
27
+ story = Story.create(:name => name, :labels => label)
28
+ story.current_state = "unstarted"
29
+ story.save
30
+ end
31
+
32
+ def create_test_file(label)
33
+ File.open("#{STORIES_ROOT}/#{label}_test.rb", "w+") do |f|
34
+ f.puts template(label)
35
+ end
36
+ end
37
+
38
+ def template(label)
39
+ File.read("#{STORIES_ROOT}/#{label}_test_template.rb")
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stories_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evelin Garcia
@@ -12,13 +12,22 @@ cert_chain: []
12
12
 
13
13
  date: 2009-10-12 00:00:00 -03:00
14
14
  default_executable:
15
- dependencies: []
16
-
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: thor
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: "0.11"
25
+ version:
17
26
  description: Manage and syncrhonize your UATs with Pivotal Tracker.
18
27
  email:
19
28
  - ehqhvm@gmail.com
20
- executables: []
21
-
29
+ executables:
30
+ - stories
22
31
  extensions: []
23
32
 
24
33
  extra_rdoc_files: []
@@ -26,8 +35,16 @@ extra_rdoc_files: []
26
35
  files:
27
36
  - README.markdown
28
37
  - lib/pivotal.rb
38
+ - bin/stories
29
39
  - lib/stories_sync.rb
30
40
  - stories_sync.gemspec
41
+ - LICENSE
42
+ - test/test_helper.rb
43
+ - test/stories_sync_test.rb
44
+ - templates/config/pivotal.yml
45
+ - templates/test/stories/label_1_test.rb
46
+ - templates/test/stories/label_1_test_template.rb
47
+ - templates/test/stories/label_2_test.rb
31
48
  has_rdoc: true
32
49
  homepage:
33
50
  licenses: []