Skip to content

Commit

Permalink
Fixes last issues from trailblazer#16
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Tich committed May 22, 2018
1 parent b25d640 commit bc9776d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/trailblazer/generator/commands/generate/contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Contract < Base
option :layout, default: :singular, values: DEFAULT_LAYOUTS, desc: OPTION_LAYOUT
option :json, desc: OPTION_JSON
option :path, desc: OPTION_PATH
option :stubs, desc: OPTION_STUBS

# Apply context and call generator
def call(concept:, **options)
Expand Down
10 changes: 5 additions & 5 deletions spec/trailblazer/generator/utils/fetch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
let(:options) { {name: "SomeName"} }
let(:custom_options) do
{
concept: nil, action: "some_name", path: false, type: type_in_string, name: "SomeName", json: false,
concept_path: concept_path, view: false, stubs: stubs
concept: nil, template: "some_name", path: false, type: type_in_string, name: "SomeName", json: false,
concept_path: concept_path, view: view_in_string, stubs: stubs
}
end
let(:custom_context) { Trailblazer::Generator::Context.new(custom_options) }
Expand All @@ -107,8 +107,8 @@
let(:stubs) { "some_stubs" }
let(:custom_options) do
{
concept: nil, action: false, path: false, type: type_in_string, name: false, json: false,
concept_path: concept_path, view: false, stubs: stubs
concept: nil, template: false, path: false, type: type_in_string, name: false, json: false,
concept_path: concept_path, view: view_in_string, stubs: stubs
}
end
let(:custom_context) { Trailblazer::Generator::Context.new(custom_options) }
Expand Down Expand Up @@ -142,7 +142,7 @@
# let(:custom_options) do
# {
# concept: nil, template: false, path: false, type: type_in_string, name: false, json: json_parsed,
# concept_path: concept_path, view: false
# concept_path: concept_path, view: view_in_string, stubs: stubs
# }
# end
# let(:custom_context) { Trailblazer::Generator::Context.new(custom_options) }
Expand Down
14 changes: 7 additions & 7 deletions spec/trailblazer/generator/utils/files_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RSpec.describe Trailblazer::Generator::Utils::Files do
let(:context) do
Trailblazer::Generator::Context.new(
template: "template",
template: template,
path: false,
concept: "Blog",
layout: "singular",
Expand All @@ -16,7 +16,7 @@
end
let(:type) { :operation }
let(:stubs) { "../stubs" }
let(:action) { "new" }
let(:template) { "new" }

subject(:files) { described_class }

Expand All @@ -34,19 +34,19 @@

context "#template" do
context "with default stubs and existing template" do
let(:action) { "create" }
it "returns action" do
let(:template) { "create" }
it "returns template" do
expect(files.template(context, type))
.to eq(
file_name: Trailblazer::Generator::Utils::String.new(action),
file_name: Trailblazer::Generator::Utils::String.new(template),
path: File.join(Dir.pwd, "/lib/trailblazer/generator/utils/../stubs")
)
end
end

context "with default stubs and not existing template" do
let(:output) { files.template(context, type) }
let(:action) { "weird" }
let(:template) { "weird" }

before { allow_any_instance_of(Trailblazer::Generator::Utils::Say).to receive(:notice).and_return(true) }

Expand All @@ -62,7 +62,7 @@
context "when passing a custom stubs" do
let(:stubs) { "custom_stubs" }

it "returns just action" do
it "returns just template" do
expect(files.template(context, type))
.to eq(
file_name: "new",
Expand Down

0 comments on commit bc9776d

Please sign in to comment.