rainforest-cli 1.6.2 → 1.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +18 -2
- data/lib/rainforest/cli/exporter.rb +20 -8
- data/lib/rainforest/cli/remote_tests.rb +25 -27
- data/lib/rainforest/cli/version.rb +1 -1
- data/spec/exporter_spec.rb +44 -16
- data/spec/remote_tests_spec.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e77dec4702b93e1e965863ef17de691657fd03ae
|
4
|
+
data.tar.gz: 578b1fa55a182adf52f74c1f2201219c4af1c72a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f9ff110e6d916871ad66b1c47ab4e19c02392629a97f9c5de5f7ad8337382a3b068dad60252163ecc31be684cc5aaa53d1b4c162b685298f2b01a5f1abbd8ea
|
7
|
+
data.tar.gz: 09a7e1779f9cec02042ee8845ae9f89a7e99718b8245f7a45f65bdd4beffe162d1819afae81557cdd923756b3888a42d5ab2765338478aa3f14a0457732b54f4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Rainforest CLI Changelog
|
2
2
|
|
3
|
+
## 1.6.4 - 10th June 2016
|
4
|
+
- Add redirects to non-embedded steps that need them as well. (2a5918d1a448f78016587c1711261e90a7be120f,
|
5
|
+
@epaulet)
|
6
|
+
- Fix a bug introduced in 1.6.1 where validating without an API token would result in an error.
|
7
|
+
(b604a5607e707057375ecc14db836d4b3ec537b1, @epaulet)
|
8
|
+
|
9
|
+
## 1.6.3 - 9th June 2016
|
10
|
+
- Add redirects to exported steps. (ccbdaec2a9fb52c775ffbee05e203e1026b256f7, @theonegri)
|
11
|
+
|
3
12
|
## 1.6.2 - 8th June 2016
|
4
13
|
- Lower concurrent thread count to 16 and allow users to modify the amount of threads used.
|
5
14
|
(4333fca172e4e109a517ff6ffc5e11f89839fe85, @epaulet)
|
data/README.md
CHANGED
@@ -32,13 +32,17 @@ You can customize the amount of threads to use when making HTTP requests by sett
|
|
32
32
|
API errors when fetching or updating multiple tests, lowering this value can help.
|
33
33
|
The default value is `16`.
|
34
34
|
|
35
|
-
|
35
|
+
#### Commands
|
36
|
+
|
37
|
+
###### Running Tests
|
38
|
+
|
39
|
+
Run all tests.
|
36
40
|
|
37
41
|
```bash
|
38
42
|
rainforest run all
|
39
43
|
```
|
40
44
|
|
41
|
-
Run all in the foreground and report
|
45
|
+
Run all in the foreground and report.
|
42
46
|
|
43
47
|
```bash
|
44
48
|
rainforest run all --fg
|
@@ -50,6 +54,8 @@ Run all tests with tag 'run-me' and abort previous in-progress runs.
|
|
50
54
|
rainforest run --tag run-me --fg --conflict abort
|
51
55
|
```
|
52
56
|
|
57
|
+
###### Creating and Managing Tests
|
58
|
+
|
53
59
|
Create new Rainforest test in RFML format (Rainforest Markup Language).
|
54
60
|
|
55
61
|
```bash
|
@@ -62,6 +68,14 @@ You may also specify a custom test title or file name.
|
|
62
68
|
rainforest new "My Awesome Title"
|
63
69
|
```
|
64
70
|
|
71
|
+
Validate your tests for syntax and correct RFML ids for embedded tests.
|
72
|
+
Use the `--token` options or `RAINFOREST_API_TOKEN` environment variable
|
73
|
+
to validate your tests against server data as well.
|
74
|
+
|
75
|
+
```bash
|
76
|
+
rainforest validate
|
77
|
+
```
|
78
|
+
|
65
79
|
Upload tests to Rainforest
|
66
80
|
|
67
81
|
```bash
|
@@ -73,6 +87,8 @@ Export all tests from Rainforest
|
|
73
87
|
rainforest export
|
74
88
|
```
|
75
89
|
|
90
|
+
###### Viewing Account Specific Information
|
91
|
+
|
76
92
|
See a list of all of your sites and their IDs
|
77
93
|
```bash
|
78
94
|
rainforest sites
|
@@ -11,6 +11,7 @@ class RainforestCli::Exporter
|
|
11
11
|
@options = options
|
12
12
|
::Rainforest.api_key = @options.token
|
13
13
|
@test_files = RainforestCli::TestFiles.new(@options)
|
14
|
+
@remote_tests = RainforestCli::RemoteTests.new(@options.token)
|
14
15
|
end
|
15
16
|
|
16
17
|
def logger
|
@@ -26,8 +27,9 @@ class RainforestCli::Exporter
|
|
26
27
|
if @options.tests.length > 0
|
27
28
|
@options.tests
|
28
29
|
else
|
29
|
-
|
30
|
+
@remote_tests.primary_ids
|
30
31
|
end
|
32
|
+
|
31
33
|
p = ProgressBar.create(title: 'Tests', total: test_ids.count, format: '%a %B %p%% %t')
|
32
34
|
Parallel.each(test_ids, in_threads: threads, finish: lambda { |_item, _i, _result| p.increment }) do |test_id|
|
33
35
|
# Get the full test from the API
|
@@ -41,8 +43,9 @@ class RainforestCli::Exporter
|
|
41
43
|
File.open(file_name, 'a') do |file|
|
42
44
|
file.puts(get_header(test))
|
43
45
|
|
46
|
+
first_step_processed = false
|
44
47
|
test.elements.each_with_index do |element, index|
|
45
|
-
process_element(file, element, index)
|
48
|
+
first_step_processed = process_element(file, element, index, first_step_processed)
|
46
49
|
end
|
47
50
|
end
|
48
51
|
end
|
@@ -50,25 +53,34 @@ class RainforestCli::Exporter
|
|
50
53
|
|
51
54
|
private
|
52
55
|
|
53
|
-
def process_element
|
56
|
+
def process_element(file, element, index, first_step_processed)
|
54
57
|
case element[:type]
|
55
58
|
when 'test'
|
56
59
|
if @options.embed_tests
|
57
60
|
file.puts '' unless index == 0
|
61
|
+
# no redirect if an embedded test is the first step
|
62
|
+
file.puts "# redirect: #{element[:redirection]}" if index > 0
|
58
63
|
file.puts "- #{element[:element][:rfml_id]}"
|
59
64
|
else
|
60
|
-
element[:element][:elements].
|
61
|
-
|
65
|
+
element[:element][:elements].each_with_index do |sub_element, i|
|
66
|
+
# no redirect flags for flattened tests
|
67
|
+
process_element(file, sub_element, i + index, true)
|
62
68
|
end
|
63
69
|
end
|
64
70
|
when 'step'
|
65
71
|
file.puts '' unless index == 0
|
66
|
-
|
67
|
-
|
68
|
-
|
72
|
+
|
73
|
+
# add redirect for first step if preceded by an embedded test
|
74
|
+
if index > 0 && first_step_processed == false
|
75
|
+
file.puts "# redirect: #{element[:redirection]}"
|
76
|
+
end
|
77
|
+
file.puts element[:element][:action].gsub("\n", ' ').strip
|
78
|
+
file.puts element[:element][:response].gsub("\n", ' ').strip
|
79
|
+
first_step_processed = true
|
69
80
|
else
|
70
81
|
raise "Unknown element type: #{element[:type]}"
|
71
82
|
end
|
83
|
+
first_step_processed
|
72
84
|
end
|
73
85
|
|
74
86
|
def get_header(test)
|
@@ -9,47 +9,45 @@ class RainforestCli::RemoteTests
|
|
9
9
|
!Rainforest.api_key.nil?
|
10
10
|
end
|
11
11
|
|
12
|
-
def rfml_ids
|
13
|
-
@rfml_ids ||= primary_key_dictionary.keys
|
14
|
-
end
|
15
|
-
|
16
12
|
def tests
|
17
13
|
@tests ||= fetch_tests
|
18
14
|
end
|
19
15
|
|
20
|
-
def
|
21
|
-
|
22
|
-
begin
|
23
|
-
logger.info 'Syncing tests...'
|
24
|
-
tests = Rainforest::Test.all(page_size: 1000)
|
25
|
-
logger.info 'Syncing completed.'
|
26
|
-
tests
|
27
|
-
rescue Rainforest::ApiError => e
|
28
|
-
logger.error "Encountered API Error: #{e.message}"
|
29
|
-
exit 4
|
30
|
-
end
|
31
|
-
else
|
32
|
-
logger.info ''
|
33
|
-
logger.info 'No API Token set. Using local tests only...'
|
34
|
-
logger.info ''
|
35
|
-
[]
|
36
|
-
end
|
16
|
+
def rfml_ids
|
17
|
+
@rfml_ids ||= tests.map { |t| t['rfml_id'] }
|
37
18
|
end
|
38
19
|
|
39
|
-
def
|
40
|
-
@
|
20
|
+
def primary_ids
|
21
|
+
@primary_ids ||= tests.map { |t| t['id'] }
|
41
22
|
end
|
42
23
|
|
43
|
-
def
|
44
|
-
|
24
|
+
def primary_key_dictionary
|
25
|
+
@primary_key_dictionary ||= make_test_dictionary
|
45
26
|
end
|
46
27
|
|
47
28
|
def make_test_dictionary
|
48
29
|
primary_key_dictionary = {}
|
49
|
-
|
50
|
-
rf_tests.each do |rf_test|
|
30
|
+
tests.each do |rf_test|
|
51
31
|
primary_key_dictionary[rf_test['rfml_id']] = rf_test['id']
|
52
32
|
end
|
53
33
|
primary_key_dictionary
|
54
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def logger
|
39
|
+
RainforestCli.logger
|
40
|
+
end
|
41
|
+
|
42
|
+
def fetch_tests
|
43
|
+
if api_token_set?
|
44
|
+
logger.info 'Fetching test data from server...'
|
45
|
+
test_list = @client.get('/tests/rfml_ids')
|
46
|
+
logger.info 'Fetch complete.'
|
47
|
+
test_list
|
48
|
+
else
|
49
|
+
logger.info 'No API Token set. Using local tests only...'
|
50
|
+
[]
|
51
|
+
end
|
52
|
+
end
|
55
53
|
end
|
data/spec/exporter_spec.rb
CHANGED
@@ -3,7 +3,7 @@ describe RainforestCli::Exporter do
|
|
3
3
|
let(:options) do
|
4
4
|
instance_double(
|
5
5
|
'RainforestCli::Options',
|
6
|
-
token:
|
6
|
+
token: 'token',
|
7
7
|
test_folder: nil,
|
8
8
|
command: nil,
|
9
9
|
debug: nil,
|
@@ -18,14 +18,14 @@ describe RainforestCli::Exporter do
|
|
18
18
|
class FileDouble < Array
|
19
19
|
alias_method :puts, :push
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
join("\n").include?(str)
|
21
|
+
def to_s
|
22
|
+
join("\n")
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
26
|
let(:file) { FileDouble.new }
|
28
|
-
let(:
|
27
|
+
let(:file_str) { file.to_s }
|
28
|
+
let(:tests) { [{ 'id' => 123, 'rfml_id' => 'rfml_id_123' }] }
|
29
29
|
let(:embedded_rfml_id) { 'embedded_test_rfml_id' }
|
30
30
|
let(:embedded_test) do
|
31
31
|
{
|
@@ -43,8 +43,14 @@ describe RainforestCli::Exporter do
|
|
43
43
|
end
|
44
44
|
let(:test_elements) do
|
45
45
|
[
|
46
|
+
{
|
47
|
+
type: 'test',
|
48
|
+
redirection: true,
|
49
|
+
element: embedded_test
|
50
|
+
},
|
46
51
|
{
|
47
52
|
type: 'step',
|
53
|
+
redirection: false,
|
48
54
|
element: {
|
49
55
|
action: 'Step Action',
|
50
56
|
response: 'Step Response'
|
@@ -52,7 +58,16 @@ describe RainforestCli::Exporter do
|
|
52
58
|
},
|
53
59
|
{
|
54
60
|
type: 'test',
|
61
|
+
redirection: true,
|
55
62
|
element: embedded_test
|
63
|
+
},
|
64
|
+
{
|
65
|
+
type: 'step',
|
66
|
+
redirection: false,
|
67
|
+
element: {
|
68
|
+
action: 'Last step',
|
69
|
+
response: 'Last step?'
|
70
|
+
}
|
56
71
|
}
|
57
72
|
]
|
58
73
|
end
|
@@ -81,7 +96,8 @@ describe RainforestCli::Exporter do
|
|
81
96
|
allow_any_instance_of(RainforestCli::TestFiles).to receive(:create_file).and_return('file_name')
|
82
97
|
allow(File).to receive(:truncate)
|
83
98
|
|
84
|
-
|
99
|
+
allow_any_instance_of(RainforestCli::HttpClient).to receive(:get).with('/tests/rfml_ids')
|
100
|
+
.and_return(tests)
|
85
101
|
allow(Rainforest::Test).to receive(:retrieve).and_return(single_test)
|
86
102
|
|
87
103
|
subject.export
|
@@ -132,37 +148,49 @@ describe RainforestCli::Exporter do
|
|
132
148
|
let(:options) do
|
133
149
|
instance_double(
|
134
150
|
'RainforestCli::Options',
|
135
|
-
token:
|
151
|
+
token: 'token', test_folder: nil, command: nil,
|
136
152
|
debug: nil, embed_tests: true, tests: [],
|
137
153
|
)
|
138
154
|
end
|
139
155
|
|
140
|
-
it 'prints an embedded test rfml id
|
156
|
+
it 'prints an embedded test rfml id' do
|
141
157
|
expect(file).to include("- #{embedded_rfml_id}")
|
142
|
-
expect(
|
143
|
-
expect(
|
158
|
+
expect(file_str).to_not include('Embedded Action')
|
159
|
+
expect(file_str).to_not include('Embedded Response')
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'prints the redirects in the correct location' do
|
163
|
+
# the first embedded test should not have a redirect before it
|
164
|
+
expect(file_str.scan(/# redirect: true\n- #{embedded_rfml_id}/).count).to eq(1)
|
165
|
+
|
166
|
+
# First real step should have a redirect
|
167
|
+
expect(file_str).to include("# redirect: false\nStep Action")
|
168
|
+
|
169
|
+
# The last step exists but no redirect with it
|
170
|
+
expect(file_str).to include('Last step')
|
171
|
+
expect(file_str).to_not include("# redirect: false\nLast step")
|
144
172
|
end
|
145
173
|
end
|
146
174
|
|
147
175
|
context 'with specific tests' do
|
148
|
-
let(:
|
176
|
+
let(:test_ids) { (123..127).to_a }
|
149
177
|
let(:options) do
|
150
178
|
instance_double(
|
151
179
|
'RainforestCli::Options',
|
152
180
|
token: nil, test_folder: nil, command: nil,
|
153
|
-
debug: nil, embed_tests: nil, tests:
|
181
|
+
debug: nil, embed_tests: nil, tests: test_ids
|
154
182
|
)
|
155
183
|
end
|
156
184
|
|
157
185
|
it 'gets specific tests instead of all' do
|
158
|
-
expect(Rainforest::Test).to receive(:retrieve).exactly(
|
159
|
-
|
186
|
+
expect(Rainforest::Test).to receive(:retrieve).exactly(test_ids.length).times
|
187
|
+
expect_any_instance_of(RainforestCli::RemoteTests).to_not receive(:primary_ids)
|
160
188
|
subject.export
|
161
189
|
end
|
162
190
|
|
163
191
|
it 'opens correct number of files' do
|
164
|
-
expect(File).to receive(:open).exactly(
|
165
|
-
expect_any_instance_of(RainforestCli::TestFiles).to receive(:create_file).exactly(
|
192
|
+
expect(File).to receive(:open).exactly(test_ids.length).times
|
193
|
+
expect_any_instance_of(RainforestCli::TestFiles).to receive(:create_file).exactly(test_ids.length).times
|
166
194
|
subject.export
|
167
195
|
end
|
168
196
|
end
|
data/spec/remote_tests_spec.rb
CHANGED
@@ -23,5 +23,16 @@ describe RainforestCli::RemoteTests do
|
|
23
23
|
test3['rfml_id'] => test3['id']
|
24
24
|
})
|
25
25
|
end
|
26
|
+
|
27
|
+
context 'no api token set' do
|
28
|
+
subject { described_class.new }
|
29
|
+
|
30
|
+
it 'does not make an API call but returns an empty dictionary' do
|
31
|
+
expect_any_instance_of(RainforestCli::HttpClient).to_not receive(:get)
|
32
|
+
dictionary = subject.primary_key_dictionary
|
33
|
+
expect(dictionary).to be_a(Hash)
|
34
|
+
expect(dictionary).to eq({})
|
35
|
+
end
|
36
|
+
end
|
26
37
|
end
|
27
38
|
end
|
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.6.
|
4
|
+
version: 1.6.4
|
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-06-
|
12
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|