cspec 0.2.8 → 0.2.9
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 +4 -4
- data/.github/workflows/ruby.yml +4 -1
- data/Gemfile.lock +1 -1
- data/examples/advance/Gemfile.lock +1 -1
- data/examples/basic/Gemfile.lock +1 -1
- data/examples/class_methods/Gemfile.lock +1 -1
- data/examples/full/.gitignore +1 -0
- data/examples/full/.rubocop.yml +1 -0
- data/examples/full/.rubocop_todo.yml +14 -0
- data/examples/full/Gemfile +7 -0
- data/examples/full/Gemfile.lock +48 -0
- data/examples/full/myspec.rb +87 -0
- data/examples/full/specs.csv +22 -0
- data/examples/method_args/Gemfile.lock +1 -1
- data/lib/cspec/data_type.rb +2 -2
- data/lib/cspec/version.rb +1 -1
- data/update_examples.sh +2 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff05c0f096c5a71f243e49fad484865fa178882d2292a577db8e1300f8ef4088
|
4
|
+
data.tar.gz: f19e5b99f507b52a2fd44a877f8486d10271b9a9283885c373b0880e4e6a441e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e4c105333a7c0bd2c03d18dd0b2ddfec206ec26e110f02d3b436de7f8d3df331344bf4c9c712fc75a5e39f43176aa1dbc02711dcd5bba4ef78f75b2388b4623
|
7
|
+
data.tar.gz: fcbf18f101007dc87b29b6a8f194337c8a0e1c95cb368ed9e6b77b91b2e1672155de96f8d0cd3f0be812f63411b328fa64f837a8933a567d1d306c0bfcfbbfaf
|
data/.github/workflows/ruby.yml
CHANGED
@@ -42,4 +42,7 @@ jobs:
|
|
42
42
|
run: bundle install && bundle exec ruby myspec.rb
|
43
43
|
- name: Run Class Methods Example
|
44
44
|
working-directory: ./examples/class_methods
|
45
|
-
run: bundle install && bundle exec ruby myspec.rb
|
45
|
+
run: bundle install && bundle exec ruby myspec.rb
|
46
|
+
- name: Run Full Example
|
47
|
+
working-directory: ./examples/full
|
48
|
+
run: bundle install && bundle exec ruby myspec.rb
|
data/Gemfile.lock
CHANGED
data/examples/basic/Gemfile.lock
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
*.log
|
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
@@ -0,0 +1,48 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ast (2.4.2)
|
5
|
+
coderay (1.1.3)
|
6
|
+
colorize (0.8.1)
|
7
|
+
cspec (0.2.8)
|
8
|
+
colorize (~> 0.8.1)
|
9
|
+
little-plugger (1.1.4)
|
10
|
+
logging (2.3.0)
|
11
|
+
little-plugger (~> 1.1)
|
12
|
+
multi_json (~> 1.14)
|
13
|
+
method_source (1.0.0)
|
14
|
+
multi_json (1.15.0)
|
15
|
+
parallel (1.21.0)
|
16
|
+
parser (3.1.1.0)
|
17
|
+
ast (~> 2.4.1)
|
18
|
+
pry (0.14.1)
|
19
|
+
coderay (~> 1.1)
|
20
|
+
method_source (~> 1.0)
|
21
|
+
rainbow (3.1.1)
|
22
|
+
regexp_parser (2.2.1)
|
23
|
+
rexml (3.2.5)
|
24
|
+
rubocop (1.26.0)
|
25
|
+
parallel (~> 1.10)
|
26
|
+
parser (>= 3.1.0.0)
|
27
|
+
rainbow (>= 2.2.2, < 4.0)
|
28
|
+
regexp_parser (>= 1.8, < 3.0)
|
29
|
+
rexml
|
30
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
31
|
+
ruby-progressbar (~> 1.7)
|
32
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
33
|
+
rubocop-ast (1.16.0)
|
34
|
+
parser (>= 3.1.1.0)
|
35
|
+
ruby-progressbar (1.11.0)
|
36
|
+
unicode-display_width (2.1.0)
|
37
|
+
|
38
|
+
PLATFORMS
|
39
|
+
ruby
|
40
|
+
|
41
|
+
DEPENDENCIES
|
42
|
+
cspec
|
43
|
+
logging
|
44
|
+
pry
|
45
|
+
rubocop
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
1.17.2
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cspec'
|
4
|
+
require 'logging'
|
5
|
+
|
6
|
+
# Logger setup
|
7
|
+
class Object
|
8
|
+
def logger_info
|
9
|
+
"#{self.class}##{__callee__} (#{object_id})"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class MyLogger
|
14
|
+
def self.instance
|
15
|
+
return @logger if @logger
|
16
|
+
|
17
|
+
@logger = Logging.logger($stdout)
|
18
|
+
@logger.level = ENV['LOG_LEVEL']&.to_sym || :warn
|
19
|
+
@logger.add_appenders \
|
20
|
+
Logging.appenders.stdout,
|
21
|
+
Logging.appenders.file("#{Time.now.strftime('%Y%m%d')}.log")
|
22
|
+
@logger
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class NumberUtil
|
27
|
+
def largest(num1, num2)
|
28
|
+
return num1 if num1 > num2
|
29
|
+
|
30
|
+
num2
|
31
|
+
end
|
32
|
+
|
33
|
+
def sum_number_range(start_num, end_num)
|
34
|
+
MyLogger.instance.debug("#{logger_info} start_num: #{start_num}, end_num: #{end_num}")
|
35
|
+
x = start_num
|
36
|
+
sum = 0
|
37
|
+
MyLogger.instance.debug("#{logger_info} #{x} <= #{end_num}: #{x <= end_num}")
|
38
|
+
while x <= end_num
|
39
|
+
MyLogger.instance.debug("#{logger_info} #{x} <= #{end_num}: #{x <= end_num}")
|
40
|
+
sum += x
|
41
|
+
MyLogger.instance.debug("#{logger_info} sum: #{sum}")
|
42
|
+
x += 1
|
43
|
+
end
|
44
|
+
sum
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class StringUtil
|
49
|
+
def greet(name)
|
50
|
+
"Hello, #{name}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class CokeMachine
|
55
|
+
def initialize(inventory_amount)
|
56
|
+
@inventory_amount = inventory_amount
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_reader :inventory_amount
|
60
|
+
end
|
61
|
+
|
62
|
+
class GradingMachine
|
63
|
+
def pass?(amount)
|
64
|
+
return false if amount < 45
|
65
|
+
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
69
|
+
def grade(amount)
|
70
|
+
if amount < 45
|
71
|
+
'F'
|
72
|
+
elsif amount >= 45 && amount < 60
|
73
|
+
'E'
|
74
|
+
elsif amount >= 60 && amount < 70
|
75
|
+
'D'
|
76
|
+
elsif amount >= 70 && amount < 80
|
77
|
+
'C'
|
78
|
+
elsif amount >= 80 && amount < 90
|
79
|
+
'B'
|
80
|
+
elsif amount >= 90
|
81
|
+
'A'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
result = CSpec::Runner.run!("#{Dir.pwd}/specs.csv")
|
87
|
+
exit result ? 0 : 1
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class,name,type,method,initialization_arg_1,method_arg_1,method_arg_2,method_arg_3,expected
|
2
|
+
StringUtil,string concatonation 1,instance,greet,,Bob,,,"Hello, Bob"
|
3
|
+
NumberUtil,if statement 1.1,instance,largest,,1,2,,2
|
4
|
+
NumberUtil,if statement 1.1,instance,largest,,3,2,,3
|
5
|
+
NumberUtil,while statement 1.1,instance,sum_number_range,,1,3,,6
|
6
|
+
NumberUtil,while statement 1.2,instance,sum_number_range,,1,7,,28
|
7
|
+
NumberUtil,while statement 1.3,instance,sum_number_range,,0,7,,28
|
8
|
+
CokeMachine,initialization arg 1,instance,inventory_amount,45,,,,45
|
9
|
+
GradingMachine,if statement 2.1,instance,pass?,,45,,,true
|
10
|
+
GradingMachine,if statement 2.2,instance,pass?,,44,,,false
|
11
|
+
GradingMachine,if elsif else statement (boundary) 1.1.1,instance,grade,,90,,,A
|
12
|
+
GradingMachine,if elsif else statement 1.1.2,instance,grade,,91,,,A
|
13
|
+
GradingMachine,if elsif else statement (boundary) 1.2.1,instance,grade,,80,,,B
|
14
|
+
GradingMachine,if elsif else statement 1.2.1,instance,grade,,81,,,B
|
15
|
+
GradingMachine,if elsif else statement (boundary) 1.3.1,instance,grade,,70,,,C
|
16
|
+
GradingMachine,if elsif else statement 1.3.1,instance,grade,,71,,,C
|
17
|
+
GradingMachine,if elsif else statement (boundary) 1.4.1,instance,grade,,60,,,D
|
18
|
+
GradingMachine,if elsif else statement 1.4.2,instance,grade,,61,,,D
|
19
|
+
GradingMachine,if elsif else statement (boundary) 1.5.1,instance,grade,,45,,,E
|
20
|
+
GradingMachine,if elsif else statement 1.5.2,instance,grade,,45,,,E
|
21
|
+
GradingMachine,if elsif else statement 1.6.1,instance,grade,,7,,,F
|
22
|
+
GradingMachine,if elsif else statement 1.6.2,instance,grade,,0,,,F
|
data/lib/cspec/data_type.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
module CSpec
|
4
4
|
module DataType
|
5
5
|
MATCHERS = [
|
6
|
-
{ condition:
|
7
|
-
{ condition:
|
6
|
+
{ condition: /^-?\d+\.\d+$/, proc: proc { |input| input.to_f } },
|
7
|
+
{ condition: /^-?\d+$/, proc: proc { |input| input.to_i } },
|
8
8
|
{ condition: /true/, proc: proc { true } },
|
9
9
|
{ condition: /^\[.*\]$/, proc: proc { |input| eval(input) } },
|
10
10
|
{ condition: /false/, proc: proc { false } },
|
data/lib/cspec/version.rb
CHANGED
data/update_examples.sh
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarrod Folino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -129,6 +129,13 @@ files:
|
|
129
129
|
- examples/class_methods/Gemfile.lock
|
130
130
|
- examples/class_methods/myspec.rb
|
131
131
|
- examples/class_methods/specs.csv
|
132
|
+
- examples/full/.gitignore
|
133
|
+
- examples/full/.rubocop.yml
|
134
|
+
- examples/full/.rubocop_todo.yml
|
135
|
+
- examples/full/Gemfile
|
136
|
+
- examples/full/Gemfile.lock
|
137
|
+
- examples/full/myspec.rb
|
138
|
+
- examples/full/specs.csv
|
132
139
|
- examples/method_args/Gemfile
|
133
140
|
- examples/method_args/Gemfile.lock
|
134
141
|
- examples/method_args/myspec.rb
|