Your SlideShare is downloading. ×
0
Athens Ruby                    16/3/2012meetup #8    Testing and BDD with    RSpec and Cucumber         Theodoros Orfanidi...
About me     ●         Web developer     ●         Ruby lover     ●         Cat lover �     ●         Tech lead at incredi...
BDD concepts     ●         Describe what your system does         (Given, When, Then)     ●         Write features/specs f...
BDD cycle                                     1                                     2                            4        ...
Cucumber     ●         Higher level     ●         Closer to natural language         (any language, even LOLspeak!)     ● ...
Cucumber – FeaturesFeature: LOLcat competition submission  In order to win the competition  As a cat owner  I want to subm...
Cucumber – Step definitionsGiven /^I have uploaded a picture$/ do  @first = Submission.new(title: “My 1337 cat!”,    image...
RSpec     ●         Lower level     ●         Closer to code     ●         Tests object behaviourAthens ruby meetup #8    ...
RSpecdescribe “submission” do  it “should allow jpg images” do    sub = Submission.new(title: “Cat”,      image: File.open...
Demo appAthens ruby meetup #8              16/3/2012
Related libraries and tools     ●         FactoryGirl     ●         Capybara     ●         Selenium     ●         Guard   ...
Thanks!Athens ruby meetup #8             16/3/2012
Upcoming SlideShare
Loading in...5
×

Athens Ruby meetup #8

537

Published on

Testing and BDD using RSpec and Cucumber

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
537
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Athens Ruby meetup #8"

  1. 1. Athens Ruby 16/3/2012meetup #8 Testing and BDD with RSpec and Cucumber Theodoros Orfanidis (aka @teoulas)
  2. 2. About me ● Web developer ● Ruby lover ● Cat lover � ● Tech lead at incrediblue.comAthens ruby meetup #8 16/3/2012
  3. 3. BDD concepts ● Describe what your system does (Given, When, Then) ● Write features/specs first, code later ● Red-Green-Refactor cycle (just like TDD)Athens ruby meetup #8 16/3/2012
  4. 4. BDD cycle 1 2 4 3 RSpec 6 5 CucumberAthens ruby meetup #8 16/3/2012
  5. 5. Cucumber ● Higher level ● Closer to natural language (any language, even LOLspeak!) ● Tests application behaviorAthens ruby meetup #8 16/3/2012
  6. 6. Cucumber – FeaturesFeature: LOLcat competition submission In order to win the competition As a cat owner I want to submit a cat picture Scenario: Cat owner submits picture Given I have a cat And I have a funny picture of her When I upload the picture Then I should see “KTHX! Bai!” Scenario: Cat owner submits a second picture Given I have already uploaded a picture When I upload another picture Then I should see “Oh noes, naughty boi!” And I should see my previous submission Athens ruby meetup #8 16/3/2012
  7. 7. Cucumber – Step definitionsGiven /^I have uploaded a picture$/ do @first = Submission.new(title: “My 1337 cat!”, image: File.open Rails.root + “tmp/sample1.jpg”)endWhen /^I upload another picture$/ do @another = Submission.new(title: “My cat again”, image: File.open Rails.root + “tmp/sample2.jpg”)endThen /^I should see “([^”]*)”$/ do |msg| page.should have_content(msg)end Athens ruby meetup #8 16/3/2012
  8. 8. RSpec ● Lower level ● Closer to code ● Tests object behaviourAthens ruby meetup #8 16/3/2012
  9. 9. RSpecdescribe “submission” do it “should allow jpg images” do sub = Submission.new(title: “Cat”, image: File.open Rails.root + “tmp/sample.jpg”) sub.should be_valid end it “should not allow gif images” do sub = Submission.new(title: “Cat”, image: File.open Rails.root + “tmp/animated.gif”) sub.should_not be_valid endend Athens ruby meetup #8 16/3/2012
  10. 10. Demo appAthens ruby meetup #8 16/3/2012
  11. 11. Related libraries and tools ● FactoryGirl ● Capybara ● Selenium ● Guard ● SporkAthens ruby meetup #8 16/3/2012
  12. 12. Thanks!Athens ruby meetup #8 16/3/2012
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×