- Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathlibrary_properties_spec.rb
76 lines (64 loc) · 2.18 KB
/
library_properties_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require"spec_helper"
RSpec.describeArduinoCI::LibraryPropertiesdo
context"property extraction"do
library_properties=ArduinoCI::LibraryProperties.new(Pathname.new(__dir__) + "properties" + "example.library.properties")
expected={
string: {
name: "WebServer",
version: "1.0.0",
maintainer: "Cristian Maglie <c.maglie@example.com>",
sentence: "A library that makes coding a Webserver a breeze.",
paragraph: "Supports HTTP1.1 and you can do GET and POST.",
category: "Communication",
url: "http://example.com/",
},
bool: {
precompiled: true
},
csv: {
author: ["Cristian Maglie <c.maglie@example.com>","Pippo Pluto <pippo@example.com>"],
architectures: ["avr"],
includes: ["WebServer.h"],
depends: ["ArduinoHttpClient"],
},
}.freeze
expected.eachdo |atype,values|
values.eachdo |meth,val|
it"reads #{atype} field #{meth}"do
expect(library_properties.send(meth)).toeq(val)
end
end
end
it"reads full_paragraph"do
expect(library_properties.full_paragraph).toeq([
expected[:string][:sentence],
expected[:string][:paragraph]
].join(" "))
end
it"doesn't crash on nonexistent fields"do
expect(library_properties.dot_a_linkage).tobe(nil)
end
it"converts to hash"do
h=library_properties.to_h
expect(h[:name].class).toeq(String)
expect(h[:name]).toeq("WebServer")
expect(h[:architectures].class).toeq(Array)
expect(h[:architectures]).tocontain_exactly("avr")
end
end
context"Input handling"do
malformed_examples=[
"extra_blank_line.library.properties",
"just_equals.library.properties",
"no_equals.library.properties",
"no_key.library.properties",
"no_value.library.properties",
].map{ |e| Pathname.new(__dir__) + "properties" + e}
malformed_examples.eachdo |e|
quirk=e.basename.to_s.split(".library.").first
it"reads a properties file with #{quirk}"do
expect{ArduinoCI::LibraryProperties.new(e)}.to_notraise_error
end
end
end
end