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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6585f0b209286fd400bb3a5b0060ee7fe4fddaa0c08f0f9414290fc5dd3caeb4
4
- data.tar.gz: df2ad99481481d95c1dd725056f0081d36720ebb831677a28319b98b05bff620
3
+ metadata.gz: ff05c0f096c5a71f243e49fad484865fa178882d2292a577db8e1300f8ef4088
4
+ data.tar.gz: f19e5b99f507b52a2fd44a877f8486d10271b9a9283885c373b0880e4e6a441e
5
5
  SHA512:
6
- metadata.gz: c64fce21bf149f25e96ae6daa3149aeb240629004c5202375afa03d2194d45744b473e1e38b68cb3ae97bde4d853bc5f46099711ab2b3695da08cd05f2c9f7e8
7
- data.tar.gz: 27e351c8aefd2bcc7e930e9c7073412bb8141c856dabe3eeed9568832efb93e66084f5e3cef5dab7154b72cacb231457ed229dbe8d858494724f3c37cf8d9ea5
6
+ metadata.gz: 5e4c105333a7c0bd2c03d18dd0b2ddfec206ec26e110f02d3b436de7f8d3df331344bf4c9c712fc75a5e39f43176aa1dbc02711dcd5bba4ef78f75b2388b4623
7
+ data.tar.gz: fcbf18f101007dc87b29b6a8f194337c8a0e1c95cb368ed9e6b77b91b2e1672155de96f8d0cd3f0be812f63411b328fa64f837a8933a567d1d306c0bfcfbbfaf
@@ -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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cspec (0.2.5)
4
+ cspec (0.2.9)
5
5
  colorize (~> 0.8.1)
6
6
 
7
7
  GEM
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 = 'exe'
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'
@@ -1,7 +1,9 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- cspec (0.2.5)
4
+ colorize (0.8.1)
5
+ cspec (0.2.8)
6
+ colorize (~> 0.8.1)
5
7
 
6
8
  PLATFORMS
7
9
  ruby
@@ -1,7 +1,9 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- cspec (0.2.5)
4
+ colorize (0.8.1)
5
+ cspec (0.2.8)
6
+ colorize (~> 0.8.1)
5
7
 
6
8
  PLATFORMS
7
9
  ruby
@@ -13,5 +13,4 @@ class MyClass
13
13
  end
14
14
 
15
15
  result = CSpec::Runner.run!("#{Dir.pwd}/specs.csv")
16
- puts "Success: #{result}"
17
16
  exit result ? 0 : 1
@@ -1,7 +1,9 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- cspec (0.2.5)
4
+ colorize (0.8.1)
5
+ cspec (0.2.8)
6
+ colorize (~> 0.8.1)
5
7
 
6
8
  PLATFORMS
7
9
  ruby
@@ -13,5 +13,4 @@ class MyClass
13
13
  end
14
14
 
15
15
  result = CSpec::Runner.run!("#{Dir.pwd}/specs.csv")
16
- puts "Success: #{result}"
17
16
  exit result ? 0 : 1
@@ -0,0 +1 @@
1
+ *.log
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,14 @@
1
+
2
+ Metrics/AbcSize:
3
+ Max: 20
4
+ Metrics/CyclomaticComplexity:
5
+ Max: 11
6
+ Metrics/MethodLength:
7
+ Max: 13
8
+ Metrics/PerceivedComplexity:
9
+ Max: 12
10
+ Style/Documentation:
11
+ Exclude:
12
+ - 'spec/**/*'
13
+ - 'test/**/*'
14
+ - 'myspec.rb'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gem 'cspec'
5
+ gem 'logging'
6
+ gem 'pry'
7
+ gem 'rubocop'
@@ -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
@@ -1,7 +1,9 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- cspec (0.2.5)
4
+ colorize (0.8.1)
5
+ cspec (0.2.8)
6
+ colorize (~> 0.8.1)
5
7
 
6
8
  PLATFORMS
7
9
  ruby
@@ -9,5 +9,4 @@ class MyClass
9
9
  end
10
10
 
11
11
  result = CSpec::Runner.run!("#{Dir.pwd}/specs.csv")
12
- puts "Success: #{result}"
13
12
  exit result ? 0 : 1
@@ -3,8 +3,8 @@
3
3
  module CSpec
4
4
  module DataType
5
5
  MATCHERS = [
6
- { condition: /^\d+\.\d+$/, proc: proc { |input| input.to_f } },
7
- { condition: /^\d+$/, proc: proc { |input| input.to_i } },
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 } },
@@ -3,7 +3,7 @@
3
3
  module CSpec
4
4
  module ResultsOutputter
5
5
  def self.display(results)
6
- results.map(&:to_s).join("\n")
6
+ results.reject { |r| r.error.nil? }.map(&:to_s).join("\n")
7
7
  end
8
8
  end
9
9
  end
data/lib/cspec/spec.rb CHANGED
@@ -21,12 +21,12 @@ module CSpec
21
21
  end
22
22
 
23
23
  def ==(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
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CSpec
4
- VERSION = '0.2.6'
4
+ VERSION = '0.2.9'
5
5
  end
data/lib/cspec.rb CHANGED
@@ -12,4 +12,7 @@ require 'cspec/results_outputter'
12
12
  require 'csv'
13
13
 
14
14
  module CSpec
15
+ def self.root
16
+ File.dirname __dir__
17
+ end
15
18
  end
@@ -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.6
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarrod Folino
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-16 00:00:00.000000000 Z
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