cspec 0.2.6 → 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/bin/cspec +30 -0
- data/cspec.gemspec +3 -2
- data/examples/advance/Gemfile.lock +3 -1
- data/examples/basic/Gemfile.lock +3 -1
- data/examples/basic/myspec.rb +0 -1
- data/examples/class_methods/Gemfile.lock +3 -1
- data/examples/class_methods/myspec.rb +0 -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 +3 -1
- data/examples/method_args/myspec.rb +0 -1
- data/lib/cspec/data_type.rb +2 -2
- data/lib/cspec/results_outputter.rb +1 -1
- data/lib/cspec/spec.rb +6 -6
- data/lib/cspec/version.rb +1 -1
- data/lib/cspec.rb +3 -0
- data/update_examples.sh +12 -0
- metadata +14 -4
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/bin/cspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'cspec'
|
7
|
+
|
8
|
+
USAGE = "\n Usage:\n\n cspec template list\n cspec generate <template name>\n"
|
9
|
+
|
10
|
+
command = ARGV[0]
|
11
|
+
sub_command = ARGV[1]
|
12
|
+
|
13
|
+
case command
|
14
|
+
when 'template'
|
15
|
+
if sub_command == 'list'
|
16
|
+
dir = File.join(CSpec.root, 'examples')
|
17
|
+
Dir.chdir(dir)
|
18
|
+
result = Dir.glob('*').select do |f|
|
19
|
+
File.directory?(f)
|
20
|
+
end
|
21
|
+
puts result
|
22
|
+
end
|
23
|
+
when 'generate'
|
24
|
+
puts "Generating from template: #{sub_command}"
|
25
|
+
example_dir = File.join(CSpec.root, 'examples', sub_command)
|
26
|
+
FileUtils.cp_r(example_dir, '.')
|
27
|
+
puts "cd into the #{sub_command} directory"
|
28
|
+
else
|
29
|
+
puts USAGE
|
30
|
+
end
|
data/cspec.gemspec
CHANGED
@@ -34,8 +34,9 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
35
35
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
36
36
|
end
|
37
|
-
spec.bindir
|
38
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.bindir = 'bin'
|
38
|
+
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
39
|
+
spec.executables << 'cspec'
|
39
40
|
spec.require_paths = ['lib']
|
40
41
|
|
41
42
|
spec.add_dependency 'colorize', '~> 0.8.1'
|
data/examples/basic/Gemfile.lock
CHANGED
data/examples/basic/myspec.rb
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/spec.rb
CHANGED
@@ -21,12 +21,12 @@ module CSpec
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def ==(other)
|
24
|
-
name == other
|
25
|
-
self.class == other
|
26
|
-
method == other
|
27
|
-
type == other
|
28
|
-
method_args == other
|
29
|
-
initialization_args == other
|
24
|
+
name == other&.name &&
|
25
|
+
self.class == other&.class &&
|
26
|
+
method == other&.method &&
|
27
|
+
type == other&.type &&
|
28
|
+
method_args == other&.method_args &&
|
29
|
+
initialization_args == other&.initialization_args
|
30
30
|
end
|
31
31
|
|
32
32
|
def error
|
data/lib/cspec/version.rb
CHANGED
data/lib/cspec.rb
CHANGED
data/update_examples.sh
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
bundle update
|
2
|
+
WORK_DIR=`pwd`
|
3
|
+
cd "$WORK_DIR/examples/advance"
|
4
|
+
bundle update
|
5
|
+
cd "$WORK_DIR/examples/basic"
|
6
|
+
bundle update
|
7
|
+
cd "$WORK_DIR/examples/class_methods"
|
8
|
+
bundle update
|
9
|
+
cd "$WORK_DIR/examples/method_args"
|
10
|
+
bundle update
|
11
|
+
cd "$WORK_DIR/examples/full"
|
12
|
+
bundle update
|
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
|
-
bindir:
|
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
|
@@ -97,7 +97,8 @@ dependencies:
|
|
97
97
|
description: A testing framework to run unit tests via csv
|
98
98
|
email:
|
99
99
|
- jarrod.folino@coderacademy.edu.au
|
100
|
-
executables:
|
100
|
+
executables:
|
101
|
+
- cspec
|
101
102
|
extensions: []
|
102
103
|
extra_rdoc_files: []
|
103
104
|
files:
|
@@ -113,6 +114,7 @@ files:
|
|
113
114
|
- README.md
|
114
115
|
- Rakefile
|
115
116
|
- bin/console
|
117
|
+
- bin/cspec
|
116
118
|
- bin/setup
|
117
119
|
- cspec.gemspec
|
118
120
|
- examples/advance/Gemfile
|
@@ -127,6 +129,13 @@ files:
|
|
127
129
|
- examples/class_methods/Gemfile.lock
|
128
130
|
- examples/class_methods/myspec.rb
|
129
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
|
130
139
|
- examples/method_args/Gemfile
|
131
140
|
- examples/method_args/Gemfile.lock
|
132
141
|
- examples/method_args/myspec.rb
|
@@ -141,6 +150,7 @@ files:
|
|
141
150
|
- lib/cspec/spec.rb
|
142
151
|
- lib/cspec/validator.rb
|
143
152
|
- lib/cspec/version.rb
|
153
|
+
- update_examples.sh
|
144
154
|
homepage: https://github.com/jarroddalefolino/cspec
|
145
155
|
licenses:
|
146
156
|
- MIT
|