add a generator, 'cause i'm both lazy and not lazy
This commit is contained in:
parent
c1379a1a9d
commit
a3e4743658
|
@ -24,6 +24,12 @@ Cucumber::StepWriter.after_write do |dir|
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Set up your sane defaults by using the generator:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
rails generator cucumber:step_writer
|
||||||
|
```
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
|
|
||||||
* If you want it to generate for different languages, I take pull requests.
|
* If you want it to generate for different languages, I take pull requests.
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
require "cucumber/step_writer"
|
require "cucumber/step_writer"
|
||||||
|
|
||||||
|
require "cucumber/step_writer/railtie" if defined?(::Rails)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
module Cucumber
|
||||||
|
class StepWriterGenerator < Rails::Generators::Base
|
||||||
|
source_root File.expand_path('../../../../skel', __FILE__)
|
||||||
|
|
||||||
|
desc "Create a step writer that opens your step definitiosn folder once steps are generated"
|
||||||
|
def generate_step_writer_after_hook
|
||||||
|
copy_file 'step_writer.rb', 'features/support/step_writer.rb'
|
||||||
|
insert_into_file 'config/cucumber.yml',
|
||||||
|
"# inserted by cucumber-step_writer\nstd_opts << ' -f Cucumber::StepWriter --out features/step_definitions'\n",
|
||||||
|
:after => %r{std_opts = "--format[^\n]*\n}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,8 @@
|
||||||
|
module Cucumber
|
||||||
|
class StepWriterRailtie < Rails::Railtie
|
||||||
|
generators do
|
||||||
|
load File.expand_path('../generators.rb', __FILE__)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
Cucumber::StepWriter.after_write do |dir|
|
||||||
|
%w{open xdg-open}.each do |cmd|
|
||||||
|
%x{which #{cmd}}
|
||||||
|
|
||||||
|
if $?.exitstatus
|
||||||
|
system %{#{cmd} #{dir}}
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue