Skip to content

Commit

Permalink
Get test suite green
Browse files Browse the repository at this point in the history
  • Loading branch information
azimux committed Mar 4, 2024
1 parent 8ba5007 commit 6cbc7bf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
11 changes: 4 additions & 7 deletions spec/foobara/generators/generate_domain_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec.describe Foobara::Generators::DomainGenerator::GenerateDomain do
let(:domain_name) { "SomeOrg::SomeDomain::SomeDomain" }
let(:domain_name) { "SomeOrg::SomeDomain" }

let(:inputs) do
{
Expand All @@ -14,10 +14,9 @@
it "generates a domain" do
expect(outcome).to be_success

domain_file = result["src/some_org/some_domain/some_domain.rb"]
domain_file = result["src/some_org/some_domain.rb"]
expect(domain_file).to include("module SomeOrg")
expect(domain_file).to include("module SomeDomain")
expect(domain_file).to include("class SomeDomain")
end

context "with all options" do
Expand All @@ -26,18 +25,16 @@
domain_name: "SomeDomain",
description: "whatever",
organization_name: "SomeOrg",
domain_name: "SomeDomain",
full_module_name: "SomeOrg::SomeDomain::SomeDomain"
full_module_name: "SomeOrg::SomeDomain"
}
end

it "generates a domain using the given options" do
expect(outcome).to be_success

domain_file = result["src/some_org/some_domain/some_domain.rb"]
domain_file = result["src/some_org/some_domain.rb"]
expect(domain_file).to include("module SomeOrg")
expect(domain_file).to include("module SomeDomain")
expect(domain_file).to include("class SomeDomain")
end
end
end
4 changes: 2 additions & 2 deletions spec/foobara/generators/write_domain_to_disk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
description: "whatever"
}
end
let(:domain_name) { "SomeOrg::SomeDomain::SomeDomain" }
let(:domain_name) { "SomeOrg::SomeDomain" }
let(:output_directory) { "#{__dir__}/../../../tmp/domain_test_suite_output" }

before do
Expand All @@ -30,7 +30,7 @@
it "contains base files" do
expect(outcome).to be_success

expect(domain.paths_to_source_code.keys).to include("src/some_org/some_domain/some_domain.rb")
expect(domain.paths_to_source_code.keys).to include("src/some_org/some_domain.rb")
end
end

Expand Down
7 changes: 2 additions & 5 deletions src/domain_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class DomainConfig < Foobara::Model
domain_name :string, :required
description :string, :allow_nil
organization_name :string, :allow_nil
domain_name :string, :allow_nil
full_module_name :string
end

Expand All @@ -20,13 +19,12 @@ def initialize(attributes = nil, options = {})
domain_name = attributes[:domain_name]
description = attributes[:description]
organization_name = attributes[:organization_name]
domain_name = attributes[:domain_name]

if organization_name.nil? && domain_name.nil? && full_module_name.nil?
if organization_name.nil? && full_module_name.nil?
full_module_name = domain_name
module_path = full_module_name.split("::")

*prefix, domain_name = module_path
*prefix, _ = module_path

*organization_parts, domain_name = prefix

Expand All @@ -40,7 +38,6 @@ def initialize(attributes = nil, options = {})
domain_name:,
description:,
organization_name:,
domain_name:,
full_module_name:
},
options
Expand Down
2 changes: 1 addition & 1 deletion src/write_domain_to_disk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def default_output_directory

def generate_file_contents
# TODO: just pass this in as the inputs instead of the domain??
self.paths_to_source_code = run_subdomain!(GenerateDomain, domain_config.attributes)
self.paths_to_source_code = run_subcommand!(GenerateDomain, domain_config.attributes)
end

def run_post_generation_tasks
Expand Down

0 comments on commit 6cbc7bf

Please sign in to comment.