pendaxes 0.0.1

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.
@@ -0,0 +1,97 @@
1
+ require_relative './spec_helper'
2
+ require 'pendaxes/pending_manager'
3
+ require 'hashr'
4
+
5
+ describe Pendaxes::PendingManager do
6
+ class Manager
7
+ include Pendaxes::PendingManager
8
+
9
+ def initialize(config={})
10
+ @config = Hashr.new(config)
11
+ @pendings = []
12
+ end
13
+ end
14
+
15
+ subject { Manager.new }
16
+
17
+ describe "#add" do
18
+ before { subject.add(commit: {:sha => 'a'}, example: {:file => 'a'}, allowed: false) }
19
+
20
+ it "adds pendings" do
21
+ subject.all_pendings.size.should == 1
22
+ subject.all_pendings.first[:commit][:sha].should == 'a'
23
+ subject.all_pendings.first[:example][:file].should == 'a'
24
+ end
25
+
26
+ context "with Array" do
27
+ let(:fixture) { [{commit: {:sha => 'b'}, example: {:file => 'b'}, allowed: true}, {commit: {:sha => 'c'}, example: {:file => 'c'}, allowed: false}] }
28
+
29
+ before do
30
+ subject.add(fixture)
31
+ end
32
+
33
+ it "adds all as pending" do
34
+ subject.all_pendings.last(2).should == fixture
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "#pendings" do
40
+ before do
41
+ subject.add(commit: {:sha => 'a'}, example: {:file => 'a'}, allowed: true)
42
+ subject.add(commit: {:sha => 'b'}, example: {:file => 'b'}, allowed: false)
43
+ end
44
+
45
+ it "returns pendings exclude allowed" do
46
+ subject.pendings.size.should == 1
47
+ subject.pendings.first[:commit][:sha].should == 'b'
48
+ subject.pendings.first[:example][:file].should == 'b'
49
+ end
50
+
51
+ context "with config[:include_allowed]" do
52
+ subject { Manager.new(Hashr.new(:include_allowed => true)) }
53
+
54
+ it "returns pendings include allowed" do
55
+ subject.pendings.size.should == 2
56
+
57
+ subject.pendings[0][:commit][:sha].should == 'a'
58
+ subject.pendings[0][:example][:file].should == 'a'
59
+
60
+ subject.pendings[1][:commit][:sha].should == 'b'
61
+ subject.pendings[1][:example][:file].should == 'b'
62
+ end
63
+
64
+ end
65
+ end
66
+
67
+ describe "#all_pendings" do
68
+ before do
69
+ subject.add(commit: {:sha => 'a'}, example: {:file => 'a'}, allowed: true)
70
+ subject.add(commit: {:sha => 'b'}, example: {:file => 'b'}, allowed: false)
71
+ end
72
+
73
+ it "returns pendings with not allowed" do
74
+ subject.all_pendings.size.should == 2
75
+
76
+ subject.all_pendings[0][:commit][:sha].should == 'a'
77
+ subject.all_pendings[0][:example][:file].should == 'a'
78
+
79
+ subject.all_pendings[1][:commit][:sha].should == 'b'
80
+ subject.all_pendings[1][:example][:file].should == 'b'
81
+ end
82
+ end
83
+
84
+
85
+ describe "#reset" do
86
+ before do
87
+ subject.add(commit: {:sha => 'a'}, example: {:file => 'a'}, allowed: true)
88
+ subject.add(commit: {:sha => 'b'}, example: {:file => 'b'}, allowed: false)
89
+ subject.reset
90
+ end
91
+
92
+ it "removes all pendings that added" do
93
+ subject.all_pendings.should be_empty
94
+ subject.pendings.should be_empty
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,23 @@
1
+
2
+ require_relative './spec_helper'
3
+ require 'pendaxes/reporter'
4
+
5
+ describe Pendaxes::Reporter do
6
+ it "has included Defaults" do
7
+ described_class.singleton_class.included_modules.include?(Pendaxes::Defaults).should be_true
8
+ end
9
+
10
+ it "has included PendingManager" do
11
+ described_class.included_modules.include?(Pendaxes::PendingManager).should be_true
12
+ end
13
+
14
+ it "responds to #report" do
15
+ described_class.new.should be_respond_to(:report)
16
+ end
17
+
18
+ describe ".html?" do
19
+ it "returns false" do
20
+ described_class.html?.should be_false
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,34 @@
1
+ require_relative '../spec_helper'
2
+ require 'pendaxes/reporters/text'
3
+
4
+ describe Pendaxes::Reporter::Text do
5
+ it "has Pendaxes::Reporter as superclass" do
6
+ described_class.superclass.should == Pendaxes::Reporter
7
+ end
8
+
9
+ describe "#report" do
10
+ subject { described_class.new }
11
+ let!(:now) { Time.now }
12
+
13
+ before do
14
+ subject.add([
15
+ {commit: {sha: 'a', name: 'foo', email: 'foo@example.com', at: (now-86400)},
16
+ example: {file: 'a_spec.rb', line: 10, message: "pending 'because it fails'"}, allowed: true},
17
+ {commit: {sha: 'b', name: 'foo', email: 'foo@example.com', at: (now-864000)},
18
+ example: {file: 'a_spec.rb', line: 15, message: "pending 'because it fails.'"}, allowed: false}
19
+ ])
20
+ end
21
+
22
+ it "reports added pendings" do
23
+ subject.report.should be_include("a_spec.rb:10 - pending 'because it fails' (@ a #{now-86400})")
24
+ subject.report.should be_include("a_spec.rb:15 - pending 'because it fails.' (@ b #{now-864000})")
25
+ end
26
+
27
+ it "reports older pending first" do
28
+ subject.report.should == (<<-EOR).chomp
29
+ * a_spec.rb:15 - pending 'because it fails.' (@ b #{now-864000})
30
+ * a_spec.rb:10 - pending 'because it fails' (@ a #{now-86400})
31
+ EOR
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ RSpec.configure do |config|
5
+ config.treat_symbols_as_metadata_keys_with_true_values = true
6
+ config.run_all_when_everything_filtered = true
7
+ config.filter_run :focus
8
+
9
+ # Run specs in random order to surface order dependencies. If you find an
10
+ # order dependency and want to debug it, you can fix the order by providing
11
+ # the seed, which is printed after each run.
12
+ # --seed 1234
13
+ config.order = 'random'
14
+
15
+ config.before(:suite) do
16
+ system "tar", "-C", "#{File.dirname(__FILE__)}/../fixtures", "-xf", "#{File.dirname(__FILE__)}/../fixtures/repo.tar.gz"
17
+ end
18
+ end
19
+
20
+ $:.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
@@ -0,0 +1,115 @@
1
+ require_relative './spec_helper'
2
+ require 'pendaxes/workspace'
3
+ require 'fileutils'
4
+
5
+ describe Pendaxes::Workspace do
6
+ let(:repository) { "#{File.dirname(__FILE__)}/../fixtures/repo" }
7
+ let(:config) { {path: "/tmp/repo", repository: repository} }
8
+
9
+ subject do
10
+ described_class.new(config)
11
+ end
12
+
13
+ describe "#clone" do
14
+ it "clones a repository" do
15
+ File.stub(:exist? => false)
16
+ subject.should_receive(:git).with("clone", repository, "/tmp/repo")
17
+
18
+ subject.clone
19
+ end
20
+
21
+ context "if repository already cloned" do
22
+ before do
23
+ File.stub(:exist? => true)
24
+ end
25
+
26
+ it "removes then clone again" do
27
+ FileUtils.should_receive(:remove_entry_secure).with("/tmp/repo").ordered
28
+ subject.should_receive(:git).with("clone", repository, "/tmp/repo")
29
+ subject.clone
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "#update" do
35
+ before { File.stub(:exist? => true) }
36
+
37
+ it "fetch and reset" do
38
+ subject.should_receive(:dive).and_yield.ordered
39
+ subject.should_receive(:git).with("fetch", "origin").ordered
40
+ subject.should_receive(:git).with("reset", "--hard", "FETCH_HEAD").ordered
41
+
42
+ subject.update
43
+ end
44
+
45
+ context "if not cloned yet" do
46
+ before do
47
+ File.stub(:exist? => false)
48
+ end
49
+
50
+ it "clones first" do
51
+ subject.should_receive(:clone).ordered
52
+ subject.should_receive(:dive).and_yield.ordered
53
+ subject.should_receive(:git).with("fetch", "origin").ordered
54
+ subject.should_receive(:git).with("reset", "--hard", "FETCH_HEAD").ordered
55
+
56
+ subject.update
57
+ end
58
+ end
59
+
60
+ context "with config.branch" do
61
+ let(:config) { {directory: "/tmp/repo", repository: repository, branch: "topic"} }
62
+
63
+ it "resets to specified branch" do
64
+ subject.should_receive(:dive).and_yield.ordered
65
+ subject.should_receive(:git).with("fetch", "origin").ordered
66
+ subject.should_receive(:git).with("reset", "--hard", "topic").ordered
67
+
68
+ subject.update
69
+ end
70
+ end
71
+ end
72
+
73
+ describe "#path" do
74
+ it "returns the path to working copy" do
75
+ subject.path.should == "/tmp/repo"
76
+ end
77
+ end
78
+
79
+ describe "#dive" do
80
+ it "yields in Dir.chdir(path)" do
81
+ Dir.should_receive(:chdir).with(subject.path).and_yield
82
+
83
+ flag = false
84
+ subject.dive { flag = true }
85
+ flag.should be_true
86
+ end
87
+ end
88
+
89
+ describe "#git" do
90
+ it "invokes git" do
91
+ IO.should_receive(:popen).with(["git", "a", "b", "c"], 'r').and_return(:foo)
92
+ subject.git("a", "b", "c").should == :foo
93
+ end
94
+
95
+ context "if git failed" do
96
+ before do
97
+ IO.stub(popen: '')
98
+ $?.stub(success?: false)
99
+ end
100
+
101
+ it "returns nil" do
102
+ subject.git('a').should be_nil
103
+ end
104
+ end
105
+
106
+ context "with config.git" do
107
+ let(:config) { {directory: "/tmp/repo", repository: repository, git: "/path/to/git"} }
108
+
109
+ it "invokes specified git" do
110
+ IO.should_receive(:popen).with(["/path/to/git", "a", "b", "c"], 'r').and_return(:bar)
111
+ subject.git("a", "b", "c").should == :bar
112
+ end
113
+ end
114
+ end
115
+ end
metadata ADDED
@@ -0,0 +1,203 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pendaxes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Shota Fukumori (sora_h)
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: hashr
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: haml
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: mail
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: simplecov
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Throw axes to pending makers!
111
+ email:
112
+ - sorah@cookpad.com
113
+ executables:
114
+ - pendaxes
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rspec
120
+ - .rvmrc
121
+ - Gemfile
122
+ - README.md
123
+ - Rakefile
124
+ - bin/pendaxes
125
+ - fixtures/repo.tar.gz
126
+ - lib/pendaxes.rb
127
+ - lib/pendaxes/command_line.rb
128
+ - lib/pendaxes/config.rb
129
+ - lib/pendaxes/defaults.rb
130
+ - lib/pendaxes/detector.rb
131
+ - lib/pendaxes/detectors/rspec.rb
132
+ - lib/pendaxes/finder.rb
133
+ - lib/pendaxes/notificator.rb
134
+ - lib/pendaxes/notificators/mail.rb
135
+ - lib/pendaxes/notificators/terminal.rb
136
+ - lib/pendaxes/pending_manager.rb
137
+ - lib/pendaxes/reporter.rb
138
+ - lib/pendaxes/reporters/haml.rb
139
+ - lib/pendaxes/reporters/template.haml
140
+ - lib/pendaxes/reporters/text.rb
141
+ - lib/pendaxes/version.rb
142
+ - lib/pendaxes/workspace.rb
143
+ - pendaxes.gemspec
144
+ - spec/defaults_spec.rb
145
+ - spec/detector_spec.rb
146
+ - spec/detectors/rspec_spec.rb
147
+ - spec/finder_spec.rb
148
+ - spec/notificator_spec.rb
149
+ - spec/notificators/mail_spec.rb
150
+ - spec/notificators/terminal_spec.rb
151
+ - spec/pendaxes_spec.rb
152
+ - spec/pending_manager_spec.rb
153
+ - spec/reporter_spec.rb
154
+ - spec/reporters/text_spec.rb
155
+ - spec/spec_helper.rb
156
+ - spec/workspace_spec.rb
157
+ homepage: ''
158
+ licenses: []
159
+ post_install_message:
160
+ rdoc_options: []
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ! '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ segments:
170
+ - 0
171
+ hash: 314574877471589493
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ! '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ segments:
179
+ - 0
180
+ hash: 314574877471589493
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 1.8.23
184
+ signing_key:
185
+ specification_version: 3
186
+ summary: Throw axes to pending makers! Leaving a pending long time is really bad,
187
+ shouldn't be happened. So, this gem sends notification to committer that added pending
188
+ after a while from the commit. Avoid the trouble due to pending examples :D
189
+ test_files:
190
+ - fixtures/repo.tar.gz
191
+ - spec/defaults_spec.rb
192
+ - spec/detector_spec.rb
193
+ - spec/detectors/rspec_spec.rb
194
+ - spec/finder_spec.rb
195
+ - spec/notificator_spec.rb
196
+ - spec/notificators/mail_spec.rb
197
+ - spec/notificators/terminal_spec.rb
198
+ - spec/pendaxes_spec.rb
199
+ - spec/pending_manager_spec.rb
200
+ - spec/reporter_spec.rb
201
+ - spec/reporters/text_spec.rb
202
+ - spec/spec_helper.rb
203
+ - spec/workspace_spec.rb