rainforest-cli 1.8.1 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +13 -0
- data/lib/rainforest_cli.rb +1 -0
- data/lib/rainforest_cli/csv_importer.rb +11 -8
- data/lib/rainforest_cli/options.rb +3 -1
- data/lib/rainforest_cli/runner.rb +1 -1
- data/lib/rainforest_cli/test_files.rb +23 -9
- data/lib/rainforest_cli/test_parser/step.rb +20 -2
- data/lib/rainforest_cli/version.rb +1 -1
- data/spec/multiple-rainforest-examples/example_test.rfml +8 -0
- data/spec/multiple-rainforest-examples/example_test_2.rfml +6 -0
- data/spec/rainforest_cli/csv_importer_spec.rb +10 -4
- data/spec/rainforest_cli/test_files_spec.rb +10 -1
- data/spec/rainforest_cli/test_parser/step_spec.rb +21 -1
- data/spec/rainforest_cli/uploader_spec.rb +1 -1
- data/spec/rainforest_cli/validator_spec.rb +3 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36eb7257778cfda59e340fea593c2b9662390949
|
4
|
+
data.tar.gz: 0c9d06828b51075a1ccd95b2710200ad94e6e5ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccddbb99af989e0d96f9761c67ed2a2a2dc9d1731264890d78adb8adb16170c51da4b17ca168c3cb602e21a793feb324307b4adf4d7195d78f27c45773b00cf5
|
7
|
+
data.tar.gz: 417541f667b2485f05f1b9528822832b19ac083489bff2fd93d79d90ff5a7c80a4dca3282f902fe61a9da291e1efe129b9dfcba838d6d80a9be35b6ba33725cd
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Rainforest CLI Changelog
|
2
2
|
|
3
|
+
## 1.9.0 - 14th September 2016
|
4
|
+
- Add `upload-csv` command for updating tabular variables without starting a new run.
|
5
|
+
(069e943cd94cbb08e6f00347ab6c8327372897ce, @epaulet)
|
6
|
+
- Add ability to filter uploads with `tag` and `site-id` and to upload specific test by file path.
|
7
|
+
(1d6e0a39d664e4c2d2135fa654571c28aaaac031, @epaulet)
|
8
|
+
|
3
9
|
## 1.8.1 - 19th August 2016
|
4
10
|
- Fix a bug that prevent uploading tests as a result from 1.8.0.
|
5
11
|
(651514ae94df6857c43e820fff60cdf8034f534d, @epaulet)
|
data/README.md
CHANGED
@@ -88,6 +88,12 @@ Upload tests to Rainforest
|
|
88
88
|
rainforest upload
|
89
89
|
```
|
90
90
|
|
91
|
+
Upload a specific test to Rainforest
|
92
|
+
|
93
|
+
```bash
|
94
|
+
rainforest upload /path/to/test/file.rfml
|
95
|
+
```
|
96
|
+
|
91
97
|
Remove RFML file and remove test from Rainforest test suite.
|
92
98
|
|
93
99
|
```bash
|
@@ -128,6 +134,13 @@ To generate a junit xml report for a test run which has already completed
|
|
128
134
|
rainforest report --run-id <run-id> --junit-file rainforest.xml
|
129
135
|
```
|
130
136
|
|
137
|
+
#### Updating Tabular Variables
|
138
|
+
|
139
|
+
Upload a CSV file to update your tabular variables
|
140
|
+
```bash
|
141
|
+
rainforest csv-upload --import-variable-csv-file PATH/TO/CSV.csv --import-variable-name my_variable
|
142
|
+
```
|
143
|
+
|
131
144
|
## Options
|
132
145
|
|
133
146
|
### General
|
data/lib/rainforest_cli.rb
CHANGED
@@ -41,6 +41,7 @@ module RainforestCli
|
|
41
41
|
when 'upload' then Uploader.new(options).upload
|
42
42
|
when 'rm' then Deleter.new(options).delete
|
43
43
|
when 'export' then Exporter.new(options).export
|
44
|
+
when 'csv-upload' then CSVImporter.new(options).import
|
44
45
|
when 'report' then Reporter.new(options).report
|
45
46
|
when 'sites', 'folders', 'browsers'
|
46
47
|
Resources.new(options).public_send(options.command)
|
@@ -6,12 +6,9 @@ require 'ruby-progressbar'
|
|
6
6
|
|
7
7
|
module RainforestCli
|
8
8
|
class CSVImporter
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@generator_name = name
|
13
|
-
@file = file
|
14
|
-
@client = HttpClient.new token: token
|
9
|
+
def initialize(options)
|
10
|
+
@generator_name = options.import_name
|
11
|
+
@file = options.import_file_name
|
15
12
|
end
|
16
13
|
|
17
14
|
def row_data columns, values
|
@@ -31,7 +28,7 @@ module RainforestCli
|
|
31
28
|
raise 'Invalid schema in CSV. You must include headers in first row.' if !columns
|
32
29
|
|
33
30
|
print 'Creating custom step variable'
|
34
|
-
response =
|
31
|
+
response = http_client.post '/generators', { name: @generator_name, description: @generator_name, columns: columns }
|
35
32
|
raise "Error creating custom step variable: #{response['error']}" if response['error']
|
36
33
|
puts "\t[OK]"
|
37
34
|
|
@@ -43,9 +40,15 @@ module RainforestCli
|
|
43
40
|
|
44
41
|
# Insert the data
|
45
42
|
Parallel.each(rows, in_threads: 16, finish: lambda { |_item, _i, _result| p.increment }) do |row|
|
46
|
-
response =
|
43
|
+
response = http_client.post("/generators/#{@generator_id}/rows", {data: row_data(@columns, row)})
|
47
44
|
raise response['error'] if response['error']
|
48
45
|
end
|
49
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def http_client
|
51
|
+
RainforestCli.http_client
|
52
|
+
end
|
50
53
|
end
|
51
54
|
end
|
@@ -135,7 +135,7 @@ module RainforestCli
|
|
135
135
|
|
136
136
|
@command = @args.shift
|
137
137
|
|
138
|
-
if ['new', 'rm'].include?(@command)
|
138
|
+
if ['new', 'rm', 'upload'].include?(@command)
|
139
139
|
@file_name = @args.shift
|
140
140
|
|
141
141
|
if @file_name && @command == 'rm'
|
@@ -187,6 +187,8 @@ module RainforestCli
|
|
187
187
|
end
|
188
188
|
elsif import_file_name || import_name
|
189
189
|
raise ValidationError, 'You must pass both --import-variable-csv-file and --import-variable-name'
|
190
|
+
elsif command == 'csv-upload'
|
191
|
+
raise ValidationError, 'You must pass both --import-variable-csv-file and --import-variable-name with the csv-upload command'
|
190
192
|
end
|
191
193
|
|
192
194
|
if command == 'rm' && file_name.nil?
|
@@ -16,7 +16,7 @@ module RainforestCli
|
|
16
16
|
|
17
17
|
if options.import_file_name && options.import_name
|
18
18
|
delete_generator(options.import_name)
|
19
|
-
CSVImporter.new(options
|
19
|
+
CSVImporter.new(options).import
|
20
20
|
end
|
21
21
|
|
22
22
|
post_opts = make_create_run_options
|
@@ -39,15 +39,7 @@ EOF
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_data
|
42
|
-
|
43
|
-
@test_data = []
|
44
|
-
if Dir.exist?(@test_folder)
|
45
|
-
Dir.glob(test_paths) do |file_name|
|
46
|
-
@test_data << RainforestCli::TestParser::Parser.new(file_name).process
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
@test_data
|
42
|
+
@test_data ||= get_test_data
|
51
43
|
end
|
52
44
|
|
53
45
|
def file_extension
|
@@ -94,6 +86,28 @@ EOF
|
|
94
86
|
|
95
87
|
private
|
96
88
|
|
89
|
+
def get_test_data
|
90
|
+
if @options.file_name
|
91
|
+
[RainforestCli::TestParser::Parser.new(@options.file_name).process]
|
92
|
+
else
|
93
|
+
data = []
|
94
|
+
if Dir.exist?(@test_folder)
|
95
|
+
Dir.glob(test_paths) do |file_name|
|
96
|
+
data << RainforestCli::TestParser::Parser.new(file_name).process
|
97
|
+
end
|
98
|
+
end
|
99
|
+
filter_tests(data)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def filter_tests(tests)
|
104
|
+
tests.select do |test|
|
105
|
+
pass_tag_filter = (@options.tags - test.tags).empty?
|
106
|
+
pass_site_filter = @options.site_id.nil? || @options.site_id == test.site_id
|
107
|
+
pass_tag_filter || pass_site_filter
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
97
111
|
def unique_path(file_path)
|
98
112
|
path = file_path[0...-file_extension.length]
|
99
113
|
identifier = 0
|
@@ -15,10 +15,28 @@ class RainforestCli::TestParser::Step < Struct.new(:action, :response, :redirect
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def uploadable_in_action
|
18
|
-
action.scan(UPLOADABLE_REGEX)
|
18
|
+
action.scan(UPLOADABLE_REGEX).select do |match|
|
19
|
+
needs_parameterization?(match)
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
23
|
def uploadable_in_response
|
22
|
-
response.scan(UPLOADABLE_REGEX)
|
24
|
+
response.scan(UPLOADABLE_REGEX).select do |match|
|
25
|
+
needs_parameterization?(match)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def needs_parameterization?(match)
|
32
|
+
argument = match[1]
|
33
|
+
parameters = argument.split(',').map(&:strip)
|
34
|
+
if parameters.length >= 2
|
35
|
+
has_file_id = parameters[0].to_i > 0
|
36
|
+
has_file_sig = parameters[1].length == 6
|
37
|
+
!(has_file_id && has_file_sig)
|
38
|
+
else
|
39
|
+
true
|
40
|
+
end
|
23
41
|
end
|
24
42
|
end
|
@@ -1,9 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
describe RainforestCli::CSVImporter do
|
3
3
|
let(:csv_file) { "#{File.dirname(__FILE__)}/../fixtures/variables.txt" }
|
4
|
+
let(:http_client) { instance_double('RainforestCli::HttpClient') }
|
5
|
+
|
6
|
+
before do
|
7
|
+
allow(RainforestCli).to receive(:http_client).and_return(http_client)
|
8
|
+
end
|
4
9
|
|
5
10
|
describe '.import' do
|
6
|
-
|
11
|
+
let(:options) { instance_double('RainforestCli::Options', import_name: 'variables', import_file_name: csv_file) }
|
12
|
+
subject { described_class.new(options) }
|
7
13
|
let(:columns) { %w(email pass) }
|
8
14
|
|
9
15
|
let(:success_response) do
|
@@ -14,7 +20,7 @@ describe RainforestCli::CSVImporter do
|
|
14
20
|
end
|
15
21
|
|
16
22
|
it 'should post the schema to the generators API' do
|
17
|
-
|
23
|
+
expect(http_client).to receive(:post)
|
18
24
|
.with('/generators', {
|
19
25
|
name: 'variables',
|
20
26
|
description: 'variables',
|
@@ -22,7 +28,7 @@ describe RainforestCli::CSVImporter do
|
|
22
28
|
})
|
23
29
|
.and_return success_response
|
24
30
|
|
25
|
-
|
31
|
+
expect(http_client).to receive(:post)
|
26
32
|
.with('/generators/12345/rows', {
|
27
33
|
data: {
|
28
34
|
0 => 'russ@rainforestqa.com',
|
@@ -30,7 +36,7 @@ describe RainforestCli::CSVImporter do
|
|
30
36
|
},
|
31
37
|
}).and_return({})
|
32
38
|
|
33
|
-
|
39
|
+
expect(http_client).to receive(:post)
|
34
40
|
.with('/generators/12345/rows', {
|
35
41
|
data: {
|
36
42
|
0 => 'bob@example.com',
|
@@ -5,7 +5,7 @@ describe RainforestCli::TestFiles do
|
|
5
5
|
|
6
6
|
describe '#test_data' do
|
7
7
|
let(:test_directory) { File.dirname(__FILE__) + '/../rainforest-example' }
|
8
|
-
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, command: nil) }
|
8
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, command: nil, file_name: nil, tags: [], site_id: nil) }
|
9
9
|
|
10
10
|
let(:rfml_test) { subject.test_data.first }
|
11
11
|
let(:text_file) { File.read(test_directory + '/example_test.rfml') }
|
@@ -14,6 +14,15 @@ describe RainforestCli::TestFiles do
|
|
14
14
|
expect(rfml_test.title).to eq(text_file.match(/^# title: (.+)$/)[1])
|
15
15
|
expect(rfml_test.rfml_id).to eq(text_file.match(/^#! (.+?)($| .+?$)/)[1])
|
16
16
|
end
|
17
|
+
|
18
|
+
context 'when filtering by file name' do
|
19
|
+
let(:file_name) { File.join(File.dirname(__FILE__), '../multiple-rainforest-examples/example_test.rfml') }
|
20
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: nil, command: nil, file_name: file_name, tags: [], site_id: nil) }
|
21
|
+
|
22
|
+
it 'only parses that file' do
|
23
|
+
expect(subject.test_data.length).to eq(1)
|
24
|
+
end
|
25
|
+
end
|
17
26
|
end
|
18
27
|
|
19
28
|
describe '#test_dictionary' do
|
@@ -9,6 +9,14 @@ describe RainforestCli::TestParser::Step do
|
|
9
9
|
'Download 1: {{ file.download(./foo) }}. Download 2: {{file.download(bar/baz) }}'
|
10
10
|
end
|
11
11
|
|
12
|
+
let(:parameterized_screenshot_string) do
|
13
|
+
'Picture 1: {{ file.screenshot(./foo) }}. Picture 2: {{file.screenshot(123, signat) }}'
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:parameterized_download_string) do
|
17
|
+
'Download 1: {{ file.download(./foo) }}. Download 2: {{file.download(123, signat, baz.txt) }}'
|
18
|
+
end
|
19
|
+
|
12
20
|
shared_examples 'a method that detects step variables' do |att|
|
13
21
|
it 'correctly detects a screenshot step variable' do
|
14
22
|
subject[att] = screenshot_string
|
@@ -16,11 +24,23 @@ describe RainforestCli::TestParser::Step do
|
|
16
24
|
.to eq([['screenshot', './foo'], ['screenshot', 'bar/baz']])
|
17
25
|
end
|
18
26
|
|
19
|
-
it 'correctly detects
|
27
|
+
it 'correctly detects a download step variable' do
|
20
28
|
subject[att] = download_string
|
21
29
|
expect(subject.send(:"uploadable_in_#{att}"))
|
22
30
|
.to eq([['download', './foo'], ['download', 'bar/baz']])
|
23
31
|
end
|
32
|
+
|
33
|
+
it 'does not detect a parameterized screenshot step variable' do
|
34
|
+
subject[att] = parameterized_screenshot_string
|
35
|
+
expect(subject.send(:"uploadable_in_#{att}"))
|
36
|
+
.to eq([['screenshot', './foo']])
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'does not detect a parameterized download step variable' do
|
40
|
+
subject[att] = parameterized_download_string
|
41
|
+
expect(subject.send(:"uploadable_in_#{att}"))
|
42
|
+
.to eq([['download', './foo']])
|
43
|
+
end
|
24
44
|
end
|
25
45
|
|
26
46
|
describe '#uploadable_in_action' do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
describe RainforestCli::Uploader do
|
3
|
-
let(:options) { instance_double('RainforestCli::Options', token: 'foo', test_folder: test_directory, command: '') }
|
3
|
+
let(:options) { instance_double('RainforestCli::Options', token: 'foo', test_folder: test_directory, command: '', file_name: nil, tags: [], site_id: nil) }
|
4
4
|
subject { described_class.new(options) }
|
5
5
|
|
6
6
|
before do
|
@@ -26,7 +26,7 @@ describe RainforestCli::Validator do
|
|
26
26
|
|
27
27
|
shared_examples 'it detects all the correct errors' do
|
28
28
|
let(:tested_method) { :validate }
|
29
|
-
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: 'api_token', command: '', tags: [], folder: nil, site_id: nil) }
|
29
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: 'api_token', command: '', tags: [], folder: nil, site_id: nil, file_name: nil) }
|
30
30
|
subject { described_class.new(options) }
|
31
31
|
|
32
32
|
before do
|
@@ -93,7 +93,7 @@ describe RainforestCli::Validator do
|
|
93
93
|
|
94
94
|
context 'when multiple tests have the same rfml_ids' do
|
95
95
|
let(:test_directory) { File.expand_path(File.dirname(__FILE__) + '/../validation-examples/duplicate_rfml_ids') }
|
96
|
-
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: 'api_token', command: '') }
|
96
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: 'api_token', command: '', file_name: nil, tags: [], site_id: nil) }
|
97
97
|
|
98
98
|
subject { described_class.new(options) }
|
99
99
|
|
@@ -130,7 +130,7 @@ describe RainforestCli::Validator do
|
|
130
130
|
|
131
131
|
context 'without a token option' do
|
132
132
|
let(:test_directory) { File.expand_path(File.dirname(__FILE__) + '/../validation-examples') }
|
133
|
-
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, command: '') }
|
133
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, command: '', file_name: nil, tags: [], site_id: nil) }
|
134
134
|
let(:http_client) { instance_double('RainforestCli::HttpClient', api_token_set?: false) }
|
135
135
|
subject { described_class.new(options) }
|
136
136
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rainforest-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Smith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -217,6 +217,8 @@ files:
|
|
217
217
|
- spec/fixtures/runs_response.json
|
218
218
|
- spec/fixtures/tests_response.json
|
219
219
|
- spec/fixtures/variables.txt
|
220
|
+
- spec/multiple-rainforest-examples/example_test.rfml
|
221
|
+
- spec/multiple-rainforest-examples/example_test_2.rfml
|
220
222
|
- spec/rainforest-example/example_test.rfml
|
221
223
|
- spec/rainforest_cli/csv_importer_spec.rb
|
222
224
|
- spec/rainforest_cli/deleter_spec.rb
|
@@ -285,6 +287,8 @@ test_files:
|
|
285
287
|
- spec/fixtures/runs_response.json
|
286
288
|
- spec/fixtures/tests_response.json
|
287
289
|
- spec/fixtures/variables.txt
|
290
|
+
- spec/multiple-rainforest-examples/example_test.rfml
|
291
|
+
- spec/multiple-rainforest-examples/example_test_2.rfml
|
288
292
|
- spec/rainforest-example/example_test.rfml
|
289
293
|
- spec/rainforest_cli/csv_importer_spec.rb
|
290
294
|
- spec/rainforest_cli/deleter_spec.rb
|