ruby_raider 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bd92fae06515596d875be2a1c9d05b2335574839da3269de1c598d4287e9fd9
4
- data.tar.gz: 8cc4c5922b36406b33d5e5df4c897ab0ce3a0d3a7036395293e634eeccbb27a2
3
+ metadata.gz: c8de2c66fd076efbcd366c5a4aa6aee74d2aa0fb511ec3f1887e669d44aae0d6
4
+ data.tar.gz: 2f28902ccb937b3c590eebb404f69fb42cb303bcc187ff1020ea931951734556
5
5
  SHA512:
6
- metadata.gz: c521e8d445f0490f04349ede87a4fd56552dd13ac1261735792b82a5ab3c064202120fc1bd4fb64c18d05f7575d5dd5b94dde68d186c3cb7b27e54ceeb095390
7
- data.tar.gz: 2d4f842b0214f55d11a6711353dd059d21085ee636cd1d6c81bd2d143b2fcee92d236f27906f1a8caa3bbc9b44dcb9a6151c2dd29f7720228a873480f9922742
6
+ metadata.gz: a4e7fdf2921ed2f7e16ff1593b1879098c7c87584a194f5a0d132f30ac3f3a032d1377fd208f1ee3d876531902cb945909161db6bb10074b675efc3adc5ae7e5
7
+ data.tar.gz: 6cacf73aa4cec432e6ab9591f04f9616661c7922f17ca0a8c83f79278191f0320851bc436df56c93afc330969f5e9ce51c147ecacb36946951685cc207264739
data/.reek.yml CHANGED
@@ -7,3 +7,6 @@ detectors:
7
7
  exclude:
8
8
  - initialize
9
9
  max_statements: 10
10
+
11
+ exclude_paths:
12
+ - 'lib/commands/open_ai_commands.rb'
data/.rubocop.yml CHANGED
@@ -1,6 +1,10 @@
1
1
  require:
2
2
  - rubocop-rspec
3
3
 
4
+ AllCops:
5
+ Exclude:
6
+ - 'lib/commands/open_ai_commands.rb'
7
+
4
8
  # Layout
5
9
  Layout/CaseIndentation:
6
10
  Enabled: false
@@ -87,4 +91,4 @@ Style/SafeNavigation:
87
91
 
88
92
  Style/SingleLineBlockParams:
89
93
  Description: 'Enforces the names of some block params.'
90
- Enabled: false
94
+ Enabled: false
data/README.md CHANGED
@@ -88,7 +88,7 @@ Select the ones you will like to work with.
88
88
 
89
89
  ```ruby
90
90
  Commands:
91
- raider generate # Provides access to all the generators commands
91
+ raider generate # Provides access to all the scaffolding commands
92
92
  raider help [COMMAND] # Describe available commands or one specific command
93
93
  raider new [PROJECT_NAME] # Creates a new framework based on settings picked
94
94
  raider open_ai # Provides access to all the open ai commands
@@ -104,6 +104,29 @@ All the basic commands have their corresponding shortcut:
104
104
  * u for utility
105
105
  * v for version
106
106
 
107
+ ### Scaffolding Commands
108
+ Ruby Raider also supports scaffolding:
109
+
110
+ * To create a new page object you do: ```raider g page [PAGE_NAME]```
111
+ * To create a new spec you do: ```raider g spec [SPEC_NAME]```
112
+ * To create a new feature you do: ```raider g feature [FEATURE_NAME]```
113
+ * To create a new steps definition you do: ```raider g steps [STEPS_NAME]```
114
+ * To create both a page/spec or a page/feature/steps you do: ```raider g scaffold [SCAFFOLD_NAME]```
115
+
116
+ It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
117
+ specs.
118
+
119
+ If you want to set the default path for the creation of your features, helpers and specs:
120
+
121
+ ```ruby
122
+ raider u path [PATH_NAME] - -feature or -f
123
+ raider u path [PATH_NAME] - -spec or -s
124
+ raider u path [PATH_NAME] - -helper or -h
125
+ ```
126
+
127
+ If you don't specify an option, path will assume you want to change the default path for pages.
128
+
129
+
107
130
  ### Appium Server Command
108
131
  To initialise Appium server run this command:
109
132
  ```ruby
