uspec 0.0.1 → 0.0.2

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/README.markdown CHANGED
@@ -5,6 +5,8 @@ Uspec is a shiny little testing framework for your apps!
5
5
 
6
6
  Anthony M. Cook 2013
7
7
 
8
+ [![Code Climate](https://codeclimate.com/github/acook/uspec.png)](https://codeclimate.com/github/acook/uspec)
9
+
8
10
  Philosophy / Why Uspec?
9
11
  -----------------------
10
12
 
@@ -70,7 +72,7 @@ end
70
72
 
71
73
  Then Uspec will let you know:
72
74
 
73
- ```
75
+ ```ruby
74
76
  -- AwesomeMcCoolname.generate creates a badass name: Unknown Result
75
77
 
76
78
  Spec did not return a boolean value
@@ -79,6 +81,25 @@ Then Uspec will let you know:
79
81
  Integer < Numeric: 5
80
82
  ```
81
83
 
84
+ Instead of `=~` (which returns either index or nil) Ruby has the nifty `include?` method, which returns a boolean:
85
+
86
+ ```ruby
87
+ spec 'AwesomeMcCoolname.generate creates a cool name' do
88
+ AwesomeMcCoolname.generate.include? 'Badass'
89
+ end
90
+ ```
91
+
92
+ If you really need to regex, you can always use Ruby's `!!` idiom to coerce a boolean out of any result,
93
+ but its more precise to specify the index if you know it.
94
+ And you can always toss in an `||` to drop in more information if a comparison fails too:
95
+
96
+ ```ruby
97
+ spec 'AwesomeMcCoolname.generate creates a cool name' do
98
+ index = AwesomeMcCoolname.generate =~ /Badass/
99
+ index == 0 || index
100
+ end
101
+ ```
102
+
82
103
  If you aren't ready to fill out a spec, maybe as a reminder to add functionality later, just leave off the block and it will be marked as `pending`:
83
104
 
84
105
  ```ruby
data/lib/uspec/dsl.rb CHANGED
@@ -12,6 +12,7 @@ module Uspec
12
12
  rescue => result
13
13
  end
14
14
 
15
+ Uspec::Stats.results << result
15
16
  print ': ', formatter.colorize(result, caller), "\n"
16
17
  end
17
18
  end
@@ -10,7 +10,7 @@ module Uspec
10
10
  end
11
11
 
12
12
  def color hue, text = nil
13
- esc("3#{colors[hue]};1") + "#{text}#{normal if text}"
13
+ esc("3#{colors[hue]};1") + "#{text}#{normal}"
14
14
  end
15
15
 
16
16
  def esc seq
@@ -0,0 +1,21 @@
1
+ module Uspec
2
+ class Stats
3
+ class << self
4
+ def results?
5
+ !results.empty?
6
+ end
7
+
8
+ def results
9
+ @results ||= clear_results!
10
+ end
11
+
12
+ def clear_results!
13
+ @results = Array.new
14
+ end
15
+
16
+ def exit_code
17
+ results.all?{|result| result == true} ? 0 : 255
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/uspec/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Uspec
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
data/lib/uspec.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative 'uspec/version'
2
2
  require_relative 'uspec/formatter'
3
3
  require_relative 'uspec/dsl'
4
+ require_relative 'uspec/stats'
4
5
 
5
6
  module Uspec
6
7
  def self.included object
@@ -13,4 +14,4 @@ module Uspec
13
14
  end
14
15
  end
15
16
 
16
-
17
+ at_exit { exit Uspec::Stats.exit_code }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2013-02-08 00:00:00.000000000 Z
12
+ date: 2013-03-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Uspec is a shiny little spec framework for your apps! Unlike other testing
15
15
  frameworks there's no need for matchers, there can only be one assertion per test,
@@ -28,6 +28,7 @@ files:
28
28
  - lib/uspec.rb
29
29
  - lib/uspec/dsl.rb
30
30
  - lib/uspec/formatter.rb
31
+ - lib/uspec/stats.rb
31
32
  - lib/uspec/version.rb
32
33
  - uspec.gemspec
33
34
  - uspec/uspec_spec.rb