bddsm 0.1.0 → 0.1.6

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
  SHA256:
3
- metadata.gz: 1ad7823b5ca54cef329506acf05ad1c81b405655de1ee48ccd85e701b79c06e1
4
- data.tar.gz: 8b23eecef4bab283602e5b1592a2be72c2de07434b94d01d0b53ccb0444372b5
3
+ metadata.gz: 286db37e9ca23e50fd515d76f7d4c1125768ccf9390bc15c9a2d4e6a4daa2ae9
4
+ data.tar.gz: 6c56c3a8bbfc73a246d900abdb1b9fabae64aa9c386cfd1f775ced50741ae4e3
5
5
  SHA512:
6
- metadata.gz: c3652b500acd7842a3168615cee5dd7a7585e29fab5199c6a123e2a835ecd2ce644506781c6683639ec97a4c67d150a7be65c5172feb4c8ee0c7c683289f795d
7
- data.tar.gz: d26aaf3d620e31be74272a1e6dd6038ea270e2611490612f46d615a234056bd9946aa7dada2c13e073c0c6d086025d78a0bc42bc1424342015342ab3cc81fe77
6
+ metadata.gz: 2db0f86b9ec74677e46e0e113d2d71cd0091ae1a37cc18aef62fef5c68befca6df11552a3bfd0b6f05c8d3cc76f5c20cbcb336d241231e307971a85ffdf7867f
7
+ data.tar.gz: dbc2f110f069a8d50d117077cd930abf98477daf73c2b8a94e8ce34f6b2f1a01ffc3e3a3a501a1f676e38f649488db7bc11ae05722b10353de09b99964c29b02
data/bin/bddsm CHANGED
@@ -3,7 +3,28 @@
3
3
  require 'pathname'
4
4
  require_relative '../lib/bddsm'
5
5
 
6
- suite = BDDSM::Suite.instance
6
+ def add_all_test_files(path_pattern)
7
+ Dir.glob(path_pattern).each do |file|
8
+ BDDSM::Suite.instance.add_path(Pathname.new(file))
9
+ end
10
+ end
7
11
 
8
- suite.add_path File.join(Dir.pwd, ARGV[0])
9
- suite.run
12
+ def add_single_test_file(file_path)
13
+ test_file = Pathname.new(__dir__).join('..', file_path)
14
+ BDDSM::Suite.instance.add_path(test_file)
15
+ end
16
+
17
+ if ARGV.empty?
18
+ test_dir = Pathname.new(__dir__).join('..', 'test', '**', '*_spec.rb')
19
+ add_all_test_files(test_dir)
20
+ else
21
+ add_single_test_file(ARGV[0])
22
+ end
23
+
24
+ BDDSM::Suite.instance.run
25
+
26
+ if BDDSM::Suite.instance.result.success?
27
+ exit 0
28
+ else
29
+ exit 1
30
+ end
@@ -1,8 +1,11 @@
1
1
  module BDDSM
2
2
  class Describe
3
+ attr_reader :memoized_lets
4
+
3
5
  def initialize(title, &block)
4
6
  @title = title
5
7
  @block = block
8
+ @memoized_lets = {}
6
9
  end
7
10
 
8
11
  def run
@@ -12,5 +15,11 @@ module BDDSM
12
15
  def it(&)
13
16
  Execution.new(describe: self, &).run
14
17
  end
18
+
19
+ def let(name, &)
20
+ singleton_class.instance_eval { attr_accessor name.to_sym } unless respond_to?(name.to_sym)
21
+ @memoized_lets[name] = instance_exec(&)
22
+ instance_variable_set("@#{name}", @memoized_lets[name])
23
+ end
15
24
  end
16
25
  end
@@ -2,7 +2,9 @@ module BDDSM
2
2
  class Execution
3
3
  def initialize(describe:, &block)
4
4
  @describe = describe
5
+ @memoized_lets ||= {}
5
6
  @block = block
7
+ memoized
6
8
  end
7
9
 
8
10
  def run
@@ -18,5 +20,17 @@ module BDDSM
18
20
  end
19
21
 
20
22
  def location = @block.source_location
23
+
24
+ private
25
+
26
+ def memoized
27
+ return unless @describe.memoized_lets
28
+
29
+ @describe.memoized_lets.each do |k, v|
30
+ self.class.define_method(k) do
31
+ @memoized_lets[k] ||= v
32
+ end
33
+ end
34
+ end
21
35
  end
22
36
  end
@@ -13,7 +13,7 @@ module BDDSM
13
13
  @io.print 'E'
14
14
  end
15
15
 
16
- def finalize
16
+ def finalize # rubocop:disable Metrics/MethodLength
17
17
  @io.puts
18
18
  @io.puts
19
19
  @io.puts 'OK!'
data/lib/bddsm/result.rb CHANGED
@@ -25,5 +25,7 @@ module BDDSM
25
25
  def subscribe(listener)
26
26
  @listeners << listener
27
27
  end
28
+
29
+ def success? = @failures.empty?
28
30
  end
29
31
  end
data/lib/bddsm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BDDSM
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bddsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei O. Udalov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-01 00:00:00.000000000 Z
11
+ date: 2024-07-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
14
- email:
13
+ description:
14
+ email:
15
15
  executables:
16
16
  - bddsm
17
17
  extensions: []
@@ -33,7 +33,7 @@ homepage: https://github.com/HeavyTechRuby/bddsm
33
33
  licenses: []
34
34
  metadata:
35
35
  rubygems_mfa_required: 'true'
36
- post_install_message:
36
+ post_install_message:
37
37
  rdoc_options: []
38
38
  require_paths:
39
39
  - lib
@@ -48,8 +48,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  requirements: []
51
- rubygems_version: 3.5.11
52
- signing_key:
51
+ rubygems_version: 3.4.19
52
+ signing_key:
53
53
  specification_version: 4
54
54
  summary: Hard Testing Framework. Multi-paradigm spec/feature/xunit-agnostic syntax
55
55
  support.