@@ -130,3 +153,7 @@ Options :
130
153
  -i, [--input = INPUT] # It uses a file as input to create the steps
131
154
 
132
155
  ```
156
+
157
+ ### Sponsors
158
+
159
+ This project is tested with BrowserStack.
@@ -1,5 +1,4 @@
1
1
  require 'thor'
2
- require 'faraday'
3
2
  require_relative '../open_ai/open_ai'
4
3
 
5
4
  class OpenAiCommands < Thor
@@ -59,27 +58,4 @@ class OpenAiCommands < Thor
59
58
  make(options[:open_ai], "#{path}/#{name}_steps.rb")
60
59
  end
61
60
  end
62
-
63
- desc 'test', 'Uses open AI to create a file or generate output'
64
- def test
65
- conn = Faraday.new(url: 'https://api.openai.com') do |faraday|
66
- faraday.headers['Content-Type'] = 'application/json'
67
- faraday.headers['Authorization'] = "Bearer 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"
68
- faraday.headers['OpenAI-Beta'] = 'assistants=v1'
69
- end
70
-
71
- # Data payload for the POST request
72
- payload = {
73
- instructions: "You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
74
- name: "Math Tutor",
75
- tools: [{ type: "code_interpreter" }],
76
- model: "gpt-4-1106-preview"
77
- }
78
-
79
- # Perform the POST request
80
- response = conn.post('/v1/assistants', payload.to_json)
81
-
82
- # Output the response body
83
- puts response.body
84
- end
85
61
  end
@@ -7,6 +7,7 @@ require_relative '../commands/utility_commands'
7
7
 
8
8
  # :reek:FeatureEnvy { enabled: false }
9
9
  # :reek:UtilityFunction { enabled: false }
10
+ # :reek:RepeatedConditional { enabled: false }
10
11
  class ScaffoldingCommands < Thor
11
12
  desc 'page [PAGE_NAME]', 'Creates a new page object'
12
13
  option :path,
@@ -15,7 +16,9 @@ class ScaffoldingCommands < Thor
15
16
  type: :boolean, required: false, desc: 'This will delete the selected page', aliases: '-d'
16
17
 
17
18
  def page(name)
18
- handle_scaffolding(name, 'page')
19
+ return delete_scaffolding(name, 'page') if options[:delete]
20
+
21
+ generate_scaffolding(name, 'page', options[:path])
19
22
  end
20
23
 
21
24
  desc 'feature [NAME]', 'Creates a new feature'
@@ -27,7 +30,9 @@ class ScaffoldingCommands < Thor
27
30
  required: false, desc: 'This will delete the selected feature', aliases: '-d'
28
31
 
29
32
  def feature(name)
30
- handle_scaffolding(name, 'feature')
33
+ return delete_scaffolding(name, 'feature') if options[:delete]
34
+
35
+ generate_scaffolding(name, 'feature', options[:path])
31
36
  end
32
37
 
33
38
  desc 'spec [SPEC_NAME]', 'Creates a new spec'
@@ -37,7 +42,9 @@ class ScaffoldingCommands < Thor
37
42
  type: :boolean, required: false, desc: 'This will delete the selected spec', aliases: '-d'
38
43
 
39
44
  def spec(name)
40
- handle_scaffolding(name, 'spec')
45
+ return delete_scaffolding(name, 'spec') if options[:delete]
46
+
47
+ generate_scaffolding(name, 'spec', options[:path])
41
48
  end
42
49
 
43
50
  desc 'helper [HELPER_NAME]', 'Creates a new helper'
@@ -47,7 +54,21 @@ class ScaffoldingCommands < Thor
47
54
  type: :boolean, required: false, desc: 'This will delete the selected helper', aliases: '-d'
48
55
 
49
56
  def helper(name)
50
- handle_scaffolding(name, 'helper')
57
+ return delete_scaffolding(name, 'helper') if options[:delete]
58
+
59
+ generate_scaffolding(name, 'helper', options[:path])
60
+ end
61
+
62
+ desc 'steps [STEPS_NAME]', 'Creates a new steps definition'
63
+ option :path,
64
+ type: :string, required: false, desc: 'The path where your steps will be created', aliases: '-p'
65
+ option :delete,
66
+ type: :boolean, required: false, desc: 'This will delete the selected steps', aliases: '-d'
67
+
68
+ def steps(name)
69
+ return delete_scaffolding(name, 'steps') if options[:delete]
70
+
71
+ generate_scaffolding(name, 'steps', options[:path])
51
72
  end
52
73
 
53
74
  desc 'scaffold [SCAFFOLD_NAME]', 'It generates everything needed to start automating'
@@ -57,46 +78,23 @@ class ScaffoldingCommands < Thor
57
78
  Scaffolding.new([name, load_config_path('spec')]).generate_spec
58
79
  else
59
80
  Scaffolding.new([name, load_config_path('feature')]).generate_feature
81
+ Scaffolding.new([name, load_config_path('steps')]).generate_steps
60
82
  end
61
- Scaffolding.new([name, load_config_path('page')]).generate_class
83
+ Scaffolding.new([name, load_config_path('page')]).generate_page
62
84
  end
63
85
 
64
- desc 'config', 'Creates configuration file'
65
- option :delete,
66
- type: :boolean, required: false, desc: 'This will delete the config file', aliases: '-d'
67
-
68
86
  no_commands do
69
87
  def load_config_path(type)
70
88
  YAML.load_file('config/config.yml')["#{type}_path"] if Pathname.new('config/config.yml').exist?
71
89
  end
72
90
 
73
- def handle_scaffolding(name, type)
74
- path = options[:path] || load_config_path(type)
75
- scaffolding = Scaffolding.new([name, path])
76
-
77
- if options[:delete]
78
- case type
79
- when 'page'
80
- scaffolding.delete_class
81
- when 'feature'
82
- scaffolding.delete_feature
83
- when 'spec'
84
- scaffolding.delete_spec
85
- when 'helper'
86
- scaffolding.delete_helper
87
- end
88
- else
89
- case type
90
- when 'page'
91
- scaffolding.generate_class
92
- when 'feature'
93
- scaffolding.generate_feature
94
- when 'spec'
95
- scaffolding.generate_spec
96
- when 'helper'
97
- scaffolding.generate_helper
98
- end
99
- end
91
+ def delete_scaffolding(name, type)
92
+ Scaffolding.new([name]).send("delete_#{type}")
93
+ end
94
+
95
+ def generate_scaffolding(name, type, path)
96
+ path ||= load_config_path(type)
97
+ Scaffolding.new([name, path]).send("generate_#{type}")
100
98
  end
101
99
  end
102
100
  end
@@ -4,6 +4,13 @@
4
4
  def initialize(browser)
5
5
  @browser = browser
6
6
  end
7
+ <% elsif axe? %>
8
+ attr_reader :driver
9
+ alias page driver
10
+
11
+ def initialize(driver)
12
+ @driver = driver
13
+ end
7
14
  <% else %>
8
15
  attr_reader :driver
9
16
 
@@ -14,6 +14,7 @@ class Login < Page
14
14
  password_field.send_keys password
15
15
  login_button.click
16
16
  end
17
+ alias log_as login
17
18
 
18
19
  private
19
20
 
@@ -9,6 +9,7 @@ class Generator < Thor::Group
9
9
  argument :framework
10
10
  argument :name
11
11
  argument :visual_automation, optional: true
12
+ argument :axe_support, optional: true
12
13
 
13
14
  def self.source_paths
14
15
  base_path = File.dirname(__FILE__)
@@ -46,7 +47,7 @@ class Generator < Thor::Group
46
47
  end
47
48
 
48
49
  def visual?
49
- initializer.first.last
50
+ args[3]
50
51
  end
51
52
 
52
53
  def watir?
@@ -57,6 +58,10 @@ class Generator < Thor::Group
57
58
  (args & (%w[selenium watir])).count.positive?
58
59
  end
59
60
 
61
+ def axe?
62
+ args.last
63
+ end
64
+
60
65
  private
61
66
 
62
67
  def _initializer
@@ -18,7 +18,8 @@ module InvokeGenerators
18
18
  framework: framework,
19
19
  generator: generator,
20
20
  name: structure[:name],
21
- visual: structure[:visual]
21
+ visual: structure[:visual],
22
+ axe_support: structure[:axe_support]
22
23
  })
23
24
  end
24
25
  end
@@ -32,6 +33,7 @@ module InvokeGenerators
32
33
  .new([structure[:automation],
33
34
  structure[:framework],
34
35
  structure[:name],
35
- structure[:visual]]).invoke_all
36
+ structure[:visual],
37
+ structure[:axe_support]]).invoke_all
36
38
  end
37
39
  end
@@ -22,7 +22,11 @@ class MenuGenerator
22
22
  end
23
23
 
24
24
  def choose_visual_automation
25
- prompt.select('Do you want to add visual automation with applitools?', visual_automation_menu_choices)
25
+ prompt.select('Do you want to add visual automation with Applitools?', yes_no_menu_choices)
26
+ end
27
+
28
+ def choose_axe_support
29
+ prompt.select('Do you want to add Axe accessibility testing tool?', yes_no_menu_choices)
26
30
  end
27
31
 
28
32
  def choose_test_framework(automation)
@@ -37,7 +41,8 @@ class MenuGenerator
37
41
  automation: options[:automation],
38
42
  framework: options[:framework],
39
43
  name: @name,
40
- visual: options[:visual_automation]
44
+ visual: options[:visual_automation],
45
+ axe_support: options[:axe_support]
41
46
  }
42
47
  generate_framework(structure)
43
48
  system "cd #{name} && gem install bundler && bundle install"
@@ -69,22 +74,32 @@ class MenuGenerator
69
74
  end
70
75
  end
71
76
 
72
- FrameworkOptions = Struct.new(:automation, :framework, :visual_automation)
77
+ FrameworkOptions = Struct.new(:automation, :framework, :visual_automation, :axe_support)
73
78
 
74
79
  def create_framework_options(params)
75
- FrameworkOptions.new(params[:automation], params[:framework], params[:visual_automation])
80
+ FrameworkOptions.new(params[:automation], params[:framework], params[:visual_automation], params[:axe_support])
76
81
  end
77
82
 
78
83
  def create_framework(framework, automation_type)
79
84
  visual_automation = choose_visual_automation if %w[selenium].include?(automation_type)
85
+ axe = choose_axe_support if automation_type == 'selenium' && framework == 'Rspec' && visual_automation == false
80
86
  options = create_framework_options(automation: automation_type,
81
87
  framework: framework.downcase,
82
- visual_automation: visual_automation)
88
+ visual_automation: visual_automation,
89
+ axe_support: axe)
90
+
91
+ # Print the chosen options
92
+ puts 'Chosen Options:'
93
+ puts " Automation Type: #{options[:automation]}"
94
+ puts " Framework: #{options[:framework]}"
95
+ puts " Visual Automation: #{options[:visual_automation]}"
96
+ puts " Axe Support: #{options[:axe_support]}"
97
+
83
98
  set_up_framework(options)
84
99
  prompt.say("You have chosen to use #{framework} with #{automation_type}")
85
100
  end
86
101
 
87
- def visual_automation_menu_choices
102
+ def yes_no_menu_choices
88
103
  {
89
104
  Yes: -> { true },
90
105
  No: -> { false },
@@ -14,4 +14,10 @@ class RspecGenerator < Generator
14
14
 
15
15
  template('spec.tt', "#{name}/spec/pdp_page_spec.rb")
16
16
  end
17
+
18
+ def generate_account_spec
19
+ return unless visual?
20
+
21
+ template('spec.tt', "#{name}/spec/account_page_spec.rb")
22
+ end
17
23
  end
@@ -6,6 +6,34 @@ require_relative '../models/model_factory'
6
6
  require_relative '../page_objects/pages/account'
7
7
  require_relative '../page_objects/pages/login'
8
8
 
9
+ <%- if axe? %>
10
+ describe 'Login' do
11
+ let(:login) { Login.new(driver) }
12
+ let(:account) { Account.new(driver) }
13
+ let(:user) { ModelFactory.for('users')['registered user'] }
14
+
15
+ before do
16
+ login.visit
17
+ login.log_as(user['username'], user['password'])
18
+ end
19
+
20
+ context 'with a login user on the account page' do
21
+ it 'no accessibility errors are present on the page' do
22
+ expect(account.page).to be_axe_clean
23
+ end
24
+
25
+ it 'no accessibility errors are present on the transaction history' do
26
+ transaction_history = '.dash-tile.dash-tile-balloon.clearfix'
27
+ expect(account.page).to be_axe_clean.within transaction_history
28
+ end
29
+
30
+ it 'no accessibility errors are present on the heading' do
31
+ heading = '.maintext'
32
+ expect(account.page).to be_axe_clean.within heading
33
+ end
34
+ end
35
+ end
36
+ <%- elsif %w[selenium watir].include? automation -%>
9
37
  describe 'Login' do
10
38
  subject(:header) { account_page.header.customer_name }
11
39
 
@@ -42,6 +70,7 @@ describe 'Login' do
42
70
  end
43
71
  end
44
72
  end
73
+ <%- end -%>
45
74
  <%- elsif automation == 'sparkling_ios' -%>
46
75
  require_relative '../helpers/spec_helper'
47
76
  require_relative '../page_objects/pages/home'
@@ -7,6 +7,10 @@ gem 'allure-cucumber'
7
7
  gem 'allure-rspec'
8
8
  gem 'allure-ruby-commons'
9
9
  <% end -%>
10
+ <% if axe? -%>
11
+ gem 'axe-core-rspec'
12
+ gem 'axe-core-selenium'
13
+ <% end -%>
10
14
  <% if visual_automation -%>
11
15
  gem 'eyes_selenium', '~> 4.6', '>= 4.6.1'
12
16
  gem 'eyes_universal', '~> 3.3', '>= 3.3.1'
@@ -1,8 +1,4 @@
1
- require 'yaml'
2
-
3
- desc 'Selects browser for automation run'
4
- task :select_browser, [:browser] do |_t, args|
5
- config = YAML.load_file('config/config.yml')
6
- config['browser'] = args.browser
7
- File.write('config/config.yml', config.to_yaml)
8
- end
1
+ desc 'Print Ruby Raider version'
2
+ task :raider do
3
+ system 'raider version'
4
+ end
@@ -39,7 +39,7 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
39
39
  | Rspec and Watir | | Rspec and Appium for Android |
40
40
  | | | Cucumber and Appium Cross-platform |
41
41
  | | | Rspec and Appium Cross-platform |
42
- | | | Cucumber and Sparkling Watir for IOS |
42
+ | | | Cucumber and Sparkling Watir for IOS |
43
43
  | | | Rspec and Sparkling Watir for IOS |
44
44
 
45
45
 
@@ -86,7 +86,7 @@ Select the ones you will like to work with.
86
86
 
87
87
  ```ruby
