ddt 0.1.0 → 0.1.1
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.
- checksums.yaml +15 -0
- data/lib/truth_test/truth_test.rb +14 -4
- data/lib/version/version.rb +1 -1
- data/spec/truth_test/module_truth_test_spec.rb +42 -0
- data/truths/upcaseify/do_truths.yaml +6 -0
- metadata +9 -7
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZTY0YzZmMjQyYTZiNzhhN2Q5MDEwY2Y5NjFmYzcyYjQyMTQ4Yjg1Yw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NGE2YTAyMThjNGVlOGMwYWFjYmViODk4Y2E5NTEwZmY4NjBhNDM5ZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjU1ZjUyM2NhNTkyOTRmOTEzODA3ZmM0ODM1ZTFjZTQ5NTExYzQ3MzRiMWJh
|
10
|
+
NzVlODc1MDgxYjRmYmMzMTBhMTdiYWFhM2YyMmM2YzFjZDZhMDc5NTNkZDQ1
|
11
|
+
NTZkNGQ1ZjhmODgxYTUxMDk3Njk3MjI2ZDc3YTdiNGRkMTQzMDM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmE1ZmJhOGIwM2RlNDdjOWFlMjQ4MWQzY2VjZGI1YTQwM2Y1NDNjNmQzZmQ0
|
14
|
+
Y2RkM2E1MmRkOWVmYjkxMDVkYzMyNDI5ODBmZWUwNThkZmNkZmFmMTA1OWEw
|
15
|
+
YmRlMGNjYzRhNzRlNmU0M2VhM2RmMDljOWU3ZWYwNjBiNGFmMjI=
|
@@ -3,7 +3,13 @@ require 'yaml'
|
|
3
3
|
|
4
4
|
class Object
|
5
5
|
def self.define_truth &block
|
6
|
-
DDT::TruthTest::define_truth_for self, &block
|
6
|
+
DDT::TruthTest::define_truth_for :class, self, &block
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Module
|
11
|
+
def define_truth &block
|
12
|
+
DDT::TruthTest::define_truth_for :module, self, &block
|
7
13
|
end
|
8
14
|
end
|
9
15
|
|
@@ -11,7 +17,7 @@ end
|
|
11
17
|
module DDT
|
12
18
|
module TruthTest
|
13
19
|
|
14
|
-
def define_truth_for the_klass, &block
|
20
|
+
def define_truth_for obj_type, the_klass, &block
|
15
21
|
klass = Class.new
|
16
22
|
|
17
23
|
klass.class_eval do
|
@@ -46,7 +52,11 @@ module DDT
|
|
46
52
|
end
|
47
53
|
|
48
54
|
klass.send(:define_method, :tester) do
|
49
|
-
|
55
|
+
if obj_type == :class
|
56
|
+
self.class.send(:tester) || the_klass.new
|
57
|
+
elsif obj_type == :module
|
58
|
+
self.class.send(:tester) || the_klass
|
59
|
+
end
|
50
60
|
end
|
51
61
|
|
52
62
|
the_klass.const_set "Truth", klass
|
@@ -126,7 +136,7 @@ module DDT
|
|
126
136
|
next
|
127
137
|
end
|
128
138
|
|
129
|
-
if
|
139
|
+
if datum.has_key?("output")
|
130
140
|
it "should respond to '#{method}(#{truth.input})' with '#{truth.output}'" do
|
131
141
|
truth.tester.send(method, truth.input).should == truth.output
|
132
142
|
end
|
data/lib/version/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Upcaseify
|
4
|
+
module_function
|
5
|
+
|
6
|
+
def do str
|
7
|
+
str.upcase
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Upcaseify::define_truth
|
12
|
+
|
13
|
+
describe DDT::TruthTest do
|
14
|
+
it "creates a Truth class under Upcasify" do
|
15
|
+
expect(Upcaseify::Truth).to respond_to(:new)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "creates an input attr_accessor" do
|
19
|
+
expect(Upcaseify::Truth.new).to respond_to(:input)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "creates an output attr_accessor" do
|
23
|
+
expect(Upcaseify::Truth.new).to respond_to(:output)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "creates a tester method" do
|
27
|
+
expect(Upcaseify::Truth).to respond_to(:tester)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "responds to tester with the module" do
|
31
|
+
expect(Upcaseify::Truth.new.tester).to eq(Upcaseify)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "allows us to override the tester method by intercepting Truth::tester" do
|
35
|
+
Upcaseify::Truth.should_receive(:tester).and_return(String)
|
36
|
+
expect(Upcaseify::Truth.new.tester).to eq(String)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe Upcaseify do
|
41
|
+
truth_test :do
|
42
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Dan Swain
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: DDT automates data driven testing. Test data is read from a YAML file.
|
15
14
|
email:
|
@@ -22,38 +21,41 @@ files:
|
|
22
21
|
- lib/truth_test/truth_test.rb
|
23
22
|
- lib/version/version.rb
|
24
23
|
- spec/spec_helper.rb
|
24
|
+
- spec/truth_test/module_truth_test_spec.rb
|
25
25
|
- spec/truth_test/truth_test_spec.rb
|
26
26
|
- truths/cat/pet_truths.yaml
|
27
27
|
- truths/dog/parse!_truths.yaml
|
28
|
+
- truths/upcaseify/do_truths.yaml
|
28
29
|
- LICENSE
|
29
30
|
- Rakefile
|
30
31
|
- README.md
|
31
32
|
homepage: http://github.com/simplifi/ddt
|
32
33
|
licenses: []
|
34
|
+
metadata: {}
|
33
35
|
post_install_message:
|
34
36
|
rdoc_options: []
|
35
37
|
require_paths:
|
36
38
|
- lib
|
37
39
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
40
|
requirements:
|
40
41
|
- - ! '>='
|
41
42
|
- !ruby/object:Gem::Version
|
42
43
|
version: '0'
|
43
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
45
|
requirements:
|
46
46
|
- - ! '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
50
|
rubyforge_project:
|
51
|
-
rubygems_version:
|
51
|
+
rubygems_version: 2.0.6
|
52
52
|
signing_key:
|
53
|
-
specification_version:
|
53
|
+
specification_version: 4
|
54
54
|
summary: Data driven testing for Ruby with RSpec. DDT kills bugs.
|
55
55
|
test_files:
|
56
56
|
- spec/spec_helper.rb
|
57
|
+
- spec/truth_test/module_truth_test_spec.rb
|
57
58
|
- spec/truth_test/truth_test_spec.rb
|
58
59
|
- truths/cat/pet_truths.yaml
|
59
60
|
- truths/dog/parse!_truths.yaml
|
61
|
+
- truths/upcaseify/do_truths.yaml
|