snapgit 0.6.4

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.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.editorconfig +17 -0
  4. data/.gitattributes +1 -0
  5. data/.gitignore +14 -0
  6. data/.rubocop.yml +10 -0
  7. data/.rubocop_todo.yml +57 -0
  8. data/.travis.yml +42 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE +165 -0
  11. data/README.md +28 -0
  12. data/Rakefile +79 -0
  13. data/bin/lolcommits +335 -0
  14. data/bin/snapgit +14 -0
  15. data/config/cucumber.yml +2 -0
  16. data/features/bugs.feature +63 -0
  17. data/features/lolcommits.feature +286 -0
  18. data/features/plugins.feature +20 -0
  19. data/features/step_definitions/lolcommits_steps.rb +142 -0
  20. data/features/support/env.rb +61 -0
  21. data/features/support/path_helpers.rb +39 -0
  22. data/lib/core_ext/class.rb +8 -0
  23. data/lib/core_ext/mini_magick/utilities.rb +15 -0
  24. data/lib/lolcommits.rb +34 -0
  25. data/lib/lolcommits/capturer.rb +24 -0
  26. data/lib/lolcommits/capturer/capture_cygwin.rb +22 -0
  27. data/lib/lolcommits/capturer/capture_fake.rb +9 -0
  28. data/lib/lolcommits/capturer/capture_linux.rb +45 -0
  29. data/lib/lolcommits/capturer/capture_linux_animated.rb +72 -0
  30. data/lib/lolcommits/capturer/capture_mac.rb +23 -0
  31. data/lib/lolcommits/capturer/capture_mac_animated.rb +73 -0
  32. data/lib/lolcommits/capturer/capture_windows.rb +22 -0
  33. data/lib/lolcommits/cli/fatals.rb +77 -0
  34. data/lib/lolcommits/cli/launcher.rb +29 -0
  35. data/lib/lolcommits/cli/process_runner.rb +48 -0
  36. data/lib/lolcommits/cli/timelapse_gif.rb +45 -0
  37. data/lib/lolcommits/configuration.rb +138 -0
  38. data/lib/lolcommits/git_info.rb +82 -0
  39. data/lib/lolcommits/init.rb +121 -0
  40. data/lib/lolcommits/installation.rb +128 -0
  41. data/lib/lolcommits/platform.rb +127 -0
  42. data/lib/lolcommits/plugin.rb +130 -0
  43. data/lib/lolcommits/plugins/dot_com.rb +50 -0
  44. data/lib/lolcommits/plugins/lol_protonet.rb +68 -0
  45. data/lib/lolcommits/plugins/lol_slack.rb +68 -0
  46. data/lib/lolcommits/plugins/lol_tumblr.rb +127 -0
  47. data/lib/lolcommits/plugins/lol_twitter.rb +155 -0
  48. data/lib/lolcommits/plugins/lol_yammer.rb +85 -0
  49. data/lib/lolcommits/plugins/lolsrv.rb +59 -0
  50. data/lib/lolcommits/plugins/loltext.rb +147 -0
  51. data/lib/lolcommits/plugins/snapgit.rb +167 -0
  52. data/lib/lolcommits/plugins/tranzlate.rb +115 -0
  53. data/lib/lolcommits/plugins/uploldz.rb +65 -0
  54. data/lib/lolcommits/runner.rb +134 -0
  55. data/lib/lolcommits/version.rb +5 -0
  56. data/snapgit.gemspec +63 -0
  57. data/test/images/test_image.jpg +0 -0
  58. data/test/lolcommits_test.rb +35 -0
  59. data/test/plugins_test.rb +52 -0
  60. data/vendor/ext/CommandCam/COPYING +674 -0
  61. data/vendor/ext/CommandCam/CommandCam.exe +0 -0
  62. data/vendor/ext/CommandCam/LICENSE +16 -0
  63. data/vendor/ext/imagesnap/ReadMeOrDont.rtf +117 -0
  64. data/vendor/ext/imagesnap/imagesnap +0 -0
  65. data/vendor/ext/videosnap/videosnap +0 -0
  66. data/vendor/fonts/Lato.ttf +0 -0
  67. data/vendor/logos/Snapgit.png +0 -0
  68. metadata +509 -0
