mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-06 09:18:50 +01:00
improve integration test of cli scripts
This commit is contained in:
parent
4c73e260e3
commit
daef1c440b
9 changed files with 152 additions and 42 deletions
36
features/add_todo_from_cli.feature
Normal file
36
features/add_todo_from_cli.feature
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
Feature: Add a todo to Tracks on console
|
||||
In order to be able to add a todo from the command line
|
||||
As a user who has installed Tracks with console access
|
||||
I want to run the script to add a todo
|
||||
|
||||
These scenarios are tagged javascript so that there is a Tracks server running
|
||||
to use from the command line script
|
||||
|
||||
Background:
|
||||
Given the following user records
|
||||
| login | password | is_admin |
|
||||
| testuser | secret | false |
|
||||
| admin | secret | true |
|
||||
And I have logged in as "testuser" with password "secret"
|
||||
And I have a context called "Context A"
|
||||
And I have a project called "Project A"
|
||||
|
||||
@javascript @aruba
|
||||
Scenario: Create a single todo
|
||||
Given a console input that looks like
|
||||
"""
|
||||
a new todo
|
||||
"""
|
||||
When I execute the add-todo script
|
||||
Then I should have 1 todo in project "Project A"
|
||||
|
||||
@javascript @aruba
|
||||
Scenario: Create multiple todos
|
||||
Given a console input that looks like
|
||||
"""
|
||||
todo 1
|
||||
todo 2
|
||||
|
||||
"""
|
||||
When I execute the add-todo script
|
||||
Then I should have 2 todo in project "Project A"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
Feature: Create project from template
|
||||
Feature: Create project from template on console
|
||||
In order to be able to create a project from a template
|
||||
As a user who has installed Tracks with console access
|
||||
I want to run the script to add projects and actions from a template
|
||||
|
|
@ -21,7 +21,7 @@ Feature: Create project from template
|
|||
My first project
|
||||
.My first task in this project
|
||||
"""
|
||||
When I execute the script
|
||||
When I execute the template script
|
||||
Then I should have a project called "My first project"
|
||||
And I should have 1 todo in project "My first project"
|
||||
|
||||
|
|
@ -33,5 +33,5 @@ Feature: Create project from template
|
|||
.Todo
|
||||
^Dependent
|
||||
"""
|
||||
When I execute the script
|
||||
When I execute the template script
|
||||
Then the successors of "Todo" should include "Dependent"
|
||||
|
|
|
|||
59
features/step_definitions/console_steps.rb
Normal file
59
features/step_definitions/console_steps.rb
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
Given /^a template that looks like$/ do |template|
|
||||
steps %{
|
||||
Given a file named "template.txt" with:
|
||||
"""
|
||||
#{template}
|
||||
"""
|
||||
}
|
||||
end
|
||||
|
||||
Given /^a console input that looks like$/ do |input|
|
||||
steps %{
|
||||
Given a file named "todo.txt" with:
|
||||
"""
|
||||
#{input}
|
||||
"""
|
||||
}
|
||||
end
|
||||
|
||||
When /^I execute the template script$/ do
|
||||
step "I cd to \"../..\""
|
||||
|
||||
context_id = @current_user.contexts.first.id
|
||||
port = Capybara.current_session.server.port
|
||||
|
||||
# assumes there is a context with id=1
|
||||
cli = "ruby doc/tracks_template_cli.rb -c #{context_id} -f tmp/aruba/template.txt"
|
||||
|
||||
set_env('GTD_LOGIN','testuser')
|
||||
set_env('GTD_PASSWORD', 'secret')
|
||||
set_env('GTD_TODOS_URL', "http://localhost:#{port}/todos.xml")
|
||||
set_env('GTD_PROJECTS_URL', "http://localhost:#{port}/projects.xml")
|
||||
set_env('GTD_CONTEXT_URL_PREFIX', "http://localhost:#{port}/contexts/")
|
||||
set_env("GTD_CONTEXT_URL","http://localhost:#{port}/contexts.xml")
|
||||
|
||||
step "I run `#{cli}`"
|
||||
end
|
||||
|
||||
When /^I execute the add-todo script$/ do
|
||||
step "I cd to \"../..\""
|
||||
|
||||
# assumes there is a context and a project
|
||||
context_id = @current_user.contexts.first.id
|
||||
project_id = @current_user.projects.first.id
|
||||
port = Capybara.current_session.server.port
|
||||
|
||||
cli = "ruby doc/tracks_cli_client.rb -c #{context_id} -p #{project_id}"
|
||||
|
||||
set_env('GTD_LOGIN','testuser')
|
||||
set_env('GTD_PASSWORD', 'secret')
|
||||
set_env('GTD_TODOS_URL', "http://localhost:#{port}/todos.xml")
|
||||
|
||||
step "I run `#{cli}` interactively"
|
||||
step "I pipe in the file \"tmp/aruba/todo.txt\""
|
||||
|
||||
# it seems aruba does not wait for process to end with interactively run command, but
|
||||
# continues anyway which will start cleaning up the database while the process is still running
|
||||
# so wait 2 secs for the process to finish
|
||||
sleep 2
|
||||
end
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
Given /^a template that looks like$/ do |template|
|
||||
steps %{
|
||||
Given a file named "template.txt" with:
|
||||
"""
|
||||
#{template}
|
||||
"""
|
||||
}
|
||||
end
|
||||
|
||||
When /^I execute the script$/ do
|
||||
step "I cd to \"../..\""
|
||||
|
||||
context_id = @current_user.contexts.first.id
|
||||
port = Capybara.current_session.server.port
|
||||
|
||||
# assumes there is a context with id=1
|
||||
cli = "ruby doc/tracks_template_cli.rb -c #{context_id} -f tmp/aruba/template.txt"
|
||||
|
||||
set_env('GTD_LOGIN','testuser')
|
||||
set_env('GTD_PASSWORD', 'secret')
|
||||
set_env('GTD_TODOS_URL', "http://localhost:#{port}/todos.xml")
|
||||
set_env('GTD_PROJECTS_URL', "http://localhost:#{port}/projects.xml")
|
||||
set_env('GTD_CONTEXT_URL_PREFIX', "http://localhost:#{port}/contexts/")
|
||||
set_env("GTD_CONTEXT_URL","http://localhost:#{port}/contexts.xml")
|
||||
|
||||
step "I run `#{cli}`"
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue