cukeup! 2012: michael nacos on just enough infrastructure for product development with cucumber
TRANSCRIPT
![Page 1: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/1.jpg)
Product development with cucumber
with just enough infrastructure
Michael Nacos
![Page 2: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/2.jpg)
what to expect from this talk
● integration tests=important for a tech startup● cucumber ecosystem is ideal for our stack
and our product requirements● cucumber + git + chef = heart● duck test/typing references don't expect:● the definitive cucumber style guide● plug-and-play solutions
Intro
![Page 3: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/3.jpg)
cucumber as part of a whole
Intro
and too many others...
![Page 4: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/4.jpg)
leemail for people
leemail
bookmarklet
![Page 5: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/5.jpg)
why
● to let people share their email fearlessly● to shift unsubscribe power back to people● to encourage ethical behaviour from vendors● to help vendors safeguard their reputation
and customer data
leemail
it's about connecting, in a way that makes everyone happy
![Page 6: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/6.jpg)
leemail for businesses
● do you collect email addresses?
● are you good?● do you want to
shout it? we help you establish and secure the relationship against leaks and bad PR
leemail
![Page 7: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/7.jpg)
what do the cukes look like
cukes over time
cukes are part of the source tree
![Page 8: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/8.jpg)
stories, branches
cukes over time
![Page 9: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/9.jpg)
Monday Tuesday Wednesday Thursday Friday
cukes over time
Cukes or else!
![Page 10: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/10.jpg)
netbooks
stack requirements
OR
if it can:● run cukes● connect to a vpn● git pull/push
... it's a dev machineeditors:
● 2 vi users● 1 emacs● 1 notepad++
![Page 11: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/11.jpg)
email is different (esp. for leemail)
● mail servers need dns records, you cannot send to [email protected]
● there is an excellent 'mail' gem, but no smtp server gem afaik
● gems like 'mailtrap' exist but our smtp servers do more than just accept emails
● our daemons feed off rabbitmq queues, they shouldn't have to be changed for tests
● ideally, we'd have a lightweight smtp server which supports rules and delivers to rabbit
stack requirements
![Page 12: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/12.jpg)
configuration is part of the product# setup postfix
%w{dynamicmaps.cf mailbox_commands main.cf master.cf sender_canonical password restricted_destinations sender_relayhosts}.each do |cfg|
template "/etc/postfix/#{cfg}" do
source "postfix/#{cfg}.erb"
owner "root"
group "root"
mode cfg == 'password' ? 0640 : 0644
notifies :restart, resources(:service => "postfix")
end
end
stack requirements
Servers
git pull # ok, you need to satisfy an erlang dependency manually once
Dev env
![Page 13: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/13.jpg)
rails environments
development test production
stack requirements
good for interactive tests on your local machine, no email infrastructure, run mailtrap
for automated tests, minimum viable test environment for email testing available
for interactive tests on a server, chef dependency and configuration management a given
(taking advnatage of)
![Page 14: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/14.jpg)
value
we want to know:● existing functionality has not been broken● new functionality is correct● before deploying to a server without:● expensive equipment● maintaining dev-specific environments● building internet replicas locally
what we test
![Page 15: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/15.jpg)
RAILS_ENV='test'
if it speaks SMTP and it can follow some rules and deliver messages to a RabbitMQ queue...
it's a leemail mailserv
then the cukes can focus on things like: ● are email headers re-written properly?● do daemons deliver only to 'on' connections?etc.
what we test
![Page 16: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/16.jpg)
extending our Worldin local_env.rb:
require ...World(EmailHelpers)
in email_helpers.rb:module EmailHelpers # called before each scenario def self.extended(base) endend# setting up email environment at cucumber startupEmailHelpers.setup_test_email_environment# tearing down email environment at cucumber exitat_exit do EmailHelpers.tear_down_test_email_environmentend
how we test
![Page 17: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/17.jpg)
postfix_stub
how we test
SMTPruby net/smtp
ruby amqpleemails
emails ruby mail
(RabbitMQ)
(filesystem mbox)
in email_helpers.rb: def get_messages_from_mbox(mbox_path) # parsing mbox format raw_messages = IO.read(mbox_path).split(/\nFrom .+\n/) # returning a list of 'mail' messages raw_messages.map { |r| Mail.read_from_string(r) }end
![Page 18: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/18.jpg)
leemail reply
examples
![Page 19: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/19.jpg)
bandit
examples
![Page 20: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/20.jpg)
i18n
makes your cukes less brittle you can write: Then I should see flash message "devise.sessions.signed_in"
tips
![Page 21: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/21.jpg)
javascript
gem 'capybara-webkit' # requires apt-get install libqt4-dev in env.rb:
# use webkit driver in @javascript scenariaCapybara.javascript_driver = :webkit # setting the test server port to a known valueCapybara.server_port =AppConfig['test_server_port']
then add @javascript tag to specific cukes
tips
![Page 22: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/22.jpg)
iframes (well, leemail iframes)
challenges
find iframe
js in iframe
nav in iframe
nav in parent
![Page 23: CukeUp! 2012: Michael Nacos on Just enough infrastructure for product development with cucumber](https://reader033.vdocuments.us/reader033/viewer/2022042814/555a6ae1d8b42a972b8b4b3b/html5/thumbnails/23.jpg)
Thank You
@mnacos @leemailme
https://leemail.me/r/CUKEUP
Product development with cucumber