• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Cucumbers & Factory Girls
 

Cucumbers & Factory Girls

on

  • 18,243 views

Presentation I gave at the October Sydney RORO meetup on Cucumber, the new Ruby library for writing executable story-based tests; and FactoryGirl, a library for creating valid AR models for ...

Presentation I gave at the October Sydney RORO meetup on Cucumber, the new Ruby library for writing executable story-based tests; and FactoryGirl, a library for creating valid AR models for tests/specs/stories.

Most examples come from the Webjam codebase which can be found on github:
http://github.com/webjam/webjam/

Video of the preso can be found here:
http://www.viddler.com/explore/snapperwolf/videos/7

Faces preso page here:
http://faces.rubyonrails.com.au/groups/sydney/meetings/2008-10-08/presos/2

Statistics

Views

Total Views
18,243
Views on SlideShare
18,197
Embed Views
46

Actions

Likes
18
Downloads
213
Comments
2

2 Embeds 46

http://www.slideshare.net 45
https://twitter.com 1

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

12 of 2 previous next

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

    Cucumbers & Factory Girls Cucumbers & Factory Girls Presentation Transcript

    • CUCUMBERS! AND FACTORY GIRLS
    • CUCUMBER
    • STORIES
    • 210 SCENARIOS
    • BIG BULLSHIT NUMBERS
    • In order to show the world how cool they are A user Should be able to edit and update their personal details
    • RSPEC STORIES
    • As a user I want to edit and update my personal details So that I can show the world how cool I am
    • OLD SCHOOL
    • GOOD OLD SCHOOL PHOTO BY: flickr.com/people/rumberodesign
    • BAD OLD SCHOOL
    • BENEFITS OF CUCUMBER?
    • HIGH WATER CONTENT
    • SKIN IS RICH IN FIBER
    • REGULATE BLOOD PRESSURE
    • RUBY + CUCUMBERS?
    • JAPAN + CUCUMBERS?
    • http://www.youtube.com/watch?v=fBsyBjQuX6E http://www.youtube.com/watch?v=U3OxKdDxkpg
    • http://github.com/aslakhellesoy/cucumber/
    • DEMO: WEBJAM http://github.com/webjam/webjam - rake features
    • /features
    • /features/*.feature
    • Story: Viewing the home page As a visitor I want to visit the home page So that I can see all the cool stuff Scenario: not logged in Given I am not logged in When I view the home page Then I see the page /features/home.feature
    • /features/steps
    • /features/steps/*_steps.rb
    • When quot;I view the home pagequot; do get home_path end /features/home_steps.rb
    • Then quot;I see the pagequot; do response.code.should == quot;200quot; end /features/response_steps.rb
    • FEATURES
    • RUBY
    • RAILS INTEGRATION
    • TREETOP
    • STORY RUNNER COMPATIBLE
    • FIT TABLES
    • Feature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen And the result class should be Fixnum | input_1 | input_2 | button | output | class | | 20 | 30 | add | 50 | Fixnum | | 2 | 5 | add | 7 | Fixnum | | 0 | 40 | add | 40 | Fixnum |
    • Before do @calc = Calculator.new end After do end Given quot;I have entered $n into the calculatorquot; do |n| @calc.push n.to_i end When /I press (w+)/ do |op| @result = @calc.send op end Then /the result should be (.*) on the screen/ do |result| @result.should == result.to_f end Then /the result class should be (w*)/ do |class_name| @result.class.name.should == class_name end
    • Before do @calc = Calculator.new end After do end Given quot;I have entered $n into the calculatorquot; do |n| @calc.push n.to_i end When /I press (w+)/ do |op| @result = @calc.send op end Then /the result should be (.*) on the screen/ do |result| @result.should == result.to_f end Then /the result class should be (w*)/ do |class_name| @result.class.name.should == class_name end
    • Before do @calc = Calculator.new end After do end Given quot;I have entered $n into the calculatorquot; do |n| @calc.push n.to_i end When /I press (w+)/ do |op| @result = @calc.send op end Then /the result should be (.*) on the screen/ do |result| @result.should == result.to_f end Then /the result class should be (w*)/ do |class_name| @result.class.name.should == class_name end
    • Before do @calc = Calculator.new end After do end Given quot;I have entered $n into the calculatorquot; do |n| @calc.push n.to_i end When /I press (w+)/ do |op| @result = @calc.send op end Then /the result should be (.*) on the screen/ do |result| @result.should == result.to_f end Then /the result class should be (w*)/ do |class_name| @result.class.name.should == class_name end
    • Feature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen And the result class should be Fixnum | input_1 | input_2 | button | output | class | | 20 | 30 | add | 50 | Fixnum | | 2 | 5 | add | 7 | Fixnum | | 0 | 40 | add | 40 | Fixnum |
    • Feature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen And the result class should be Fixnum | input_1 | input_2 | button | output | class | | 20 | 30 | add | 50 | Fixnum | | 2 | 5 | add | 7 | Fixnum | | 0 | 40 | add | 40 | Fixnum |
    • GETTING STARTED WITH RAILS
    • INSTALL PLUGIN
    • ./script/generate cucumber
    • FACTORY GIRL
    • INSTANTIATING MODELS
    • FIXTURELESS
    • SPECS and/or STORIES
    • HORNSBY LACHIE (LACHIE COX)
    • MACHINIST NOTAHAT (PETE YANDELL)
    • AGAIN, WEBJAM http://github.com/webjam/webjam/tree/master/spec/factories.rb
    • Factory.define :presentation, :class => Jam do |p| p.title 'Preso title' p.description 'Preso description' p.number {Factory.next(:jam_number)} p.users {|u| [u.association(:user)]} p.association :event end
    • When quot;I view an event presentation pagequot; do @event = Factory.create(:past_event) @presentation = Factory.create(:presentation, :event => @event) get event_presentation_path(@event, @presentation) end
    • ASSOCIATIONS
    • SEQUENCES
    • TIM LUCAS TWITTER.COM/TOOLMANTIM TOOLMANTIM.COM