big_ml 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +1 -1
- data/.rvmrc.example +1 -1
- data/.travis.yml +1 -1
- data/README.md +6 -5
- data/lib/big_ml.rb +5 -0
- data/lib/big_ml/base.rb +31 -0
- data/lib/big_ml/batch_prediction.rb +39 -0
- data/lib/big_ml/ensemble.rb +32 -0
- data/lib/big_ml/evaluation.rb +31 -0
- data/lib/big_ml/prediction.rb +2 -2
- data/lib/big_ml/util/client.rb +1 -0
- data/lib/big_ml/util/config.rb +4 -1
- data/lib/big_ml/util/request.rb +9 -4
- data/lib/big_ml/version.rb +1 -1
- data/spec/integration/dataset_spec.rb +21 -23
- data/spec/integration/ensemble_spec.rb +73 -0
- data/spec/integration/evaluation_spec.rb +64 -0
- data/spec/integration/model_spec.rb +23 -25
- data/spec/integration/prediction_spec.rb +20 -22
- data/spec/integration/source_spec.rb +22 -24
- data/spec/spec_helper.rb +4 -3
- data/spec/units/client_spec.rb +58 -26
- data/spec/units/source_spec.rb +3 -3
- data/spec/vcr_cassettes/BigML_Dataset/one_dataset/can_be_converted_in_a_model.yml +180 -99
- data/spec/vcr_cassettes/BigML_Dataset/one_dataset/must_be_able_to_be_find_using_the_reference.yml +144 -163
- data/spec/vcr_cassettes/BigML_Ensemble/no_ensemble/_all/must_be_empty.yml +223 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/can_be_converted_in_a_prediction.yml +1074 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/must_be_able_to_be_deleted_using_the_destroy_method.yml +1082 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/must_be_able_to_be_find_using_the_reference.yml +734 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/must_be_able_to_remove_the_ensemble.yml +1215 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/must_be_able_to_set_number_of_models.yml +853 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/must_be_able_to_update_the_name.yml +1226 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/must_be_able_to_update_the_name_from_the_instance.yml +1226 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/must_have_only_one_item.yml +686 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/must_have_the_same_size.yml +732 -0
- data/spec/vcr_cassettes/BigML_Ensemble/one_ensemble/was_created_successfully.yml +495 -0
- data/spec/vcr_cassettes/BigML_Evaluation/no_evaluation/_all/must_be_empty.yml +600 -0
- data/spec/vcr_cassettes/BigML_Evaluation/one_evaluation/must_be_able_to_be_deleted_using_the_destroy_method.yml +1127 -0
- data/spec/vcr_cassettes/BigML_Evaluation/one_evaluation/must_be_able_to_be_find_using_the_reference.yml +1151 -0
- data/spec/vcr_cassettes/BigML_Evaluation/one_evaluation/must_be_able_to_remove_the_evaluation.yml +1203 -0
- data/spec/vcr_cassettes/BigML_Evaluation/one_evaluation/must_be_able_to_update_the_name.yml +1374 -0
- data/spec/vcr_cassettes/BigML_Evaluation/one_evaluation/must_be_able_to_update_the_name_from_the_instance.yml +1373 -0
- data/spec/vcr_cassettes/BigML_Evaluation/one_evaluation/must_have_only_one_item.yml +1103 -0
- data/spec/vcr_cassettes/BigML_Evaluation/one_evaluation/must_have_the_same_name.yml +1108 -0
- data/spec/vcr_cassettes/BigML_Evaluation/one_evaluation/was_created_successfully.yml +922 -0
- data/spec/vcr_cassettes/BigML_Model/one_model/must_be_able_to_be_find_using_the_reference.yml +269 -282
- data/spec/vcr_cassettes/BigML_Prediction/one_prediction/must_be_able_to_be_find_using_the_reference.yml +360 -312
- data/spec/vcr_cassettes/BigML_Source/one_source/must_be_able_to_be_find_using_the_reference.yml +75 -72
- data/spec/vcr_cassettes/BigML_Util_Client/response_handling/debug_mode/raises_on_bad_request.yml +38 -0
- data/spec/vcr_cassettes/BigML_Util_Client/response_handling/normal_mode/does_not_raise_on_bad_request.yml +38 -0
- metadata +74 -43
@@ -0,0 +1,64 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BigML::Evaluation, :vcr do
|
4
|
+
|
5
|
+
before do
|
6
|
+
BigML::Source.delete_all
|
7
|
+
BigML::Dataset.delete_all
|
8
|
+
BigML::Model.delete_all
|
9
|
+
BigML::Evaluation.delete_all
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "no evaluation" do
|
13
|
+
describe ".all" do
|
14
|
+
it "must be empty" do
|
15
|
+
expect(BigML::Evaluation.all).to eq([])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "one evaluation" do
|
21
|
+
let(:source) { BigML::Source.create 'spec/fixtures/iris.csv' }
|
22
|
+
let(:dataset) { BigML::Dataset.create source.wait_for_ready.resource }
|
23
|
+
let(:model) { BigML::Model.create dataset.wait_for_ready.resource }
|
24
|
+
let!(:evaluation) { BigML::Evaluation.create model.wait_for_ready.resource, dataset.wait_for_ready.resource }
|
25
|
+
|
26
|
+
it "was created successfully" do
|
27
|
+
expect(evaluation.code).to eq(201)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "must have only one item" do
|
31
|
+
expect(BigML::Evaluation.all.length).to eq(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must have the same name" do
|
35
|
+
expect(BigML::Evaluation.all.first.name).to match(/^Evaluation of iris/)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "must be able to be find using the reference" do
|
39
|
+
expect(BigML::Evaluation.find(evaluation.id).id).to eq(evaluation.id)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "must be able to update the name" do
|
43
|
+
expect(BigML::Evaluation.update(evaluation.wait_for_ready.id, { :name => 'foo name' }).code).to eq(202)
|
44
|
+
expect(BigML::Evaluation.find(evaluation.id).name).to eq('foo name')
|
45
|
+
end
|
46
|
+
|
47
|
+
it "must be able to update the name from the instance" do
|
48
|
+
expect(evaluation.wait_for_ready.update(name: 'foo name').code).to eq(202)
|
49
|
+
expect(BigML::Evaluation.find(evaluation.id).name).to eq('foo name')
|
50
|
+
end
|
51
|
+
|
52
|
+
it "must be able to remove the evaluation" do
|
53
|
+
BigML::Evaluation.delete evaluation.id
|
54
|
+
expect(BigML::Evaluation.find evaluation.id).to be_nil
|
55
|
+
expect(BigML::Evaluation.all.length).to eq(0)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "must be able to be deleted using the destroy method" do
|
59
|
+
evaluation_id = evaluation.id
|
60
|
+
evaluation.destroy
|
61
|
+
expect(BigML::Evaluation.find evaluation_id).to be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe BigML::Model, :vcr do
|
4
4
|
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
BigML::Source.delete_all
|
7
7
|
BigML::Dataset.delete_all
|
8
8
|
BigML::Model.delete_all
|
@@ -11,60 +11,58 @@ describe BigML::Model, :vcr do
|
|
11
11
|
describe "no model" do
|
12
12
|
describe ".all" do
|
13
13
|
it "must be empty" do
|
14
|
-
BigML::Model.all.
|
14
|
+
expect(BigML::Model.all).to eq([])
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "one model" do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@model = BigML::Model.create(@dataset.resource)
|
24
|
-
end
|
20
|
+
let(:source) { BigML::Source.create 'spec/fixtures/iris.csv' }
|
21
|
+
let(:dataset) { BigML::Dataset.create source.resource }
|
22
|
+
let(:model) { BigML::Model.create dataset.resource }
|
25
23
|
|
26
24
|
it "was created successfully" do
|
27
|
-
|
25
|
+
expect(model.code).to eq(201)
|
28
26
|
end
|
29
27
|
|
30
|
-
it "must have only one item" do
|
31
|
-
BigML::Model.all.
|
28
|
+
it "must have only one item" do
|
29
|
+
expect(BigML::Model.all.length).to eq(1)
|
32
30
|
end
|
33
31
|
|
34
32
|
it "must have the same size" do
|
35
|
-
BigML::Model.all.first.size.
|
33
|
+
expect(BigML::Model.all.first.size).to eq(4608)
|
36
34
|
end
|
37
35
|
|
38
36
|
it "must be able to be find using the reference" do
|
39
|
-
BigML::Model.find(
|
37
|
+
expect(BigML::Model.find(model.id).id).to eq(model.id)
|
40
38
|
end
|
41
39
|
|
42
40
|
it "must be able to update the name" do
|
43
|
-
BigML::Model.update(
|
44
|
-
BigML::Model.find(
|
41
|
+
expect(BigML::Model.update(model.id, { name: 'foo name' }).code).to eq(202)
|
42
|
+
expect(BigML::Model.find(model.id).name).to eq('foo name')
|
45
43
|
end
|
46
44
|
|
47
45
|
it "must be able to update the name from the instance" do
|
48
|
-
|
49
|
-
BigML::Model.find(
|
46
|
+
expect(model.update(name: 'foo name').code).to eq(202)
|
47
|
+
expect(BigML::Model.find(model.id).name).to eq('foo name')
|
50
48
|
end
|
51
49
|
|
52
50
|
it "must be able to remove the model" do
|
53
|
-
BigML::Model.delete
|
54
|
-
BigML::Model.find
|
55
|
-
BigML::Model.all.
|
51
|
+
BigML::Model.delete model.id
|
52
|
+
expect(BigML::Model.find model.id).to be_nil
|
53
|
+
expect(BigML::Model.all.length).to eq(0)
|
56
54
|
end
|
57
55
|
|
58
56
|
it "must be able to be deleted using the destroy method" do
|
59
|
-
model_id =
|
60
|
-
|
61
|
-
BigML::Model.find
|
57
|
+
model_id = model.id
|
58
|
+
model.destroy
|
59
|
+
expect(BigML::Model.find model_id).to be_nil
|
62
60
|
end
|
63
61
|
|
64
62
|
it "can be converted in a prediction" do
|
65
|
-
prediction =
|
66
|
-
prediction.
|
67
|
-
prediction.code.
|
63
|
+
prediction = model.to_prediction(input_data: { "000001" => 3 })
|
64
|
+
expect(prediction).to be_instance_of(BigML::Prediction)
|
65
|
+
expect(prediction.code).to eq(201)
|
68
66
|
end
|
69
67
|
end
|
70
68
|
end
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe BigML::Prediction, :vcr do
|
4
4
|
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
BigML::Source.delete_all
|
7
7
|
BigML::Dataset.delete_all
|
8
8
|
BigML::Model.delete_all
|
@@ -12,55 +12,53 @@ describe BigML::Prediction, :vcr do
|
|
12
12
|
describe "no prediction" do
|
13
13
|
describe ".all" do
|
14
14
|
it "must be empty" do
|
15
|
-
BigML::Prediction.all.
|
15
|
+
expect(BigML::Prediction.all).to eq([])
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "one prediction" do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@prediction = BigML::Prediction.create(@model.resource, { :input_data => { "000001" => 3 }})
|
26
|
-
end
|
21
|
+
let(:source) { BigML::Source.create 'spec/fixtures/iris.csv' }
|
22
|
+
let(:dataset) { BigML::Dataset.create source.resource }
|
23
|
+
let(:model) { BigML::Model.create dataset.resource }
|
24
|
+
let(:prediction) { BigML::Prediction.create model.resource, { input_data: { "000001" => 3 }} }
|
27
25
|
|
28
26
|
it "was created successfully" do
|
29
|
-
|
27
|
+
expect(prediction.code).to eq(201)
|
30
28
|
end
|
31
29
|
|
32
30
|
it "must have only one item" do
|
33
|
-
BigML::Prediction.all.
|
31
|
+
expect(BigML::Prediction.all.length).to eq(1)
|
34
32
|
end
|
35
33
|
|
36
34
|
it "must have the same name" do
|
37
|
-
BigML::Prediction.all.first.name.
|
35
|
+
expect(BigML::Prediction.all.first.name).to eq("Prediction for species")
|
38
36
|
end
|
39
37
|
|
40
38
|
it "must be able to be find using the reference" do
|
41
|
-
BigML::Prediction.find(
|
39
|
+
expect(BigML::Prediction.find(prediction.id).id).to eq(prediction.id)
|
42
40
|
end
|
43
41
|
|
44
42
|
it "must be able to update the name" do
|
45
|
-
BigML::Prediction.update(
|
46
|
-
BigML::Prediction.find(
|
43
|
+
expect(BigML::Prediction.update(prediction.id, { :name => 'foo name' }).code).to eq(202)
|
44
|
+
expect(BigML::Prediction.find(prediction.id).name).to eq('foo name')
|
47
45
|
end
|
48
46
|
|
49
47
|
it "must be able to update the name from the instance" do
|
50
|
-
|
51
|
-
BigML::Prediction.find(
|
48
|
+
expect(prediction.update(name: 'foo name').code).to eq(202)
|
49
|
+
expect(BigML::Prediction.find(prediction.id).name).to eq('foo name')
|
52
50
|
end
|
53
51
|
|
54
52
|
it "must be able to remove the prediction" do
|
55
|
-
BigML::Prediction.delete
|
56
|
-
BigML::Prediction.find
|
57
|
-
BigML::Prediction.all.
|
53
|
+
BigML::Prediction.delete prediction.id
|
54
|
+
expect(BigML::Prediction.find prediction.id).to be_nil
|
55
|
+
expect(BigML::Prediction.all.length).to eq(0)
|
58
56
|
end
|
59
57
|
|
60
58
|
it "must be able to be deleted using the destroy method" do
|
61
|
-
prediction_id =
|
62
|
-
|
63
|
-
BigML::Prediction.find
|
59
|
+
prediction_id = prediction.id
|
60
|
+
prediction.destroy
|
61
|
+
expect(BigML::Prediction.find prediction_id).to be_nil
|
64
62
|
end
|
65
63
|
end
|
66
64
|
end
|
@@ -2,67 +2,65 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe BigML::Source, :vcr do
|
4
4
|
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
BigML::Source.delete_all
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "no source" do
|
10
10
|
describe ".all" do
|
11
11
|
it "must be empty" do
|
12
|
-
BigML::Source.all.
|
12
|
+
expect(BigML::Source.all).to eq([])
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "one source" do
|
18
|
-
|
19
|
-
@source = BigML::Source.create("spec/fixtures/iris.csv")
|
20
|
-
end
|
18
|
+
let(:source) { BigML::Source.create 'spec/fixtures/iris.csv' }
|
21
19
|
|
22
20
|
it "was created successfully" do
|
23
|
-
|
21
|
+
expect(source.code).to eq(201)
|
24
22
|
end
|
25
23
|
|
26
24
|
it "must have only one item" do
|
27
|
-
BigML::Source.all.
|
25
|
+
expect(BigML::Source.all.length).to eq(1)
|
28
26
|
end
|
29
27
|
|
30
28
|
it "must have the same file_name" do
|
31
|
-
BigML::Source.all.first.file_name.
|
29
|
+
expect(BigML::Source.all.first.file_name).to eq("iris.csv")
|
32
30
|
end
|
33
31
|
|
34
32
|
it "must be able to be find using the reference" do
|
35
|
-
BigML::Source.find(
|
33
|
+
expect(BigML::Source.find(source.id).id).to eq(source.id)
|
36
34
|
end
|
37
35
|
|
38
36
|
it "must be able to update the name" do
|
39
|
-
BigML::Source.find(
|
40
|
-
BigML::Source.update(
|
41
|
-
BigML::Source.find(
|
37
|
+
expect(BigML::Source.find(source.id).name).to eq('iris.csv')
|
38
|
+
expect(BigML::Source.update(source.id, { name: 'new name' }).code).to eq(202)
|
39
|
+
expect(BigML::Source.find(source.id).name).to eq('new name')
|
42
40
|
end
|
43
41
|
|
44
42
|
it "must be able to update the name from the instance" do
|
45
|
-
BigML::Source.find(
|
46
|
-
|
47
|
-
BigML::Source.find(
|
43
|
+
expect(BigML::Source.find(source.id).name).to eq('iris.csv')
|
44
|
+
expect(source.update(name: 'new name').code).to eq(202)
|
45
|
+
expect(BigML::Source.find(source.id).name).to eq('new name')
|
48
46
|
end
|
49
47
|
|
50
48
|
it "must be able to remove the source" do
|
51
|
-
BigML::Source.delete
|
52
|
-
BigML::Source.find
|
53
|
-
BigML::Source.all.
|
49
|
+
BigML::Source.delete source.id
|
50
|
+
expect(BigML::Source.find source.id).to be_nil
|
51
|
+
expect(BigML::Source.all.length).to eq(0)
|
54
52
|
end
|
55
53
|
|
56
54
|
it "must be able to be deleted using the destroy method" do
|
57
|
-
source_id =
|
58
|
-
|
59
|
-
BigML::Source.find
|
55
|
+
source_id = source.id
|
56
|
+
source.destroy
|
57
|
+
expect(BigML::Source.find source_id).to be_nil
|
60
58
|
end
|
61
59
|
|
62
60
|
it "can be converted in a dataset" do
|
63
|
-
dataset =
|
64
|
-
dataset.
|
65
|
-
dataset.code.
|
61
|
+
dataset = source.to_dataset
|
62
|
+
expect(dataset).to be_instance_of(BigML::Dataset)
|
63
|
+
expect(dataset.code).to eq(201)
|
66
64
|
end
|
67
65
|
end
|
68
66
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,7 +16,8 @@ VCR.configure do |c|
|
|
16
16
|
c.filter_sensitive_data('<API_KEY>') { BigML.api_key }
|
17
17
|
end
|
18
18
|
|
19
|
-
RSpec.configure do |
|
20
|
-
|
21
|
-
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.expect_with :rspec do |c|
|
21
|
+
c.syntax = :expect
|
22
|
+
end
|
22
23
|
end
|
data/spec/units/client_spec.rb
CHANGED
@@ -1,81 +1,113 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BigML::Util::Client do
|
4
|
-
let(:keys) {
|
5
|
-
BigML::Util::Config::VALID_OPTIONS_KEYS
|
6
|
-
}
|
4
|
+
let(:keys) { BigML::Util::Config::VALID_OPTIONS_KEYS }
|
7
5
|
|
8
6
|
context "module configuration" do
|
9
|
-
before
|
7
|
+
before do
|
10
8
|
BigML.configure do |config|
|
11
9
|
keys.each { |key| config.send("#{key}=", key) }
|
12
10
|
end
|
13
|
-
|
11
|
+
end
|
14
12
|
|
15
13
|
it "should inherit module configuration" do
|
16
14
|
api = BigML::Util::Client.new
|
17
|
-
keys.each { |key| api.send(key).
|
15
|
+
keys.each { |key| expect(api.send(key)).to eq(key) }
|
18
16
|
end
|
19
17
|
end
|
20
18
|
|
21
19
|
context "class configuration" do
|
22
|
-
let(:config)
|
20
|
+
let(:config) do
|
23
21
|
{
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
22
|
+
username: 'user',
|
23
|
+
api_key: 'secret',
|
24
|
+
dev_mode: true,
|
25
|
+
debug: false
|
27
26
|
}
|
28
|
-
|
27
|
+
end
|
29
28
|
|
30
29
|
context "during initialization" do
|
31
30
|
it "should override module configuration" do
|
32
31
|
api = BigML::Util::Client.new(config)
|
33
|
-
keys.each { |key| api.send(key).
|
32
|
+
keys.each { |key| expect(api.send(key)).to eq(config[key]) }
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
36
|
context "after initilization" do
|
38
|
-
before
|
37
|
+
before do
|
39
38
|
BigML.configure do |config|
|
40
39
|
keys.each { |key| config.send("#{key}=", key) }
|
41
40
|
end
|
42
|
-
|
41
|
+
end
|
43
42
|
|
44
43
|
it "should override module configuration" do
|
45
44
|
api = BigML::Util::Client.new
|
46
45
|
config.each { |key, value| api.send("#{key}=", value) }
|
47
|
-
keys.each { |key| api.send(key).
|
46
|
+
keys.each { |key| expect(api.send(key)).to eq(config[key]) }
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
51
|
context "reset module configuration" do
|
53
|
-
let(:api) {
|
54
|
-
BigML::Util::Client.new
|
55
|
-
}
|
52
|
+
let(:api) { BigML::Util::Client.new }
|
56
53
|
|
57
|
-
before
|
54
|
+
before do
|
58
55
|
BigML.reset
|
59
|
-
|
56
|
+
end
|
60
57
|
|
61
58
|
it "sets default username to nil" do
|
62
|
-
api.username.
|
59
|
+
expect(api.username).to be_nil
|
63
60
|
end
|
64
61
|
|
65
62
|
it "sets default api key to nil" do
|
66
|
-
api.api_key.
|
63
|
+
expect(api.api_key).to be_nil
|
67
64
|
end
|
68
65
|
end
|
69
66
|
|
70
|
-
context "
|
67
|
+
context "environment mode" do
|
71
68
|
it "uses production mode as default" do
|
72
|
-
BigML::Util::Client.base_uri.
|
69
|
+
expect(BigML::Util::Client.base_uri).to eq(BigML::Util::Config::BIGML_PROD_ENDPOINT)
|
73
70
|
end
|
74
71
|
|
75
72
|
it "uses development when dev_mode is enabled" do
|
76
|
-
BigML::Util::Client.new({:
|
77
|
-
BigML::Util::Client.base_uri.
|
73
|
+
BigML::Util::Client.new({ dev_mode: true })
|
74
|
+
expect(BigML::Util::Client.base_uri).to eq(BigML::Util::Config::BIGML_DEV_ENDPOINT)
|
78
75
|
end
|
79
76
|
end
|
80
77
|
|
78
|
+
context 'response handling', :vcr do
|
79
|
+
let(:client) { BigML::Util::Client.new config }
|
80
|
+
let(:base_config) do
|
81
|
+
{
|
82
|
+
username: 'bad',
|
83
|
+
api_key: 'auth',
|
84
|
+
dev_mode: true,
|
85
|
+
}
|
86
|
+
end
|
87
|
+
let(:resource) { BigML::Source }
|
88
|
+
|
89
|
+
before do
|
90
|
+
resource.instance_variable_set :@client, client
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'debug mode' do
|
94
|
+
let(:config) { base_config.merge debug: true}
|
95
|
+
|
96
|
+
it 'raises on bad request' do
|
97
|
+
expect{resource.create 'spec/fixtures/iris.csv'}.to raise_error(BigML::UnsuccessfulRequestError, /unauthorized/i)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'normal mode' do
|
102
|
+
let(:config) { base_config.merge debug: false}
|
103
|
+
|
104
|
+
it 'does not raise on bad request' do
|
105
|
+
expect{resource.create 'spec/fixtures/iris.csv'}.not_to raise_error
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
after do
|
110
|
+
resource.instance_variable_set :@client, nil
|
111
|
+
end
|
112
|
+
end
|
81
113
|
end
|