Skip to content

Instantly share code, notes, and snippets.

module TranslateEnglishToRuby
module RubyConstantName
def RubyConstantName.from sentence
joined_together capitalised( words_from sentence )
end
#... other methods defined here `joined_together()` etc
end
end
.
├── model
│ ├── ApplicationInformation.java
│ ├── TodoStatus.java
│ └── TodoStatusFilter.java
├── questions
│ ├── ApplicationDetails.java
│ ├── ClearCompletedItemsOptionAvailability.java
│ ├── CurrentFilter.java
│ ├── DisplayedItems.java
package net.serenitybdd.demos.todos.user_interface;
import net.serenitybdd.screenplay.targets.Target;
public class TodoListItem {
public static Target COMPLETE_ITEM = the(“Complete item tick box”).locatedBy( “//*[@class=’view’ and contains(.,’{0}’)]//input[@type=’checkbox’]”);
public static Target DELETE_ITEM = the(“Delete item button”).locatedBy( “//*[@class=’view’ and contains(.,’{0}’)]//button[@class=’destroy’]”);
}
package net.serenitybdd.demos.todos.user_interface;
import net.serenitybdd.screenplay.targets.Target;
public class ToDoList {
public static Target WHAT_NEEDS_TO_BE_DONE = the(“’What needs to be done?’ field”).locatedBy(“#new-todo”);
public static Target ITEMS = the(“List of todo items”).locatedBy(“.view label”);
public static Target ITEMS_LEFT = the(“Count of items left”).locatedBy(“#todo-count strong”);
public static Target TOGGLE_ALL = the(“Complete all items link”).locatedBy(“#toggle-all”);
public static Target CLEAR_COMPLETED = the(“Clear completed link”).locatedBy(“#clear-completed”);
public class TheItems implements Question<List<String>> {
@Override
public List<String> answeredBy(Actor actor) {
return Text.of(ToDoList.ITEMS)
.viewedBy(actor)
.asList();
}
public static Question<List<String>> displayed() { return new TheItems(); }
}
then(james).should(seeThat(TheItems.displayed(), hasItem(“Buy some milk”)));
seeThat(TheItems.displayed(), hasItem(“Buy some milk”));
public class AddATodoItem implements Task {
private final String thingToDo;
public <T extends Actor> void performAs(T theActor) {
theActor.attemptsTo(
Enter.theValue(thingToDo)
.into(WHAT_NEEDS_TO_BE_DONE)
.thenHit(RETURN)
);
}
@Before
public void ourUsersCanBrowseTheWeb() {
james.can(BrowseTheWeb.with(hisBrowser));
jane.can(BrowseTheWeb.with(herBrowser));
}
@Test
public void should_not_affect_todos_belonging_to_another_user() {
givenThat(james).wasAbleTo(Start.withATodoListContaining(“Walk the dog”, “Put out the garbage”));
andThat(jane).wasAbleTo(Start.withATodoListContaining(“Walk the dog”, “Feed the cat”));
Actor james = Actor.named(“James”);
james.can(BrowseTheWeb.with(hisBrowser));