Rails - DRY in Cucumber scenarios. What is a good balance? - ruby-on-rails

I have the following scenarios:
Scenario: Create a game with valid information
Given I am logged in
When I visit the new game page
And I fill in "Game type" with "Basketball"
And I fill in "Zip code" with "94040"
And I fill in "Description" with "Friendly match"
And I click on the button "Create Game"
Then I should see "Awesome! Your game has been created."
Scenario: Create a game with missing information
Given I am logged in
When I visit the new game page
And I fill in "Zip code" with "94040"
And I fill in "Description" with "Friendly match"
And I click on the button "Create Game"
Then I should see "Game type can't be blank."
As you can see I am repeating code and as a developer point of view, I hate that I am repeating some sentences in both scenarios. However, I assume that scenarios have to be independent clear, so any stakeholder can take a look and say..Oh, I know what this scenario is describing.
I am trying to test if my form validation is working correctly for different kind of field values. So, I will have many similar scenarios that will be basically changing the "fill in" parts. So, another similar/related scenario would be the one that checks that zip code has to be numeric:
Scenario: Create a game with invalid zip code
Given I am logged in
When I visit the new game page
And I fill in "Game type" with "Basketball"
And I fill in "Zip code" with "ffff"
And I fill in "Description" with "Friendly match"
And I click on the button "Create Game"
Then I should see "Zip code has to contain 5 digits."
So, my question is: Is there any DRY, business people friendly way of doing this? I mean, a balance between code optimization and clear and understandable independent scenario definition?

I think scenario outline would suit you well.

Related

JIRA: How do you create custom logic around a custom field?

All! I've been searching for an answer to this question for ages. Hoping somebody is able to help me out here.
Here is what I want to do:
Create a custom field. (Either a drop-down with a simple [yes/no] or checkbox).
Implement logic, based on the value of the custom field, which dictates the next column on the Kanban board the story must be put in.
Real World Example:
Here's an example:
I create a Drop-Down/Checkbox called: "Business Review Required".
I have three columns on my kanban board: "In Progress", "Business Review", "QA"
If the value of the "Business Review Required" custom field is 'yes' or 'enabled', then the Story MUST go into the "Business Review" column on my kanban board.
If the value of the "Business Review Required" custom field is 'no' or 'disabled', then the Story will be PREVENTED from going into the "Business Review" column, and must go to "QA".
I appreciate any assistance anybody can provide. Thank you very much!
Define transitions from the first status to each of the other three statuses
Add a condition to each transition to restrict when that transition is valid, e.g. "Business Review Required" custom field is 'yes'
Now only the appropriate transition button will appear.
The problem is that users don't know why the other choices are not shown

NLU - extract string that is related to entity

is it possible in any NLU (e.g RASA, or Lex) to get attrbitued string of an entity?
Here is an example:
"please make sure to remind me about getting the project done"
let's say I'll put remind me as a REGEX - how can I extract the latter?
I'm talking about NLU perspective (and not naive string manipulation).
would like an output like
{
Intent:"remind_me"
Value:"about getting the project done"
}
Here's a description of how to do it in Lex.
From your example:
User: "please make sure to remind me about getting the project done"
This is the user input, also called an Utterance.
First you create an Intent. You can name it like you did: remind_me
Then you provide Lex with intent-utterances, or phrases that the user will say to trigger that intent. Perhaps, something like:
"remember this for me"
"make a reminder"
"can you remind me about something"
"please remind me"
Those would simply trigger the intent and you can then ask the user for the information to remember.
Any value that you want to store in Lex is called a Slot Value because it is held in a Slot, which is basically just Alexa and Lex's term for 'variable'.
You could name the Slot: reminder
If your intent is triggered, then you Elicit Slot and ask the user:
"Okay, what would you like me to remind you about?"
You "teach" Lex what to listen for by providing all the variations of utterances you think the user might say, and simply place the SlotName in curly braces {} inside the utterance at the point where they are likely to say the word or phrase you want to store in the Slot.
"remind me about {reminder}"
"please remember {reminder}"
"make sure to remind me {reminder}"
These can even be the intent-utterances so you capture the reminder value without needing to elicit it with a question.
Lex will then provide you with exactly what you are looking for and more, I'll simplify the JSON that Lex creates for you:
}
"currentIntent": {
"name": "remind-me",
"slots": {
"reminder": "about getting the project done"
}
},
"inputTranscript": "please make sure to remind me about getting the project done"
}
To view the full format see Lex Lambda Function Input Event and Response Format
Notice that Lex even provides the full user utterance in inputTranscript. That's great for doing your own parsing and validating.

