rainforest-cli 1.5.0 → 1.6.0
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/CHANGELOG.md +10 -2
- data/README.md +6 -0
- data/lib/rainforest/cli.rb +2 -0
- data/lib/rainforest/cli/deleter.rb +61 -0
- data/lib/rainforest/cli/options.rb +10 -46
- data/lib/rainforest/cli/test_files.rb +30 -9
- data/lib/rainforest/cli/test_parser.rb +1 -1
- data/lib/rainforest/cli/version.rb +1 -1
- data/spec/deleter_spec.rb +93 -0
- data/spec/exporter_spec.rb +13 -5
- data/spec/options_spec.rb +17 -8
- data/spec/test_files_spec.rb +36 -5
- data/spec/test_parser_spec.rb +9 -0
- data/spec/uploader_spec.rb +1 -1
- data/spec/validator_spec.rb +3 -3
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 572509cbd3863f100fbe585b1bef8cd87b1e6660
|
4
|
+
data.tar.gz: 9d1b997c421aee71f56fe5901d77c245d2291130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3dea6785acb946d8882d5a7ef86bc49e0d3a8fbc95580838de499cee1690502e01c647bdcd696567210d4853fcb77e7d611b29e7e69b64390848c9910b2bcba
|
7
|
+
data.tar.gz: 1fde1d05b2894bc0fca33fe018c38afd8469828f29e31416316e9d21fa1f04f04b217a932e2eb03303f345ac18a1aefff8c613f4b80cbf0d833cd4b9a7680b6e
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,20 @@
|
|
1
1
|
# Rainforest CLI Changelog
|
2
2
|
|
3
|
-
## 1.
|
3
|
+
## 1.6.0 - 8th June 2016
|
4
|
+
- Add `rm` command to delete tests. (cf077bd440e83852d8d23f66eb72ba94fece0c07, @marktran)
|
5
|
+
- New tests use title given when created using `rainforest new [TEST_NAME]`.
|
6
|
+
(01e30ba9d97558ba11c239a5c9842192d38dfd3f, @epaulet)
|
7
|
+
- Remove static browser list and stop client side validation of browsers for run
|
8
|
+
creation. Allow the API to validate against the dynamic list of client browsers
|
9
|
+
instead. (48a4d11e524d020e78e14991bf8a0c5bf82b65c9, @epaulet)
|
10
|
+
|
11
|
+
## 1.5.0 - 23rd May 2016
|
4
12
|
- Retry on API exceptions when creating a run. (85830adcef426e64bd72c9d6208881e955a5bb0c, @bbeck)
|
5
13
|
- Add `browsers` command. (2a810ec27edfc66ef7bf27d8cb7da1129b05e32b, @epaulet)
|
6
14
|
- Add support for files using `app-source-url`. (562e4772e71e8028209d128091ff644f4ae0a9f6, @marianafranco)
|
7
15
|
- Remove newlines from test actions and questions when exporting. (e28583b553b5f30b33b232b2e377c109123b11ff, @epaulet)
|
8
16
|
|
9
|
-
## 1.4.0
|
17
|
+
## 1.4.0 - 22nd April 2016
|
10
18
|
- Support for new `--version` command. (4362c85fe599a02eaa1b772d184be31e692e934e, @epaulet)
|
11
19
|
- Validate duplicate RFML IDs before uploading. (67f71d053c755eaf92c1bd205931e89e903b88c9, @curtis-rainforestqa)
|
12
20
|
- Add `folders` commands for a folder ID reference. (4ab19fec0924b4764e140fb3c5aa85f1dbfe4006, @epaulet)
|
data/README.md
CHANGED
@@ -51,6 +51,12 @@ Create new Rainforest test in RFML format (Rainforest Markup Language).
|
|
51
51
|
rainforest new
|
52
52
|
```
|
53
53
|
|
54
|
+
You may also specify a custom test title or file name.
|
55
|
+
|
56
|
+
```bash
|
57
|
+
rainforest new "My Awesome Title"
|
58
|
+
```
|
59
|
+
|
54
60
|
Upload tests to Rainforest
|
55
61
|
|
56
62
|
```bash
|
data/lib/rainforest/cli.rb
CHANGED
@@ -14,6 +14,7 @@ require 'rainforest/cli/test_files'
|
|
14
14
|
require 'rainforest/cli/remote_tests'
|
15
15
|
require 'rainforest/cli/validator'
|
16
16
|
require 'rainforest/cli/exporter'
|
17
|
+
require 'rainforest/cli/deleter'
|
17
18
|
require 'rainforest/cli/uploader'
|
18
19
|
require 'rainforest/cli/resources'
|
19
20
|
|
@@ -34,6 +35,7 @@ module RainforestCli
|
|
34
35
|
when 'new' then TestFiles.new(options).create_file
|
35
36
|
when 'validate' then Validator.new(options).validate
|
36
37
|
when 'upload' then Uploader.new(options).upload
|
38
|
+
when 'rm' then Deleter.new(options).delete
|
37
39
|
when 'export' then Exporter.new(options).export
|
38
40
|
when 'sites', 'folders', 'browsers'
|
39
41
|
Resources.new(options).public_send(options.command)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'rainforest'
|
3
|
+
|
4
|
+
class RainforestCli::Deleter
|
5
|
+
attr_reader :test_files, :remote_tests
|
6
|
+
|
7
|
+
def initialize(options)
|
8
|
+
@file_name = options.file_name
|
9
|
+
@test_files = RainforestCli::TestFiles.new(options)
|
10
|
+
@remote_tests = RainforestCli::RemoteTests.new(options.token)
|
11
|
+
end
|
12
|
+
|
13
|
+
def delete
|
14
|
+
validate_file_extension
|
15
|
+
delete_remote_test(test_file)
|
16
|
+
delete_local_file(test_file.file_name)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def validate_file_extension
|
22
|
+
if !rfml_extension?
|
23
|
+
logger.fatal "Error: file extension must be .rfml"
|
24
|
+
exit 2
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def rfml_extension?
|
29
|
+
extname = File.extname(@file_name)
|
30
|
+
RainforestCli::TestFiles::FILE_EXTENSION == extname
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete_local_file(path_to_file)
|
34
|
+
File.delete(path_to_file)
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete_remote_test(rfml_test)
|
38
|
+
Rainforest::Test.delete(primary_key_dictionary[rfml_test.rfml_id])
|
39
|
+
rescue Exception => e
|
40
|
+
logger.fatal "Unable to delete remote rfml test"
|
41
|
+
exit 2
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_file
|
45
|
+
@test_file ||= rfml_tests.detect do |rfml_test|
|
46
|
+
rfml_test.file_name == @file_name
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def rfml_tests
|
51
|
+
@rfml_tests ||= test_files.test_data
|
52
|
+
end
|
53
|
+
|
54
|
+
def primary_key_dictionary
|
55
|
+
@primary_key_dictionary ||= remote_tests.primary_key_dictionary
|
56
|
+
end
|
57
|
+
|
58
|
+
def logger
|
59
|
+
RainforestCli.logger
|
60
|
+
end
|
61
|
+
end
|
@@ -8,39 +8,6 @@ module RainforestCli
|
|
8
8
|
:import_file_name, :import_name, :custom_url, :description, :folder,
|
9
9
|
:debug, :file_name, :test_folder, :embed_tests, :app_source_url, :crowd
|
10
10
|
|
11
|
-
# Note, not all of these may be available to your account
|
12
|
-
# also, we may remove this in the future.
|
13
|
-
VALID_BROWSERS = %w{
|
14
|
-
android_phone_landscape
|
15
|
-
android_phone_portrait
|
16
|
-
android_tablet_landscape
|
17
|
-
android_tablet_portrait
|
18
|
-
chrome
|
19
|
-
chrome_1440_900
|
20
|
-
chrome_adblock
|
21
|
-
chrome_ghostery
|
22
|
-
chrome_guru
|
23
|
-
chrome_ublock
|
24
|
-
firefox
|
25
|
-
firefox_1440_900
|
26
|
-
ie10
|
27
|
-
ie10_1440_900
|
28
|
-
ie11
|
29
|
-
ie11_1440_900
|
30
|
-
ie8
|
31
|
-
ie8_1440_900
|
32
|
-
ie9
|
33
|
-
ie9_1440_900
|
34
|
-
ios_iphone4s
|
35
|
-
office2010
|
36
|
-
office2013
|
37
|
-
osx_chrome
|
38
|
-
osx_firefox
|
39
|
-
safari
|
40
|
-
ubuntu_chrome
|
41
|
-
ubuntu_firefox
|
42
|
-
iphone_6s_v9_0
|
43
|
-
}.freeze
|
44
11
|
TOKEN_NOT_REQUIRED = %w{new validate}.freeze
|
45
12
|
|
46
13
|
def initialize(args)
|
@@ -152,8 +119,12 @@ module RainforestCli
|
|
152
119
|
|
153
120
|
@command = @args.shift
|
154
121
|
|
155
|
-
if
|
122
|
+
if ['new', 'rm'].include?(@command)
|
156
123
|
@file_name = @args.shift
|
124
|
+
|
125
|
+
if @file_name && @command == 'rm'
|
126
|
+
@file_name = File.expand_path(@file_name) if @file_name
|
127
|
+
end
|
157
128
|
end
|
158
129
|
|
159
130
|
@tests = @args.dup
|
@@ -182,10 +153,6 @@ module RainforestCli
|
|
182
153
|
end
|
183
154
|
end
|
184
155
|
|
185
|
-
if browsers
|
186
|
-
raise BrowserException, browsers unless (browsers - VALID_BROWSERS).empty?
|
187
|
-
end
|
188
|
-
|
189
156
|
if custom_url && site_id.nil?
|
190
157
|
raise ValidationError, 'The site-id and custom-url options are both required.'
|
191
158
|
end
|
@@ -194,21 +161,18 @@ module RainforestCli
|
|
194
161
|
unless File.exist?(import_file_name)
|
195
162
|
raise ValidationError, "Input file: #{import_file_name} not found"
|
196
163
|
end
|
197
|
-
|
198
164
|
elsif import_file_name || import_name
|
199
165
|
raise ValidationError, 'You must pass both --import-variable-csv-file and --import-variable-name'
|
200
166
|
end
|
167
|
+
|
168
|
+
if command == 'rm' && file_name.nil?
|
169
|
+
raise ValidationError, 'You must include a file name'
|
170
|
+
end
|
171
|
+
|
201
172
|
true
|
202
173
|
end
|
203
174
|
|
204
175
|
class ValidationError < RuntimeError
|
205
176
|
end
|
206
|
-
|
207
|
-
class BrowserException < ValidationError
|
208
|
-
def initialize browsers
|
209
|
-
invalid_browsers = browsers - OptionParser::VALID_BROWSERS
|
210
|
-
super "#{invalid_browsers.join(', ')} is not valid. Valid browsers: #{OptionParser::VALID_BROWSERS.join(', ')}"
|
211
|
-
end
|
212
|
-
end
|
213
177
|
end
|
214
178
|
end
|
@@ -4,7 +4,7 @@ class RainforestCli::TestFiles
|
|
4
4
|
FILE_EXTENSION = '.rfml'
|
5
5
|
SAMPLE_FILE = <<EOF
|
6
6
|
#! %s
|
7
|
-
# title:
|
7
|
+
# title: %s
|
8
8
|
# start_uri: /
|
9
9
|
# tags: rfml-test
|
10
10
|
#
|
@@ -21,7 +21,10 @@ EOF
|
|
21
21
|
|
22
22
|
def initialize(options)
|
23
23
|
@options = options
|
24
|
-
|
24
|
+
|
25
|
+
if @options.command == 'rm'
|
26
|
+
@test_folder = File.dirname(@options.file_name)
|
27
|
+
elsif @options.test_folder.nil?
|
25
28
|
logger.info "No test folder supplied. Using default folder: #{DEFAULT_TEST_FOLDER}"
|
26
29
|
@test_folder = File.expand_path(DEFAULT_TEST_FOLDER)
|
27
30
|
else
|
@@ -70,20 +73,38 @@ EOF
|
|
70
73
|
def create_file(file_name = @options.file_name)
|
71
74
|
ensure_directory_exists
|
72
75
|
|
73
|
-
|
76
|
+
title = file_name || 'Unnamed Test'
|
77
|
+
file_path = title.dup
|
74
78
|
|
75
|
-
|
76
|
-
|
77
|
-
|
79
|
+
if title[-file_extension.length..-1] == file_extension
|
80
|
+
title = title[0...-file_extension.length]
|
81
|
+
else
|
82
|
+
file_path += file_extension
|
83
|
+
end
|
78
84
|
|
79
|
-
|
85
|
+
file_path = unique_path(File.join(test_folder, file_path))
|
80
86
|
|
81
|
-
|
82
|
-
|
87
|
+
File.open(file_path, 'w') { |file| file.write(sprintf(SAMPLE_FILE, SecureRandom.uuid, title)) }
|
88
|
+
|
89
|
+
logger.info "Created #{file_path}"
|
90
|
+
file_path
|
83
91
|
end
|
84
92
|
|
85
93
|
private
|
86
94
|
|
95
|
+
def unique_path(file_path)
|
96
|
+
path = file_path[0...-file_extension.length]
|
97
|
+
identifier = 0
|
98
|
+
|
99
|
+
loop do
|
100
|
+
id_string = (identifier > 0) ? " (#{identifier})" : ''
|
101
|
+
test_path = path + id_string + file_extension
|
102
|
+
|
103
|
+
return test_path unless File.exist?(test_path)
|
104
|
+
identifier += 1
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
87
108
|
def logger
|
88
109
|
RainforestCli.logger
|
89
110
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
describe RainforestCli::Deleter do
|
3
|
+
let(:options) do
|
4
|
+
instance_double(
|
5
|
+
'RainforestCli::Options',
|
6
|
+
token: 'foo',
|
7
|
+
test_folder: test_directory,
|
8
|
+
command: 'rm',
|
9
|
+
file_name: file_name
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:test_directory) do
|
14
|
+
File.expand_path(File.join(__FILE__, '../validation-examples/correct-embeds'))
|
15
|
+
end
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
allow(File).to receive(:delete)
|
19
|
+
end
|
20
|
+
|
21
|
+
subject { described_class.new(options) }
|
22
|
+
|
23
|
+
describe '#delete' do
|
24
|
+
context 'with incorrect file extension' do
|
25
|
+
let(:file_name) { 'embedded_test' }
|
26
|
+
|
27
|
+
it 'exits with the correct error' do
|
28
|
+
begin
|
29
|
+
expect_any_instance_of(
|
30
|
+
Logger
|
31
|
+
).to receive(:fatal).with('Error: file extension must be .rfml')
|
32
|
+
|
33
|
+
subject.delete
|
34
|
+
rescue SystemExit => exception
|
35
|
+
expect(exception.status).to eq(2)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with correct file extension' do
|
41
|
+
let(:file_name) { 'embedded_test.rfml' }
|
42
|
+
let(:rfml_id) { 'embedded_test' }
|
43
|
+
let(:test_id) { 25 }
|
44
|
+
let(:primary_key_dictionary) { Hash[rfml_id, test_id] }
|
45
|
+
let(:test_data) do
|
46
|
+
[instance_double(RainforestCli::TestParser::Test, file_name: file_name, rfml_id: rfml_id)]
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with remote rfml test' do
|
50
|
+
before do
|
51
|
+
allow_any_instance_of(RainforestCli::RemoteTests)
|
52
|
+
.to receive(:primary_key_dictionary).and_return(primary_key_dictionary)
|
53
|
+
allow_any_instance_of(RainforestCli::TestFiles)
|
54
|
+
.to receive(:test_data).and_return(test_data)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'deletes the remote rfml test' do
|
58
|
+
expect(Rainforest::Test).to receive(:delete).with(test_id)
|
59
|
+
# make sure that we don't reach SystemExit lines of file
|
60
|
+
expect { subject.delete }.to_not raise_error
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'deletes the local file' do
|
64
|
+
allow(Rainforest::Test).to receive(:delete).with(test_id).and_return({})
|
65
|
+
expect(File).to receive(:delete).with(file_name)
|
66
|
+
# make sure that we don't reach SystemExit lines of file
|
67
|
+
expect { subject.delete }.to_not raise_error
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'without remote rfml test' do
|
72
|
+
let(:test_data) { [OpenStruct.new(file_name: 'foobar.rfml')] }
|
73
|
+
let(:test_files) { OpenStruct.new(test_data: test_data) }
|
74
|
+
|
75
|
+
before do
|
76
|
+
allow(RainforestCli::TestFiles).to receive(:new).and_return(test_files)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'exits with the correct error' do
|
80
|
+
begin
|
81
|
+
expect_any_instance_of(
|
82
|
+
Logger
|
83
|
+
).to receive(:fatal).with('Unable to delete remote rfml test')
|
84
|
+
|
85
|
+
subject.delete
|
86
|
+
rescue SystemExit => exception
|
87
|
+
expect(exception.status).to eq(2)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/spec/exporter_spec.rb
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
describe RainforestCli::Exporter do
|
3
3
|
let(:options) do
|
4
|
-
instance_double(
|
4
|
+
instance_double(
|
5
|
+
'RainforestCli::Options',
|
6
|
+
token: nil,
|
7
|
+
test_folder: nil,
|
8
|
+
command: nil,
|
9
|
+
debug: nil,
|
10
|
+
embed_tests: nil,
|
11
|
+
tests: []
|
12
|
+
)
|
5
13
|
end
|
6
14
|
subject { described_class.new(options) }
|
7
15
|
|
@@ -124,8 +132,8 @@ describe RainforestCli::Exporter do
|
|
124
132
|
let(:options) do
|
125
133
|
instance_double(
|
126
134
|
'RainforestCli::Options',
|
127
|
-
token: nil, test_folder: nil,
|
128
|
-
debug: nil, embed_tests: true, tests: []
|
135
|
+
token: nil, test_folder: nil, command: nil,
|
136
|
+
debug: nil, embed_tests: true, tests: [],
|
129
137
|
)
|
130
138
|
end
|
131
139
|
|
@@ -141,8 +149,8 @@ describe RainforestCli::Exporter do
|
|
141
149
|
let(:options) do
|
142
150
|
instance_double(
|
143
151
|
'RainforestCli::Options',
|
144
|
-
token: nil, test_folder: nil,
|
145
|
-
embed_tests: nil, tests: tests
|
152
|
+
token: nil, test_folder: nil, command: nil,
|
153
|
+
debug: nil, embed_tests: nil, tests: tests
|
146
154
|
)
|
147
155
|
end
|
148
156
|
|
data/spec/options_spec.rb
CHANGED
@@ -24,6 +24,18 @@ describe RainforestCli::OptionParser do
|
|
24
24
|
its(:crowd) { should == 'some_name' }
|
25
25
|
end
|
26
26
|
|
27
|
+
context 'new' do
|
28
|
+
let(:args) { ['new', 'foo.rfml']}
|
29
|
+
its(:command) { should == 'new' }
|
30
|
+
its(:file_name) { should == 'foo.rfml' }
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'rm' do
|
34
|
+
let(:args) { ['rm', 'foo.rfml']}
|
35
|
+
its(:command) { should == 'rm' }
|
36
|
+
its(:file_name) { should == File.expand_path('foo.rfml') }
|
37
|
+
end
|
38
|
+
|
27
39
|
context 'app_source_url' do
|
28
40
|
let(:args) { ['--app-source-url', 'some_app'] }
|
29
41
|
its(:app_source_url) { should == 'some_app' }
|
@@ -134,6 +146,11 @@ describe RainforestCli::OptionParser do
|
|
134
146
|
it { raises_a_validation_exception }
|
135
147
|
end
|
136
148
|
|
149
|
+
context 'with missing filename' do
|
150
|
+
let(:args) { %w(--token foo rm) }
|
151
|
+
it { raises_a_validation_exception }
|
152
|
+
end
|
153
|
+
|
137
154
|
context 'with a custom url but no site id' do
|
138
155
|
let(:args) { %w(--token foo --custom-url http://www.example.com) }
|
139
156
|
it { raises_a_validation_exception }
|
@@ -155,13 +172,5 @@ describe RainforestCli::OptionParser do
|
|
155
172
|
it { raises_a_validation_exception }
|
156
173
|
end
|
157
174
|
end
|
158
|
-
|
159
|
-
context 'with invalid browsers' do
|
160
|
-
let(:args) { %w{run --browsers lulbrowser --token foo} }
|
161
|
-
|
162
|
-
it 'raises an exception' do
|
163
|
-
expect { subject.validate! }.to raise_error(RainforestCli::OptionParser::BrowserException)
|
164
|
-
end
|
165
|
-
end
|
166
175
|
end
|
167
176
|
end
|
data/spec/test_files_spec.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
describe RainforestCli::TestFiles do
|
3
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: nil, command: nil) }
|
4
|
+
subject { described_class.new(options) }
|
5
|
+
|
3
6
|
describe '#test_data' do
|
4
7
|
let(:test_directory) { File.dirname(__FILE__) + '/rainforest-example' }
|
5
|
-
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory) }
|
6
|
-
subject { described_class.new(options) }
|
8
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, command: nil) }
|
7
9
|
|
8
10
|
let(:rfml_test) { subject.test_data.first }
|
9
11
|
let(:text_file) { File.read(test_directory + '/example_test.rfml') }
|
@@ -16,9 +18,6 @@ describe RainforestCli::TestFiles do
|
|
16
18
|
|
17
19
|
describe '#test_dictionary' do
|
18
20
|
Test = Struct.new(:rfml_id, :id)
|
19
|
-
|
20
|
-
let(:options) { instance_double('RainforestCli::Options', test_folder: nil) }
|
21
|
-
subject { described_class.new(options) }
|
22
21
|
let(:tests) { [Test.new('foo', 123), Test.new('bar', 456), Test.new('baz', 789)] }
|
23
22
|
|
24
23
|
before do
|
@@ -31,4 +30,36 @@ describe RainforestCli::TestFiles do
|
|
31
30
|
expect(subject.test_dictionary).to include({})
|
32
31
|
end
|
33
32
|
end
|
33
|
+
|
34
|
+
describe '#create_file' do
|
35
|
+
let(:file) { instance_double('File') }
|
36
|
+
let(:test_title) { 'My Test Title' }
|
37
|
+
|
38
|
+
it 'sets the file name as the given test title' do
|
39
|
+
allow(file).to receive(:write)
|
40
|
+
|
41
|
+
expect(File).to receive(:open).with(a_string_including("#{test_title}.rfml"), 'w').and_yield(file)
|
42
|
+
subject.create_file(test_title)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'sets the title of the test as the given test title' do
|
46
|
+
allow(File).to receive(:open).and_yield(file)
|
47
|
+
|
48
|
+
expect(file).to receive(:write).with(a_string_including("# title: #{test_title}"))
|
49
|
+
subject.create_file(test_title)
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'when there is an existing file with the same title' do
|
53
|
+
before do
|
54
|
+
allow(file).to receive(:write)
|
55
|
+
expect(File).to receive(:exist?).twice.and_return(true).ordered
|
56
|
+
expect(File).to receive(:exist?).and_return(false).ordered
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'sets the file name as given test title with a number for uniqueness' do
|
60
|
+
expect(File).to receive(:open).with(a_string_including("#{test_title} (2).rfml"), 'w').and_yield(file)
|
61
|
+
subject.create_file(test_title)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
34
65
|
end
|
data/spec/test_parser_spec.rb
CHANGED
@@ -26,6 +26,15 @@ describe RainforestCli::TestParser do
|
|
26
26
|
describe RainforestCli::TestParser::Parser do
|
27
27
|
subject { described_class.new(file_name) }
|
28
28
|
|
29
|
+
describe '#initialize' do
|
30
|
+
let(:file_name) { './spec/rainforest-example/example_test.rfml' }
|
31
|
+
|
32
|
+
it 'expands the file name path' do
|
33
|
+
test = subject.instance_variable_get(:@test)
|
34
|
+
expect(test.file_name).to eq(File.expand_path(file_name))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
29
38
|
describe '#process' do
|
30
39
|
context 'redirection' do
|
31
40
|
context 'step' do
|
data/spec/uploader_spec.rb
CHANGED
@@ -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) }
|
3
|
+
let(:options) { instance_double('RainforestCli::Options', token: 'foo', test_folder: test_directory, command: '') }
|
4
4
|
subject { described_class.new(options) }
|
5
5
|
|
6
6
|
before do
|
data/spec/validator_spec.rb
CHANGED
@@ -30,7 +30,7 @@ describe RainforestCli::Validator do
|
|
30
30
|
shared_examples 'it detects all the correct errors' do
|
31
31
|
let(:tested_method) { :validate }
|
32
32
|
let(:raises_error) { false }
|
33
|
-
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: 'api_token') }
|
33
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: 'api_token', command: '') }
|
34
34
|
subject { described_class.new(options) }
|
35
35
|
|
36
36
|
before do
|
@@ -97,7 +97,7 @@ describe RainforestCli::Validator do
|
|
97
97
|
|
98
98
|
context 'when multiple tests have the same rfml_ids' do
|
99
99
|
let(:test_directory) { File.expand_path(File.join(__FILE__, '../validation-examples/duplicate_rfml_ids')) }
|
100
|
-
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: 'api_token') }
|
100
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: 'api_token', command: '') }
|
101
101
|
|
102
102
|
subject { described_class.new(options) }
|
103
103
|
|
@@ -121,7 +121,7 @@ describe RainforestCli::Validator do
|
|
121
121
|
|
122
122
|
context 'without a token option' do
|
123
123
|
let(:test_directory) { File.expand_path(File.join(__FILE__, '../validation-examples')) }
|
124
|
-
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: nil) }
|
124
|
+
let(:options) { instance_double('RainforestCli::Options', test_folder: test_directory, token: nil, command: '') }
|
125
125
|
subject { described_class.new(options) }
|
126
126
|
|
127
127
|
it 'validates locally and tells the user to include a token to valid with server tests as well' do
|
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.6.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-06-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- lib/rainforest/cli.rb
|
165
165
|
- lib/rainforest/cli/constants.rb
|
166
166
|
- lib/rainforest/cli/csv_importer.rb
|
167
|
+
- lib/rainforest/cli/deleter.rb
|
167
168
|
- lib/rainforest/cli/exporter.rb
|
168
169
|
- lib/rainforest/cli/git_trigger.rb
|
169
170
|
- lib/rainforest/cli/http_client.rb
|
@@ -179,6 +180,7 @@ files:
|
|
179
180
|
- rainforest-cli.gemspec
|
180
181
|
- spec/cli_spec.rb
|
181
182
|
- spec/csv_importer_spec.rb
|
183
|
+
- spec/deleter_spec.rb
|
182
184
|
- spec/exporter_spec.rb
|
183
185
|
- spec/fixtures/variables.txt
|
184
186
|
- spec/git_trigger_spec.rb
|
@@ -239,6 +241,7 @@ summary: Command line utility for Rainforest QA
|
|
239
241
|
test_files:
|
240
242
|
- spec/cli_spec.rb
|
241
243
|
- spec/csv_importer_spec.rb
|
244
|
+
- spec/deleter_spec.rb
|
242
245
|
- spec/exporter_spec.rb
|
243
246
|
- spec/fixtures/variables.txt
|
244
247
|
- spec/git_trigger_spec.rb
|