· 2 min read

Screencast: Pickle mit Cucumber

Download(32.5 MB, 16:43) alternativer download für iPod & Apple TV (21.7 MB, 16:43)

Resourcen:

Quellcode:

[bash] rails store sudo rake gems:install RAILS_ENV=test script/generate cucumber script/generate pickle script/generate rspec_model product name:string price:decimal rake db:migrate rake db:test:clone script/generate rspec_controller products show cucumber features -q [/bash] [ruby] # config/environments/test.rb config.gem “rspec”, :lib => false, :version => ”>=1.2.9” config.gem “rspec-rails”, :lib => false, :version => ”>=1.2.9” config.gem “webrat”, :lib => false, :version => ”>=0.5.3” config.gem “cucumber”, :lib => false, :version => ”>=0.4.3” config.gem “pickle”, :lib => false, :version => ”>=0.1.21”

# product_steps.rb Then(/^I should see products table$/) do |expected_table| html_table = table_at(“#products”).to_a html_table.map! { |r| r.map! { |c| c.gsub(/<.+?>/, ”) } } expected_table.diff!(html_table) end [/ruby]

[bash] # display_products.feature Feature: Display Products In order to purchase the right product As a customer I want to browse products and see detailed information Scenario: Show product Given a product exists with name: “Milk”, price: “2.99” When I go to the show page for that product Then I should see “Milk” within “h1” And I should see “$2.99” Scenario: List products Given the following products exist | name | price | | Milk | 2.99 | | Puzzle | 8.99 | When I go to path “/products” Then I should see products table | Milk | $2.99 | | Puzzle | $8.99 | Then show me the page [/bash]

Back to Blog