88
88
  Commands:
89
- raider generate # Provides access to all the generators commands
89
+ raider generate # Provides access to all the scaffolding commands
90
90
  raider help [COMMAND] # Describe available commands or one specific command
91
91
  raider new [PROJECT_NAME] # Creates a new framework based on settings picked
92
92
  raider open_ai # Provides access to all the open ai commands
@@ -102,6 +102,28 @@ All the basic commands have their corresponding shortcut:
102
102
  * u for utility
103
103
  * v for version
104
104
 
105
+ ### Scaffolding Commands
106
+ Ruby Raider also supports scaffolding:
107
+
108
+ * To create a new page object you do: ```raider g page [PAGE_NAME]```
109
+ * To create a new spec you do: ```raider g spec [SPEC_NAME]```
110
+ * To create a new feature you do: ```raider g feature [FEATURE_NAME]```
111
+ * To create a new steps definition you do: ```raider g steps [STEPS_NAME]```
112
+ * To create both a page/spec or a page/feature/steps you do: ```raider g scaffold [SCAFFOLD_NAME]```
113
+
114
+ It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
115
+ specs.
116
+
117
+ If you want to set the default path for the creation of your features, helpers and specs:
118
+
119
+ ```ruby
120
+ raider u path [PATH_NAME] - -feature or -f
121
+ raider u path [PATH_NAME] - -spec or -s
122
+ raider u path [PATH_NAME] - -helper or -h
123
+ ```
124
+
125
+ If you don't specify an option, path will assume you want to change the default path for pages.
126
+
105
127
 
