Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

New built-in steps #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/cucapp/Resources/features/step_definitions/steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,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
end

Then /^the application delegate should have the property (\w*) set to (.*)$/ do |property, value|
check_delegate_property(property, value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call the method check_application_delegate_property ?

end
18 changes: 17 additions & 1 deletion lib/cucapp/Resources/features/support/Cucumber+Extensions.j
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@
return '{"result" : "__CUKE_ERROR__"}';
}

@end
- (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
Copy link
Author

@cacaodev cacaodev May 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the way errors are reported here, following the pattern i'm used to in obj-c: if there is no error (NO_ERROR) then it is a success.
If there is a convention in cucumber/ruby that I am not honoring, please tell me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't any convention or something, we are used to use '{"result" : "OK"}'; or '{"result" : "__CUKE_ERROR__"}';
I think it would be better to continue like this for consistency

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, no custom error explaining the failure reason ?

Copy link
Member

@Dogild Dogild May 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have something like {"result" : "__CUKE_ERROR__", "message" "Because blabla"}'

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do that.

8 changes: 7 additions & 1 deletion lib/cucapp/Resources/features/support/encumber_category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
end
6 changes: 5 additions & 1 deletion lib/cucapp/Resources/features/support/steps_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -89,4 +93,4 @@ def create_xpath(element, property, property_value)
end

return "//" + $cappuccino_control_mappings[element] + "["+ $property_mappings[property] +"='#{property_value}']"
end
end