Skip to content

Commit

Permalink
feat(rspec): adds support to defined arguments to the create_dummy_pr…
Browse files Browse the repository at this point in the history
…oject method
  • Loading branch information
blackjid committed Mar 3, 2016
1 parent 34a7c5b commit a1a67ac
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions spec/support/potassium_test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ def create_tmp_directory
FileUtils.mkdir_p(tmp_path)
end

def create_dummy_project
def create_dummy_project(arguments = {})
Dir.chdir(tmp_path) do
Bundler.with_clean_env do
run_command("#{potassium_bin} create #{APP_NAME} #{bin_arguments}")
full_arguments = hash_to_arguments(default_arguments.merge(arguments))
run_command("#{potassium_bin} create #{APP_NAME} #{full_arguments}")
end
end
end
Expand Down Expand Up @@ -44,18 +45,30 @@ def potassium_bin
File.join(root_path, "bin", "potassium")
end

def bin_arguments
[
"--db=mysql",
"--lang=es",
"--no-devise",
"--no-admin",
"--no-pundit",
"--no-paperclip",
"--no-api",
"--no-heroku",
"--no-delayed-job"
].join(" ")
def default_arguments
{
"db" => "mysql",
"lang" => "es",
"heroku" => false,
"admin" => false,
"pundit" => false,
"paperclip" => false,
"devise" => false,
"api" => false,
"delayed-job" => false
}
end

def hash_to_arguments(hash)
hash.map do |key, value|
if value == true
"--#{key}"
elsif value == false
"--no-#{key}"
elsif value
"--#{key}=#{value}"
end
end.join(" ")
end

def root_path
Expand Down

0 comments on commit a1a67ac

Please sign in to comment.