Skip to content

Instantly share code, notes, and snippets.

View fabiolnm's full-sized avatar

Fábio Luiz Nery de Miranda fabiolnm

View GitHub Profile
@fabiolnm
fabiolnm / problem5.rb
Last active January 3, 2016 21:14
Five programming problems every software engineer should be able to solve in less than 1 hour
# 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
#
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
Given /^I have no contacts$/ do
assert_equal 0, Contact.count
end
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
...
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
$ 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)
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 }
}
@fabiolnm
fabiolnm / gist:1380592
Created November 20, 2011 18:01
Cucumber install
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
@fabiolnm
fabiolnm / gist:1380514
Created November 20, 2011 17:14
Cucumber dependencies
group :tests do
gem "database_cleaner"
gem "cucumber-rails"
gem "rspec-rails"
end
@fabiolnm
fabiolnm / gist:1380288
Created November 20, 2011 13:56
Contact List Features
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."