106
128
  ### Appium Server Command
107
129
  To initialise Appium server run this command:
@@ -128,4 +150,4 @@ Options :
128
150
  -pr, [--prompt = PROMPT] # This will create the selected steps based on your prompt using open ai
129
151
  -i, [--input = INPUT] # It uses a file as input to create the steps
130
152
 
131
- ```
153
+ ```
@@ -21,6 +21,9 @@ module DriverHelper
21
21
  end
22
22
  <%- else -%>
23
23
  # frozen_string_literal: true
24
+ <% if axe? -%>
25
+ require 'axe-selenium'
26
+ <% end -%>
24
27
  require 'yaml'
25
28
  <% if automation == 'selenium' -%>
26
29
  require 'active_support/inflector'
@@ -30,10 +33,14 @@ require 'appium_lib'
30
33
  <% end -%>
31
34
 
32
35
  module DriverHelper
33
- <% if automation == 'selenium' -%>
36
+ <% if automation == 'selenium' && axe? == false -%>
34
37
  def driver(*opts)
35
38
  @driver ||= create_driver(*opts)
36
39
  end
40
+ <% elsif axe? == true -%>
41
+ def driver(browser = :chrome, js_path = nil, skip_iframes = nil)
42
+ @driver ||= create_driver(browser, js_path, skip_iframes)
43
+ end
37
44
  <% else -%>
38
45
  def driver
39
46
  @driver ||= create_driver
@@ -1,4 +1,11 @@
1
- <% if automation == 'selenium' -%>
1
+ <% if automation == 'selenium' && axe? == true -%>
2
+ def create_driver(browser, js_path, skip_iframes)
3
+ AxeSelenium.configure(browser) do |config|
4
+ config.jslib_path = js_path if js_path
5
+ config.skip_iframes = skip_iframes if skip_iframes
6
+ end.page
7
+ end
8
+ <% elsif automation == 'selenium' -%>
2
9
  def create_driver(*opts)
3
10
  @config = YAML.load_file('config/config.yml')
4
11
  browser = @config['browser'].to_sym
@@ -22,7 +29,6 @@
22
29
  driver_options.each { |opt| options.add_option(opt.first, opt.last) }
23
30
  options
24
31
  end
25
-
26
32
  <% elsif automation == 'cross_platform' -%>
27
33
  def create_driver
28
34
  platform = config['platform'].to_s
@@ -30,6 +30,9 @@ end
30
30
  <%- else -%>
31
31
  # frozen_string_literal: true
32
32
 
33
+ <%- if axe? %>
34
+ require 'axe-rspec'
35
+ <%- end -%>
33
36
  require 'rspec'
34
37
  require 'tmpdir'
