This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.shiftedup.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour | |
# | |
# 5th problem: | |
# 1 _ 23456789 1 op | |
# 1 _ 2 _ 3456789 2 ops | |
# 1 _ 23 _ 456 _ 789 3 ops | |
# ... | |
# 1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9 8 ops | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: Empty Contact List # features/manage_contacts.feature:6 | |
Given I have no contacts # features/step_definitions/contact_list_steps.rb:1 | |
uninitialized constant Contact (NameError) | |
./features/step_definitions/contact_list_steps.rb:2:in `/^I have no contacts$/' | |
features/manage_contacts.feature:7:in `Given I have no contacts' | |
When I go to the contact list # features/step_definitions/contact_list_steps.rb:5 | |
Then I should see "No contacts found." # features/step_definitions/contact_list_steps.rb:9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given /^I have no contacts$/ do | |
assert_equal 0, Contact.count | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scenario: Empty Contact List # features/manage_contacts.feature:6 | |
Given I have no contacts # features/step_definitions/contact_list_steps.rb:1 | |
TODO (Cucumber::Pending) | |
./features/step_definitions/contact_list_steps.rb:2:in `/^I have no contacts$/' | |
features/manage_contacts.feature:7:in `Given I have no contacts' | |
When I go to the contact list # features/step_definitions/contact_list_steps.rb:5 | |
Then I should see "No contacts found." # features/step_definitions/contact_list_steps.rb:9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
9 scenarios (9 undefined) | |
39 steps (39 undefined) | |
0m2.451s | |
You can implement step definitions for undefined steps with these snippets: | |
Given /^I have no contacts$/ do | |
pending # express the regexp above with the code you wish you had |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bundle exec cucumber | |
Using the default profile... | |
Feature: Manage Contacts | |
In order to keep my contacts' phone numbers | |
As a popular person | |
I want to make a Contact List | |
Scenario: Empty Contact List # features/manage_contacts.feature:6 | |
Given I have no contacts # features/manage_contacts.feature:7 | |
Undefined step: "I have no contacts" (Cucumber::Undefined) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
notas = { | |
"Renato": { "Marguerita" : 4, "Quatro Queijos" : 5, "Escarola" : 4, "Portuguesa" : 5, "Frango+Catupiry" : 4, "Napolitana" : 3 }, | |
"Marcelo": { "Marguerita" : 2, "Quatro Queijos" : 2, "Escarola" : 1, "Portuguesa" : 3, "Frango+Catupiry" : 5, "Napolitana" : 2 }, | |
"Lenon": { "Marguerita" : 4, "Quatro Queijos" : 5, "Escarola" : 2, "Portuguesa" : 1, "Frango+Catupiry" : 1, "Napolitana" : 3 }, | |
"Renata": { "Marguerita" : 4, "Quatro Queijos" : 5, "Escarola" : 1, "Portuguesa" : 1, "Frango+Catupiry" : 3, "Napolitana" : 4 }, | |
"Washington": { "Marguerita" : 1, "Quatro Queijos" : 1, "Escarola" : 2, "Portuguesa" : 3, "Frango+Catupiry" : 4, "Napolitana" : 3 }, | |
"Tino": { "Marguerita" : 1, "Quatro Queijos" : 5, "Escarola" : 1, "Portuguesa" : 4, "Frango+Catupiry" : 3, "Napolitana" : 2 }, | |
"Luca": { "Marguerita" : 5, "Quatro Queijos" : 4, "Escarola" : 3, "Portuguesa" : 4, "Frango+Catupiry" : 3, "Napolitana" : 2 } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rails generate cucumber:install | |
create config/cucumber.yml | |
create script/cucumber | |
chmod script/cucumber | |
create features/step_definitions | |
create features/support | |
create features/support/env.rb | |
exist lib/tasks | |
create lib/tasks/cucumber.rake | |
gsub config/database.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :tests do | |
gem "database_cleaner" | |
gem "cucumber-rails" | |
gem "rspec-rails" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Manage Contacts | |
In order to make a Contact List | |
As a popular person | |
I want to create and manage contacts | |
Scenario: Empty Contact List | |
Given I have no contacts | |
When I go to the contact list | |
Then I should see "No contacts found." |
NewerOlder