Skip to content

Instantly share code, notes, and snippets.

View TranslateEnglishToRuby.rb
module TranslateEnglishToRuby
module RubyConstantName
def RubyConstantName.from sentence
joined_together capitalised( words_from sentence )
end
#... other methods defined here `joined_together()` etc
end
end
View package_layout
.
├── model
│ ├── ApplicationInformation.java
│ ├── TodoStatus.java
│ └── TodoStatusFilter.java
├── questions
│ ├── ApplicationDetails.java
│ ├── ClearCompletedItemsOptionAvailability.java
│ ├── CurrentFilter.java
│ ├── DisplayedItems.java
View todolist_item_ui.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’]”);
}
View todolist_ui_complete.java
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”);
View question.java
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(); }
}
View consequence_in_context.java
then(james).should(seeThat(TheItems.displayed(), hasItem(“Buy some milk”)));
View consequence.java
seeThat(TheItems.displayed(), hasItem(“Buy some milk”));
View AddATodoItem.java
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)
);
}
View multiple_actors.java
@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”));
View an_actor_can_browse_the_web.java
Actor james = Actor.named(“James”);
james.can(BrowseTheWeb.with(hisBrowser));