rainforest-cli 0.0.13 → 0.0.14
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
- checksums.yaml.gz.sig +0 -0
- data/.travis.yml +1 -1
- data/README.md +2 -0
- data/certs/ukd1.pem +22 -0
- data/lib/rainforest/cli/options.rb +10 -1
- data/lib/rainforest/cli/version.rb +1 -1
- data/lib/rainforest/cli.rb +34 -5
- data/spec/cli_spec.rb +88 -0
- data/spec/options_spec.rb +10 -0
- data.tar.gz.sig +2 -1
- metadata +3 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f42f5204c7270c3eac865f11542df5a4018a95a
|
4
|
+
data.tar.gz: 4d3e1c7e16bbb265f6d1fb0f9f3602b8f48dc8e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39cac3328e88e9d2cc174c0386f135ff11d7cd52b012b0daea620733a3aab1e0f7f0ee02623c156e1a2eb8e69c55422426f2c3a2364aff7c84f447b9e583abc7
|
7
|
+
data.tar.gz: 9cd678e820f6dc9385a2db12b4d5d29ea58dbb50c590a48a055f4723bb734dc5ff9ab2b89046420b408f2aca2cb4196d3b93d19e5190067a6fd694fe55a76d6e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -36,6 +36,8 @@ The options are:
|
|
36
36
|
- `--conflict abort` - if you trigger rainforest more than once, anything running will be aborted and a fresh run started
|
37
37
|
- `--fail-fast` - fail the build as soon as the first failed result comes in. If you don't pass this it will wait until 100% of the run is done
|
38
38
|
- `--fg` - results in the foreground - this is what you want to make the build pass / fail dependent on rainforest results
|
39
|
+
- `--site-id` - only run tests for a specific site. Get in touch with us for help on getting that you site id if you are unable to.
|
40
|
+
- `--custom-url` - use a custom url for this run. Example use case: an ad-hoc QA environment with [Fourchette](https://github.com/rainforestapp/fourchette). You will need to specify a `site_id` too for this to work. Please note that we will be creating environments under the hood and will not affect your test permanently.
|
39
41
|
|
40
42
|
|
41
43
|
## Contributing
|
data/certs/ukd1.pem
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMR0wGwYDVQQDDBRydXNz
|
3
|
+
ZWxsLmhvd2FyZC5zbWl0aDESMBAGCgmSJomT8ixkARkWAm1lMRMwEQYKCZImiZPy
|
4
|
+
LGQBGRYDY29tMB4XDTE0MDgxNDA1Mzc0NloXDTE1MDgxNDA1Mzc0NlowSDEdMBsG
|
5
|
+
A1UEAwwUcnVzc2VsbC5ob3dhcmQuc21pdGgxEjAQBgoJkiaJk/IsZAEZFgJtZTET
|
6
|
+
MBEGCgmSJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
7
|
+
ggEBAKSK3Sfhs+miX1jdDywi9Khl1QjIn2DUM1U+bou6WLkQaOUtqhX/T2jHltQ9
|
8
|
+
Olc7jaz4XO5g+YngELX2tGFA6zbUnvaHXnPz23hPsP5TUErFAI1VJYl9fmQY6sEd
|
9
|
+
komCT8jZwB09Re20iyZtNsEMa8gagR7qX1wgPVqxAncE7OJ5stwHxcSQABfGrInF
|
10
|
+
sdZyjqNE2D0NxWZoWTC7CERaRNUm12y4NpHm6fdvtbgsB14WQjaqOYYUmFffT89Y
|
11
|
+
c0TOOGUV1aMbjpRUZFhu/tAaWGW+GfZnln9F3GWYJMRzC5k8+awB1vXgnfqZH007
|
12
|
+
ef85jyOutXfKKYyXcWlvrDMoTTUCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
13
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUFws4YIAtrBiQdbpWgqwcYd/+Hh4wJgYDVR0RBB8w
|
14
|
+
HYEbcnVzc2VsbC5ob3dhcmQuc21pdGhAbWUuY29tMCYGA1UdEgQfMB2BG3J1c3Nl
|
15
|
+
bGwuaG93YXJkLnNtaXRoQG1lLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEADHQJiURU
|
16
|
+
PJbfReV/MgIum917Vktz9Zv1GPzKzY5EkIL34FylaSernkITWe6GcsMb8yNrdG/1
|
17
|
+
eSyAvx32v/L3ef2mp7kHXbtzcXBq3xyCewfH6AfX3dm65CfgaeGx+qK/F/bl0iiZ
|
18
|
+
SQpNWk3RB/7deQThk3SYD8jS8n1d7KSRLogpXnSNWRyaSHtZ2x7T2qVpn4lp1PIi
|
19
|
+
/4Hg5bJrO0VqDlVG8UvsFbFB24ZNDQVq73MLZFNez0UBhOZVo4kBlSUvyEv5YLlA
|
20
|
+
wWdLLpBZZ1O4GE0uzQovmTiis4iyCF+8tFIgjbM/FVwKUBV6OZpxs4FOBtR1mK6L
|
21
|
+
lj0cPcKRm/FZUw==
|
22
|
+
-----END CERTIFICATE-----
|
@@ -10,7 +10,8 @@ module Rainforest
|
|
10
10
|
end
|
11
11
|
|
12
12
|
class OptionParser
|
13
|
-
attr_reader :command, :token, :tags, :conflict, :browsers, :
|
13
|
+
attr_reader :command, :token, :tags, :conflict, :browsers, :site_id,
|
14
|
+
:import_file_name, :import_name, :custom_url
|
14
15
|
|
15
16
|
VALID_BROWSERS = %w{chrome firefox safari ie8 ie9}.freeze
|
16
17
|
|
@@ -53,6 +54,14 @@ module Rainforest
|
|
53
54
|
opts.on("--conflict MODE", String, "How should Rainforest handle existing in progress runs?") do |value|
|
54
55
|
@conflict = value
|
55
56
|
end
|
57
|
+
|
58
|
+
opts.on("--site-id ID", Integer, "Only run tests for a specific site") do |value|
|
59
|
+
@site_id = value
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on("--custom-url URL", String, "Use a custom url for this run. You will need to specify a site_id too for this to work.") do |value|
|
63
|
+
@custom_url = value
|
64
|
+
end
|
56
65
|
end.parse!(@args)
|
57
66
|
|
58
67
|
@command = @args.shift
|
data/lib/rainforest/cli.rb
CHANGED
@@ -10,13 +10,18 @@ module Rainforest
|
|
10
10
|
|
11
11
|
def self.start(args)
|
12
12
|
@options = OptionParser.new(args)
|
13
|
-
|
13
|
+
|
14
|
+
if @options.custom_url && @options.site_id.nil?
|
15
|
+
puts "The site-id and custom-url options work together, you need both of them."
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
|
14
19
|
if @options.import_file_name && @options.import_name
|
15
20
|
unless File.exists?(@options.import_file_name)
|
16
21
|
puts "Input file: #{@options.import_file_name} not found"
|
17
22
|
exit 2
|
18
23
|
end
|
19
|
-
|
24
|
+
|
20
25
|
delete_generator(@options.import_name)
|
21
26
|
CSVImporter.new(@options.import_name, @options.import_file_name, @options.token).import
|
22
27
|
elsif @options.import_file_name || @options.import_name
|
@@ -33,8 +38,11 @@ module Rainforest
|
|
33
38
|
|
34
39
|
post_opts[:conflict] = @options.conflict if @options.conflict
|
35
40
|
post_opts[:browsers] = @options.browsers if @options.browsers
|
41
|
+
post_opts[:site_id] = @options.site_id if @options.site_id
|
36
42
|
post_opts[:gem_version] = Rainforest::Cli::VERSION
|
37
43
|
|
44
|
+
post_opts[:environment_id] = get_environment_id(@options.custom_url) if @options.custom_url
|
45
|
+
|
38
46
|
puts "Issuing run"
|
39
47
|
|
40
48
|
response = post(API_URL + '/runs', post_opts)
|
@@ -68,11 +76,11 @@ module Rainforest
|
|
68
76
|
end
|
69
77
|
true
|
70
78
|
end
|
71
|
-
|
79
|
+
|
72
80
|
def self.list_generators
|
73
81
|
get("#{API_URL}/generators")
|
74
82
|
end
|
75
|
-
|
83
|
+
|
76
84
|
def self.delete_generator(name)
|
77
85
|
generator = list_generators.find {|g| g['type'] == 'custom' && g['key'] == name }
|
78
86
|
delete("#{API_URL}/generators/#{generator['id']}") if generator
|
@@ -83,7 +91,7 @@ module Rainforest
|
|
83
91
|
body: body,
|
84
92
|
headers: {"CLIENT_TOKEN" => @options.token}
|
85
93
|
}
|
86
|
-
|
94
|
+
|
87
95
|
JSON.parse(response.body)
|
88
96
|
end
|
89
97
|
|
@@ -108,5 +116,26 @@ module Rainforest
|
|
108
116
|
nil
|
109
117
|
end
|
110
118
|
end
|
119
|
+
|
120
|
+
def self.get_environment_id url
|
121
|
+
begin
|
122
|
+
URI.parse(url)
|
123
|
+
rescue URI::InvalidURIError
|
124
|
+
puts "The custom URL is invalid"
|
125
|
+
exit 1
|
126
|
+
end
|
127
|
+
|
128
|
+
env_post_body = { name: 'temporary-env-for-custom-url-via-CLI', url: url }
|
129
|
+
environment = post("#{API_URL}/environments", env_post_body)
|
130
|
+
|
131
|
+
if environment['error']
|
132
|
+
# I am talking about a URL here because the environments are pretty
|
133
|
+
# much hidden from clients so far.
|
134
|
+
puts "Error creating the ad-hoc URL: #{environment['error']}"
|
135
|
+
exit 1
|
136
|
+
end
|
137
|
+
|
138
|
+
return environment['id']
|
139
|
+
end
|
111
140
|
end
|
112
141
|
end
|
data/spec/cli_spec.rb
CHANGED
@@ -1,12 +1,70 @@
|
|
1
1
|
describe Rainforest::Cli do
|
2
2
|
before do
|
3
3
|
Kernel.stub(:sleep)
|
4
|
+
stub_const("Rainforest::Cli::API_URL", 'http://app.rainforest.dev/api/1')
|
4
5
|
end
|
5
6
|
|
6
7
|
describe ".start" do
|
7
8
|
let(:valid_args) { %w(--token foo run --fg all) }
|
8
9
|
let(:ok_progress) { {"state" => "in_progress", "current_progress" => {"percent" => "1"} } }
|
9
10
|
|
11
|
+
context "with bad parameters" do
|
12
|
+
context "with custom-url with no site-id" do
|
13
|
+
it 'errors out' do
|
14
|
+
expect(STDOUT).to receive(:puts).with('The site-id and custom-url options work together, you need both of them.')
|
15
|
+
begin
|
16
|
+
described_class.start(%w(--custom-url http://ad-hoc.example.com))
|
17
|
+
rescue SystemExit => e
|
18
|
+
# That's fine, this is expected but tested in a differnet assertion
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'exits with exit code 1' do
|
23
|
+
expect {
|
24
|
+
described_class.start(%w(--custom-url http://ad-hoc.example.com))
|
25
|
+
}.to raise_error { |error|
|
26
|
+
expect(error).to be_a(SystemExit)
|
27
|
+
expect(error.status).to eq 1
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with site-id and custom-url" do
|
34
|
+
it "creates a new environment" do
|
35
|
+
allow(described_class).to receive(:post).and_return { exit }
|
36
|
+
expect(described_class).to receive(:post).with(
|
37
|
+
"http://app.rainforest.dev/api/1/environments",
|
38
|
+
{
|
39
|
+
:name => "temporary-env-for-custom-url-via-CLI",
|
40
|
+
:url=>"http://ad-hoc.example.com"
|
41
|
+
}
|
42
|
+
).and_return(
|
43
|
+
{ 'id' => 333 }
|
44
|
+
)
|
45
|
+
|
46
|
+
# This is a hack because when expecting a function to be called with
|
47
|
+
# parameters, the last call is compared but I want to compare the first
|
48
|
+
# call, not the call to create a run, so I exit, but rescue from it here
|
49
|
+
# so that the spec doesn't fail. It's horrible, sorry!
|
50
|
+
begin
|
51
|
+
described_class.start(%w(--site 3 --custom-url http://ad-hoc.example.com))
|
52
|
+
rescue SystemExit => e
|
53
|
+
# That's fine, this is expected but tested in a differnet assertion
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it "starts the run with site_id and environment_id" do
|
58
|
+
allow(described_class).to receive(:get_environment_id).and_return(333)
|
59
|
+
|
60
|
+
expect(described_class).to receive(:post).with(
|
61
|
+
"http://app.rainforest.dev/api/1/runs",
|
62
|
+
{ :tests=>[], :site_id=>3, :gem_version=>"0.0.13", :environment_id=>333 }
|
63
|
+
).and_return( {} )
|
64
|
+
described_class.start(%w(--site 3 --custom-url http://ad-hoc.example.com))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
10
68
|
context "a simple run" do
|
11
69
|
before do
|
12
70
|
described_class.stub(:post) { {"id" => 1} }
|
@@ -42,4 +100,34 @@ describe Rainforest::Cli do
|
|
42
100
|
end
|
43
101
|
end
|
44
102
|
end
|
103
|
+
|
104
|
+
describe ".get_environment_id" do
|
105
|
+
context "with an invalid URL" do
|
106
|
+
it 'errors out and exits' do
|
107
|
+
expect(STDOUT).to receive(:puts).with("The custom URL is invalid")
|
108
|
+
expect {
|
109
|
+
described_class.get_environment_id('http://some=weird')
|
110
|
+
}.to raise_error { |error|
|
111
|
+
expect(error).to be_a(SystemExit)
|
112
|
+
expect(error.status).to eq 1
|
113
|
+
}
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'on API error' do
|
118
|
+
before do
|
119
|
+
allow(described_class).to receive(:post).and_return( {"error"=>"Some API error"} )
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'errors out and exits' do
|
123
|
+
expect(STDOUT).to receive(:puts).with("Error creating the ad-hoc URL: Some API error")
|
124
|
+
expect {
|
125
|
+
described_class.get_environment_id('http://example.com')
|
126
|
+
}.to raise_error { |error|
|
127
|
+
expect(error).to be_a(SystemExit)
|
128
|
+
expect(error.status).to eq 1
|
129
|
+
}
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
45
133
|
end
|
data/spec/options_spec.rb
CHANGED
@@ -61,4 +61,14 @@ describe Rainforest::Cli::OptionParser do
|
|
61
61
|
let(:args) { ["run", "--fail-fast"] }
|
62
62
|
its(:failfast?) { should be_true }
|
63
63
|
end
|
64
|
+
|
65
|
+
context "it parses the site-id flag" do
|
66
|
+
let(:args) { ["run", "--site-id", '3'] }
|
67
|
+
its(:site_id) { should eq 3 }
|
68
|
+
end
|
69
|
+
|
70
|
+
context "it parses the custom-url flag" do
|
71
|
+
let(:args) { ["run", "--custom-url", 'http://ad-hoc.example.com'] }
|
72
|
+
its(:custom_url) { should eq 'http://ad-hoc.example.com' }
|
73
|
+
end
|
64
74
|
end
|
data.tar.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
Z��K�i�
|
2
|
+
�P3�W�wl������Yj����ߌR�
|
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: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Mathieu
|
@@ -32,7 +32,7 @@ cert_chain:
|
|
32
32
|
wWdLLpBZZ1O4GE0uzQovmTiis4iyCF+8tFIgjbM/FVwKUBV6OZpxs4FOBtR1mK6L
|
33
33
|
lj0cPcKRm/FZUw==
|
34
34
|
-----END CERTIFICATE-----
|
35
|
-
date: 2014-08
|
35
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
36
36
|
dependencies:
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: httparty
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- README.md
|
124
124
|
- Rakefile
|
125
125
|
- bin/rainforest
|
126
|
+
- certs/ukd1.pem
|
126
127
|
- lib/rainforest/cli.rb
|
127
128
|
- lib/rainforest/cli/csv_importer.rb
|
128
129
|
- lib/rainforest/cli/options.rb
|
metadata.gz.sig
CHANGED
Binary file
|