fis-test 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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjBiZDQ0MWMxNDU4YjVmMmMwNWI2ZTZhMzA1YTczZjZkN2IxODk3Zg==
4
+ MDQ4OTk4YmZkZmQ5MmJkN2U1NzZlNTlhYWRmYWEwZmNmMGRiMzU1Mw==
5
5
  data.tar.gz: !binary |-
6
- MDdlYTY1MWRkZTU0OTk1OWFhZjY2MWVjYTIyZDBjMzI4YjBiMjY2MA==
6
+ YWQ5NDM4ZmJiMGVhYjQ3N2Y0OWQ0NGY3MjdkZDdlN2Q2ZjhkZGEyOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDM1NjdlMzI5ODYzNTU4ZTVmNTMxZjBkODkzM2Y0YWUyYTA5YzBkM2QwZDVi
10
- Y2ZkZDhhN2Y1YTc0ZjI1YjRkZTkwNWZlZmQ2MDU4N2ZhMWFiMGU2NmQ4YThk
11
- ZTk5M2VmOWVhNWZlNWFiNTU2NmYyZTVlYWE2MTVlOWUxZjYyNTE=
9
+ NDljZmRhMDhlMTBlZWFiNWFjNGE0MmUwMzg3YmNlNjdlODcwZjQ0M2U1NmZk
10
+ OWQyNjMwNmZmMzRmYTM2M2E3NjZmOGYxYjEwNGNmZTc5ZmNlNjZhOGNiY2Iy
11
+ ZmU4NzcxYjVlMDc3NjUwMTE0OTQ1ZGE1MTU5ZDg2YjExMjU5MjY=
12
12
  data.tar.gz: !binary |-
13
- N2NiMWYxYTEwNzM5YjM2ZTBjZWY1OTg4MWUxYzNiZTU4MDAxZjMzMTUzZDY2
14
- MzgzOWNkNmYwNmZiNTcxOTk5NDNjN2E0NGM1ZjQ1ZWQyNjhiNTcyMmYxYmRl
15
- ZmM5NmM5MmU1ZTFkZmY3ZWE2N2Q2OTBjY2JiNjY3ZjMyYmZhNmI=
13
+ MTAyYTAwNDllMmU1YTFkMDZhMmEyZTViNjc2MDA1OTRiN2RhMGRkOGViNDkx
14
+ OTAzOGUzNDJiYTQxYWZhZGY3ODZmZGNjNTM0YTQ1Nzc5NGYyYTIyYmUyMGQz
15
+ YTcxZTU5MmQ2YzljYTQ1N2NkYmM5NTMyZTNiNjA3YjIwZjUxNTM=
File without changes
data/README.md CHANGED
@@ -23,7 +23,25 @@ Or install it yourself as:
23
23
  The core of `fis-test` is the following structure.
24
24
 
25
25
  ```ruby
26
+ require 'fis/test'
27
+
28
+ extend Fis::Test
29
+
30
+ test 'a Song should have name' do
31
+ s = Song.new
32
+ s.name = "Get Lucky"
33
+ assert_equal s.name, "Get Lucky"
34
+ end
35
+ ```
36
+ You can easily skip a test if necessary
37
+
38
+ ```ruby
39
+ require 'fis/test'
40
+
41
+ extend Fis::Test
42
+
26
43
  test 'a Song should have name' do
44
+ skip("skip this for now")
27
45
  s = Song.new
28
46
  s.name = "Get Lucky"
29
47
  assert_equal s.name, "Get Lucky"
@@ -32,25 +50,30 @@ end
32
50
 
33
51
  `test` is a simple wrapper method to give you some nice output.
34
52
 
35
- `assert` and `assert_equal` are all you get.
53
+ `assert`, `assert_equal`, and `skip` are all you get.
36
54
 
37
55
  No setup/teardown. You can DRY your code with simple helper methods.
38
56
 
39
57
  ```ruby
58
+ require 'fis/test'
40
59
 
41
- def setup_song
42
- @song = Song.new
43
- end
60
+ class SongTest
61
+ extend Fis::Test
44
62
 
45
- def teardown_song
46
- @song = nil
47
- end
63
+ def setup_song
64
+ @song = Song.new
65
+ end
48
66
 
49
- test 'a Song should have name' do
50
- setup_song
51
- @song.name = "Get Lucky"
52
- assert_equal @song.name, "Get Lucky"
53
- teardown_song
67
+ def teardown_song
68
+ @song = nil
69
+ end
70
+
71
+ test 'a Song should have name' do
72
+ setup_song
73
+ @song.name = "Get Lucky"
74
+ assert_equal @song.name, "Get Lucky"
75
+ teardown_song
76
+ end
54
77
  end
