-
Notifications
You must be signed in to change notification settings - Fork 481
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #652 from guard/acceptance_tests
Acceptance tests
- Loading branch information
Showing
20 changed files
with
214 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "guard" | ||
require "guard/cli" | ||
|
||
Guard::CLI.start | ||
begin | ||
require "guard/aruba_adapter" | ||
rescue LoadError => e | ||
abort "#{e.inspect} - perhaps you need to run using `bundle exec`?" | ||
end | ||
|
||
Guard::ArubaAdapter.new(ARGV.dup).execute! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Feature: Guard "init" command | ||
|
||
In order to quickly start a new project with Guard | ||
As a user | ||
I want Guard to create a Guardfile template for me | ||
|
||
Scenario: Create an empty Guardfile | ||
When I run `guard init -b` | ||
Then the output should match /Writing new Guardfile to .*Guardfile$/ | ||
And the file "Guardfile" should contain "# A sample Guardfile" | ||
|
||
Scenario: Create a Guardfile using a plugin's template | ||
When I run `guard init rspec` | ||
Then the output should match /Writing new Guardfile to .*Guardfile$/ | ||
And the file "Guardfile" should match /^guard :rspec, cmd: 'bundle exec rspec' do$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Feature: Show | ||
|
||
In order to know the defined groups and plugins | ||
As a developer using Guard | ||
I want to see a table of groups and plugins | ||
|
||
Scenario: Show error when no Guardfile | ||
When I run `guard show` | ||
Then the output should match /No Guardfile found, please create one with `guard init`\./ | ||
And the exit status should not be 0 | ||
|
||
Scenario: Show error when Guardfile has no plugins | ||
Given an empty file named "Guardfile" | ||
When I run `guard show` | ||
Then the output should match /No Guard plugins found in Guardfile, please add at least one\.$/ | ||
# TODO: this step fails | ||
# And the exit status should not be 0 | ||
|
||
Scenario: Show plugins and their configuration | ||
Given a file named "Guardfile" with: | ||
""" | ||
guard :ronn do | ||
end | ||
""" | ||
When I run `guard show` | ||
Then the output should match /^| Default | Ronn\s+ |/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require "aruba" | ||
require "aruba/cucumber" | ||
|
||
require "aruba/in_process" | ||
require "guard/aruba_adapter" | ||
|
||
Aruba::InProcess.main_class = Guard::ArubaAdapter | ||
Aruba::process = Aruba::InProcess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Feature: Guard "version" command | ||
|
||
In order to know if the Guard is up to date | ||
As a user | ||
I want to get the Guard version | ||
|
||
Scenario: Show Guard's version | ||
When I run `guard version` | ||
Then the output should match /^Guard version \d+.\d+.\d+$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
require "guard/cli" | ||
|
||
module Guard | ||
class ArubaAdapter | ||
def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, | ||
kernel = Kernel) | ||
@argv = argv | ||
@stdin = stdin | ||
@stdout = stdout | ||
@stderr = stderr | ||
@kernel = kernel | ||
::Guard::UI.options = ::Guard::UI.options.merge(flush_seconds: 0) | ||
end | ||
|
||
def execute! | ||
exit_code = execute | ||
# Proxy our exit code back to the injected kernel. | ||
@kernel.exit(exit_code) | ||
end | ||
|
||
def execute | ||
# Thor accesses these streams directly rather than letting | ||
# them be injected, so we replace them... | ||
$stderr = @stderr | ||
$stdin = @stdin | ||
$stdout = @stdout | ||
|
||
# Run our normal Thor app the way we know and love. | ||
::Guard::CLI.start(@argv) | ||
|
||
# Thor::Base#start does not have a return value, assume | ||
# success if no exception is raised. | ||
0 | ||
rescue StandardError => e | ||
# The ruby interpreter would pipe this to STDERR and exit 1 in the case | ||
# of an unhandled exception | ||
b = e.backtrace | ||
b.unshift("#{b.shift}: #{e.message} (#{e.class})") | ||
@stderr.puts(b.map { |s| "\tfrom #{s}" }.join("\n")) | ||
1 | ||
rescue SystemExit => e | ||
e.status | ||
ensure | ||
# flush the logger so the output doesn't appear in next CLI invocation | ||
::Guard::UI.logger.flush | ||
::Guard::UI.logger.close | ||
::Guard::UI.reset_logger | ||
|
||
# ...then we put them back. | ||
$stderr = STDERR | ||
$stdin = STDIN | ||
$stdout = STDOUT | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ def process(*entries) | |
return | ||
end | ||
|
||
::Guard.scope = scope | ||
::Guard.setup_scope(scope) | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.