data/bin/snapgit ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
5
+ bin_path = File.join(File.expand_path('..', __FILE__), 'lolcommits')
6
+
7
+ # We basically only want to provide the `init` command
8
+ if ARGV.first == 'init'
9
+ require 'lolcommits/init'
10
+ Lolcommits::Init.run_setup(bin_path)
11
+ else
12
+ # Wups, nothing we want to deal with, let's forward this to lolcommits
13
+ exec("#{bin_path} #{ARGV.join(' ')}")
14
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ default: <%= (RbConfig::CONFIG['host_os'] =~ /darwin/) ? 'features' : '--tags ~@mac-only' %>
@@ -0,0 +1,63 @@
1
+ Feature: Bug regression testing
2
+ As a developer
3
+ I want to ensure fixed bugs stay fixed
4
+ So that I don't have to fix them again!
5
+
6
+ Background:
7
+ Given a mocked home directory
8
+
9
+ #
10
+ # issue #58, https://github.com/mroth/lolcommits/issues/58
11
+ #
12
+ Scenario: handle git repos with spaces in directory name
13
+ Given I am in a git repo named "test lolol" with lolcommits enabled
14
+ And I successfully run `git commit --allow-empty -m 'can haz commit'`
15
+ Then the output should contain "*** Preserving this moment in history."
16
+ And a directory named "../.lolcommits/test-lolol" should exist
17
+
18
+ #
19
+ # issue #68, https://github.com/mroth/lolcommits/issues/68
20
+ #
21
+ @fake-interactive-rebase @slow_process @unstable
22
+ Scenario: Don't trigger capture during a git rebase
23
+ Given I am in a git repo named "yuh8history" with lolcommits enabled
24
+ And I do 6 git commits
25
+ When I successfully run `git rebase -i HEAD~5`
26
+ # Then there should be 4 commit entries in the git log
27
+ Then there should be exactly 6 jpgs in "../.lolcommits/yuh8history"
28
+
29
+ #
30
+ # issue #81, https://github.com/mroth/lolcommits/issues/81
31
+ #
32
+ Scenario: don't want initialized constant warning from Faraday (MRI 1.8.7)
33
+ When I successfully run `lolcommits`
34
+ Then the output should not contain:
35
+ """
36
+ warning: already initialized constant DEFAULT_BOUNDARY
37
+ """
38
+
39
+ #
40
+ # issue #87, https://github.com/mroth/lolcommits/issues/87
41
+ #
42
+ @fake-no-imagemagick
43
+ Scenario: gracefully fail when imagemagick is not installed
44
+ When I run `lolcommits`
45
+ Then the output should contain:
46
+ """
47
+ ImageMagick does not appear to be properly installed
48
+ """
49
+ And the exit status should be 1
50
+
51
+ #
52
+ # issue #50, https://github.com/mroth/lolcommits/issues/50
53
+ #
54
+ Scenario: catch upstream bug with ruby-git and color=always
55
+ Given I am in a git repo named "whatev" with lolcommits enabled
56
+ And I successfully run `git config color.ui always`
57
+ When I run `lolcommits`
58
+ Then the output should contain:
59
+ """
60
+ Due to a bug in the ruby-git library, git config for color.ui cannot be set to 'always'.
61
+ """
62
+ And the output should contain "Try setting it to 'auto' instead!"
63
+ And the exit status should be 1
@@ -0,0 +1,286 @@
1
+ Feature: Basic UI functionality
2
+
3
+ Background:
4
+ Given a mocked home directory
5
+
6
+ Scenario: App just runs
7
+ When I get help for "lolcommits"
8
+ Then the exit status should be 0
9
+ And the banner should be present
10
+
11
+ Scenario: Help should show the animate option on a Mac platform
12
+ Given I am using a "darwin" platform
13
+ When I get help for "lolcommits"
14
+ Then the following options should be documented:
15
+ | --animate | which is optional |
16
+ | -a | which is optional |
17
+
18
+ Scenario: Help should not show the animate option on a Windows plaftorm
19
+ Given I am using a "win32" platform
20
+ When I get help for "lolcommits"
21
+ Then the output should not match /\-a\, \-\-animate\=SECONDS/
22
+
23
+ Scenario: Enable in a naked git repo
24
+ Given I am in a git repo
25
+ When I successfully run `lolcommits --enable`
26
+ Then the output should contain "installed lolcommit hook to:"
27
+ And the lolcommits post-commit hook should be properly installed
28
+ And the exit status should be 0
29
+
30
+ Scenario: Enable in a git repo that already has a post-commit hook
31
+ Given I am in a git repo
32
+ And a post-commit hook with "#!/bin/sh\n\n/my/own/script"
33
+ When I successfully run `lolcommits --enable`
34
+ Then the output should contain "installed lolcommit hook to:"
35
+ And the lolcommits post-commit hook should be properly installed
36
+ And the post-commit hook should contain "#!/bin/sh"
37
+ And the post-commit hook should contain "/my/own/script"
38
+ And the exit status should be 0
39
+
40
+ Scenario: Enable in a git repo that has post-commit hook with a bad shebang
41
+ Given I am in a git repo
42
+ And a post-commit hook with "#!/bin/ruby"
43
+ And I run `lolcommits --enable`
44
+ Then the output should contain "doesn't start with a good shebang"
45
+ And the post-commit hook should not contain "lolcommits --capture"
46
+ And the exit status should be 1
47
+
48
+ Scenario: Enable in a git repo passing capture arguments
49
+ Given I am in a git repo
50
+ When I successfully run `lolcommits --enable -w 5 --fork`
51
+ Then the post-commit hook should contain "lolcommits --capture -w 5 --fork"
52
+ And the exit status should be 0
53
+
54
+ Scenario: Disable in a enabled git repo
55
+ Given I am in a git repo with lolcommits enabled
56
+ When I successfully run `lolcommits --disable`
57
+ Then the output should contain "uninstalled"
58
+ And a file named ".git/hooks/post-commit" should exist
59
+ And the exit status should be 0
60
+
61
+ Scenario: Trying to enable while not in a git repo fails
62
+ Given I am in a directory named "svnrulez"
63
+ When I run `lolcommits --enable`
64
+ Then the output should contain:
65
+ """
66
+ You don't appear to be in the base directory of a git project.
67
+ """
68
+ And the exit status should be 1
69
+
70
+ Scenario: Capture doesnt break in forked mode
71
+ Given I am in a git repo named "forked"
72
+ And I do a git commit
73
+ When I successfully run `lolcommits --capture --fork`
74
+ Then there should be exactly 1 pid in "~/.lolcommits/forked"
75
+ When I wait for the child process to exit in "forked"
76
+ Then a directory named "~/.lolcommits/forked" should exist
77
+ And a file named "~/.lolcommits/forked/tmp_snapshot.jpg" should not exist
78
+ And there should be exactly 1 jpg in "~/.lolcommits/forked"
79
+
80
+ Scenario: Commiting in an enabled repo triggers successful capture
81
+ Given I am in a git repo named "myrepo" with lolcommits enabled
82
+ When I do a git commit
83
+ Then the output should contain "*** Preserving this moment in history."
84
+ And a directory named "~/.lolcommits/myrepo" should exist
85
+ And a file named "~/.lolcommits/myrepo/tmp_snapshot.jpg" should not exist
86
+ And there should be exactly 1 jpg in "~/.lolcommits/myrepo"
87
+
88
+ Scenario: Commiting in enabled repo subdirectory triggers successful capture
89
+ Given I am in a git repo named "testcapture" with lolcommits enabled
90
+ And a directory named "subdir"
91
+ And an empty file named "subdir/FOOBAR"
92
+ When I cd to "subdir/"
93
+ And I do a git commit
94
+ Then the output should contain "*** Preserving this moment in history."
95
+ And a directory named "~/.lolcommits/testcapture" should exist
96
+ And a directory named "~/.lolcommits/subdir" should not exist
97
+ And there should be exactly 1 jpg in "~/.lolcommits/testcapture"
98
+
99
+ Scenario: Stealth mode does not alert the user
100
+ Given I am in a git repo named "teststealth"
101
+ And I do a git commit
102
+ When I run `lolcommits --stealth --capture`
103
+ Then the output should not contain "*** Preserving this moment in history."
104
+ And there should be exactly 1 jpg in "~/.lolcommits/teststealth"
105
+
106
+ Scenario: Commiting in stealth mode captures without alerting the committer
107
+ Given I am in a git repo with lolcommits enabled
108
+ And I have environment variable LOLCOMMITS_STEALTH set to 1
109
+ When I do a git commit
110
+ Then the output should not contain "*** Preserving this moment in history."
111
+ And there should be exactly 1 jpg in its loldir
112
+
113
+ Scenario: Show plugins
114
+ When I successfully run `lolcommits --plugins`
115
+ Then the output should contain a list of plugins
116
+
117
+ Scenario: Configuring loltext plugin
118
+ Given I am in a git repo named "config-test"
119
+ When I run `lolcommits --config` interactively
120
+ And I wait for output to contain "Name of plugin to configure:"
121
+ Then I type "loltext"
122
+ And I wait for output to contain "enabled:"
123
+ Then I type "true"
124
+ And I wait for output to contain "color"
125
+ Then I type "red"
126
+ And I wait for output to contain "font"
127
+ Then I type "my-font.ttf"
128
+ And I wait for output to contain "position"
129
+ Then I type "SouthEast"
130
+ And I wait for output to contain "size"
131
+ Then I type "32"
132
+ And I wait for output to contain "stroke color"
133
+ Then I type "white"
134
+ And I wait for output to contain "sha text"
135
+ Then I type ""
136
+ Then I type ""
137
+ Then I type ""
138
+ Then I type ""
139
+ Then I type ""
140
+ Then the output should contain "Successfully configured plugin: loltext"
141
+ And the output should contain a list of plugins
142
+ And a file named "~/.lolcommits/config-test/config.yml" should exist
143
+ When I successfully run `lolcommits --show-config`
144
+ Then the output should match /enabled: true/
145
+ And the output should match /:font: my-font\.ttf/
146
+ And the output should match /:size: 32/
147
+ And the output should match /:position: SouthEast/
148
+ And the output should match /:color: red/
149
+ And the output should match /:stroke_color: white/
150
+
151
+ Scenario: Configuring loltext plugin in test mode affects test loldir not repo loldir
152
+ Given I am in a git repo named "testmode-config-test"
153
+ When I run `lolcommits --config --test -p loltext` interactively
154
+ And I wait for output to contain "enabled:"
155
+ Then I type "false"
156
+ Then the output should contain "Successfully configured plugin: loltext"
157
+ And a file named "~/.lolcommits/test/config.yml" should exist
158
+ When I successfully run `lolcommits --test --show-config`
159
+ Then the output should match /loltext:\s+enabled: false/
160
+
161
+ Scenario: test capture should work regardless of whether in a git repo
162
+ Given I am in a directory named "nothingtoseehere"
163
+ When I run `lolcommits --test --capture`
164
+ Then the output should contain "*** Capturing in test mode."
165
+ And the output should not contain "path does not exist (ArgumentError)"
166
+ And the exit status should be 0
167
+
168
+ Scenario: test capture should store in its own test directory
169
+ Given I am in a git repo named "randomgitrepo" with lolcommits enabled
170
+ When I successfully run `lolcommits --test --capture`
171
+ Then a directory named "~/.lolcommits/test" should exist
172
+ And a directory named "~/.lolcommits/randomgitrepo" should not exist
173
+
174
+ Scenario: last command should work properly when in a lolrepo
175
+ Given I am in a git repo
176
+ And its loldir has 2 lolimages
177
+ When I run `lolcommits --last`
178
+ Then the exit status should be 0
179
+
180
+ Scenario: last command should work properly when in a lolrepo subdirectory
181
+ Given I am in a git repo
182
+ And its loldir has 2 lolimages
183
+ And a directory named "randomdir"
184
+ And I cd to "randomdir"
185
+ When I run `lolcommits --last`
186
+ Then the output should not contain:
187
+ """
188
+ Can't do that since we're not in a valid git repository!
189
+ """
190
+ And the exit status should be 0
191
+
192
+ @in-tempdir
193
+ Scenario: last command should fail gracefully if not in a lolrepo
194
+ Given I am in a directory named "gitsuxcvs4eva"
195
+ When I run `lolcommits --last`
196
+ Then the output should contain:
197
+ """
198
+ Can't do that since we're not in a valid git repository!
199
+ """
200
+ And the exit status should be 1
201
+
202
+ Scenario: last command should fail gracefully if zero lolimages in lolrepo
203
+ Given I am in a git repo
204
+ And its loldir has 0 lolimages
205
+ When I run `lolcommits --last`
206
+ Then the output should contain:
207
+ """
208
+ No lolcommits have been captured for this repository yet.
209
+ """
210
+ Then the exit status should be 1
211
+
212
+ Scenario: browse command should work properly when in a lolrepo
213
+ Given I am in a git repo
214
+ And its loldir has 2 lolimages
215
+ When I run `lolcommits --browse`
216
+ Then the exit status should be 0
217
+
218
+ Scenario: browse command should work properly when in a lolrepo subdirectory
219
+ Given I am in a git repo
220
+ And its loldir has 2 lolimages
221
+ And a directory named "subdir"
222
+ And I cd to "subdir"
223
+ When I run `lolcommits --browse`
224
+ Then the output should not contain:
225
+ """
226
+ Can't do that since we're not in a valid git repository!
227
+ """
228
+ And the exit status should be 0
229
+
230
+ @in-tempdir
231
+ Scenario: browse command should fail gracefully when not in a lolrepo
232
+ Given I am in a directory named "gitsuxcvs4eva"
233
+ When I run `lolcommits --browse`
234
+ Then the output should contain:
235
+ """
236
+ Can't do that since we're not in a valid git repository!
237
+ """
238
+ And the exit status should be 1
239
+
240
+ Scenario: handle commit messages with quotation marks
241
+ Given I am in a git repo with lolcommits enabled
242
+ When I successfully run `git commit --allow-empty -m 'no "air quotes" bae'`
243
+ Then the exit status should be 0
244
+ And there should be exactly 1 jpg in its loldir
245
+
246
+ Scenario: generate gif should store in its own archive directory
247
+ Given I am in a git repo named "giffy" with lolcommits enabled
248
+ And a loldir named "giffy" with 2 lolimages
249
+ When I successfully run `lolcommits -g`
250
+ Then the output should contain "Generating animated gif."
251
+ And a directory named "~/.lolcommits/giffy/archive" should exist
252
+ And a file named "~/.lolcommits/giffy/archive/archive.gif" should exist
253
+
254
+ Scenario: generate gif with argument 'today'
255
+ Given I am in a git repo named "sunday" with lolcommits enabled
256
+ And a loldir named "sunday" with 2 lolimages
257
+ When I successfully run `lolcommits -g today`
258
+ Then there should be exactly 1 gif in "~/.lolcommits/sunday/archive"
259
+
260
+ @mac-only
261
+ Scenario: should generate an animated gif on the Mac platform
262
+ Given I am in a git repo named "animate"
263
+ And I do a git commit
264
+ When I run `lolcommits --capture --animate=1`
265
+ Then the output should contain "*** Preserving this moment in history."
266
+ And a directory named "~/.lolcommits/animate" should exist
267
+ And a file named "~/.lolcommits/animate/tmp_video.mov" should not exist
268
+ And a directory named "~/.lolcommits/animate/tmp_frames" should not exist
269
+ And there should be exactly 1 gif in "~/.lolcommits/animate"
270
+
271
+ @fake-no-ffmpeg
272
+ Scenario: gracefully fail when ffmpeg not installed and --animate is used
273
+ Given I am using a "darwin" platform
274
+ When I run `lolcommits --animate=3`
275
+ Then the output should contain:
276
+ """
277
+ ffmpeg does not appear to be properly installed
278
+ """
279
+ And the exit status should be 1
280
+
281
+ Scenario: Enable on windows platform setting PATH in post-commit hook
282
+ Given I am using a "win32" platform
283
+ And I am in a git repo
284
+ When I successfully run `lolcommits --enable`
285
+ Then the post-commit hook should contain "set path"
286
+ And the exit status should be 0
@@ -0,0 +1,20 @@
1
+ Feature: Plugins Work
2
+
3
+ Background:
4
+ Given a mocked home directory
5
+
6
+ @slow_process @unstable
7
+ Scenario: Lolcommits.com integration works
8
+ Given I am in a git repo named "dot_com" with lolcommits enabled
9
+ When I run `lolcommits --config` interactively
10
+ And I wait for output to contain "Name of plugin to configure:"
11
+ Then I type "dot_com"
12
+ And I wait for output to contain "enabled:"
13
+ Then I type "true"
14
+ And I wait for output to contain "api_key:"
15
+ Then I type "b2a70ac0b64e012fa61522000a8c42dc"
16
+ And I wait for output to contain "api_secret:"
17
+ Then I type "b2a70ac0b64e012fa61522000a8c42dc"
18
+ And I wait for output to contain "repo_id:"
19
+ Then I type "b2a70ac0b64e012fa61522000a8c42dc"
20
+ Then the output should contain "Successfully configured plugin: dot_com"
@@ -0,0 +1,142 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'fileutils'
3
+ require 'aruba/api'
4
+
5
+ def postcommit_hook
6
+ '.git/hooks/post-commit'
7
+ end
8
+
9
+ def default_repo
10
+ 'mygit'
11
+ end
12
+
13
+ def default_loldir
14
+ absolute_path("~/.lolcommits/#{default_repo}")
15
+ end
16
+
17
+ Given(/^I am in a directory named "(.*?)"$/) do |dir_name|
18
+ steps %(
19
+ Given a directory named "#{dir_name}"
20
+ And I cd to "#{dir_name}"
21
+ )
22
+ end
23
+
24
+ Given(/^a git repo named "(.*?)"$/) do |repo_name|
25
+ steps %(
26
+ Given I successfully run `git init --quiet "#{repo_name}"`
27
+ )
28
+ end
29
+
30
+ Given(/^I am in a git repo named "(.*?)"$/) do |repo|
31
+ steps %(
32
+ Given a git repo named "#{repo}"
33
+ And I cd to "#{repo}"
34
+ )
35
+ end
36
+
37
+ Given(/^I am in a git repo$/) do
38
+ steps %(
39
+ Given I am in a git repo named "#{default_repo}"
40
+ )
41
+ end
42
+
43
+ Given(/^I am in a git repo named "(.*?)" with lolcommits enabled$/) do |repo|
44
+ steps %(
45
+ Given I am in a git repo named "#{repo}"
46
+ And I successfully run `lolcommits --enable`
47
+ )
48
+ end
49
+
50
+ Given(/^I am in a git repo with lolcommits enabled$/) do
51
+ steps %(
52
+ Given I am in a git repo named "#{default_repo}" with lolcommits enabled
53
+ )
54
+ end
55
+
56
+ Given(/^a post\-commit hook with "(.*?)"$/) do |file_content|
57
+ steps %(
58
+ Given a file named "#{postcommit_hook}" with:
59
+ """
60
+ #{file_content}
61
+ """
62
+ )
63
+ end
64
+
65
+ Then(/^the lolcommits post\-commit hook should be properly installed$/) do
66
+ steps %(
67
+ Then the post-commit hook should contain "lolcommits --capture"
68
+ )
69
+ end
70
+
71
+ Then(/^the post\-commit hook (should|should not) contain "(.*?)"$/) do |should, content|
72
+ steps %(
73
+ Then the file "#{postcommit_hook}" #{should} contain "#{content}"
74
+ )
75
+ end
76
+
77
+ Given(/^I have environment variable (.*?) set to (.*?)$/) do |var, value|
78
+ set_env var, value
79
+ end
80
+
81
+ Given(/^its loldir has (\d+) lolimages$/) do |num_images|
82
+ steps %(
83
+ Given a loldir named "#{default_repo}" with #{num_images} lolimages
84
+ )
85
+ end
86
+
87
+ Given(/^a loldir named "(.*?)" with (\d+) lolimages$/) do |repo, num_images|
88
+ loldir = absolute_path("~/.lolcommits/#{repo}")
89
+ FileUtils.mkdir_p loldir
90
+ num_images.to_i.times do
91
+ hex = format('%011x', (rand * 0xfffffffffff)).to_s
92
+ FileUtils.cp 'test/images/test_image.jpg', File.join(loldir, "#{hex}.jpg")
93
+ end
94
+ end
95
+
96
+ Then(/^there should be exactly (.*?) (jpg|gif|pid)s? in its loldir$/) do |n, type|
97
+ steps %(
98
+ Then there should be exactly #{n} #{type} in "#{default_loldir}"
99
+ )
100
+ end
101
+
102
+ Then(/^there should be exactly (.*?) (jpg|gif|pid)s? in "(.*?)"$/) do |n, type, folder|
103
+ expect(Dir[absolute_path(folder, "*.#{type}")].count).to eq(n.to_i)
104
+ end
105
+
106
+ Then(/^the output should contain a list of plugins$/) do
107
+ step %(the output should contain "Available plugins: ")
108
+ end
109
+
110
+ When(/^I do a git commit with commit message "(.*?)"$/) do |commit_msg|
111
+ filename = Faker::Lorem.words(1).first
112
+ steps %(
113
+ Given a 98 byte file named "#{filename}"
114
+ And I successfully run `git add #{filename}`
115
+ And I successfully run `git commit -m "#{commit_msg}"`
116
+ )
117
+ end
118
+
119
+ When(/^I do a git commit$/) do
120
+ step %(I do a git commit with commit message "#{Faker::Lorem.sentence}")
121
+ end
122
+
123
+ When(/^I do (\d+) git commits$/) do |n|
124
+ n.to_i.times do
125
+ step %(I do a git commit)
126
+ sleep 0.1
127
+ end
128
+ end
129
+
130
+ Then(/^there should be (\d+) commit entries in the git log$/) do |n|
131
+ sleep 1 # let the file writing catch up
132
+ expect(n.to_i).to eq `git shortlog | grep -E '^[ ]+\w+' | wc -l`.chomp.to_i
133
+ end
134
+
135
+ Given(/^I am using a "(.*?)" platform$/) do |host_os_name|
136
+ set_env 'LOLCOMMITS_FAKE_HOST_OS', host_os_name
137
+ end
138
+
139
+ When(/^I wait for the child process to exit in "(.*?)"$/) do |repo_name|
140
+ pid_loc = absolute_path("~/.lolcommits/#{repo_name}/lolcommits.pid")
141
+ sleep 0.1 while File.exist?(pid_loc)
142
+ end