+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Athens Ruby meetup #8
1. Athens Ruby 16/3/2012
meetup #8
Testing and BDD with
RSpec and Cucumber
Theodoros Orfanidis
(aka @teoulas)
2. About me
●
Web developer
●
Ruby lover
●
Cat lover �
●
Tech lead at incrediblue.com
Athens ruby meetup #8 16/3/2012
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
5. Cucumber
●
Higher level
●
Closer to natural language
(any language, even LOLspeak!)
●
Tests application behavior
Athens ruby meetup #8 16/3/2012
6. Cucumber – Features
Feature: 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. Cucumber – Step definitions
Given /^I have uploaded a picture$/ do
@first = Submission.new(title: “My 1337 cat!”,
image: File.open Rails.root + “tmp/sample1.jpg”)
end
When /^I upload another picture$/ do
@another = Submission.new(title: “My cat again”,
image: File.open Rails.root + “tmp/sample2.jpg”)
end
Then /^I should see “([^”]*)”$/ do |msg|
page.should have_content(msg)
end
Athens ruby meetup #8 16/3/2012
9. RSpec
describe “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
end
end
Athens ruby meetup #8 16/3/2012