testme 0.5.3 → 0.5.45

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.
data/bin/testme CHANGED
@@ -6,7 +6,7 @@ def boot name, folder, &block
6
6
  end
7
7
 
8
8
  def testme_load filepath
9
- if @file.include?(TestMe::testme.suffix)
9
+ if filepath.include?(testme.suffix)
10
10
  testme do
11
11
  load filepath
12
12
  end
@@ -26,6 +26,7 @@ testme.format = :console
26
26
  testme.colors = :default
27
27
  ]
28
28
  )} unless File.exists?("./.testme")
29
+
29
30
  puts 'Creating test folder "/test"'
30
31
  Dir::mkdir('./test/') unless File.directory?("./test/") || File.exists?("./test/")
31
32
  puts 'Creating empty test file "/app.test.rb"'
@@ -50,13 +51,12 @@ TESTME_RUNNING = true
50
51
 
51
52
  if ARGV.empty?
52
53
  testme do
53
- Dir["#{Dir.pwd}/#{testme.DIR}/**/*#{testme.suffix}"].each{|f| load f }
54
+ Dir["#{Dir.pwd}/#{testme.dir}/**/*#{testme.suffix}"].each{|f| load f }
54
55
  end
55
56
  elsif ARGV[0][0] == ':'
56
57
  o = @testme_boot[ARGV[0][1..-1].to_sym][1]
57
58
  o.call
58
-
59
- Dir["#{o[0]}/**/*#{testme.suffix}"].each do |f|
59
+ Dir["#{Dir.pwd}/#{testme.dir}/**/*#{testme.suffix}"].each do |f|
60
60
  testme_load(f)
61
61
  end
62
62
  else
@@ -65,7 +65,7 @@ else
65
65
 
66
66
  if File.directory?(@file)
67
67
  Dir["#{@file}/**/*#{testme.suffix}"].each do |f|
68
- testme_load(@file)
68
+ testme_load(f)
69
69
  end
70
70
  elsif File.exists?(@file)
71
71
  testme_load(@file)
@@ -30,23 +30,25 @@ module TestMe
30
30
  def compile; end
31
31
  end
32
32
 
33
- class Text
33
+ class Console
34
+ #TODO color_scheme
35
+
34
36
  def test topic
35
- log "test " + topic.name
37
+ log "\n test ".bright + topic.name.bright.color(250, 37, 115)
36
38
  end
37
39
 
38
40
  def given desc=nil, stubs=nil, &block
39
- log "given " + context_to_string(desc, stubs, &block)
41
+ log " given " + context_to_string(desc, stubs, &block)
40
42
  end
41
43
 
42
44
  def also desc=nil, stubs=nil, &block
43
- log "also " + context_to_string(desc, stubs, &block)
45
+ log " also " + context_to_string(desc, stubs, &block)
44
46
  end
45
47
 
46
48
  def is? method, actual, expected
47
49
  success = actual == expected
48
50
 
49
- log 'is ' + method.to_s + ', ' + expected.to_s + '? ' + (success ? 'YES' : "NO, it was '#{actual}'")
51
+ log ' is '.bright + method.to_s + ', ' + expected.to_s.yellow + '? ' + (success ? 'YES'.bright.green : "NO, it was '#{actual}'".bright.red) + "\n\n"
50
52
  end
51
53
 
52
54
  def compile
@@ -57,12 +59,16 @@ module TestMe
57
59
  def block_to_string &block
58
60
  "(block)"
59
61
  end
62
+
63
+ def log msg
64
+ puts msg
65
+ end
60
66
 
61
67
  def context_to_string desc=nil, stubs=nil, &block
62
68
  str = ""
63
69
 
64
70
  if desc.class == String || desc.class == Symbol
65
- str += ":#{desc}: "
71
+ str += ":#{desc}: ".blue
66
72
  end
67
73
 
68
74
  if desc.class == Hash
@@ -70,7 +76,7 @@ module TestMe
70
76
  end
71
77
 
72
78
  if stubs
73
- str += stubs.map{|k,v| (k.to_s + ': ' + v.to_s)}.join(', ')
79
+ str += stubs.map{|k,v| (k.to_s + ': ' + v.to_s).bright}.join(', ') + ' '
74
80
  end
75
81
 
76
82
  if block
@@ -79,27 +85,26 @@ module TestMe
79
85
 
80
86
  return str
81
87
  end
88
+
82
89
  end
83
-
84
- class Console
85
- #TODO color_scheme
86
90
 
91
+ class Text < Console
87
92
  def test topic
88
- log "\n test ".bright + topic.name.bright.color(250, 37, 115)
93
+ log "test " + topic.name
89
94
  end
90
95
 
91
96
  def given desc=nil, stubs=nil, &block
92
- log " given " + context_to_string(desc, stubs, &block)
97
+ log "given " + context_to_string(desc, stubs, &block)
93
98
  end
