testaroni 0.0.2 → 0.0.4

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28d681b309900cdf3d1c96f24e9fa540a4d8668d224330466c5603e05015fc71
4
- data.tar.gz: 05be8d4e6dc955be5c27bc9761e8392ebc8fdbc068fee164fc380b008fb2a7ba
3
+ metadata.gz: e98257815aa4fe0e8dba3a6d09b620603b53d096361cade4f04c39a868b7f538
4
+ data.tar.gz: a401773f6fb9146cd976339e60d318bb7fb5dec3ec6fd102e4795c1f2c2cf760
5
5
  SHA512:
6
- metadata.gz: 6e2b62090725c1865c9ef6edbc9daeb9c0f6bae12dc38c871474c8bf18a1d446ea45d2a889f66888b7142b21114541cb3914f7836cc24dd631ecd3afd9e67e7d
7
- data.tar.gz: 183643da6c40d63ac3a8466e56092cbe9a10ad2dc2170299b59a761584b978d6813d55c4f296f474ce8a791049c0f343de2a8b4cb4e54068240e0e05dfbbfb55
6
+ metadata.gz: 88dbd46c61dd97065069cdfe979719b57d0e22582fec4b0b2616d27bb799590f13204b7f4abe2f975a5e37ff79141b9452c64b7d5337a2fddcaadd7c07d8cd61
7
+ data.tar.gz: 8d38bdb6cf1b355572deb27499e709874180dd5a867838dfb4610d698a59bf6aaf4623e32d23edf7f102971f0ca79057b5f36a0d0d7f060050b81e531105e5cd
data/bin/testaroni ADDED
@@ -0,0 +1,6 @@
1
+ if File.exist?("tests")
2
+ puts '🍕 Running tests'
3
+ Dir.glob("tests/**/*.rb").each do |file|
4
+ load(file)
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ class Testaroni
2
+ class AssertionError < StandardError; end
3
+ end
@@ -1,26 +1,18 @@
1
+ # Responsible for handling questions after calling make_sure or other methods
1
2
  class Testaroni
2
3
  class Evaluation
3
- # Responsible for handling questions after calling
4
- # make_sure or other methods
5
- attr_reader :original_value
6
- def initialize(original_value)
4
+ attr_reader :original_value, :runner
5
+ def initialize(runner, original_value)
6
+ @runner = runner
7
7
  @original_value = original_value
8
8
  end
9
9
 
10
10
  def equals(matching_value)
11
- if original_value == matching_value
12
- puts "✅ Test passed"
13
- else
14
- puts "❌ Test failed"
15
- end
11
+ raise Testaroni::AssertionError if original_value != matching_value
16
12
  end
17
13
 
18
14
  def is_not(matching_value)
19
- if original_value != matching_value
20
- puts "✅ Test passed"
21
- else
22
- puts "❌ Test failed"
23
- end
15
+ raise Testaroni::AssertionError if original_value == matching_value
24
16
  end
25
17
  end
26
18
  end
@@ -1,21 +1,31 @@
1
1
  class Testaroni
2
2
  class Runner
3
- attr_reader :test_block
4
- def initialize(&test_block)
3
+ attr_reader :description, :test_block
4
+ def initialize(description, &test_block)
5
+ @description = description
5
6
  @test_block = test_block
6
7
  end
7
-
8
+
8
9
  def call
9
10
  instance_eval(&test_block)
10
11
  end
11
12
 
12
- # Base level helpers
13
+ # Use it as a way to add to description?
14
+ # def it(description_addition)
15
+ # @description_addition += " - #{description_addition}"
16
+ # end
13
17
 
18
+ # Base level helpers
14
19
  def make_sure(value)
15
- # Need to ensure something happens
16
- # Returns an object with access to methods
17
- # .equals .is_not
18
- Testaroni::Evaluation.new(value)
20
+ # Returns an object with access to methods ( .equals .is_not )
21
+ Testaroni::Evaluation.new(self, value)
22
+ end
23
+
24
+ alias :ensure :make_sure
25
+ alias :assert :make_sure
26
+
27
+ def should
28
+ Testaroni::ShouldContext.new(self)
19
29
  end
20
30
  end
21
31
  end
@@ -0,0 +1,12 @@
1
+ class Testaroni
2
+ class ShouldContext
3
+ attr_reader :runner
4
+ def initialize(runner)
5
+ @runner = runner
6
+ end
7
+
8
+ def have(file)
9
+ raise AssertionError if !File.exist?(file)
10
+ end
11
+ end
12
+ end
@@ -1,10 +1,13 @@
1
1
  class Testaroni
2
2
  module Test
3
3
  def test(description, &block)
4
- # need to define test helper methods
5
- # Run this in an isolated context with helpers included?
6
- test_runner = Testaroni::Runner.new(&block)
4
+ # Run this in an isolated context with helpers included
5
+ test_runner = Testaroni::Runner.new(description, &block)
7
6
  test_runner.call
7
+ rescue => AssertionError
8
+ puts "❌ Test failed: #{test_runner.description}"
9
+ else
10
+ puts "✅ Test passed: #{test_runner.description}"
8
11
  end
9
12
  end
10
13
  end
data/lib/testaroni.rb CHANGED
@@ -1,10 +1,8 @@
1
1
  require_relative "./testaroni/test"
2
+ require_relative "./testaroni/errors"
2
3
  require_relative "./testaroni/evaluation"
4
+ require_relative "./testaroni/should_context"
3
5
  require_relative "./testaroni/runner"
4
-
5
6
  include Testaroni::Test
6
7
 
7
- class Testaroni
8
- end
9
-
10
- puts "🍕 Running tests now!"
8
+ class Testaroni; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testaroni
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indigo Tech Tutorials
@@ -11,13 +11,17 @@ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Write tests for your ruby code.
13
13
  email: indigo@tech.tut
14
- executables: []
14
+ executables:
15
+ - testaroni
15
16
  extensions: []
16
17
  extra_rdoc_files: []
17
18
  files:
19
+ - bin/testaroni
18
20
  - lib/testaroni.rb
21
+ - lib/testaroni/errors.rb
19
22
  - lib/testaroni/evaluation.rb
20
23
  - lib/testaroni/runner.rb
24
+ - lib/testaroni/should_context.rb
21
25
  - lib/testaroni/test.rb
22
26
  homepage: https://rubygems.org/gems/testaroni
23
27
  licenses: