ruby_raider 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/CONTRIBUTING.md +5 -0
- data/README.md +51 -37
- data/Rakefile +10 -0
- data/bin/raider +1 -1
- data/lib/commands/open_ai_commands.rb +59 -0
- data/lib/commands/scaffolding_commands.rb +7 -32
- data/lib/commands/utility_commands.rb +12 -50
- data/lib/generators/templates/common/read_me.tt +50 -36
- data/lib/open_ai/open_ai.rb +61 -0
- data/lib/ruby_raider.rb +31 -2
- data/lib/utilities/utilities.rb +82 -75
- data/ruby_raider.gemspec +3 -1
- data/spec/open_ai_commands_spec.rb +36 -0
- data/spec/scaffolding_commands_spec.rb +1 -55
- data/spec/utility_commands_spec.rb +94 -0
- metadata +34 -3
- data/lib/utilities/open_ai.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73b511158597de3220db924f54274e1927bfc868354a14de1f1258fc9c5cbfe3
|
4
|
+
data.tar.gz: f767e96bbf74bcd1445c7df25015e4c3be0023665b563eb2d2c0ba52dfb0f2d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d4b944d4d72e9fd3c2be66740a2b19d0c4db088161a10055a538c90c629a6383f670965ea8b99b7f50cd6ea8dfdd52477d9a093a772cb1cd81b6d6cbe5c542b
|
7
|
+
data.tar.gz: 9b3c33fd07290c620dae1624518b94e0f82fd2e5a204e8b930fd1939d1085ce002904a31ccfee55b24197207ae5efb71e5a1f92c22c02b1f9ae9e0c83db165be
|
data/.gitignore
CHANGED
data/CONTRIBUTING.md
CHANGED
data/README.md
CHANGED
@@ -58,7 +58,12 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
|
|
58
58
|
|
59
59
|
***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
|
60
60
|
|
61
|
-
***In order to run the visual tests with applitools, you need to create an account and get your api key, you can read
|
61
|
+
***In order to run the visual tests with applitools, you need to create an account and get your api key, you can read
|
62
|
+
more [here](https://applitools.com/docs/topics/overview/obtain-api-key.html#:~:text=If%20you%20already%20have%20an,Your%20key%20will%20be%20displayed.)
|
63
|
+
.***
|
64
|
+
|
65
|
+
***To use the open ai integration you need to set up the OPENAI_ACCESS_TOKEN environment variable and
|
66
|
+
you can also set the optional OPENAI_ORGANIZATION_ID if you have an organization***
|
62
67
|
|
63
68
|
This works in all the platforms (Tested on Mac OS, Linux and Windows).
|
64
69
|
|
@@ -78,50 +83,38 @@ gem install ruby_raider
|
|
78
83
|
raider new [name_of_project]
|
79
84
|
```
|
80
85
|
|
81
|
-
Then a TUI/CLI will appear where the configuration of which frameworks you want to be generated/scaffolded can be
|
86
|
+
Then a TUI/CLI will appear where the configuration of which frameworks you want to be generated/scaffolded can be
|
87
|
+
selected.
|
82
88
|
|
83
89
|
Select the ones you will like to work with.
|
84
90
|
|
85
|
-
### Ruby raider provides the following list of commands
|
91
|
+
### Ruby raider provides the following list of basic commands
|
86
92
|
|
87
93
|
###### Anything between square brackets([...]) is where your imput goes
|
88
94
|
|
89
95
|
```ruby
|
90
|
-
Commands:
|
91
|
-
raider
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
raider help [COMMAND] # Describes available commands or one specific command
|
98
|
-
|
99
|
-
raider helper [HELPER_NAME] # Creates a new helper
|
100
|
-
|
101
|
-
raider new [PROJECT_NAME] # Creates a new framework based on settings picked
|
102
|
-
|
103
|
-
raider page [PAGE_NAME] # Creates a new page object
|
104
|
-
|
105
|
-
raider path [PATH] # Sets the default path for scaffolding
|
106
|
-
|
107
|
-
raider platform [PLATFORM] # Sets the default platform for a cross-platform project
|
108
|
-
|
109
|
-
raider raid # Runs all the tests in a project
|
110
|
-
|
111
|
-
raider scaffold [SCAFFOLD_NAME] # Generates everything needed to start automating
|
112
|
-
|
113
|
-
raider spec [SPEC_NAME] # Creates a new spec
|
114
|
-
|
115
|
-
raider url [URL] # Sets the default url for a project
|
116
|
-
|
117
|
-
raider version # It shows the version of Ruby Raider you are currently using
|
96
|
+
Commands :
|
97
|
+
raider generate # Provides access to all the generators commands
|
98
|
+
raider help [COMMAND] # Describe available commands or one specific command
|
99
|
+
raider new [PROJECT_NAME] # Creates a new framework based on settings picked
|
100
|
+
raider open_ai # Provides access to all the open ai commands
|
101
|
+
raider utility # Provides access to all the utility commands
|
102
|
+
raider version # It shows the version of Ruby Raider you are currently using
|
118
103
|
```
|
119
104
|
|
105
|
+
All the basic commands have their corresponding shortcut:
|
106
|
+
|
107
|
+
* g for generate
|
108
|
+
* n for new
|
109
|
+
* o for open_ai
|
110
|
+
* u for utility
|
111
|
+
* v for version
|
112
|
+
|
120
113
|
Ruby raider also supports scaffolding:
|
121
114
|
|
122
|
-
* To create a new page object you do: ```raider page [PAGE_NAME]```
|
123
|
-
* To create a new spec you do: ```raider spec [SPEC_NAME]```
|
124
|
-
* To create a new feature you do: ```raider feature [FEATURE_NAME]```
|
115
|
+
* To create a new page object you do: ```raider g page [PAGE_NAME]```
|
116
|
+
* To create a new spec you do: ```raider g spec [SPEC_NAME]```
|
117
|
+
* To create a new feature you do: ```raider g feature [FEATURE_NAME]```
|
125
118
|
|
126
119
|
It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
|
127
120
|
specs.
|
@@ -129,9 +122,30 @@ specs.
|
|
129
122
|
If you want to set the default path for the creation of your features, helpers and specs:
|
130
123
|
|
131
124
|
```ruby
|
132
|
-
raider path [PATH_NAME]
|
133
|
-
raider path [PATH_NAME]
|
134
|
-
raider path [PATH_NAME]
|
125
|
+
raider u path [PATH_NAME] - -feature or -f
|
126
|
+
raider u path [PATH_NAME] - -spec or -s
|
127
|
+
raider u path [PATH_NAME] - -helper or -h
|
135
128
|
```
|
136
129
|
|
137
130
|
If you don't specify an option, path will assume you want to change the default path for pages.
|
131
|
+
|
132
|
+
### Open AI Commands
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
# Will print the result of the request on the terminal
|
136
|
+
raider o make [REQUEST]
|
137
|
+
# Will create a file with the result of your request as content
|
138
|
+
raider o make [REQUEST] - -path or -p [PATH]
|
139
|
+
# Will input the content of the chosen file into open ai and will edit it based on the result
|
140
|
+
raider o make [PATH_NAME] - -edit or -e [FILE_PATH]
|
141
|
+
# Creates a cucumber file and uses it to input into open ai and create a steps file
|
142
|
+
# The prompt is not required because it uses a based prompt
|
143
|
+
raider o cucumber [NAME] - -prompt or -p [PROMPT]
|
144
|
+
# Creates a cucumber step definitions file based on an scenario file
|
145
|
+
raider open_ai steps [NAME]
|
146
|
+
Options :
|
147
|
+
-p, [--path = PATH] # The path where your steps will be created
|
148
|
+
-pr, [--prompt = PROMPT] # This will create the selected steps based on your prompt using open ai
|
149
|
+
-i, [--input = INPUT] # It uses a file as input to create the steps
|
150
|
+
|
151
|
+
```
|
data/Rakefile
CHANGED
@@ -17,3 +17,13 @@ desc 'Sets a browser'
|
|
17
17
|
task :browser, [:type, :options] do |_t, args|
|
18
18
|
ScaffoldingCommands.new.invoke(:browser, nil, %W[:#{args.type} --opts #{args.options}])
|
19
19
|
end
|
20
|
+
|
21
|
+
desc 'Updates a path'
|
22
|
+
task :path, [:path] do |_t, args|
|
23
|
+
ScaffoldingCommands.new.invoke(:path, nil, %W[#{args.path} -s])
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Download mobile builds'
|
27
|
+
task :builds, [:type] do |_t, args|
|
28
|
+
ScaffoldingCommands.new.invoke(:download_builds, nil, %W[#{args.type}])
|
29
|
+
end
|
data/bin/raider
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative '../open_ai/open_ai'
|
3
|
+
|
4
|
+
class OpenAiCommands < Thor
|
5
|
+
desc 'open_ai [REQUEST]', 'Uses open AI to create a file or generate output'
|
6
|
+
option :path,
|
7
|
+
type: :string, required: false, desc: 'The path where your file will be created', aliases: '-p'
|
8
|
+
option :edit,
|
9
|
+
type: :string, required: false, desc: 'Path to the file you want to edit', aliases: '-e'
|
10
|
+
|
11
|
+
def make(request, path = nil)
|
12
|
+
path ||= options[:path]
|
13
|
+
if options[:edit]
|
14
|
+
pp 'Editing File...'
|
15
|
+
OpenAi.edit_file(options[:edit], request)
|
16
|
+
pp "File #{options[:edit]} edited"
|
17
|
+
elsif path
|
18
|
+
pp 'Generating File...'
|
19
|
+
OpenAi.create_file(path, request)
|
20
|
+
pp "File created in #{path}"
|
21
|
+
else
|
22
|
+
puts OpenAi.output(request)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'cucumber [NAME]', 'Creates feature and step files only using open ai'
|
27
|
+
option :prompt,
|
28
|
+
type: :string,
|
29
|
+
required: false, desc: 'The prompt for open ai', aliases: '-p'
|
30
|
+
|
31
|
+
def cucumber(name)
|
32
|
+
feature_path = "features/#{name}.feature"
|
33
|
+
make(options[:prompt], feature_path)
|
34
|
+
prompt_step = "create cucumber steps for the following scenarios in ruby #{File.read(feature_path)}"
|
35
|
+
make(prompt_step, "features/step_definitions/#{name}_steps.rb")
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'steps [NAME]', 'Creates a new step definitions file'
|
39
|
+
option :path,
|
40
|
+
type: :string,
|
41
|
+
required: false, desc: 'The path where your steps will be created', aliases: '-p'
|
42
|
+
option :prompt,
|
43
|
+
type: :string, required: false,
|
44
|
+
desc: 'This will create the selected steps based on your prompt using open ai', aliases: '-pr'
|
45
|
+
option :input,
|
46
|
+
type: :string,
|
47
|
+
required: false, desc: 'It uses a file as input to create the steps', aliases: '-i'
|
48
|
+
|
49
|
+
def steps(name)
|
50
|
+
path = 'features/step_definitions'
|
51
|
+
if options[:input]
|
52
|
+
prompt = options[:prompt] || 'create cucumber steps for the following scenarios in ruby'
|
53
|
+
content = "#{prompt} #{File.read(options[:input])}"
|
54
|
+
make(content, "#{path}/#{name}_steps.rb")
|
55
|
+
else
|
56
|
+
make(options[:open_ai], "#{path}/#{name}_steps.rb")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,18 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'thor'
|
3
4
|
require_relative '../generators/menu_generator'
|
4
5
|
require_relative '../scaffolding/scaffolding'
|
5
6
|
require_relative '../commands/utility_commands'
|
6
7
|
|
7
|
-
class ScaffoldingCommands <
|
8
|
-
desc 'new [PROJECT_NAME]', 'Creates a new framework based on settings picked'
|
9
|
-
|
10
|
-
def new(project_name)
|
11
|
-
MenuGenerator.new(project_name).generate_choice_menu
|
12
|
-
end
|
13
|
-
|
14
|
-
map '-n' => 'new'
|
15
|
-
|
8
|
+
class ScaffoldingCommands < Thor
|
16
9
|
desc 'page [PAGE_NAME]', 'Creates a new page object'
|
17
10
|
option :path,
|
18
11
|
type: :string, required: false, desc: 'The path where your page will be created', aliases: '-p'
|
@@ -28,13 +21,13 @@ class ScaffoldingCommands < UtilityCommands
|
|
28
21
|
end
|
29
22
|
end
|
30
23
|
|
31
|
-
|
32
|
-
|
33
|
-
desc 'feature [FEATURE_NAME]', 'Creates a new feature'
|
24
|
+
desc 'feature [NAME]', 'Creates a new feature'
|
34
25
|
option :path,
|
35
|
-
type: :string,
|
26
|
+
type: :string,
|
27
|
+
required: false, desc: 'The path where your feature will be created', aliases: '-p'
|
36
28
|
option :delete,
|
37
|
-
type: :boolean,
|
29
|
+
type: :boolean,
|
30
|
+
required: false, desc: 'This will delete the selected feature', aliases: '-d'
|
38
31
|
|
39
32
|
def feature(name)
|
40
33
|
path = options[:path] || load_config_path('feature')
|
@@ -45,8 +38,6 @@ class ScaffoldingCommands < UtilityCommands
|
|
45
38
|
end
|
46
39
|
end
|
47
40
|
|
48
|
-
map '-f' => 'feature'
|
49
|
-
|
50
41
|
desc 'spec [SPEC_NAME]', 'Creates a new spec'
|
51
42
|
option :path,
|
52
43
|
type: :string, required: false, desc: 'The path where your spec will be created', aliases: '-p'
|
@@ -62,8 +53,6 @@ class ScaffoldingCommands < UtilityCommands
|
|
62
53
|
end
|
63
54
|
end
|
64
55
|
|
65
|
-
map '-s' => 'spec'
|
66
|
-
|
67
56
|
desc 'helper [HELPER_NAME]', 'Creates a new helper'
|
68
57
|
option :path,
|
69
58
|
type: :string, required: false, desc: 'The path where your helper will be created', aliases: '-p'
|
@@ -79,8 +68,6 @@ class ScaffoldingCommands < UtilityCommands
|
|
79
68
|
end
|
80
69
|
end
|
81
70
|
|
82
|
-
map '-h' => 'helper'
|
83
|
-
|
84
71
|
desc 'scaffold [SCAFFOLD_NAME]', 'It generates everything needed to start automating'
|
85
72
|
|
86
73
|
def scaffold(name)
|
@@ -92,22 +79,10 @@ class ScaffoldingCommands < UtilityCommands
|
|
92
79
|
Scaffolding.new([name, load_config_path('page')]).generate_class
|
93
80
|
end
|
94
81
|
|
95
|
-
map '-sf' => 'scaffold'
|
96
|
-
|
97
82
|
desc 'config', 'Creates configuration file'
|
98
83
|
option :delete,
|
99
84
|
type: :boolean, required: false, desc: 'This will delete the config file', aliases: '-d'
|
100
85
|
|
101
|
-
def config
|
102
|
-
if options[:delete]
|
103
|
-
Scaffolding.new.delete_config
|
104
|
-
else
|
105
|
-
Scaffolding.new.generate_config
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
map '-c' => 'config'
|
110
|
-
|
111
86
|
no_commands do
|
112
87
|
def load_config_path(type)
|
113
88
|
YAML.load_file('config/config.yml')["#{type}_path"] if Pathname.new('config/config.yml').exist?
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'thor'
|
4
4
|
require_relative '../utilities/utilities'
|
5
|
-
require_relative '../utilities/open_ai'
|
6
5
|
|
7
6
|
class UtilityCommands < Thor
|
8
7
|
desc 'path [PATH]', 'Sets the default path for scaffolding'
|
@@ -15,19 +14,15 @@ class UtilityCommands < Thor
|
|
15
14
|
|
16
15
|
def path(default_path)
|
17
16
|
type = options.empty? ? 'page' : options.keys.first
|
18
|
-
Utilities.
|
17
|
+
Utilities.send("#{type}_path=", default_path)
|
19
18
|
end
|
20
19
|
|
21
|
-
map '-p' => 'path'
|
22
|
-
|
23
20
|
desc 'url [URL]', 'Sets the default url for a project'
|
24
21
|
|
25
22
|
def url(default_url)
|
26
|
-
Utilities.
|
23
|
+
Utilities.url = default_url
|
27
24
|
end
|
28
25
|
|
29
|
-
map '-u' => 'url'
|
30
|
-
|
31
26
|
desc 'browser [BROWSER]', 'Sets the default browser for a project'
|
32
27
|
option :opts,
|
33
28
|
type: :array, required: false, desc: 'The options you want your browser to run with', aliases: '-o'
|
@@ -35,23 +30,19 @@ class UtilityCommands < Thor
|
|
35
30
|
type: :boolean, required: false, desc: 'This will delete your browser options', aliases: '-d'
|
36
31
|
|
37
32
|
def browser(default_browser = nil)
|
38
|
-
Utilities.
|
33
|
+
Utilities.browser = default_browser if default_browser
|
39
34
|
browser_options(options[:opts]) if options[:opts] || options[:delete]
|
40
35
|
end
|
41
36
|
|
42
|
-
map '-b' => 'browser'
|
43
|
-
|
44
37
|
desc 'browser_options [OPTIONS]', 'Sets the browser options for the project'
|
45
38
|
option :delete,
|
46
39
|
type: :boolean, required: false, desc: 'This will delete your browser options', aliases: '-d'
|
47
40
|
|
48
41
|
def browser_options(*opts)
|
49
|
-
Utilities.
|
50
|
-
Utilities.
|
42
|
+
Utilities.browser_options = opts unless opts.empty?
|
43
|
+
Utilities.delete_browser_options if options[:delete]
|
51
44
|
end
|
52
45
|
|
53
|
-
map '-bo' => 'browser_options'
|
54
|
-
|
55
46
|
desc 'raid', 'It runs all the tests in a project'
|
56
47
|
option :parallel,
|
57
48
|
type: :boolean, required: false, desc: 'It runs the tests in parallel', aliases: '-p'
|
@@ -60,14 +51,12 @@ class UtilityCommands < Thor
|
|
60
51
|
|
61
52
|
def raid
|
62
53
|
if options[:parallel]
|
63
|
-
Utilities.
|
54
|
+
Utilities.parallel_run(options[:opts])
|
64
55
|
else
|
65
|
-
Utilities.
|
56
|
+
Utilities.run(options[:opts])
|
66
57
|
end
|
67
58
|
end
|
68
59
|
|
69
|
-
map '-r' => 'raid'
|
70
|
-
|
71
60
|
desc 'config', 'Creates a new config file'
|
72
61
|
option :path,
|
73
62
|
type: :string, required: false, desc: 'The path where your config file will be created', aliases: '-p'
|
@@ -77,40 +66,13 @@ class UtilityCommands < Thor
|
|
77
66
|
desc 'platform [PLATFORM]', 'Sets the default platform for a cross-platform project'
|
78
67
|
|
79
68
|
def platform(platform)
|
80
|
-
Utilities.
|
81
|
-
end
|
82
|
-
|
83
|
-
map '-pl' => 'platform'
|
84
|
-
|
85
|
-
desc 'download_builds [BUILD_TYPE]', 'It downloads the example builds for appium projects'
|
86
|
-
def download_builds(build_type)
|
87
|
-
if %w[android, ios, both].include?(build_type)
|
88
|
-
raise 'Please select one of the following build types: android, ios, both'
|
89
|
-
end
|
90
|
-
|
91
|
-
Utilities.new.download_builds build_type
|
69
|
+
Utilities.platform = platform
|
92
70
|
end
|
93
71
|
|
94
|
-
|
72
|
+
desc 'builds [BUILD_TYPE]', 'It downloads the example builds for appium projects'
|
73
|
+
def builds(build_type)
|
74
|
+
raise 'Please select one of the following build types: android, ios, both' unless %w[android ios both].include?(build_type)
|
95
75
|
|
96
|
-
|
97
|
-
def version
|
98
|
-
puts 'The Ruby Raider version is 0.5.1, Happy testing!'
|
76
|
+
Utilities.download_builds build_type
|
99
77
|
end
|
100
|
-
|
101
|
-
map '-v' => 'version'
|
102
|
-
|
103
|
-
desc 'open_ai [REQUEST]', 'Uses open AI to create a file or generate output'
|
104
|
-
option :path,
|
105
|
-
type: :string, required: false, desc: 'The path where your file will be created', aliases: '-p'
|
106
|
-
|
107
|
-
def open_ai(request)
|
108
|
-
if options[:path]
|
109
|
-
OpenAi.create_file(choice = 0, options[:path], request)
|
110
|
-
else
|
111
|
-
OpenAi.output(request)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
map '-oa' => 'open_ai'
|
116
78
|
end
|
@@ -54,7 +54,12 @@ Ruby Raider is a generator and scaffolding gem to make UI test automation easier
|
|
54
54
|
|
55
55
|
***In order to run the Appium tests, download the example [app](https://github.com/saucelabs/my-demo-app-rn).***
|
56
56
|
|
57
|
-
***In order to run the visual tests with applitools, you need to create an account and get your api key, you can read
|
57
|
+
***In order to run the visual tests with applitools, you need to create an account and get your api key, you can read
|
58
|
+
more [here](https://applitools.com/docs/topics/overview/obtain-api-key.html#:~:text=If%20you%20already%20have%20an,Your%20key%20will%20be%20displayed.)
|
59
|
+
.***
|
60
|
+
|
61
|
+
***To use the open ai integration you need to set up the OPENAI_ACCESS_TOKEN environment variable and
|
62
|
+
you can also set the optional OPENAI_ORGANIZATION_ID if you have an organization***
|
58
63
|
|
59
64
|
This works in all the platforms (Tested on Mac OS, Linux and Windows).
|
60
65
|
|
@@ -74,50 +79,38 @@ gem install ruby_raider
|
|
74
79
|
raider new [name_of_project]
|
75
80
|
```
|
76
81
|
|
77
|
-
Then a TUI/CLI will appear where the configuration of which frameworks you want to be generated/scaffolded can be
|
82
|
+
Then a TUI/CLI will appear where the configuration of which frameworks you want to be generated/scaffolded can be
|
83
|
+
selected.
|
78
84
|
|
79
85
|
Select the ones you will like to work with.
|
80
86
|
|
81
|
-
### Ruby raider provides the following list of commands
|
87
|
+
### Ruby raider provides the following list of basic commands
|
82
88
|
|
83
89
|
###### Anything between square brackets([...]) is where your imput goes
|
84
90
|
|
85
91
|
```ruby
|
86
|
-
Commands:
|
87
|
-
raider
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
raider helper [HELPER_NAME] # Creates a new helper
|
96
|
-
|
97
|
-
raider new [PROJECT_NAME] # Creates a new framework based on settings picked
|
98
|
-
|
99
|
-
raider page [PAGE_NAME] # Creates a new page object
|
100
|
-
|
101
|
-
raider path [PATH] # Sets the default path for scaffolding
|
102
|
-
|
103
|
-
raider platform [PLATFORM] # Sets the default platform for a cross-platform project
|
104
|
-
|
105
|
-
raider raid # Runs all the tests in a project
|
106
|
-
|
107
|
-
raider scaffold [SCAFFOLD_NAME] # Generates everything needed to start automating
|
92
|
+
Commands :
|
93
|
+
raider generate # Provides access to all the generators commands
|
94
|
+
raider help [COMMAND] # Describe available commands or one specific command
|
95
|
+
raider new [PROJECT_NAME] # Creates a new framework based on settings picked
|
96
|
+
raider open_ai # Provides access to all the open ai commands
|
97
|
+
raider utility # Provides access to all the utility commands
|
98
|
+
raider version # It shows the version of Ruby Raider you are currently using
|
99
|
+
```
|
108
100
|
|
109
|
-
|
101
|
+
All the basic commands have their corresponding shortcut:
|
110
102
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
103
|
+
* g for generate
|
104
|
+
* n for new
|
105
|
+
* o for open_ai
|
106
|
+
* u for utility
|
107
|
+
* v for version
|
115
108
|
|
116
109
|
Ruby raider also supports scaffolding:
|
117
110
|
|
118
|
-
* To create a new page object you do: ```raider page [PAGE_NAME]```
|
119
|
-
* To create a new spec you do: ```raider spec [SPEC_NAME]```
|
120
|
-
* To create a new feature you do: ```raider feature [FEATURE_NAME]```
|
111
|
+
* To create a new page object you do: ```raider g page [PAGE_NAME]```
|
112
|
+
* To create a new spec you do: ```raider g spec [SPEC_NAME]```
|
113
|
+
* To create a new feature you do: ```raider g feature [FEATURE_NAME]```
|
121
114
|
|
122
115
|
It's possible to add the option --path or -p if you want to specify where to create your features, pages, helpers and
|
123
116
|
specs.
|
@@ -125,9 +118,30 @@ specs.
|
|
125
118
|
If you want to set the default path for the creation of your features, helpers and specs:
|
126
119
|
|
127
120
|
```ruby
|
128
|
-
raider path [PATH_NAME]
|
129
|
-
raider path [PATH_NAME]
|
130
|
-
raider path [PATH_NAME]
|
121
|
+
raider u path [PATH_NAME] - -feature or -f
|
122
|
+
raider u path [PATH_NAME] - -spec or -s
|
123
|
+
raider u path [PATH_NAME] - -helper or -h
|
131
124
|
```
|
132
125
|
|
133
126
|
If you don't specify an option, path will assume you want to change the default path for pages.
|
127
|
+
|
128
|
+
### Open AI Commands
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
# Will print the result of the request on the terminal
|
132
|
+
raider o make [REQUEST]
|
133
|
+
# Will create a file with the result of your request as content
|
134
|
+
raider o make [REQUEST] - -path or -p [PATH]
|
135
|
+
# Will input the content of the chosen file into open ai and will edit it based on the result
|
136
|
+
raider o make [PATH_NAME] - -edit or -e [FILE_PATH]
|
137
|
+
# Creates a cucumber file and uses it to input into open ai and create a steps file
|
138
|
+
# The prompt is not required because it uses a based prompt
|
139
|
+
raider o cucumber [NAME] - -prompt or -p [PROMPT]
|
140
|
+
# Creates a cucumber step definitions file based on an scenario file
|
141
|
+
raider open_ai steps [NAME]
|
142
|
+
Options :
|
143
|
+
-p, [--path = PATH] # The path where your steps will be created
|
144
|
+
-pr, [--prompt = PROMPT] # This will create the selected steps based on your prompt using open ai
|
145
|
+
-i, [--input = INPUT] # It uses a file as input to create the steps
|
146
|
+
|
147
|
+
```
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'openai'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module OpenAi
|
5
|
+
class << self
|
6
|
+
def client
|
7
|
+
@client ||= create_client
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_client
|
11
|
+
configure_client
|
12
|
+
OpenAI::Client.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure_client
|
16
|
+
OpenAI.configure do |config|
|
17
|
+
config.access_token = ENV.fetch('OPENAI_ACCESS_TOKEN')
|
18
|
+
config.organization_id = ENV.fetch('OPENAI_ORGANIZATION_ID', nil)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def input(request, model = 'gpt-3.5-turbo', temperature = 0.7)
|
23
|
+
client.chat(
|
24
|
+
parameters: {
|
25
|
+
model: model,
|
26
|
+
messages: [{ role: 'user', content: request }],
|
27
|
+
temperature: temperature
|
28
|
+
})
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_file(path, request, choice = 0)
|
32
|
+
File.write(path, output(request, choice))
|
33
|
+
end
|
34
|
+
|
35
|
+
def output(request, choice = 0)
|
36
|
+
extract_text(input(request), 'choices', choice, 'message', 'content')
|
37
|
+
end
|
38
|
+
|
39
|
+
def edit_file(path, request, choice = 0)
|
40
|
+
content = File.read(path)
|
41
|
+
response = edit(content, request)
|
42
|
+
File.write(path, extract_text(response, 'choices', choice, 'text'))
|
43
|
+
end
|
44
|
+
|
45
|
+
def edit(input, request, model = 'text-davinci-edit-001')
|
46
|
+
client.edits(
|
47
|
+
parameters: {
|
48
|
+
model: model,
|
49
|
+
input: input,
|
50
|
+
instruction: request
|
51
|
+
}
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def extract_text(response, *keys)
|
58
|
+
response.dig(*keys)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/ruby_raider.rb
CHANGED
@@ -1,9 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../lib/commands/open_ai_commands'
|
3
4
|
require_relative '../lib/commands/scaffolding_commands'
|
5
|
+
require_relative '../lib/commands/utility_commands'
|
4
6
|
|
5
7
|
module RubyRaider
|
6
|
-
|
7
|
-
|
8
|
+
class Raider < Thor
|
9
|
+
desc 'new [PROJECT_NAME]', 'Creates a new framework based on settings picked'
|
10
|
+
|
11
|
+
def new(project_name)
|
12
|
+
MenuGenerator.new(project_name).generate_choice_menu
|
13
|
+
end
|
14
|
+
|
15
|
+
map '-n' => 'new'
|
16
|
+
|
17
|
+
desc 'version', 'It shows the version of Ruby Raider you are currently using'
|
18
|
+
def version
|
19
|
+
spec = Gem::Specification.load('ruby_raider.gemspec')
|
20
|
+
version = spec.version
|
21
|
+
puts "The Ruby Raider version is #{version}, Happy testing!"
|
22
|
+
end
|
23
|
+
|
24
|
+
map 'v' => 'version'
|
25
|
+
|
26
|
+
desc 'generate', 'Provides access to all the generators commands'
|
27
|
+
subcommand 'generate', ScaffoldingCommands
|
28
|
+
map 'g' => 'generate'
|
29
|
+
|
30
|
+
desc 'open_ai', 'Provides access to all the open ai commands'
|
31
|
+
subcommand 'open_ai', OpenAiCommands
|
32
|
+
map 'o' => 'open_ai'
|
33
|
+
|
34
|
+
desc 'utility', 'Provides access to all the utility commands'
|
35
|
+
subcommand 'utility', UtilityCommands
|
36
|
+
map 'u' => 'utility'
|
8
37
|
end
|
9
38
|
end
|
data/lib/utilities/utilities.rb
CHANGED
@@ -1,99 +1,106 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
-
require '
|
4
|
+
require 'faraday'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
@path = 'config/config.yml'
|
9
|
-
@config = YAML.load_file(@path)
|
10
|
-
end
|
6
|
+
module Utilities
|
7
|
+
@path = 'config/config.yml'
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
class << self
|
10
|
+
def browser=(browser)
|
11
|
+
config['browser'] = browser
|
12
|
+
overwrite_yaml
|
13
|
+
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
def page_path=(path)
|
16
|
+
config['page_path'] = path
|
17
|
+
overwrite_yaml
|
18
|
+
end
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
def spec_path=(path)
|
21
|
+
config['spec_path'] = path
|
22
|
+
overwrite_yaml
|
23
|
+
end
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
def feature_path=(path)
|
26
|
+
config['feature_path'] = path
|
27
|
+
overwrite_yaml
|
28
|
+
end
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
def helper_path=(path)
|
31
|
+
config['helper_path'] = path
|
32
|
+
overwrite_yaml
|
33
|
+
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
def url=(url)
|
36
|
+
config['url'] = url
|
37
|
+
overwrite_yaml
|
38
|
+
end
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
def platform=(platform)
|
41
|
+
config['platform'] = platform
|
42
|
+
overwrite_yaml
|
43
|
+
end
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
def browser_options=(*opts)
|
46
|
+
config['browser_options'] = opts.flatten
|
47
|
+
overwrite_yaml
|
48
|
+
end
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
def delete_browser_options
|
51
|
+
config.delete('browser_options')
|
52
|
+
overwrite_yaml
|
53
|
+
end
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
def run(opts = nil)
|
56
|
+
command = File.directory?('spec') ? 'rspec spec/' : 'cucumber features'
|
57
|
+
system "#{command} #{opts}"
|
58
|
+
end
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
def parallel_run(opts = nil, _settings = nil)
|
61
|
+
command = File.directory?('spec') ? 'parallel_rspec spec/' : 'parallel_cucumber features'
|
62
|
+
system "#{command} #{opts}"
|
63
|
+
end
|
66
64
|
|
67
|
-
|
68
|
-
|
69
|
-
|
65
|
+
def download_builds(build_type)
|
66
|
+
case build_type
|
67
|
+
when 'android'
|
68
|
+
download_android_build
|
69
|
+
when 'ios'
|
70
|
+
download_ios_build
|
71
|
+
else
|
72
|
+
download_android_build
|
73
|
+
download_ios_build
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
70
78
|
|
71
|
-
|
72
|
-
|
73
|
-
when 'android'
|
74
|
-
download_android_build
|
75
|
-
when 'ios'
|
76
|
-
download_ios_build
|
77
|
-
else
|
78
|
-
download_android_build
|
79
|
-
download_ios_build
|
79
|
+
def overwrite_yaml
|
80
|
+
File.open(@path, 'w') { |file| YAML.dump(config, file) }
|
80
81
|
end
|
81
|
-
end
|
82
82
|
|
83
|
-
|
83
|
+
def download_android_build
|
84
|
+
download_build('Android-MyDemoAppRN.1.3.0.build-244.apk',
|
85
|
+
'https://github.com/saucelabs/my-demo-app-rn/releases/download/v1.3.0/Android-MyDemoAppRN.1.3.0.build-244.apk')
|
86
|
+
end
|
84
87
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
88
|
+
def download_ios_build
|
89
|
+
download_build('iOS-Simulator-MyRNDemoApp.1.3.0-162.zip',
|
90
|
+
'https://github.com/saucelabs/my-demo-app-rn/releases/download/v1.3.0/iOS-Simulator-MyRNDemoApp.1.3.0-162.zip')
|
91
|
+
end
|
89
92
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
93
|
+
def download_build(name, url)
|
94
|
+
response = Faraday.get(url)
|
95
|
+
build_url = Faraday.get(response.headers['location'])
|
96
|
+
|
97
|
+
File.open(name, 'wb') do |file|
|
98
|
+
file.write(build_url.body)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def config
|
103
|
+
@config ||= File.exist?(@path) ? YAML.load_file(@path) : nil
|
97
104
|
end
|
98
105
|
end
|
99
106
|
end
|
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.5.
|
5
|
+
s.version = '0.5.3'
|
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']
|
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.files = `git ls-files -z`.split("\x0")
|
14
14
|
s.bindir = 'bin'
|
15
15
|
s.executables << 'raider'
|
16
|
+
s.add_development_dependency 'dotenv', '~> 2.8'
|
16
17
|
s.add_development_dependency 'rake', '~> 13.0.6'
|
17
18
|
s.add_development_dependency 'reek', '~> 6.1.0'
|
18
19
|
s.add_development_dependency 'rspec', '~> 3.11.0'
|
@@ -20,6 +21,7 @@ Gem::Specification.new do |s|
|
|
20
21
|
s.add_development_dependency 'rubocop-performance', '~> 1.15.0'
|
21
22
|
s.add_development_dependency 'rubocop-rspec', '~> 2.9.0'
|
22
23
|
|
24
|
+
s.add_runtime_dependency 'faraday', '~> 2.7'
|
23
25
|
s.add_runtime_dependency 'ruby-openai', '~> 3.5'
|
24
26
|
s.add_runtime_dependency 'thor', '~> 1.2.1'
|
25
27
|
s.add_runtime_dependency 'tty-prompt', '~> 0.23.1'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'pathname'
|
4
|
+
require 'yaml'
|
5
|
+
require_relative '../lib/generators/common_generator'
|
6
|
+
require_relative '../lib/commands/open_ai_commands'
|
7
|
+
require_relative '../lib/scaffolding/scaffolding'
|
8
|
+
require_relative 'spec_helper'
|
9
|
+
|
10
|
+
describe OpenAiCommands do
|
11
|
+
let(:open_ai) { described_class }
|
12
|
+
let(:name) { 'test' }
|
13
|
+
|
14
|
+
orig_dir = Dir.pwd
|
15
|
+
Dotenv.load
|
16
|
+
|
17
|
+
after do
|
18
|
+
Dir.chdir orig_dir
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'without any project' do
|
22
|
+
after do
|
23
|
+
FileUtils.rm_rf('joke.txt')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'creates a file using open ai' do
|
27
|
+
open_ai.new.invoke(:make, nil, ['tell me a joke', '--path', 'joke.txt'])
|
28
|
+
expect(File).to be_size('joke.txt')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'edits an existing file using open ai' do
|
32
|
+
FileUtils.touch('joke.txt')
|
33
|
+
open_ai.new.invoke(:make, nil, ['tell me a better joke', '--edit', 'joke.txt'])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'dotenv'
|
1
2
|
require 'pathname'
|
2
3
|
require 'yaml'
|
3
4
|
require_relative '../lib/generators/common_generator'
|
@@ -49,30 +50,6 @@ describe ScaffoldingCommands do
|
|
49
50
|
expect(Pathname.new("page_objects/pages/#{name}_page.rb")).to be_file
|
50
51
|
end
|
51
52
|
|
52
|
-
it 'changes the path for specs' do
|
53
|
-
scaffold.new.invoke(:path, nil, %W[#{path} -s])
|
54
|
-
config = YAML.load_file('config/config.yml')
|
55
|
-
expect(config['spec_path']).to eql path
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'updates the url' do
|
59
|
-
scaffold.new.invoke(:url, nil, %w[test.com])
|
60
|
-
config = YAML.load_file('config/config.yml')
|
61
|
-
expect(config['url']).to eql 'test.com'
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'updates the browser' do
|
65
|
-
scaffold.new.invoke(:browser, nil, %w[:firefox])
|
66
|
-
config = YAML.load_file('config/config.yml')
|
67
|
-
expect(config['browser']).to eql ':firefox'
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'updates the browser options' do
|
71
|
-
scaffold.new.invoke(:browser, nil, %w[:firefox --opts headless start-maximized start-fullscreen])
|
72
|
-
config = YAML.load_file('config/config.yml')
|
73
|
-
expect(config['browser_options']).to eql %w[headless start-maximized start-fullscreen]
|
74
|
-
end
|
75
|
-
|
76
53
|
it 'creates a page with a path' do
|
77
54
|
scaffold.new.invoke(:page, nil, %W[#{name} --path #{new_path}])
|
78
55
|
expect(Pathname.new("#{new_path}/#{name}_page.rb")).to be_file
|
@@ -118,37 +95,6 @@ describe ScaffoldingCommands do
|
|
118
95
|
expect(Pathname.new('features/login.feature')).not_to be_file
|
119
96
|
end
|
120
97
|
|
121
|
-
it 'changes the path for pages' do
|
122
|
-
scaffold.new.invoke(:path, nil, %W[#{path}])
|
123
|
-
config = YAML.load_file('config/config.yml')
|
124
|
-
expect(config['page_path']).to eql path
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'changes the path for features' do
|
128
|
-
scaffold.new.invoke(:path, nil, %W[#{path} -f])
|
129
|
-
config = YAML.load_file('config/config.yml')
|
130
|
-
expect(config['feature_path']).to eql path
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'updates only the browser options' do
|
134
|
-
scaffold.new.invoke(:browser, nil, %w[:firefox --opts headless])
|
135
|
-
config = YAML.load_file('config/config.yml')
|
136
|
-
expect(config['browser_options']).to eql %w[headless]
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'deletes the browser options when passed with the delete parameter' do
|
140
|
-
scaffold.new.invoke(:browser, nil, %w[:firefox --opts headless --delete])
|
141
|
-
config = YAML.load_file('config/config.yml')
|
142
|
-
expect(config['browser_options']).to be_nil
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'deletes the browser options' do
|
146
|
-
scaffold.new.invoke(:browser, nil, %w[:firefox --opts headless])
|
147
|
-
scaffold.new.invoke(:browser, nil, %w[--delete])
|
148
|
-
config = YAML.load_file('config/config.yml')
|
149
|
-
expect(config['browser_options']).to be_nil
|
150
|
-
end
|
151
|
-
|
152
98
|
it 'creates a feature' do
|
153
99
|
scaffold.new.invoke(:feature, nil, %W[#{name} --path #{new_path}])
|
154
100
|
expect(Pathname.new("#{new_path}/#{name}.feature")).to be_file
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'pathname'
|
4
|
+
require 'yaml'
|
5
|
+
require_relative '../lib/generators/common_generator'
|
6
|
+
require_relative '../lib/commands/utility_commands'
|
7
|
+
require_relative '../lib/scaffolding/scaffolding'
|
8
|
+
require_relative 'spec_helper'
|
9
|
+
|
10
|
+
describe UtilityCommands do
|
11
|
+
let(:utility) { described_class }
|
12
|
+
let(:name) { 'test' }
|
13
|
+
|
14
|
+
orig_dir = Dir.pwd
|
15
|
+
|
16
|
+
after do
|
17
|
+
Dir.chdir orig_dir
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with a spec folder' do
|
21
|
+
let(:new_path) { 'test_folder' }
|
22
|
+
|
23
|
+
path = "#{FRAMEWORKS.last}_#{AUTOMATION_TYPES[2]}"
|
24
|
+
|
25
|
+
before do
|
26
|
+
Dir.chdir path
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'changes the path for specs' do
|
30
|
+
utility.new.invoke(:path, nil, %W[#{path} -s])
|
31
|
+
config = YAML.load_file('config/config.yml')
|
32
|
+
expect(config['spec_path']).to eql path
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'updates the url' do
|
36
|
+
utility.new.invoke(:url, nil, %w[test.com])
|
37
|
+
config = YAML.load_file('config/config.yml')
|
38
|
+
expect(config['url']).to eql 'test.com'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'updates the browser' do
|
42
|
+
utility.new.invoke(:browser, nil, %w[:firefox])
|
43
|
+
config = YAML.load_file('config/config.yml')
|
44
|
+
expect(config['browser']).to eql ':firefox'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'updates the browser options' do
|
48
|
+
utility.new.invoke(:browser, nil, %w[:firefox --opts headless start-maximized start-fullscreen])
|
49
|
+
config = YAML.load_file('config/config.yml')
|
50
|
+
expect(config['browser_options']).to eql %w[headless start-maximized start-fullscreen]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'with a features folder' do
|
55
|
+
let(:new_path) { 'test_folder' }
|
56
|
+
|
57
|
+
path = "#{FRAMEWORKS.first}_#{AUTOMATION_TYPES.last}"
|
58
|
+
|
59
|
+
before do
|
60
|
+
Dir.chdir path
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'changes the path for pages' do
|
64
|
+
utility.new.invoke(:path, nil, %W[#{path}])
|
65
|
+
config = YAML.load_file('config/config.yml')
|
66
|
+
expect(config['page_path']).to eql path
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'changes the path for features' do
|
70
|
+
utility.new.invoke(:path, nil, %W[#{path} -f])
|
71
|
+
config = YAML.load_file('config/config.yml')
|
72
|
+
expect(config['feature_path']).to eql path
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'updates only the browser options' do
|
76
|
+
utility.new.invoke(:browser, nil, %w[:firefox --opts headless])
|
77
|
+
config = YAML.load_file('config/config.yml')
|
78
|
+
expect(config['browser_options']).to eql %w[headless]
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'deletes the browser options when passed with the delete parameter' do
|
82
|
+
utility.new.invoke(:browser, nil, %w[:firefox --opts headless --delete])
|
83
|
+
config = YAML.load_file('config/config.yml')
|
84
|
+
expect(config['browser_options']).to be_nil
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'deletes the browser options' do
|
88
|
+
utility.new.invoke(:browser, nil, %w[:firefox --opts headless])
|
89
|
+
utility.new.invoke(:browser, nil, %w[--delete])
|
90
|
+
config = YAML.load_file('config/config.yml')
|
91
|
+
expect(config['browser_options']).to be_nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_raider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agustin Pequeno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dotenv
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.8'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: 2.9.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: faraday
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.7'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.7'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: ruby-openai
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -158,6 +186,7 @@ files:
|
|
158
186
|
- README.md
|
159
187
|
- Rakefile
|
160
188
|
- bin/raider
|
189
|
+
- lib/commands/open_ai_commands.rb
|
161
190
|
- lib/commands/scaffolding_commands.rb
|
162
191
|
- lib/commands/utility_commands.rb
|
163
192
|
- lib/generators/automation_generator.rb
|
@@ -225,22 +254,24 @@ files:
|
|
225
254
|
- lib/generators/templates/helpers/visual_spec_helper.tt
|
226
255
|
- lib/generators/templates/rspec/base_spec.tt
|
227
256
|
- lib/generators/templates/rspec/spec.tt
|
257
|
+
- lib/open_ai/open_ai.rb
|
228
258
|
- lib/ruby_raider.rb
|
229
259
|
- lib/scaffolding/scaffolding.rb
|
230
260
|
- lib/scaffolding/templates/feature.tt
|
231
261
|
- lib/scaffolding/templates/helper.tt
|
232
262
|
- lib/scaffolding/templates/page_object.tt
|
233
263
|
- lib/scaffolding/templates/spec.tt
|
234
|
-
- lib/utilities/open_ai.rb
|
235
264
|
- lib/utilities/utilities.rb
|
236
265
|
- ruby_raider.gemspec
|
237
266
|
- spec/automation_generator_spec.rb
|
238
267
|
- spec/common_generator_spec.rb
|
239
268
|
- spec/cucumber_generator_spec.rb
|
240
269
|
- spec/helpers_generator_spec.rb
|
270
|
+
- spec/open_ai_commands_spec.rb
|
241
271
|
- spec/rspec_generator_spec.rb
|
242
272
|
- spec/scaffolding_commands_spec.rb
|
243
273
|
- spec/spec_helper.rb
|
274
|
+
- spec/utility_commands_spec.rb
|
244
275
|
homepage: https://github.com/RubyRaider/ruby_raider
|
245
276
|
licenses:
|
246
277
|
- MIT
|
data/lib/utilities/open_ai.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'openai'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
module OpenAi
|
5
|
-
class << self
|
6
|
-
def create_client
|
7
|
-
configure_client
|
8
|
-
OpenAI::Client.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def configure_client
|
12
|
-
OpenAI.configure do |config|
|
13
|
-
config.access_token = ENV.fetch('OPENAI_ACCESS_TOKEN')
|
14
|
-
config.organization_id = ENV.fetch('OPENAI_ORGANIZATION_ID', nil)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def input(model = "gpt-3.5-turbo", temperature = 0.7, request)
|
19
|
-
create_client.chat(
|
20
|
-
parameters: {
|
21
|
-
model: model,
|
22
|
-
messages: [{ role: "user", content: request }],
|
23
|
-
temperature: temperature
|
24
|
-
})
|
25
|
-
end
|
26
|
-
|
27
|
-
def create_file(choice = 0, path, request)
|
28
|
-
response = input(request)
|
29
|
-
File.write(path, response.dig("choices", choice, "message", "content"))
|
30
|
-
end
|
31
|
-
|
32
|
-
def output(choice = 0, request)
|
33
|
-
response = input(request)
|
34
|
-
puts response.dig("choices", choice, "message", "content")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|