spout 0.2.0 → 0.3.0.rc

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b17c5cb1d0059611bb4ebb9807ffb83f5015a765
4
- data.tar.gz: 3c3e5d7493590ecfffcb6a7534d73b4ce0f56bee
3
+ metadata.gz: ac53c71982fc81b63947e6de99639a70f1a4c0e9
4
+ data.tar.gz: 4f13cfb9b25c7a07acec482ddf6ee57bb72cc7d2
5
5
  SHA512:
6
- metadata.gz: 50846a11d41e8654a283a5836bd9d5496745bdf4c0707e2a7494ceca86633ac743ac2f9fda054185a5ebe6f0c72bf218414c4b7d71fa05deda1541ab368f2bad
7
- data.tar.gz: 08da58a7d5533b2210144e66d30158e825131a24f968f956cd7d64aae584084b3c97aed6acdb00d47351132158ca44dbab0aa9862874681d010ba4d08438d8b3
6
+ metadata.gz: a81fcf660ba4a79ad38d64dec2d9bbde2a5a0702a513036f9f79f508ff78df83c007f2e551f81bfefb270d254ac3820d3f324dfadd35af2229d355070a15b410
7
+ data.tar.gz: b041c265cea682d7729b0ca7d2149d1c143c7399d23b8a190e500ee259ea76eb9e845b0b920e4c271c539ed56fedaf59f005d9d33a9da1be70f742fba54db812
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.3.0
2
+
3
+ ### Enhancements
4
+ - Tests now hide passing tests by default
5
+ - To show all tests, use `spout tv`, or verbose tests
6
+ - Exports will now create a folder based on the version specified in the `VERSION` file located in the root of the data dictionary
7
+ - If a version is specified, `spout export 1.0.1` then the command line version is used
8
+ - If no version is specified, and no `VERSION` file exists, then the default `1.0.0` is used
9
+ - The version must be specified on the first line in the `VERSION` file
10
+ - Use of Ruby 2.0.0-p247 is now recommended
11
+
1
12
  ## 0.2.0 (June 26, 2013)
2
13
 
3
14
  ### Enhancements
data/lib/spout/actions.rb CHANGED
@@ -9,6 +9,8 @@ module Spout
9
9
  puts "Spout #{Spout::VERSION::STRING}"
10
10
  when 'test', 't', 'te', 'tes', '--test', '-t', '-te', '-tes'
11
11
  system "bundle exec rake"
12
+ when 'tv'
13
+ system "bundle exec rake VERBOSE_TESTS=true"
12
14
  when 'import', 'i', 'im', 'imp', '--import', '-i', '-im', '-imp'
13
15
  import_from_csv(argv)
14
16
  when 'import_domain', '--import_domain', 'import_domains', '--import_domains'
@@ -53,7 +55,9 @@ The most common spout commands are:
53
55
  [n]ew Create a new Spout dictionary.
54
56
  "spout new my_dd" creates a new data
55
57
  dictionary called MyDD in "./my_dd"
56
- [t]est Running the test file
58
+ [t]est Run tests and show failing tests
59
+ [tv] Run the tests and show passing and failing
60
+ tests
57
61
  [i]mport Import a CSV file into the JSON repository
58
62
  [e]xport [1.0.0] Export the JSON respository to a CSV
59
63
  h[y]brid [1.0.0] Export the JSON repository in the Hybrid
