Skip to content

Commit

Permalink
fix up features, refactor @in-tempdir tag
Browse files Browse the repository at this point in the history
  • Loading branch information
matthutchinson committed Jan 29, 2018
1 parent f54f6ac commit 0e2eaac
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 36 deletions.
2 changes: 2 additions & 0 deletions Gemfile
@@ -1,2 +1,4 @@
source 'https://rubygems.org'
gemspec

gem 'pry-remote'
1 change: 0 additions & 1 deletion Rakefile
Expand Up @@ -37,7 +37,6 @@ CLEAN << CUKE_RESULTS
Cucumber::Rake::Task.new(:features) do |t|
optstr = "features --format html -o #{CUKE_RESULTS} --format progress -x"
optstr << " --tags @#{ENV['tag']}" unless ENV['tag'].nil?
optstr << ' --tags ~@unstable' if ENV['tag'].nil? # ignore unstable tests unless specifying something at CLI
t.cucumber_opts = optstr
t.fork = false
end
Expand Down
8 changes: 4 additions & 4 deletions features/bugs.feature
Expand Up @@ -18,12 +18,12 @@ Feature: Bug regression testing
#
# issue #68, https://github.com/mroth/lolcommits/issues/68
#
@fake-interactive-rebase @slow_process @unstable
@fake-interactive-rebase @slow_process
Scenario: Don't trigger capture during a git rebase
Given I am in a git repo named "yuh8history" with lolcommits enabled
And I do 6 git commits
When I run `git rebase -i HEAD~5`
Then there should be exactly 6 jpgs in ".lolcommits/yuh8history"
And I do 3 git commits
When I run `git rebase -i HEAD~2`
Then there should be exactly 3 jpgs in "~/.lolcommits/yuh8history"

#
# issue #87, https://github.com/mroth/lolcommits/issues/87
Expand Down
30 changes: 13 additions & 17 deletions features/lolcommits.feature
Expand Up @@ -118,7 +118,6 @@ Feature: Basic UI functionality
Scenario: Configuring loltext plugin in test mode affects test loldir not repo loldir
Given I am in a git repo named "testmode-config-test"
When I run `lolcommits --config --test -p loltext` interactively
And I wait for output to contain "enabled:"
Then I type "false"
Then the output should contain "Disabling plugin: loltext - answer with 'true' to enable & configure"
And a file named "~/.lolcommits/test/config.yml" should exist
Expand Down Expand Up @@ -156,26 +155,33 @@ Feature: Basic UI functionality
"""
And the exit status should be 0

@in-tempdir
Scenario: last command should fail gracefully if not in a lolrepo
Given I am in a directory named "gitsuxcvs4eva"
@no-repo-dir
Scenario: last command should fail gracefully if not in a repo
When I run `lolcommits --last`
Then the output should contain:
"""
You don't appear to be in a directory of a supported vcs project.
"""
And the exit status should be 1

@in-tempdir
Scenario: Configuring loltext plugin if not in a lolrepo
Given I am in a directory named "gitsuxcvs4eva"
@no-repo-dir
Scenario: Configuring loltext plugin if not in a repo
When I run `lolcommits --config`
Then the output should contain:
"""
You don't appear to be in a directory of a supported vcs project.
"""
And the exit status should be 1

@no-repo-dir
Scenario: browse command should fail gracefully when not in a repo
When I run `lolcommits --browse`
Then the output should contain:
"""
You don't appear to be in a directory of a supported vcs project.
"""
And the exit status should be 1

Scenario: last command should fail gracefully if zero lolimages in lolrepo
Given I am in a git repo
And its loldir has 0 lolimages
Expand Down Expand Up @@ -204,16 +210,6 @@ Feature: Basic UI functionality
"""
And the exit status should be 0

@in-tempdir
Scenario: browse command should fail gracefully when not in a lolrepo
Given I am in a directory named "gitsuxcvs4eva"
When I run `lolcommits --browse`
Then the output should contain:
"""
You don't appear to be in a directory of a supported vcs project.
"""
And the exit status should be 1

Scenario: handle git commit messages with quotation marks
Given I am in a git repo with lolcommits enabled
When I run `git commit --allow-empty -m 'no "air quotes" bae'`
Expand Down
11 changes: 3 additions & 8 deletions features/step_definitions/lolcommits_steps.rb
Expand Up @@ -14,7 +14,7 @@ def default_repo
end

def default_loldir
expand_path("~/.lolcommits/#{default_repo}")
"~/.lolcommits/#{default_repo}"
end

Given(/^I am in a directory named "(.*?)"$/) do |dir_name|
Expand Down Expand Up @@ -156,19 +156,14 @@ def default_loldir
end

Then(/^there should be exactly (.*?) (jpg|gif|pid)s? in "(.*?)"$/) do |n, type, folder|
lolcommits_path = Aruba.platform.expand_path("#{folder}/*.jpg", "tmp/aruba")
expect(Dir[lolcommits_path].count).to eq(n.to_i)
expect(Dir[expand_path("#{folder}/*.#{type}")].count).to eq(n.to_i)
end

Then(/^the output should contain a list of plugins$/) do
step %(the output should contain "Installed plugins: (* enabled)")
step %(the output should contain "[*] loltext")
end

When("debugger") do
require 'pry'; binding.pry
end

When(/^I do a git commit with commit message "(.*?)"$/) do |commit_msg|
filename = FFaker::Lorem.words(1).first
steps %(
Expand All @@ -185,7 +180,7 @@ def default_loldir
When(/^I do (\d+) git commits$/) do |n|
n.to_i.times do
step %(I do a git commit)
sleep 0.1
sleep 0.2
end
end

Expand Down
19 changes: 14 additions & 5 deletions features/support/env.rb
Expand Up @@ -51,11 +51,20 @@
reject_paths_with_cmd('ffmpeg')
end

# do test in temporary directory so our own git repo-ness doesn't affect it
Before('@in-tempdir') do
@@working_directory = [Dir.mktmpdir]
# do test in a new temp directory (outside our own git repo-ness)
# due to https://github.com/cucumber/aruba/issues/478 aruba no longer allows
# wandering out of `tmp/aruba` so this pop/restore is necessary
Before('@no-repo-dir') do
@original_root = aruba.root_directory.pop
@original_dir = aruba.current_directory.pop
@working_dir = Dir.mktmpdir
aruba.current_directory << @working_dir
end

After('@in-tempdir') do
FileUtils.rm_rf(@working_directory.first)
After('@no-repo-dir') do
aruba.current_directory.pop
aruba.root_directory << @original_root
aruba.current_directory << @original_dir

FileUtils.rm_rf(@working_dir)
end
2 changes: 1 addition & 1 deletion features/support/path_helpers.rb
Expand Up @@ -5,7 +5,7 @@
module PathHelpers
def reject_paths_with_cmd(cmd)
# make a new subdir that still contains cmds
tmpbindir = File.expand_path(File.join('tmp/aruba', 'bin'))
tmpbindir = expand_path('./bin')
FileUtils.mkdir_p tmpbindir

preseve_cmds_in_path(%w(git mplayer), tmpbindir)
Expand Down

0 comments on commit 0e2eaac

Please sign in to comment.