Skip to content

Instantly share code, notes, and snippets.

@eduardocl
Created August 1, 2013 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardocl/6131013 to your computer and use it in GitHub Desktop.
Save eduardocl/6131013 to your computer and use it in GitHub Desktop.
describe "#list" do
it "list attribute as ruby object" do
attrs = @controller.list_attributes
attrs.each do |a|
a.should be_an_instance_of Attribute
end
end
it "list attribute in xml format" do
xml = @controller.list_attributes(:xml)
puts xml
attrs = Nokogiri::XML(xml)
attrs.root.search('attribute').should have(2).attributes
#for attribute field we test the values from
#the previous two attributes tested
test_attrs_values = {
'name' => ['email', 'num_of_bugs'],
'label' => ['Email', 'Num. of Bugs'],
'type' => ['numerical', 'alphanumerical']
}
test_attrs_values.each do |field, values|
attrs.xpath("//#{field}").each do |f|
values.should include(f.content)
end
end
end
it "list attributes in json format" do
json_data = @controller.list_attributes(:json)
#puts json_data
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment