Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def to_markdown
body.map(&:to_markdown).join("\n")
end

def to_rdoc
body.map(&:to_rdoc).join("\n")
end

def to_yard
body.map(&:to_yard).join("\n")
end

def to_default
body.map(&:to_default).join("\n")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def to_markdown
body.map(&:to_markdown).join("\n")
end

def to_rdoc
body.map(&:to_rdoc).join("\n")
end

def to_yard
body.map(&:to_yard).join("\n")
end

def to_default
body.map(&:to_default).join("\n")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def to_markdown
body.map(&:to_markdown).join("\n")
end

def to_rdoc
body.map(&:to_rdoc).join("\n")
end

def to_yard
body.map(&:to_yard).join("\n")
end

def to_default
body.map(&:to_default).join("\n")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
subject { described_class.new(model, options).build }
let(:default_format) { subject.to_default }
let(:markdown_format) { subject.to_markdown }
let(:yard_format) { subject.to_yard }
let(:rdoc_format) { subject.to_rdoc }

let(:model) do
instance_double(
Expand Down Expand Up @@ -94,5 +96,41 @@

it { expect(default_format).to be_nil }
end

context "using yard format" do
let(:expected_result) do
<<~RESULT.strip
#
# Check Constraints
#
# alive (age < 150)
# missing_expression
# multiline_test (CASE WHEN (age >= 18) THEN (age <= 21) ELSE true END)
# must_be_adult (age >= 18)
RESULT
end

it "annotates the check constraints" do
expect(yard_format).to eq(expected_result)
end
end

context "using rdoc format" do
let(:expected_result) do
<<~RESULT.strip
#
# Check Constraints
#
# alive (age < 150)
# missing_expression
# multiline_test (CASE WHEN (age >= 18) THEN (age <= 21) ELSE true END)
# must_be_adult (age >= 18)
RESULT
end

it "annotates the check constraints" do
expect(rdoc_format).to eq(expected_result)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
subject { described_class.new(model, options).build }
let(:default_format) { subject.to_default }
let(:markdown_format) { subject.to_markdown }
let(:yard_format) { subject.to_yard }
let(:rdoc_format) { subject.to_rdoc }

let(:model) do
klass = begin
Expand Down Expand Up @@ -155,5 +157,43 @@
it { expect(markdown_format).to eq(expected_output) }
end
end

describe "#to_yard" do
let(:foreign_keys) do
[mock_foreign_key("fk_rails_cf2568e89e", "foreign_thing_id", "foreign_things")]
end

let(:expected_output) do
<<~OUTPUT.strip
#
# Foreign Keys
#
# fk_rails_cf2568e89e (foreign_thing_id => foreign_things.id)
OUTPUT
end

it "returns annotation in yard format" do
expect(yard_format).to eq(expected_output)
end
end

describe "#to_rdoc" do
let(:foreign_keys) do
[mock_foreign_key("fk_rails_cf2568e89e", "foreign_thing_id", "foreign_things")]
end

let(:expected_output) do
<<~OUTPUT.strip
#
# Foreign Keys
#
# fk_rails_cf2568e89e (foreign_thing_id => foreign_things.id)
OUTPUT
end

it "returns annotation in rdoc format" do
expect(rdoc_format).to eq(expected_output)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
subject { described_class.new(model, options).build }
let(:default_format) { subject.to_default }
let(:markdown_format) { subject.to_markdown }
let(:yard_format) { subject.to_yard }
let(:rdoc_format) { subject.to_rdoc }

let(:model) do
klass = begin
Expand Down Expand Up @@ -163,5 +165,43 @@
expect(default_format).to eq(expected_result)
end
end

describe "#to_yard" do
let(:indexes) do
[mock_index("index_rails_02e851e3b7", columns: ["id"])]
end

let(:expected_result) do
<<~EOS.strip
#
# Indexes
#
# index_rails_02e851e3b7 (id)
EOS
end

it "returns annotation in yard format" do
expect(yard_format).to eq(expected_result)
end
end

describe "#to_rdoc" do
let(:indexes) do
[mock_index("index_rails_02e851e3b7", columns: ["id"])]
end

let(:expected_result) do
<<~EOS.strip
#
# Indexes
#
# index_rails_02e851e3b7 (id)
EOS
end

it "returns annotation in rdoc format" do
expect(rdoc_format).to eq(expected_result)
end
end
end
end
Loading