rails_proof 1.0.0

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.
@@ -0,0 +1,87 @@
1
+ module RailsProof
2
+ class TestWriter
3
+ attr_reader :model_class_name, :concerns
4
+
5
+ def initialize(model_class_name:, concerns:)
6
+ @model_class_name = model_class_name
7
+ @concerns = concerns
8
+ end
9
+
10
+ def render
11
+ concerns.map do |concern|
12
+ indent(render_concern(concern), 2)
13
+ end.join("\n\n")
14
+ end
15
+
16
+ def render_test_file
17
+ [
18
+ 'require "test_helper"',
19
+ "",
20
+ "class #{model_class_name}Test < ActiveSupport::TestCase",
21
+ render,
22
+ "end",
23
+ ""
24
+ ].join("\n")
25
+ end
26
+
27
+ private
28
+
29
+ def render_concern(concern)
30
+ case concern[:type]
31
+ when :association
32
+ render_association(concern)
33
+ when :validation
34
+ render_validation(concern)
35
+ else
36
+ raise ArgumentError, "Unsupported test concern: #{concern.inspect}"
37
+ end
38
+ end
39
+
40
+ def render_association(concern)
41
+ macro = concern.fetch(:macro)
42
+ name = concern.fetch(:name)
43
+ test_name = "#{macro.to_s.tr("_", " ")} #{name}"
44
+
45
+ <<~RUBY.chomp
46
+ test "#{test_name}" do
47
+ association = #{model_class_name}.reflect_on_association(:#{name})
48
+
49
+ assert_not_nil association
50
+ assert_equal :#{macro}, association.macro
51
+ end
52
+ RUBY
53
+ end
54
+
55
+ def render_validation(concern)
56
+ validation = concern.fetch(:validation)
57
+ attribute = concern.fetch(:attribute)
58
+
59
+ case validation
60
+ when :presence
61
+ render_presence_validation(attribute)
62
+ else
63
+ raise ArgumentError, "Unsupported validation: #{validation.inspect}"
64
+ end
65
+ end
66
+
67
+ def render_presence_validation(attribute)
68
+ <<~RUBY.chomp
69
+ test "validates presence of #{attribute}" do
70
+ record = #{model_class_name}.new(#{attribute}: nil)
71
+
72
+ record.validate
73
+
74
+ assert record.errors.of_kind?(:#{attribute}, :blank)
75
+ end
76
+ RUBY
77
+ end
78
+
79
+ def indent(source, spaces)
80
+ prefix = " " * spaces
81
+
82
+ source.lines.map do |line|
83
+ line.strip.empty? ? line : "#{prefix}#{line}"
84
+ end.join
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,3 @@
1
+ module RailsProof
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,13 @@
1
+ require "rails_proof/version"
2
+ require "rails_proof/railtie"
3
+ require "rails_proof/open_ai_client"
4
+
5
+ module RailsProof
6
+ class << self
7
+ attr_writer :ai_client
8
+
9
+ def ai_client
10
+ @ai_client ||= OpenAiClient.new
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :rails_proof do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_proof
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Oak Harbor Ventures, LLC
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 8.1.3.1
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '9.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 8.1.3.1
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '9.0'
32
+ description: RailsProof analyzes Rails applications using deterministic Rails inspection
33
+ and AI-assisted reasoning, generates ordinary Minitest tests, executes candidate
34
+ tests against the application, and preserves disagreements for human review. Get
35
+ help, ask questions, or talk to us at https://support.oakharborventures.com.
36
+ email:
37
+ - john@oakharborventures.com
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - CHANGELOG.md
43
+ - MIT-LICENSE
44
+ - README.md
45
+ - Rakefile
46
+ - lib/generators/rails_proof/test/USAGE
47
+ - lib/generators/rails_proof/test/test_generator.rb
48
+ - lib/rails_proof.rb
49
+ - lib/rails_proof/ai_concern_filter.rb
50
+ - lib/rails_proof/ai_test_executor.rb
51
+ - lib/rails_proof/ai_test_identity.rb
52
+ - lib/rails_proof/ai_test_planner.rb
53
+ - lib/rails_proof/ai_test_validator.rb
54
+ - lib/rails_proof/ai_test_writer.rb
55
+ - lib/rails_proof/controller_inspector.rb
56
+ - lib/rails_proof/controller_test_coverage_plan.rb
57
+ - lib/rails_proof/controller_test_plan.rb
58
+ - lib/rails_proof/controller_test_writer.rb
59
+ - lib/rails_proof/model_inspector.rb
60
+ - lib/rails_proof/model_test_plan.rb
61
+ - lib/rails_proof/open_ai_client.rb
62
+ - lib/rails_proof/railtie.rb
63
+ - lib/rails_proof/review_store.rb
64
+ - lib/rails_proof/target_discovery.rb
65
+ - lib/rails_proof/test_coverage_plan.rb
66
+ - lib/rails_proof/test_inspector.rb
67
+ - lib/rails_proof/test_runner.rb
68
+ - lib/rails_proof/test_writer.rb
69
+ - lib/rails_proof/version.rb
70
+ - lib/tasks/rails_proof_tasks.rake
71
+ homepage: https://support.oakharborventures.com
72
+ licenses:
73
+ - MIT
74
+ metadata:
75
+ homepage_uri: https://support.oakharborventures.com
76
+ source_code_uri: https://github.com/johnnynumberfive-coder/railsproof
77
+ changelog_uri: https://github.com/johnnynumberfive-coder/railsproof/blob/main/CHANGELOG.md
78
+ bug_tracker_uri: https://github.com/johnnynumberfive-coder/railsproof/issues
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '4.0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubygems_version: 4.0.16
94
+ specification_version: 4
95
+ summary: AI-assisted Minitest generation for modern Rails applications.
96
+ test_files: []