Class: Brut::CLI::Apps::Scaffold::E2ETest
- Defined in:
- lib/brut/cli/apps/scaffold.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Command
#after_bootstrap, args, #args, #before_execute, default_env, #delegate_to_commands, description, detailed_description, env_var, #err, #global_options, #handle_bootstrap_exception, #initialize, name_matches?, option_parser, #options, opts, #out, requires_project_env, requires_project_env?, #system!
Methods included from Framework::Errors
Methods included from I18n::ForCLI
Methods included from I18n::BaseMethods
#l, #t, #t_direct, #this_field_value
Methods included from ExecutionResults
#abort_execution, #as_execution_result, #cli_usage_error, #continue_execution, #show_cli_usage, #stop_execution
Constructor Details
This class inherits a constructor from Brut::CLI::Command
Class Method Details
.command_name ⇒ Object
110 |
# File 'lib/brut/cli/apps/scaffold.rb', line 110 def self.command_name = "test:e2e" |
Instance Method Details
#execute ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/brut/cli/apps/scaffold.rb', line 113 def execute if args.empty? err.puts "'#{self.class.command_name}' requires a name" return 1 end test_name = args.join(" ").gsub(/\"/,"'") test_file_name = args.join("_").gsub(/\W/,"_").gsub(/__+/,"_").downcase + ".spec.rb" test_file_dir = Brut.container.e2e_specs_dir if !.path.nil? test_file_dir = test_file_dir / .path end path_to_test_file = test_file_dir / test_file_name verb = "Created" dry_run_verb = "create" if path_to_test_file.exist? if .overwrite? verb = "Overwrote" dry_run_verb = "overwrite" else err.puts "#{path_to_test_file.relative_path_from(Brut.container.project_root)} exists. Use --overwrite to replace it" return 1 end end code = %{require "spec_helper" RSpec.describe "#{test_name}" do it "should have tests" do page.goto("/") expect(page).to be_page_for(page_class_here) end end} if .dry_run? out.puts "Will #{dry_run_verb} #{path_to_test_file.relative_path_from(Brut.container.project_root)} with this code:" out.puts_no_prefix out.puts_no_prefix code else FileUtils.mkdir_p test_file_dir File.open(path_to_test_file,"w") do |file| file.puts code end out.puts "#{verb} #{path_to_test_file.relative_path_from(Brut.container.project_root)}" end 0 end |