94
99
 
95
100
  def also desc=nil, stubs=nil, &block
96
- log " also " + context_to_string(desc, stubs, &block)
101
+ log "also " + context_to_string(desc, stubs, &block)
97
102
  end
98
103
 
99
104
  def is? method, actual, expected
100
105
  success = actual == expected
101
106
 
102
- log ' is '.bright + method.to_s + ', ' + expected.to_s.yellow + '? ' + (success ? 'YES'.bright.green : "NO, it was '#{actual}'".bright.red) + "\n\n"
107
+ log 'is ' + method.to_s + ', ' + expected.to_s + '? ' + (success ? 'YES' : "NO, it was '#{actual}'")
103
108
  end
104
109
 
105
110
  def compile
@@ -110,16 +115,12 @@ module TestMe
110
115
  def block_to_string &block
111
116
  "(block)"
112
117
  end
113
-
114
- def log msg
115
- puts msg
116
- end
117
118
 
118
119
  def context_to_string desc=nil, stubs=nil, &block
119
120
  str = ""
120
121
 
121
122
  if desc.class == String || desc.class == Symbol
122
- str += ":#{desc}: ".blue
123
+ str += ":#{desc}: "
123
124
  end
124
125
 
125
126
  if desc.class == Hash
@@ -127,7 +128,7 @@ module TestMe
127
128
  end
128
129
 
129
130
  if stubs
130
- str += stubs.map{|k,v| (k.to_s + ': ' + v.to_s).bright}.join(', ') + ' '
131
+ str += stubs.map{|k,v| (k.to_s + ': ' + v.to_s)}.join(', ')
131
132
  end
132
133
 
133
134
  if block
@@ -136,7 +137,6 @@ module TestMe
136
137
 
137
138
  return str
138
139
  end
139
-
140
140
  end
141
141
 
142
142
  end
@@ -8,7 +8,7 @@ module TestMe
8
8
  @before = nil
9
9
  @contexts = {}
10
10
 
11
- @@formatter ||= Formatter::create(testme.format)
11
+ @@formatter = Formatter::create(testme.format)
12
12
  @@formatter.test topic
13
13
 
14
14
  @topic_class = topic
@@ -69,13 +69,13 @@ module TestMe
69
69
  method = block
70
70
  result = block.call
71
71
  else
72
- if args[0].class == Hash
72
+ if args[0].is_a? Hash
73
73
  method = args[0].first[0]
74
74
  expected = args[0].first[1]
75
75
  actual = topic.send(method)
76
76
  end
77
77
 
78
- if args[0].class == Symbol
78
+ if args[0].is_a? Symbol
79
79
  params = args[0].args
80
80
  expected = args[1]
81
81
  actual = topic.send(args[0], *params)
@@ -54,15 +54,15 @@ module TestMe
54
54
  # Config Module
55
55
  # ---------------------------------------------------------------- #
56
56
  require "configatron"
57
- @config = Configatron::Store.new
57
+ @@config = Configatron::Store.new
58
58
 
59
59
  # Defaults
60
- @config.dir = '/test/'
61
- @config.suffix = '.test.rb'
62
- @config.format = :console
63
- @config.colors = :default
60
+ @@config.dir = '/test/'
61
+ @@config.suffix = '.test.rb'
62
+ @@config.format = :console
63
+ @@config.colors = :default
64
64
 
65
- def self.config; @config; end
65
+ def self.config; @@config; end
66
66
  end
67
67
 
68
68
  # ---------------------------------------------------------------- #
@@ -0,0 +1,12 @@
1
+ module TestMe::Formatter
2
+ class Text
3
+ def log msg
4
+ return msg
5
+ end
6
+ end
7
+ end
8
+
9
+ test TestMe::Formatter::Text
10
+ #is? :test[TestMe::Formatter::Text], 'test TestMe::Formatter::Text'
11
+ is? :given[{description: "I format things"}], 'given description: I format things'
12
+ is? :also[{description: "I format things"}], 'also description: I format things'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.45
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-12 00:00:00.000000000 Z
12
+ date: 2012-08-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rainbow
@@ -86,6 +86,7 @@ files:
86
86
  - spec/double_spec.rb
87
87
  - spec/spec_helper.rb
88
88
  - spec/testme_spec.rb
89
+ - test/formatter.test.rb
89
90
  - testme.gemspec
90
91
  homepage: http://github.com/danielshuey/testme
91
92
  licenses: []
@@ -101,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
102
  version: '0'
102
103
  segments:
103
104
  - 0
104
- hash: 734885775
105
+ hash: -955234925
105
106
  required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  none: false
107
108
  requirements:
@@ -110,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  version: '0'
111
112
  segments:
112
113
  - 0
113
- hash: 734885775
114
+ hash: -955234925
114
115
  requirements: []
115
116
  rubyforge_project:
116
117
  rubygems_version: 1.8.24