• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Athens Ruby meetup #8
 

Athens Ruby meetup #8

on

  • 655 views

Testing and BDD using RSpec and Cucumber

Testing and BDD using RSpec and Cucumber

Statistics

Views

Total Views
655
Views on SlideShare
655
Embed Views
0

Actions

Likes
1
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Athens Ruby meetup #8 Athens Ruby meetup #8 Presentation Transcript

    • Athens Ruby 16/3/2012meetup #8 Testing and BDD with RSpec and Cucumber Theodoros Orfanidis (aka @teoulas)
    • About me ● Web developer ● Ruby lover ● Cat lover � ● Tech lead at incrediblue.comAthens ruby meetup #8 16/3/2012
    • 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
    • BDD cycle 1 2 4 3 RSpec 6 5 CucumberAthens ruby meetup #8 16/3/2012
    • Cucumber ● Higher level ● Closer to natural language (any language, even LOLspeak!) ● Tests application behaviorAthens ruby meetup #8 16/3/2012
    • 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
    • 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
    • RSpec ● Lower level ● Closer to code ● Tests object behaviourAthens ruby meetup #8 16/3/2012
    • 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
    • Demo appAthens ruby meetup #8 16/3/2012
    • Related libraries and tools ● FactoryGirl ● Capybara ● Selenium ● Guard ● SporkAthens ruby meetup #8 16/3/2012
    • Thanks!Athens ruby meetup #8 16/3/2012