-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ruby: Merge pull request #9 from mkllnk/specs
Rewrite MiniTest tests as Rspec specs
- Loading branch information
Showing
27 changed files
with
321 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/org/datafoodconsortium/connector/codegen/ruby/static/.rspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--require spec_helper |
2 changes: 2 additions & 0 deletions
2
src/org/datafoodconsortium/connector/codegen/ruby/static/Gemfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
source "https://rubygems.org" | ||
gemspec | ||
|
||
gem "rspec" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/org/datafoodconsortium/connector/codegen/ruby/static/Rakefile
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/org/datafoodconsortium/connector/codegen/ruby/static/spec/address_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
describe DataFoodConsortium::Connector::Address do | ||
it "can be empty when exported" do | ||
subject = DataFoodConsortium::Connector::Address.new( | ||
"https://myplatform.com/a" | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/a","@type":"dfc-b:Address","dfc-b:hasStreet":"","dfc-b:hasPostalCode":"","dfc-b:hasCity":"","dfc-b:hasCountry":""}' | ||
) | ||
end | ||
|
||
it "contains all fields when exported" do | ||
subject = DataFoodConsortium::Connector::Address.new( | ||
"https://myplatform.com/a", | ||
street: "street", | ||
postalCode: "postalCode", | ||
city: "city", | ||
country: "country" | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/a","@type":"dfc-b:Address","dfc-b:hasStreet":"street","dfc-b:hasPostalCode":"postalCode","dfc-b:hasCity":"city","dfc-b:hasCountry":"country"}' | ||
) | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
src/org/datafoodconsortium/connector/codegen/ruby/static/spec/catalog_item_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
describe DataFoodConsortium::Connector::CatalogItem do | ||
it "can be empty when exported" do | ||
subject = DataFoodConsortium::Connector::CatalogItem.new( | ||
"https://myplatform.com/ci" | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/ci","@type":"dfc-b:CatalogItem","dfc-b:sku":"","dfc-b:stockLimitation":0.0}' | ||
) | ||
end | ||
|
||
it "contains all fields when exported" do | ||
sp = DataFoodConsortium::Connector::CatalogItem.new("https://myplatform.com/sp") | ||
offer = DataFoodConsortium::Connector::CatalogItem.new("https://myplatform.com/o") | ||
subject = DataFoodConsortium::Connector::CatalogItem.new( | ||
"https://myplatform.com/ci", | ||
product: sp, | ||
sku: "sku", | ||
stockLimitation: 10, | ||
offers: [offer] | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/ci","@type":"dfc-b:CatalogItem","dfc-b:references":"https://myplatform.com/sp","dfc-b:sku":"sku","dfc-b:stockLimitation":10,"dfc-b:offeredThrough":"https://myplatform.com/o"}' | ||
) | ||
end | ||
end |
22 changes: 22 additions & 0 deletions
22
src/org/datafoodconsortium/connector/codegen/ruby/static/spec/customer_category_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
describe DataFoodConsortium::Connector::CustomerCategory do | ||
it "can be empty when exported" do | ||
subject = DataFoodConsortium::Connector::CustomerCategory.new( | ||
"https://myplatform.com/cc" | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/cc","@type":"dfc-b:CustomerCategory","dfc-b:description":""}' | ||
) | ||
end | ||
|
||
it "contains all fields when exported" do | ||
subject = DataFoodConsortium::Connector::CustomerCategory.new( | ||
"https://myplatform.com/cc", | ||
description: "description" | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/cc","@type":"dfc-b:CustomerCategory","dfc-b:description":"description"}' | ||
) | ||
end | ||
end |
60 changes: 60 additions & 0 deletions
60
src/org/datafoodconsortium/connector/codegen/ruby/static/spec/enterprise_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
describe DataFoodConsortium::Connector::Enterprise do | ||
it "can be empty when exported" do | ||
subject = DataFoodConsortium::Connector::Enterprise.new( | ||
"https://myplatform.com/e" | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/e","@type":"dfc-b:Enterprise","dfc-b:name":"","dfc-b:hasDescription":"","dfc-b:VATnumber":""}' | ||
) | ||
end | ||
|
||
it "contains all fields when exported" do | ||
subject = DataFoodConsortium::Connector::Enterprise.new( | ||
"https://myplatform.com/e", | ||
name: "name", | ||
description: "description", | ||
vatNumber: "vatNumber", | ||
customerCategories: [ | ||
DataFoodConsortium::Connector::CustomerCategory.new("https://myplatform.com/cc") | ||
], | ||
suppliedProducts: [ | ||
DataFoodConsortium::Connector::SuppliedProduct.new("https://myplatform.com/sp") | ||
], | ||
catalogItems: [ | ||
DataFoodConsortium::Connector::CatalogItem.new("https://myplatform.com/ci") | ||
], | ||
localizations: [] | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/e","@type":"dfc-b:Enterprise","dfc-b:name":"name","dfc-b:hasDescription":"description","dfc-b:VATnumber":"vatNumber","dfc-b:defines":"https://myplatform.com/cc","dfc-b:manages":"https://myplatform.com/ci","dfc-b:supplies":"https://myplatform.com/sp"}' | ||
) | ||
end | ||
|
||
it "contains collections as arrays when exported" do | ||
subject = DataFoodConsortium::Connector::Enterprise.new( | ||
"https://myplatform.com/e", | ||
name: "name", | ||
description: "description", | ||
vatNumber: "vatNumber", | ||
customerCategories: [ | ||
DataFoodConsortium::Connector::CustomerCategory.new("https://myplatform.com/cc"), | ||
DataFoodConsortium::Connector::CustomerCategory.new("https://myplatform.com/cc2") | ||
], | ||
suppliedProducts: [ | ||
DataFoodConsortium::Connector::SuppliedProduct.new("https://myplatform.com/sp"), | ||
DataFoodConsortium::Connector::SuppliedProduct.new("https://myplatform.com/sp2") | ||
], | ||
catalogItems: [ | ||
DataFoodConsortium::Connector::CatalogItem.new("https://myplatform.com/ci"), | ||
DataFoodConsortium::Connector::CatalogItem.new("https://myplatform.com/ci2") | ||
], | ||
localizations: [] | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/e","@type":"dfc-b:Enterprise","dfc-b:name":"name","dfc-b:hasDescription":"description","dfc-b:VATnumber":"vatNumber","dfc-b:defines":["https://myplatform.com/cc","https://myplatform.com/cc2"],"dfc-b:manages":["https://myplatform.com/ci","https://myplatform.com/ci2"],"dfc-b:supplies":["https://myplatform.com/sp","https://myplatform.com/sp2"]}' | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/org/datafoodconsortium/connector/codegen/ruby/static/spec/offer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
describe DataFoodConsortium::Connector::Offer do | ||
it "can be empty when exported" do | ||
subject = DataFoodConsortium::Connector::Offer.new( | ||
"https://myplatform.com/o" | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/o","@type":"dfc-b:Offer","dfc-b:stockLimitation":0.0}' | ||
) | ||
end | ||
|
||
it "contains all fields when exported" do | ||
ci = DataFoodConsortium::Connector::CatalogItem.new("https://myplatform.com/ci") | ||
cc = DataFoodConsortium::Connector::CustomerCategory.new("https://myplatform.com/cc") | ||
subject = DataFoodConsortium::Connector::Offer.new( | ||
"https://myplatform.com/o", | ||
price: DataFoodConsortium::Connector::Price.new( | ||
value: 12.78, | ||
vatRate: 5.22, | ||
unit: connector.MEASURES.EURO | ||
), | ||
stockLimitation: 52, | ||
offeredItem: ci, | ||
offeredTo: cc | ||
) | ||
result = connector.export(subject) | ||
expect(result).to eq( | ||
'{"@context":"https://www.datafoodconsortium.org","@id":"https://myplatform.com/o","@type":"dfc-b:Offer","dfc-b:hasPrice":{"@type":"dfc-b:Price","dfc-b:value":12.78,"dfc-b:VATrate":5.22,"dfc-b:hasUnit":"dfc-m:Euro"},"dfc-b:stockLimitation":52,"dfc-b:offeredItem":"https://myplatform.com/ci","dfc-b:offeredTo":"https://myplatform.com/cc"}' | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.