require './lib/geoff' require './lib/geoff/neo4j_wrapper_validator' describe Neo4jWrapperValidator do let(:validator) { Neo4jWrapperValidator.new } { "(Egg)-[:relates]->(1)" => {existing_nodes: %w(Branch Starbucks Cafe), node_name: "Egg", valid: false}, "((Branch)-[:relates]->(1)" => {existing_nodes: %w(Branch Cafe Starbucks), node_name: "Branch", valid: false}, "(Starbucks)-[:relates]->(1)" => {existing_nodes: %w(Branch Cafe Starbucks), node_name: "Starbucks", valid: true}, "((_Branch)-[:relates]->(1)" => {existing_nodes: %w(Branch), node_name: "(_Branch", valid: false}, "((Bra nch)-[:relates]->(1)" => {existing_nodes: %w(Branch Cafe), node_name: "(Bra nch", valid: false}, "((Branch)-[:relates]->(1)" => {existing_nodes: %w(Branch Cafe), node_name: "(Branch", valid: false}, "(Branch)-[:relates]->(1)" => {existing_nodes: [], node_name: "Branch", valid: false}}.each do |input, details| specify do valid = details[:valid] existing_nodes = details[:existing_nodes] node_name = details[:node_name] container = mock 'container', node_list: existing_nodes if valid validator.call(container, input).should == true else ->{validator.call(container, input)}.should raise_error Geoff::MissingNodeDefinition, node_name end end end end