Getting value from input box of one page and passing it to the heading of another page

I have a feature I'm struggling to implement, didn't find a proper answer anywhere.
When a user puts some text in an input form and clicks a "next" button, he sees the input text as a heading of another page.
You can login to my app to see exactly what I mean: http://murmuring-headland-8091.herokuapp.com/
For example, a user writes down a decision he wants to make: "Which job to choose?", and after clicking "What are your options?" button, he sees "Which job to choose?" instead of "Step 2 of 4.".
I think what I want to implement is called "a string", but I can't go any further with that knowledge.
Hope I made my question clear. I'm a newbie, so I hope to get a detailed answer.
Here's the github of my app: https://github.com/strikhar/decisions
Thank you for taking your time and helping me!
The input field "Which job to choose?" has no name associated with it. So, you need to assign it a name for accessing the input given by user.
Once you assign it a name, say whichjob, you will be able to access its string through params[:whichjob]. Then using this, you can display this string in place of "Step 2 of 4."
Instead of using this means
What are your options? ->
use a submit field for the same. For example,
<form action='/options'>
.
.
.
.
<input type='submit' value='Submit it now and go to "What are your options?"' />

Cucumber scenarios for extremely long work flow

We need to test a long process of steps for one Feature. From logging in to many modal dialogs, multi-step forms, and users of different roles all interacting. How can we break parts of this process down into individual Scenarios?
Here is an example:
Scenario: New Manuscript
Given I am on the manuscripts page
When I press "Submit A New Manuscript"
Then I should see "Please specify this manuscript's type"
Scenario: Choose Manuscript Type
Given I am choosing a manuscript type
When I click "Original Paper"
Then I should see "Edit Manuscript Details"
Scenario: Edit Manuscript Details
Given I am editing manuscript details
And I am on the editing page
When I fill in "Manuscript Title" with "Testing Story"
Then I should see "Suggest Reviewers"
And so on and so on for dozens of scenarios. The problem is each scenario is built off of the last one. How can I test each scenario in isolation without repeating all of the previous ones?
Scenarios are supposed to be self contained, so you can either create a setup Background process, that setups a basic manuscript that you can use in different scenarios:
Feature: ...
Background:
Given a single manuscript exists
Scenario: ...
Scenario: ...
Scenario: ...
If you are really building on the previous step and are entirely dependent upon it, then create a single scenario:
Scenario: Manuscript flow
Given I am on the manuscripts page
When I press "Submit A New Manuscript"
Then I should see "Please specify this manuscript's type"
Given I am choosing a manuscript type
When I click "Original Paper"
Then I should see "Edit Manuscript Details"
Given I am editing manuscript details
And I am on the editing page
When I fill in "Manuscript Title" with "Testing Story"
Then I should see "Suggest Reviewers"

Fogbugz: A way to pre-fill custom fields via HTTP post?

Greetings!
Situation:
We have a CRM system that generates unique customer IDs. Now we added a field "customer match code" to our Fogbugz cases, using the Custom Fields Plugin.
In the CRM we have a button "Add case to customer" that launches a VB script to open a URL, ie. Fogbugz.
Obviously, it would be nice to pre-fill the custom field "customer match code" with the ID. Normal fields are easy to pre-fill:
http://devserver/fogbugz/default.asp?command=new&pg=pgEditBug&sTitle=MyTitle
Since the field is a custom field, I found it not in the table "Bug", but in "Plugin_6_CustomBugData", where it is called "customerxmatchxcodeX62".
Neither accessing "customerxmatchxcodeX62", nor "customer match code", nor "Customer Match Code" worked.
Does anyone know of a way to access custom fields like this?
Note: I am aware of the XML API. I'm trying to avoid it in this case, because all I want to do is open a browser with Fogbugz "new case" page and fill this one field.
Thank you for any helpful responses!
Best regards,
Robin
http://fogbugz.stackexchange.com/ Try this site instead =)

Resources