@@ -0,0 +1,175 @@
1
+ require 'turn/reporter'
2
+
3
+ module Spout
4
+ # = Based on Pretty Reporter (by Paydro)
5
+ # = Modified to hide passing tests
6
+ #
7
+ # Example output:
8
+ # TestCaseName:
9
+ # PASS test: Succesful test case. (0:00:02:059)
10
+ # ERROR test: Bogus test case. (0:00:02:059)
11
+ # FAIL test: Failed test case. (0:00:02:059)
12
+ #
13
+ class HiddenReporter < Turn::Reporter
14
+ # Second column left padding in chars.
15
+ TAB_SIZE = 10
16
+
17
+ # Character to put in front of backtrace.
18
+ TRACE_MARK = '@ '
19
+
20
+ def initialize(show_passing = false)
21
+ @io = $stdout
22
+ @trace = nil
23
+ @natural = nil
24
+ @verbose = nil
25
+ @mark = 0
26
+ @show_passing = show_passing
27
+ end
28
+
29
+ # At the very start, before any testcases are run, this is called.
30
+ def start_suite(suite)
31
+ @suite = suite
32
+ @time = Time.now
33
+
34
+ io.puts Turn::Colorize.bold("Loaded Suite #{suite.name}")
35
+ io.puts
36
+ if suite.seed
37
+ io.puts "Started at #{Time.now} w/ seed #{suite.seed}."
38
+ else
39
+ io.puts "Started at #{Time.now}."
40
+ end
41
+ io.puts
42
+ end
43
+
44
+ # Invoked before a testcase is run.
45
+ def start_case(kase)
46
+ # Print case name if there any tests in suite
47
+ # TODO: Add option which will show all test cases, even without tests?
48
+ io.puts kase.name if kase.size > 0
49
+ end
50
+
51
+ # Invoked before a test is run.
52
+ def start_test(test)
53
+ @test_time = Time.now
54
+ @test = test
55
+ end
56
+
57
+ # Invoked when a test passes.
58
+ def pass(message=nil)
59
+ if @show_passing
60
+ banner PASS
61
+
62
+ if message
63
+ message = Turn::Colorize.magenta(message)
64
+ message = message.to_s.tabto(TAB_SIZE)
65
+
66
+ io.puts(message)
67
+ end
68
+ end
69
+ end
70
+
71
+ # Invoked when a test raises an assertion.
72
+ def fail(assertion, message=nil)
73
+ banner FAIL
74
+
75
+ prettify(assertion, message)
76
+ end
77
+
78
+ # Invoked when a test raises an exception.
79
+ def error(exception, message=nil)
80
+ banner ERROR
81
+
82
+ prettify(exception, message)
83
+ end
84
+
85
+ # Invoked when a test is skipped.
86
+ def skip(exception, message=nil)
87
+ banner SKIP
88
+
89
+ prettify(exception, message)
90
+ end
91
+
92
+ # Invoked after all tests in a testcase have ben run.
93
+ def finish_case(kase)
94
+ # Print newline is there any tests in suite
95
+ io.puts if kase.size > 0
96
+ end
97
+
98
+ # After all tests are run, this is the last observable action.
99
+ def finish_suite(suite)
100
+ total = colorize_count("%d tests", suite.count_tests, :bold)
101
+ passes = colorize_count("%d passed", suite.count_passes, :pass)
102
+ assertions = colorize_count("%d assertions", suite.count_assertions, nil)
103
+ failures = colorize_count("%d failures", suite.count_failures, :fail)
104
+ errors = colorize_count("%d errors", suite.count_errors, :error)
105
+ skips = colorize_count("%d skips", suite.count_skips, :skip)
106
+
107
+ io.puts "Finished in %.6f seconds." % (Time.now - @time)
108
+ io.puts
109
+
110
+ io.puts [ total, passes, failures, errors, skips, assertions ].join(", ")
111
+
112
+ # Please keep this newline, since it will be useful when after test case
113
+ # there will be other lines. For example "rake aborted!" or kind of.
114
+ io.puts
115
+ end
116
+
117
+ private
118
+ # Creates an optionally-colorized string describing the number of occurances an event occurred.
119
+ #
120
+ # @param [String] str A printf-style string that expects an integer argument (i.e. the count)
121
+ # @param [Integer] count The number of occurances of the event being described.
122
+ # @param [nil, Symbol] colorize_method The method on Turn::Colorize to call in order to apply color to the result, or nil
123
+ # to not apply any coloring at all.
124
+ def colorize_count(str, count, colorize_method)
125
+ str= str % [count]
126
+ str= Turn::Colorize.send(colorize_method, str) if colorize_method and count != 0
127
+ str
128
+ end
129
+
130
+ # TODO: Could also provide % done with time info. But it's already taking up
131
+ # a lot of screen realestate. Maybe use --verbose flag to offer two forms.
132
+
133
+ # Outputs test case header for given event (error, fail & etc)
134
+ #
135
+ # Example:
136
+ # PASS test: Test decription. (0.15s 0:00:02:059)
137
+ def banner(event)
138
+ name = naturalized_name(@test)
139
+ delta = Time.now - @test_time # test runtime
140
+ if @verbose
141
+ out = "%18s (%0.5fs) (%s) %s" % [event, delta, ticktock, name]
142
+ else
143
+ out = "%18s (%s) %s" % [event, ticktock, name]
144
+ end
145
+ if @mark > 0 && delta > @mark
146
+ out[1] = Turn::Colorize.mark('*')
147
+ end
148
+ io.puts out
149
+ end
150
+
151
+ # Cleanups and prints test payload
152
+ #
153
+ # Example:
154
+ # fail is not 1
155
+ # @ test/test_runners.rb:46:in `test_autorun_with_trace'
156
+ # bin/turn:4:in `<main>'
157
+ def prettify(raised, message=nil)
158
+ # Get message from raised, if not given
159
+ message ||= raised.message
160
+
161
+ backtrace = raised.respond_to?(:backtrace) ? raised.backtrace : raised.location
162
+
163
+ # Filter and clean backtrace
164
+ backtrace = clean_backtrace(backtrace)
165
+
166
+ # Add trace mark to first line.
167
+ backtrace.first.insert(0, TRACE_MARK)
168
+
169
+ io.puts Turn::Colorize.bold(message.tabto(TAB_SIZE))
170
+ io.puts backtrace.shift.tabto(TAB_SIZE - TRACE_MARK.length)
171
+ io.puts backtrace.join("\n").tabto(TAB_SIZE)
172
+ io.puts
173
+ end
174
+ end
175
+ end
@@ -19,7 +19,7 @@ namespace :dd do
19
19
  desc 'Create Data Dictionary from repository'
