diff --git a/lib/cucapp/Resources/features/step_definitions/steps.rb b/lib/cucapp/Resources/features/step_definitions/steps.rb index e3cef7d..8d8005b 100644 --- a/lib/cucapp/Resources/features/step_definitions/steps.rb +++ b/lib/cucapp/Resources/features/step_definitions/steps.rb @@ -7,6 +7,10 @@ end end +# Given I wait for n seconds +Given /^I wait for (\d+) seconds?$/ do |n| + sleep(eval("#{n.to_i}")) +end # When I close the popover When /^I close the popover$/ do @@ -166,4 +170,8 @@ # Then the field with the property cucapp-identifier set to cucapp-identifier-textfield-description should have the value cucapp Then /^the (\w*\-*\w*) with the property (\w*\-*\w*) set to (.*) should have the value (.*)$/ do |element, property, property_value, value| check_value_control(element, property, property_value, value) -end \ No newline at end of file +end + +Then /^the application delegate should have the property (\w*) set to (.*)$/ do |property, value| + check_delegate_property(property, value) +end diff --git a/lib/cucapp/Resources/features/support/Cucumber+Extensions.j b/lib/cucapp/Resources/features/support/Cucumber+Extensions.j index 6c0c743..acecb00 100644 --- a/lib/cucapp/Resources/features/support/Cucumber+Extensions.j +++ b/lib/cucapp/Resources/features/support/Cucumber+Extensions.j @@ -16,4 +16,20 @@ return '{"result" : "__CUKE_ERROR__"}'; } -@end \ No newline at end of file +- (CPString)delegatePropertyIsEqual:(CPArray)params +{ + var property = params[0]; + + if (property == nil) + return '{"error" : "The property ' + property +' was not found"}'; + + var expected_value = params[1], + current_value = [[[CPApplication sharedApplication] delegate] valueForKey:property]; + + if (current_value != expected_value) + return '{"error" : "The value should be ' + expected_value +' but was '+ [current_value description] + '"}'; + + return '{"error" : "__NO_ERROR__"}'; +} + +@end diff --git a/lib/cucapp/Resources/features/support/encumber_category.rb b/lib/cucapp/Resources/features/support/encumber_category.rb index 985d401..da10a63 100644 --- a/lib/cucapp/Resources/features/support/encumber_category.rb +++ b/lib/cucapp/Resources/features/support/encumber_category.rb @@ -10,5 +10,11 @@ def value_is_equal(xpath, value) result = command 'valueIsEqual', id_for_element(xpath), value raise "Value #{value} not found" if result["result"] != "OK" end + + def delegate_property_is_equal(property, value) + result = command 'delegatePropertyIsEqual', property, value + error = result["error"] + raise "#{error}" if error != "__NO_ERROR__" + end end -end \ No newline at end of file +end diff --git a/lib/cucapp/Resources/features/support/steps_helpers.rb b/lib/cucapp/Resources/features/support/steps_helpers.rb index 701df0c..a5b84d1 100644 --- a/lib/cucapp/Resources/features/support/steps_helpers.rb +++ b/lib/cucapp/Resources/features/support/steps_helpers.rb @@ -5,6 +5,10 @@ def check_value_control(element, property, property_value, value) app.gui.value_is_equal xpath, value end +def check_delegate_property(property, value) + app.gui.delegate_property_is_equal property, value +end + def simulate_keyboard_event(keys, mask) app.gui.simulate_keyboard_events cappuccino_key(keys), [cappuccino_key(mask)] end @@ -89,4 +93,4 @@ def create_xpath(element, property, property_value) end return "//" + $cappuccino_control_mappings[element] + "["+ $property_mappings[property] +"='#{property_value}']" -end \ No newline at end of file +end