Class: Hoboken::AddOns::Turnip
- Inherits:
-
Group
- Object
- Thor::Group
- Group
- Hoboken::AddOns::Turnip
show all
- Defined in:
- lib/hoboken/add_ons/turnip.rb
Overview
Gherkin extension for RSpec
Instance Method Summary
collapse
Methods inherited from Group
#classic?, #modular?, #rspec?, #rubocop?, #sequel?, source_root
#gem, #indent
Instance Method Details
#add_gems ⇒ Object
8
9
10
11
12
|
# File 'lib/hoboken/add_ons/turnip.rb', line 8
def add_gems
return unless rspec?
gem 'turnip', version: '4.3', group: :test
end
|
#add_helper ⇒ Object
rubocop:enable Metrics/MethodLength
55
56
57
58
59
60
61
62
|
# File 'lib/hoboken/add_ons/turnip.rb', line 55
def add_helper
return unless rspec?
template(
'hoboken/templates/spec/turnip_helper.rb.tt',
'spec/turnip_helper.rb'
)
end
|
#add_sample_files ⇒ Object
rubocop:disable Metrics/MethodLength
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/hoboken/add_ons/turnip.rb', line 15
def add_sample_files
return unless rspec?
empty_directory('spec/features')
empty_directory('spec/support/steps')
create_file('spec/features/example.feature') do
<<~TEXT
@feature
Feature: An Example
This is an example feature spec that can be deleted.
Scenario: Name of some scenario
Given nothing
When I do nothing
Then nothing should happen
TEXT
end
create_file('spec/support/steps/example_steps.rb') do
<<~CODE
# frozen_string_literal: true
# Steps for the example feature that can be deleted.
step 'nothing' do
# ...
end
step 'I do nothing' do
# ...
end
step 'nothing should happen' do
# ...
end
CODE
end
end
|
#ci_task ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/hoboken/add_ons/turnip.rb', line 88
def ci_task
return unless rspec?
gsub_file('Rakefile', /task ci:.*/) do |match|
if match.include?('rubocop')
'task ci: %w[spec turnip rubocop]'
else
'task ci: %w[spec turnip]'
end
end
end
|
#default_rake_task ⇒ Object
82
83
84
85
86
|
# File 'lib/hoboken/add_ons/turnip.rb', line 82
def default_rake_task
return unless rspec?
gsub_file('Rakefile', /task default:.*/, 'task default: %w[spec turnip]')
end
|
#rake_task ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/hoboken/add_ons/turnip.rb', line 64
def rake_task
return unless rspec?
create_file('tasks/turnip.rake') do
<<~TEXT
# frozen_string_literal: true
require 'rspec/core/rake_task'
desc 'Run turnip acceptance tests'
RSpec::Core::RakeTask.new(:turnip) do |t|
t.pattern = './spec{,/*/**}/*.feature'
t.rspec_opts = ['-r turnip/rspec']
end
TEXT
end
end
|
#reminders ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/hoboken/add_ons/turnip.rb', line 100
def reminders
if rspec?
say "Gemfile updated... don't forget to 'bundle install'", :green
else
say 'Turnip requires RSpec to be setup', :red
end
end
|