55
78
  ```
56
79
 
@@ -64,12 +87,17 @@ That's it! Write tests. Stop writing code.
64
87
  4. Push to the branch (`git push origin my-new-feature`)
65
88
  5. Create new Pull Request
66
89
 
90
+ ## Notes
91
+
92
+ *This is a very early release. It needs a lot of work.* I would wait to use this for a bit.
93
+
67
94
  ## TODO
68
95
 
69
96
  - Write tests for the tests.
70
97
  - Automate setup/teardown method calls if they exist
71
98
  - More modularity for test groups
72
99
  - Better output
100
+ - fix extend / include confusion, better/easier way to get to testing methods.
73
101
 
74
102
  ## Caveats
75
103
 
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_runtime_dependency "colorize", "~> 0.5.8"
23
24
  end
@@ -1,28 +1,29 @@
1
1
  require "fis/test/version"
2
+ require 'colorize'
2
3
 
3
4
  module Fis
4
5
  module Test
6
+ class SkippedError < StandardError
7
+ end
8
+
5
9
  def test(title, &b)
6
10
  begin
7
11
  if b
8
12
  result = b.call
9
- if result.is_a?(Array)
10
- puts "fail: #{title}"
11
- puts " expected #{result.first} to equal #{result.last}"
12
- elsif result
13
- puts "pass: #{title}"
14
- else
15
- puts "fail: #{title}"
16
- end
13
+ puts evaluate(result, title)
17
14
  else
18
- puts "pending: #{title}"
15
+ puts "pending:".blue + " #{title}"
19
16
  end
20
17
  rescue => e
21
- puts "fail: #{title}"
22
- puts e
18
+ puts exception_handler(e, title)
23
19
  end
24
20
  end
25
21
 
22
+ def skip(message=nil)
23
+ message ||= "skipped."
24
+ raise SkippedError.new(message)
25
+ end
26
+
26
27
  def assert(statement)
27
28
  !!statement
28
29
  end
@@ -34,5 +35,26 @@ module Fis
34
35
  [expected, actual]
35
36
  end
36
37
  end
38
+
39
+ private
40
+
41
+ def exception_handler(e, title)
42
+ if e.class == Fis::Test::SkippedError
43
+ "skipped:".blue + " #{e.message}"
44
+ else
45
+ "fail:".red + " #{title}\n#{e}\n#{e.backtrace.first}"
46
+ end
47
+ end
48
+
49
+ def evaluate(result, title)
50
+ if result.is_a?(Array)
51
+ "fail:".red + " #{title}\n expected #{result.first} to equal #{result.last}"
52
+ elsif result
53
+ "pass:".green + " #{title}"
54
+ else
55
+ "fail:".red + " #{title}"
56
+ end
57
+ end
58
+
37
59
  end
38
60
  end
@@ -1,5 +1,5 @@
1
1
  module Fis
2
2
  module Test
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,50 @@
1
+ require_relative '../../../lib/fis/test'
2
+
3
+ extend Fis::Test
4
+
5
+
6
+ test 'should fail if result is false' do
7
+
8
+ # test 'this is a failing assertion' do
9
+ # assert false
10
+ # end
11
+
12
+ result = false
13
+ title = "this is a failing assertion"
14
+ assert_equal self.send(:evaluate, result, title), "fail: #{title}"
15
+ end
16
+
17
+ test 'should return true when the result is true' do
18
+
19
+ # test 'this is a passing assertion' do
20
+ # assert false
21
+ # end
22
+
23
+ result = true
24
+ title = "this is a passing assertion"
25
+ assert_equal self.send(:evaluate, result, title), "pass: #{title}"
26
+ end
27
+
28
+ test 'should return the expected/actual return when an assert_equal is true' do
29
+
30
+ # test 'this is a failing assert_equal statement' do
31
+ # assert_equal true, false
32
+ # end
33
+
34
+ result = [true, false]
35
+ title = "this is a failing assert_equal statement"
36
+ assert_equal self.send(:evaluate,result, title) , "fail: #{title}\n expected #{result.first} to equal #{result.last}"
37
+ end
38
+
39
+ test 'should skip if the skip method is used' do
40
+
41
+ # test 'This is a skipped assertion' do
42
+ # skip("skipping")
43
+ # assert_equal true, false
44
+ # end
45
+
46
+ error = Fis::Test::SkippedError.new("skipping")
47
+ title = "This is a skipped assertion"
48
+ assert_equal self.send(:exception_handler,error, title), "skipped: #{error.message}"
49
+ end
50
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fis-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - aviflombaum
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-18 00:00:00.000000000 Z
11
+ date: 2013-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.5.8
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.8
41
55
  description: Really simple testing framework used at Flatiron School
42
56
  email:
43
57
  - avi@flombaum.com
@@ -45,14 +59,15 @@ executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
62
+ - .gitignore
48
63
  - Gemfile
49
64
  - LICENSE.txt
50
65
  - README.md
51
66
  - Rakefile
52
67
  - fis-test.gemspec
53
- - fis-test/.gitignore
54
68
  - lib/fis/test.rb
55
69
  - lib/fis/test/version.rb
70
+ - test/fis/test/test_test.rb
56
71
  homepage: http://github.com/flatiron-school/test
57
72
  licenses:
58
73
  - MIT
@@ -77,4 +92,5 @@ rubygems_version: 2.0.3
77
92
  signing_key:
78
93
  specification_version: 4
79
94
  summary: 32 lines of code, the majority of what you need to write tests.
80
- test_files: []
95
+ test_files:
96
+ - test/fis/test/test_test.rb