fulcrum 0.1.2
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.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +123 -0
- data/Rakefile +8 -0
- data/fulcrum.gemspec +27 -0
- data/lib/fulcrum.rb +13 -0
- data/lib/fulcrum/api.rb +95 -0
- data/lib/fulcrum/choice_list.rb +38 -0
- data/lib/fulcrum/classification_set.rb +39 -0
- data/lib/fulcrum/form.rb +39 -0
- data/lib/fulcrum/member.rb +16 -0
- data/lib/fulcrum/photo.rb +36 -0
- data/lib/fulcrum/record.rb +38 -0
- data/lib/fulcrum/validators/base_validator.rb +31 -0
- data/lib/fulcrum/validators/choice_list_validator.rb +30 -0
- data/lib/fulcrum/validators/classification_set_validator.rb +38 -0
- data/lib/fulcrum/validators/form_validator.rb +150 -0
- data/lib/fulcrum/validators/record_validator.rb +18 -0
- data/lib/fulcrum/version.rb +3 -0
- data/spec/data/form_data.json +175 -0
- data/spec/data/test.jpg +0 -0
- data/spec/lib/api_spec.rb +39 -0
- data/spec/lib/choice_list_spec.rb +120 -0
- data/spec/lib/classification_set_spec.rb +119 -0
- data/spec/lib/form_spec.rb +120 -0
- data/spec/lib/member_spec.rb +52 -0
- data/spec/lib/photo_spec.rb +94 -0
- data/spec/lib/record_spec.rb +120 -0
- data/spec/lib/validators/choice_list_validator_spec.rb +73 -0
- data/spec/lib/validators/classification_set_validator_spec.rb +88 -0
- data/spec/lib/validators/form_validator_spec.rb +4 -0
- data/spec/lib/validators/record_validator_spec.rb +53 -0
- data/spec/spec_helper.rb +5 -0
- metadata +182 -0
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fulcrum::Photo do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
Fulcrum::Api.configure do |config|
|
7
|
+
config.uri = 'http://foo.bar/api/v2'
|
8
|
+
config.key = 'foobar'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'successful requests' do
|
13
|
+
context '#retrieve' do
|
14
|
+
it 'should retrieve the specified photo' do
|
15
|
+
photo_id = 'abc'
|
16
|
+
stub_request(:get, "#{Fulcrum::Api.configuration.uri}/photos/#{photo_id}.jpg").to_return(:status => 200)
|
17
|
+
Fulcrum::Photo.find('abc', format: 'jpg')
|
18
|
+
Fulcrum::Photo.response.status.should eq(200)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context '#create' do
|
23
|
+
it 'should create a new photo and return status 201' do
|
24
|
+
stub_request(:post, "#{Fulcrum::Api.configuration.uri}/photos.json").to_return(:status => 201)
|
25
|
+
pic = File.join(File.dirname(__FILE__), '..', 'data', 'test.jpg')
|
26
|
+
Fulcrum::Photo.create(pic, 'image/*', 'abc', '')
|
27
|
+
Fulcrum::Photo.response.status.should eq(201)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context '#thumbnail' do
|
32
|
+
it 'should retrieve the photo thumbnail and return status 200' do
|
33
|
+
photo_id = 'abc'
|
34
|
+
stub_request(:get, "#{Fulcrum::Api.configuration.uri}/photos/#{photo_id}/thumbnail.jpg").to_return(:status => 200)
|
35
|
+
r = Fulcrum::Photo.thumbnail(photo_id)
|
36
|
+
Fulcrum::Photo.response.status.should eq(200)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context '#delete' do
|
41
|
+
it 'should delete the photo and return status 200' do
|
42
|
+
photo_id = 'abc'
|
43
|
+
stub_request(:delete, "#{Fulcrum::Api.configuration.uri}/photos/#{photo_id}.json").to_return(:status => 200, :body => '{"photo":{}}')
|
44
|
+
r = Fulcrum::Photo.delete(photo_id)
|
45
|
+
Fulcrum::Photo.response.status.should eq(200)
|
46
|
+
r = JSON.parse(r)
|
47
|
+
r.keys.should include('photo')
|
48
|
+
r['photo'].should be_a(Hash)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'unsuccessful requests' do
|
54
|
+
context '#retrieve' do
|
55
|
+
it 'should receive 404' do
|
56
|
+
photo_id = 'abc'
|
57
|
+
stub_request(:get, "#{Fulcrum::Api.configuration.uri}/photos/#{photo_id}.jpg").to_return(:status => 404)
|
58
|
+
p = Fulcrum::Photo.find(photo_id, format: 'jpg')
|
59
|
+
p.keys.should include(:error)
|
60
|
+
p[:error][:status].should eq(404)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context '#create' do
|
65
|
+
it 'should receive a 422 response' do
|
66
|
+
stub_request(:post, "#{Fulcrum::Api.configuration.uri}/photos.json").to_return(:status => 422)
|
67
|
+
pic = File.join(File.dirname(__FILE__), '..', 'data', 'test.jpg')
|
68
|
+
p = Fulcrum::Photo.create(pic, 'image/*', 'abc', '')
|
69
|
+
p.keys.should include(:error)
|
70
|
+
p[:error][:status].should eq(422)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context '#thumbnail' do
|
75
|
+
it 'should receive a 422 response' do
|
76
|
+
photo_id = 'abc'
|
77
|
+
stub_request(:get, "#{Fulcrum::Api.configuration.uri}/photos/#{photo_id}/thumbnail.jpg").to_return(:status => 404)
|
78
|
+
p = Fulcrum::Photo.thumbnail(photo_id)
|
79
|
+
p.keys.should include(:error)
|
80
|
+
p[:error][:status].should eq(404)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context '#delete' do
|
85
|
+
it 'should receive a 404 response' do
|
86
|
+
photo_id = 'abc'
|
87
|
+
stub_request(:delete, "#{Fulcrum::Api.configuration.uri}/photos/#{photo_id}.json").to_return(:status => 404)
|
88
|
+
p = Fulcrum::Photo.delete(photo_id)
|
89
|
+
p.keys.should include(:error)
|
90
|
+
p[:error][:status].should eq(404)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fulcrum::Record do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
Fulcrum::Api.configure do |config|
|
7
|
+
config.uri = 'http://foo.bar/api/v2'
|
8
|
+
config.key = 'foobar'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'successful requests' do
|
13
|
+
context '#all' do
|
14
|
+
it 'should retrieve all records' do
|
15
|
+
stub_request(:get, "#{Fulcrum::Api.configuration.uri}/records.json").to_return(:status => 200, :body => '{"current_page":1,"total_pages":1,"total_count":1,"per_page":50,"records":[]}')
|
16
|
+
records = Fulcrum::Record.all
|
17
|
+
Fulcrum::Record.response.status.should eq(200)
|
18
|
+
records = JSON.parse(records)
|
19
|
+
records.keys.should include('current_page')
|
20
|
+
records.keys.should include('total_pages')
|
21
|
+
records.keys.should include('total_count')
|
22
|
+
records.keys.should include('per_page')
|
23
|
+
records.keys.should include('records')
|
24
|
+
records['records'].should be_a(Array)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context '#retrieve' do
|
29
|
+
it 'should retrieve the specified record' do
|
30
|
+
record_id = 'abc'
|
31
|
+
stub_request(:get, "#{Fulcrum::Api.configuration.uri}/records/#{record_id}.json").to_return(:status => 200, :body => '{"record":{}}')
|
32
|
+
r = Fulcrum::Record.find('abc')
|
33
|
+
Fulcrum::Record.response.status.should eq(200)
|
34
|
+
r = JSON.parse(r)
|
35
|
+
r.keys.should include('record')
|
36
|
+
r['record'].should be_a(Hash)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context '#create' do
|
41
|
+
it 'should create a new record and return status 201' do
|
42
|
+
stub_request(:post, "#{Fulcrum::Api.configuration.uri}/records.json").to_return(:status => 201, :body => '{"record":{}}')
|
43
|
+
Fulcrum::RecordValidator.any_instance.stub(:validate!).and_return(true)
|
44
|
+
r = Fulcrum::Record.create({})
|
45
|
+
Fulcrum::Record.response.status.should eq(201)
|
46
|
+
r = JSON.parse(r)
|
47
|
+
r.keys.should include('record')
|
48
|
+
r['record'].should be_a(Hash)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context '#update' do
|
53
|
+
it 'should update the record and return status 200' do
|
54
|
+
record_id = 'abc'
|
55
|
+
stub_request(:put, "#{Fulcrum::Api.configuration.uri}/records/#{record_id}.json").to_return(:status => 200, :body => '{"record":{}}')
|
56
|
+
Fulcrum::RecordValidator.any_instance.stub(:validate!).and_return(true)
|
57
|
+
r = Fulcrum::Record.update(record_id, {})
|
58
|
+
Fulcrum::Record.response.status.should eq(200)
|
59
|
+
r = JSON.parse(r)
|
60
|
+
r.keys.should include('record')
|
61
|
+
r['record'].should be_a(Hash)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context '#delete' do
|
66
|
+
it 'should delete the record and return status 200' do
|
67
|
+
record_id = 'abc'
|
68
|
+
stub_request(:delete, "#{Fulcrum::Api.configuration.uri}/records/#{record_id}.json").to_return(:status => 200, :body => '{"record":{}}')
|
69
|
+
r = Fulcrum::Record.delete(record_id)
|
70
|
+
Fulcrum::Record.response.status.should eq(200)
|
71
|
+
r = JSON.parse(r)
|
72
|
+
r.keys.should include('record')
|
73
|
+
r['record'].should be_a(Hash)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'unsuccessful requests' do
|
79
|
+
context '#retrieve' do
|
80
|
+
it 'should receive 404' do
|
81
|
+
record_id = 'abc'
|
82
|
+
stub_request(:get, "#{Fulcrum::Api.configuration.uri}/records/#{record_id}.json").to_return(:status => 404)
|
83
|
+
r = Fulcrum::Record.find(record_id)
|
84
|
+
r.keys.should include(:error)
|
85
|
+
r[:error][:status].should eq(404)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context '#create' do
|
90
|
+
it 'should receive a 422 response' do
|
91
|
+
stub_request(:post, "#{Fulcrum::Api.configuration.uri}/records.json").to_return(:status => 422)
|
92
|
+
Fulcrum::RecordValidator.any_instance.stub(:validate!).and_return(true)
|
93
|
+
r = Fulcrum::Record.create({})
|
94
|
+
r.keys.should include(:error)
|
95
|
+
r[:error][:status].should eq(422)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context '#update' do
|
100
|
+
it 'should receive a 422 response' do
|
101
|
+
record_id = 'abc'
|
102
|
+
stub_request(:put, "#{Fulcrum::Api.configuration.uri}/records/#{record_id}.json").to_return(:status => 422)
|
103
|
+
Fulcrum::RecordValidator.any_instance.stub(:validate!).and_return(true)
|
104
|
+
r = Fulcrum::Record.update(record_id, {})
|
105
|
+
r.keys.should include(:error)
|
106
|
+
r[:error][:status].should eq(422)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context '#delete' do
|
111
|
+
it 'should receive a 404 response' do
|
112
|
+
record_id = 'abc'
|
113
|
+
stub_request(:delete, "#{Fulcrum::Api.configuration.uri}/records/#{record_id}.json").to_return(:status => 404)
|
114
|
+
r = Fulcrum::Record.delete(record_id)
|
115
|
+
r.keys.should include(:error)
|
116
|
+
r[:error][:status].should eq(404)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fulcrum::ChoiceListValidator do
|
4
|
+
|
5
|
+
describe '#validates!' do
|
6
|
+
it 'should not be valid without a choice_list hash' do
|
7
|
+
data = {}
|
8
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
9
|
+
validator.should_not be_valid
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should not be valid if choice_list is not a hash' do
|
13
|
+
data = { 'choice_list' => nil }
|
14
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
15
|
+
validator.should_not be_valid
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should not be valid without an empty choice_list hash' do
|
19
|
+
data = { 'choice_list' => {}}
|
20
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
21
|
+
validator.should_not be_valid
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should not be valid without a name' do
|
25
|
+
data = { 'choice_list' => { 'name' => '' } }
|
26
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
27
|
+
validator.should_not be_valid
|
28
|
+
validator.errors['choice_list']['name'].should_not be_blank
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should not be valid without any choices' do
|
32
|
+
data = { 'choice_list' => { 'name' => 'foobar' } }
|
33
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
34
|
+
validator.should_not be_valid
|
35
|
+
validator.errors['choice_list']['choices'].should_not be_blank
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should not be valid with a non array choices element' do
|
39
|
+
data = { 'choice_list' => { 'name' => 'foobar', 'choices'=> {} } }
|
40
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
41
|
+
validator.should_not be_valid
|
42
|
+
validator.errors['choice_list']['choices'].should_not be_blank
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should not be valid with an empty choices array' do
|
46
|
+
data = { 'choice_list' => { 'name' => 'foobar', 'choices'=> [] } }
|
47
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
48
|
+
validator.should_not be_valid
|
49
|
+
validator.errors['choice_list']['choices'].should_not be_blank
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should not be valid with an empty choice' do
|
53
|
+
data = { 'choice_list' => { 'name' => 'foobar', 'choices'=> [{}] } }
|
54
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
55
|
+
validator.should_not be_valid
|
56
|
+
validator.errors['choices']['choice'].should_not be_blank
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should not be valid with a choice that does not have label' do
|
60
|
+
data = { 'choice_list' => { 'name' => 'foobar', 'choices'=> [{ 'foo' => 'bar' }] } }
|
61
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
62
|
+
validator.should_not be_valid
|
63
|
+
validator.errors['choice']['label'].should_not be_blank
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should be valid' do
|
67
|
+
data = { 'choice_list' => { 'name' => 'foobar', 'choices'=> [{ 'label' => 'foo' }] } }
|
68
|
+
validator = Fulcrum::ChoiceListValidator.new(data)
|
69
|
+
validator.should be_valid
|
70
|
+
validator.errors.should be_empty
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fulcrum::ClassificationSetValidator do
|
4
|
+
|
5
|
+
describe '#validates!' do
|
6
|
+
it 'should not be valid without a classification_set hash' do
|
7
|
+
data = {}
|
8
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
9
|
+
validator.should_not be_valid
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should not be valid if classification_set is not a hash' do
|
13
|
+
data = { 'classification_set' => nil }
|
14
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
15
|
+
validator.should_not be_valid
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should not be valid without an empty classification_set hash' do
|
19
|
+
data = { 'classification_set' => {}}
|
20
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
21
|
+
validator.should_not be_valid
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should not be valid without a name' do
|
25
|
+
data = { 'classification_set' => { 'name' => '' } }
|
26
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
27
|
+
validator.should_not be_valid
|
28
|
+
validator.errors['classification_set']['name'].should_not be_blank
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should not be valid without any items' do
|
32
|
+
data = { 'classification_set' => { 'name' => 'foobar' } }
|
33
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
34
|
+
validator.should_not be_valid
|
35
|
+
validator.errors['classification_set']['items'].should_not be_blank
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should not be valid with a non array items element' do
|
39
|
+
data = { 'classification_set' => { 'name' => 'foobar', 'items'=> {} } }
|
40
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
41
|
+
validator.should_not be_valid
|
42
|
+
validator.errors['classification_set']['items'].should_not be_blank
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should not be valid with an empty items array' do
|
46
|
+
data = { 'classification_set' => { 'name' => 'foobar', 'items'=> [] } }
|
47
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
48
|
+
validator.should_not be_valid
|
49
|
+
validator.errors['classification_set']['items'].should_not be_blank
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should not be valid with an empty item' do
|
53
|
+
data = { 'classification_set' => { 'name' => 'foobar', 'items'=> [{}] } }
|
54
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
55
|
+
validator.should_not be_valid
|
56
|
+
validator.errors['items']['item'].should_not be_blank
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should not be valid with a item that does not have label' do
|
60
|
+
data = { 'classification_set' => { 'name' => 'foobar', 'items'=> [{ 'foo' => 'bar' }] } }
|
61
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
62
|
+
validator.should_not be_valid
|
63
|
+
validator.errors['item']['label'].should_not be_blank
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should be valid with a good classification set item' do
|
67
|
+
data = { 'classification_set' => { 'name' => 'foobar', 'items'=> [{ 'label' => 'foo' }] } }
|
68
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
69
|
+
validator.should be_valid
|
70
|
+
validator.errors.should be_empty
|
71
|
+
end
|
72
|
+
|
73
|
+
# child classifications
|
74
|
+
it 'should not be valid if an item has an empty child classifications' do
|
75
|
+
data = { 'classification_set' => { 'name' => 'foobar', 'items'=> [{ 'label' => 'bar', 'child_classifications' => [] }] } }
|
76
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
77
|
+
validator.should_not be_valid
|
78
|
+
validator.errors['child_classification']['item'].should_not be_blank
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should be valid with good child classifications' do
|
82
|
+
data = { 'classification_set' => { 'name' => 'foobar', 'items'=> [{ 'label' => 'bar', 'child_classifications' => [{ 'label' => 'foo'}] }] } }
|
83
|
+
validator = Fulcrum::ClassificationSetValidator.new(data)
|
84
|
+
validator.should be_valid
|
85
|
+
validator.errors.should be_empty
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fulcrum::RecordValidator do
|
4
|
+
describe '#validates!' do
|
5
|
+
it 'should not be valid without a record hash' do
|
6
|
+
data = {}
|
7
|
+
validator = Fulcrum::RecordValidator.new(data)
|
8
|
+
validator.should_not be_valid
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should not be valid if record is not a hash' do
|
12
|
+
data = { 'record' => nil }
|
13
|
+
validator = Fulcrum::RecordValidator.new(data)
|
14
|
+
validator.should_not be_valid
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should not be valid without a form_id' do
|
18
|
+
data = { 'record' => { 'form_id' => '' } }
|
19
|
+
validator = Fulcrum::RecordValidator.new(data)
|
20
|
+
validator.should_not be_valid
|
21
|
+
validator.errors['record']['form_id'].should_not be_blank
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should not be valid if form_values is not a hash' do
|
25
|
+
data = { 'record' => { 'form_id' => 'foobar', 'form_values' => nil } }
|
26
|
+
validator = Fulcrum::RecordValidator.new(data)
|
27
|
+
validator.should_not be_valid
|
28
|
+
validator.errors['record']['form_values'].should_not be_blank
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should not be valid if form_values is empty' do
|
32
|
+
data = { 'record' => { 'form_id' => 'foobar', 'form_values' => {} } }
|
33
|
+
validator = Fulcrum::RecordValidator.new(data)
|
34
|
+
validator.should_not be_valid
|
35
|
+
validator.errors['record']['form_values'].should_not be_blank
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should not be valid with invalid coordinates' do
|
39
|
+
data = { 'record' => { 'form_id' => 'foobar', 'form_values' => { 'foo' => 'bar'}, 'latitude' => '0', 'longitude' => '0' } }
|
40
|
+
validator = Fulcrum::RecordValidator.new(data)
|
41
|
+
validator.should_not be_valid
|
42
|
+
validator.errors['record']['coordinates'].should_not be_blank
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should be valid' do
|
46
|
+
data = { 'record' => { 'form_id' => 'foobar', 'form_values' => { 'foo' => 'bar'}, 'latitude' => '1.0', 'longitude' => '1.0' } }
|
47
|
+
validator = Fulcrum::RecordValidator.new(data)
|
48
|
+
validator.should be_valid
|
49
|
+
validator.errors.should be_empty
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fulcrum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Hall
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70332002261400 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70332002261400
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70332002260640 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70332002260640
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: webmock
|
38
|
+
requirement: &70332002260060 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70332002260060
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: debugger
|
49
|
+
requirement: &70332002259620 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70332002259620
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: activesupport
|
60
|
+
requirement: &70332002259100 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70332002259100
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faraday
|
71
|
+
requirement: &70332002258540 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70332002258540
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: hashie
|
82
|
+
requirement: &70332002258000 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70332002258000
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: faraday_middleware
|
93
|
+
requirement: &70332002257480 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70332002257480
|
102
|
+
description: Fulcrum API Gem
|
103
|
+
email:
|
104
|
+
- chris@spatialnetworks.com
|
105
|
+
executables: []
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- .gitignore
|
110
|
+
- .rvmrc
|
111
|
+
- Gemfile
|
112
|
+
- LICENSE
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- fulcrum.gemspec
|
116
|
+
- lib/fulcrum.rb
|
117
|
+
- lib/fulcrum/api.rb
|
118
|
+
- lib/fulcrum/choice_list.rb
|
119
|
+
- lib/fulcrum/classification_set.rb
|
120
|
+
- lib/fulcrum/form.rb
|
121
|
+
- lib/fulcrum/member.rb
|
122
|
+
- lib/fulcrum/photo.rb
|
123
|
+
- lib/fulcrum/record.rb
|
124
|
+
- lib/fulcrum/validators/base_validator.rb
|
125
|
+
- lib/fulcrum/validators/choice_list_validator.rb
|
126
|
+
- lib/fulcrum/validators/classification_set_validator.rb
|
127
|
+
- lib/fulcrum/validators/form_validator.rb
|
128
|
+
- lib/fulcrum/validators/record_validator.rb
|
129
|
+
- lib/fulcrum/version.rb
|
130
|
+
- spec/data/form_data.json
|
131
|
+
- spec/data/test.jpg
|
132
|
+
- spec/lib/api_spec.rb
|
133
|
+
- spec/lib/choice_list_spec.rb
|
134
|
+
- spec/lib/classification_set_spec.rb
|
135
|
+
- spec/lib/form_spec.rb
|
136
|
+
- spec/lib/member_spec.rb
|
137
|
+
- spec/lib/photo_spec.rb
|
138
|
+
- spec/lib/record_spec.rb
|
139
|
+
- spec/lib/validators/choice_list_validator_spec.rb
|
140
|
+
- spec/lib/validators/classification_set_validator_spec.rb
|
141
|
+
- spec/lib/validators/form_validator_spec.rb
|
142
|
+
- spec/lib/validators/record_validator_spec.rb
|
143
|
+
- spec/spec_helper.rb
|
144
|
+
homepage: http://docs.fulcrumapp.com/
|
145
|
+
licenses: []
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
152
|
+
requirements:
|
153
|
+
- - ! '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ! '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
requirements: []
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 1.8.17
|
165
|
+
signing_key:
|
166
|
+
specification_version: 3
|
167
|
+
summary: Fulcrum API Gem
|
168
|
+
test_files:
|
169
|
+
- spec/data/form_data.json
|
170
|
+
- spec/data/test.jpg
|
171
|
+
- spec/lib/api_spec.rb
|
172
|
+
- spec/lib/choice_list_spec.rb
|
173
|
+
- spec/lib/classification_set_spec.rb
|
174
|
+
- spec/lib/form_spec.rb
|
175
|
+
- spec/lib/member_spec.rb
|
176
|
+
- spec/lib/photo_spec.rb
|
177
|
+
- spec/lib/record_spec.rb
|
178
|
+
- spec/lib/validators/choice_list_validator_spec.rb
|
179
|
+
- spec/lib/validators/classification_set_validator_spec.rb
|
180
|
+
- spec/lib/validators/form_validator_spec.rb
|
181
|
+
- spec/lib/validators/record_validator_spec.rb
|
182
|
+
- spec/spec_helper.rb
|