twtest 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +10 -0
- data/lib/twtest/testcase.rb +45 -0
- data/lib/twtest/version.rb +7 -0
- data/lib/twtest.rb +11 -0
- data/templates/taskrc.erb +3 -0
- data/test/test_helper.rb +4 -0
- data/test/unit/test_testcase.rb +32 -0
- data/twtest.gemspec +16 -0
- metadata +59 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Nicholas E. Rabenau
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# twtest
|
2
|
+
|
3
|
+
Helpers for writing TaskWarrior tests in Ruby
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'twtest'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install twtest
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'erb'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module TaskWarrior
|
8
|
+
module Test
|
9
|
+
module Integration
|
10
|
+
class TestCase < ::Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
@data_dir = Dir.mktmpdir
|
13
|
+
@taskrc_file = build_taskrc(:data_dir => @data_dir)
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
FileUtils.rm_r(@data_dir)
|
18
|
+
File.delete(@taskrc_file)
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
def export_tasks
|
23
|
+
JSON[exec('export')]
|
24
|
+
end
|
25
|
+
|
26
|
+
def exec(cmd)
|
27
|
+
ENV['TASKRC'] = @taskrc_file
|
28
|
+
%x[task #{cmd}]
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_taskrc(options = {})
|
32
|
+
taskrc_file = Tempfile.new('taskrc')
|
33
|
+
data_dir = options[:data_dir]
|
34
|
+
|
35
|
+
begin
|
36
|
+
taskrc_file.write(ERB.new(File.read(File.join(File.dirname(__FILE__), '..', '..', 'templates', 'taskrc.erb')), 0, "%<>").result(binding))
|
37
|
+
return taskrc_file.path
|
38
|
+
ensure
|
39
|
+
taskrc_file.close
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/twtest.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestTestCase < TaskWarrior::Test::Integration::TestCase
|
4
|
+
def test_empty
|
5
|
+
# http://taskwarrior.org/issues/1017
|
6
|
+
# assert_empty(export_tasks)
|
7
|
+
|
8
|
+
# Use a placeholder as workaround
|
9
|
+
exec("add placeholder")
|
10
|
+
assert_equal(1, export_tasks.size)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_import
|
14
|
+
contents = {:description => "foobar"}
|
15
|
+
input_file = Tempfile.new('test_simple')
|
16
|
+
|
17
|
+
begin
|
18
|
+
input_file.write(contents.to_json)
|
19
|
+
input_file.close
|
20
|
+
|
21
|
+
# TODO Replace temp file with in-process version
|
22
|
+
# exec("import <(echo '#{contents.to_json}')")
|
23
|
+
exec("import #{input_file.path}")
|
24
|
+
|
25
|
+
tasks = export_tasks
|
26
|
+
assert_equal(1, tasks.size)
|
27
|
+
assert_equal('foobar', tasks.first['description'])
|
28
|
+
ensure
|
29
|
+
input_file.unlink
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/twtest.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/twtest/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Nicholas E. Rabenau"]
|
6
|
+
gem.email = ["nerab@gmx.net"]
|
7
|
+
gem.description = %q{Provides helpers for writing TaskWarrior integration tests in Ruby}
|
8
|
+
gem.summary = %q{Helpers for writing TaskWarrior tests in Ruby}
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "twtest"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = TaskWarrior::Test::Integration::VERSION
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twtest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nicholas E. Rabenau
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-29 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Provides helpers for writing TaskWarrior integration tests in Ruby
|
15
|
+
email:
|
16
|
+
- nerab@gmx.net
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- lib/twtest.rb
|
27
|
+
- lib/twtest/testcase.rb
|
28
|
+
- lib/twtest/version.rb
|
29
|
+
- templates/taskrc.erb
|
30
|
+
- test/test_helper.rb
|
31
|
+
- test/unit/test_testcase.rb
|
32
|
+
- twtest.gemspec
|
33
|
+
homepage:
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.8.24
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: Helpers for writing TaskWarrior tests in Ruby
|
57
|
+
test_files:
|
58
|
+
- test/test_helper.rb
|
59
|
+
- test/unit/test_testcase.rb
|