20
20
  task :create do
21
21
 
22
- folder = "dd/#{ENV['VERSION'] || '1.0.0'}"
22
+ folder = "dd/#{ENV['VERSION'] || standard_version}"
23
23
  FileUtils.mkpath folder
24
24
 
25
25
  case ENV['TYPE']
@@ -44,6 +44,11 @@ namespace :dd do
44
44
  end
45
45
  end
46
46
 
47
+ def standard_version
48
+ version = File.open('VERSION', &:readline).strip rescue ''
49
+ version == '' ? '1.0.0' : version
50
+ end
51
+
47
52
  def standard_export(folder)
48
53
  CSV.open("#{folder}/variables.csv", "wb") do |csv|
49
54
  keys = %w(id display_name description type units domain labels calculation)
data/lib/spout/tests.rb CHANGED
@@ -18,3 +18,13 @@ module Spout
18
18
  Turn.config.trace = 1
19
19
  end
20
20
  end
21
+
22
+ require 'spout/hidden_reporter'
23
+
24
+ module Turn
25
+ class Configuration
26
+ def reporter
27
+ @reporter ||= Spout::HiddenReporter.new(ENV['VERBOSE_TESTS'] == 'true')
28
+ end
29
+ end
30
+ end
data/lib/spout/version.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  module Spout
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 2
4
+ MINOR = 3
5
5
  TINY = 0
6
- BUILD = nil # nil, "pre", "rc", "rc2"
6
+ BUILD = "rc" # nil, "pre", "rc", "rc2"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0.rc
5
5
  platform: ruby
6
6
  authors:
7
7
  - Remo Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-26 00:00:00.000000000 Z
11
+ date: 2013-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -92,6 +92,7 @@ files:
92
92
  - bin/spout
93
93
  - lib/spout/actions.rb
94
94
  - lib/spout/application.rb
95
+ - lib/spout/hidden_reporter.rb
95
96
  - lib/spout/tasks/engine.rake
96
97
  - lib/spout/tasks.rb
97
98
  - lib/spout/templates/Gemfile
@@ -128,9 +129,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
129
  version: '0'
129
130
  required_rubygems_version: !ruby/object:Gem::Requirement
130
131
  requirements:
131
- - - '>='
132
+ - - '>'
132
133
  - !ruby/object:Gem::Version
133
- version: '0'
134
+ version: 1.3.1
134
135
  requirements: []
135
136
  rubyforge_project:
136
137
  rubygems_version: 2.0.3