35
38
  require_relative 'allure_helper'
@@ -14,12 +14,12 @@ module OpenAi
14
14
 
15
15
  def configure_client
16
16
  OpenAI.configure do |config|
17
- config.access_token = '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'
17
+ config.access_token = ENV.fetch('OPENAI_ACCESS_TOKEN')
18
18
  config.organization_id = ENV.fetch('OPENAI_ORGANIZATION_ID', nil)
19
19
  end
20
20
  end
21
21
 
22
- def input(request, model = 'gpt-4', temperature = 0.7)
22
+ def input(request, model = 'gpt-3.5-turbo', temperature = 0.7)
23
23
  client.chat(
24
24
  parameters: {
25
25
  model: model,
data/lib/ruby_raider.rb CHANGED
@@ -19,12 +19,12 @@ module RubyRaider
19
19
  desc 'version', 'It shows the version of Ruby Raider you are currently using'
20
20
 
21
21
  def version
22
- puts "The version is #{parsed_version}, happy testing!"
22
+ puts "The version is #{current_version}, happy testing!"
23
23
  end
24
24
 
25
25
  map 'v' => 'version'
26
26
 
27
- desc 'generate', 'Provides access to all the generator commands'
27
+ desc 'generate', 'Provides access to all the scaffolding commands'
28
28
  subcommand 'generate', ScaffoldingCommands
29
29
  map 'g' => 'generate'
30
30
 
@@ -37,8 +37,7 @@ module RubyRaider
37
37
  map 'u' => 'utility'
38
38
 
39
39
  no_commands do
40
- def gemspec = Gem::Specification.load('ruby_raider.gemspec')
41
- def parsed_version = Gem::Version.new(gemspec.version)
40
+ def current_version = File.read(File.expand_path('version', __dir__)).strip
42
41
  end
43
42
  end
44
43
  end
@@ -12,8 +12,8 @@ class Scaffolding < Thor::Group
12
12
  "#{File.dirname(__FILE__)}/templates"
13
13
  end
14
14
 
15
- def generate_class
16
- template('page_object.tt', default_path("page_objects/pages/#{name}_page.rb", '_page.rb'))
15
+ def generate_page
16
+ template('page_object.tt', default_path("page_objects/pages/#{name}.rb", '_page.rb'))
17
17
  end
18
18
 
19
19
  def generate_feature
@@ -21,20 +21,24 @@ class Scaffolding < Thor::Group
21
21
  end
22
22
 
23
23
  def generate_spec
24
- template('spec.tt', default_path("spec/#{name}_spec.rb", '_spec.rb'))
24
+ template('spec.tt', default_path("spec/#{name}_page_spec.rb", '_spec.rb'))
25
25
  end
26
26
 
27
27
  def generate_helper
28
28
  template('helper.tt', default_path("helpers/#{name}_helper.rb", '_helper.rb'))
29
29
  end
30
30
 
31
+ def generate_steps
32
+ template('steps.tt', default_path("features/step_definitions/#{name}_steps.rb", '_steps.rb'))
33
+ end
34
+
31
35
  def generate_config
32
36
  template('../../generators/templates/common/config.tt',
33
37
  default_path('config/config.yml', '.yml'))
34
38
  end
35
39
 
36
- def delete_class
37
- remove_file(default_path("page_objects/pages/#{name}_page.rb", '_page.rb'))
40
+ def delete_page
41
+ remove_file(default_path("page_objects/pages/#{name}.rb", '_page.rb'))
38
42
  end
39
43
 
40
44
  def delete_feature
@@ -42,13 +46,17 @@ class Scaffolding < Thor::Group
42
46
  end
43
47
 
44
48
  def delete_spec
45
- remove_file(default_path("spec/#{name}_spec.rb", '_spec.rb'))
49
+ remove_file(default_path("spec/#{name}_page_spec.rb", '_spec.rb'))
46
50
  end
47
51
 
48
52
  def delete_helper
49
53
  remove_file(default_path("helpers/#{name}_helper.rb", '_helper.rb'))
50
54
  end
51
55
 
56
+ def delete_steps
57
+ remove_file(default_path("features/step_definitions/#{name}_steps.rb", '_steps.rb'))
58
+ end
59
+
52
60
  def delete_config
53
61
  remove_file(default_path('config/config.yml', '.yml'))
54
62
  end
@@ -1,4 +1,4 @@
1
- Feature: <%= name %>
1
+ Feature: <%= name.capitalize %>
2
2
 
3
3
  Scenario: Scenario name
4
4
  Given I am
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../abstract/abstract_page'
3
+ require_relative '../abstract/page'
4
4
 
5
- class <%= name.split('_').map {|word| word.capitalize }.join + 'Page' %> < AbstractPage
5
+ class <%= name.split('_').map {|word| word.capitalize }.join %> < Page
6
6
 
7
7
  # Actions
8
8
 
@@ -1,5 +1,4 @@
1
- require_relative 'base_spec'
2
- require_relative '../page_objects/pages/<%= name %>_page'
1
+ require_relative '../page_objects/pages/<%= name %>'
3
2
 
4
- describe <%= name.split('_').map {|word| word.capitalize }.join + 'Page' %> do
3
+ describe '<%= name.split('_').map {|word| word.capitalize }.join %>' do
5
4
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../page_objects/pages/<%= name %>'
4
+
5
+ Given ('') do
6
+ end
7
+
8
+ When ('') do
9
+ end
10
+
11
+ Then ('') do
12
+ end
data/lib/version ADDED
@@ -0,0 +1 @@
1
+ 0.8.7
data/ruby_raider.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ruby_raider'
5
- s.version = '0.8.6'
5
+ s.version = File.read(File.expand_path('lib/version', __dir__)).strip
6
6
  s.summary = 'A gem to make setup and start of UI automation projects easier'
7
7
  s.description = 'This gem has everything you need to start working with test automation'
8
8
  s.authors = ['Agustin Pequeno']
@@ -27,12 +27,12 @@ describe ScaffoldingCommands do
27
27
 
28
28
  it 'scaffolds for rspec creating a spec' do
29
29
  scaffold.new.invoke(:scaffold, nil, %W[#{name}])
30
- expect(Pathname.new("spec/#{name}_spec.rb")).to be_file
30
+ expect(Pathname.new("spec/#{name}_page_spec.rb")).to be_file
31
31
  end
32
32
 
33
33
  it 'scaffolds for rspec creating a page' do
34
34
  scaffold.new.invoke(:scaffold, nil, %W[#{name}])
35
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
35
+ expect(Pathname.new("page_objects/pages/#{name}.rb")).to be_file
36
36
  end
37
37
 
38
38
  it 'deletes a spec' do
@@ -47,7 +47,7 @@ describe ScaffoldingCommands do
47
47
 
48
48
  it 'creates a page' do
49
49
  scaffold.new.invoke(:page, nil, %W[#{name}])
50
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
50
+ expect(Pathname.new("page_objects/pages/#{name}.rb")).to be_file
51
51
  end
52
52
 
53
53
  it 'creates a page with a path' do
@@ -77,7 +77,12 @@ describe ScaffoldingCommands do
77
77
 
78
78
  it 'scaffolds for cucumber creating a page' do
79
79
  scaffold.new.invoke(:scaffold, nil, %W[#{name}])
80
- expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
80
+ expect(Pathname.new("page_objects/pages/#{name}.rb")).to be_file
81
+ end
82
+
83
+ it 'scaffolds for cucumber creating a steps definition' do
84
+ scaffold.new.invoke(:scaffold, nil, %W[#{name}])
85
+ expect(Pathname.new("features/step_definitions/#{name}_steps.rb")).to be_file
81
86
  end
82
87
 
83
88
  it 'creates a helper' do
@@ -85,6 +90,11 @@ describe ScaffoldingCommands do
85
90
  expect(Pathname.new("helpers/#{name}_helper.rb")).to be_file
86
91
  end
87
92
 
93
+ it 'creates a steps definition' do
94
+ scaffold.new.invoke(:steps, nil, %W[#{name}])
95
+ expect(Pathname.new("features/step_definitions/#{name}_steps.rb")).to be_file
96
+ end
97
+
88
98
  it 'deletes a page' do
89
99
  scaffold.new.invoke(:page, nil, %w[login --delete])
90
100
  expect(Pathname.new('page_objects/pages/login_page.rb')).not_to be_file
data/spec/spec_helper.rb CHANGED
@@ -15,7 +15,7 @@ RSpec.configure do |config|
15
15
  FRAMEWORKS.each do |framework|
16
16
  AUTOMATION_TYPES.each do |automation|
17
17
  [true, false].each do |visual|
18
- settings = create_settings(framework: framework, automation: automation, visual: visual)
18
+ settings = create_settings(framework: framework, automation: automation, visual: visual, axe: axe_support)
19
19
  generate_framework(settings)
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_raider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustin Pequeno
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-26 00:00:00.000000000 Z
11
+ date: 2024-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -269,8 +269,10 @@ files:
269
269
  - lib/scaffolding/templates/helper.tt
270
270
  - lib/scaffolding/templates/page_object.tt
271
271
  - lib/scaffolding/templates/spec.tt
272
+ - lib/scaffolding/templates/steps.tt
272
273
  - lib/utilities/logger.rb
273
274
  - lib/utilities/utilities.rb
275
+ - lib/version
274
276
  - ruby_raider.gemspec
275
277
  - spec/integration/commands/open_ai_commands_spec.rb
276
278
  - spec/integration/commands/scaffolding_commands_spec.rb
@@ -303,7 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
305
  - !ruby/object:Gem::Version
304
306
  version: '0'
305
307
  requirements: []
306
- rubygems_version: 3.4.10
308
+ rubygems_version: 3.5.5
307
309
  signing_key:
308
310
  specification_version: 4
309
311
  summary: A gem to make setup and start of UI automation projects easier