Skip to content

Commit 1c48040

Browse files
committed
test: CLI:generated integration
1 parent 1801d7a commit 1c48040

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

spec/rails/diff_spec.rb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,33 @@
44
it "has a version number" do
55
expect(Rails::Diff::VERSION).not_to be nil
66
end
7-
end
7+
8+
describe ".generated" do
9+
before do
10+
allow(Rails::Diff).to receive(:system!).and_return(true)
11+
allow(Rails::Diff).to receive(:ensure_template_app_exists)
12+
allow(Rails::Diff).to receive(:install_app_dependencies)
13+
allow(Rails::Diff).to receive(:generated_files).and_return(["file1.rb", "file2.rb"])
14+
allow(Rails::Diff).to receive(:diff_with_header).and_return("file1.rb diff:\n===\nDiff content")
15+
end
16+
17+
it "returns the diff for generated files" do
18+
result = Rails::Diff.generated("model", "User", no_cache: true)
19+
expect(result).to include("file1.rb diff:")
20+
end
21+
end
22+
23+
describe Rails::Diff::CLI do
24+
describe "#generated" do
25+
before do
26+
allow(Rails::Diff).to receive(:system!).and_return(true)
27+
allow(Rails::Diff).to receive(:generated).and_return("file1.rb diff:\n===\nDiff content")
28+
end
29+
30+
it "runs without error" do
31+
cli = Rails::Diff::CLI.new
32+
expect { cli.generated("model", "User") }.not_to raise_error
33+
end
34+
end
35+
end
36+
end

0 commit comments

Comments
 (0)