Projekat

Općenito

Profil

Akcije

Nove funkcije #18004

Zatvoren

TDD, BDD: cucumber, spork test server

Dodano od Ernad Husremović prije skoro 17 godina. Izmjenjeno prije oko 16 godina.

Status:
Zatvoreno
Prioritet:
Normalan
Odgovorna osoba:
Kategorija:
-
Početak:
25.07.2009
Završetak:
% završeno:

0%

Procjena vremena:

Opis

bdd cucumber


Fajlovi


Povezani tiketi 1 (0 otvoreno1 zatvoren)

korelira sa ruby - Podrška #18003: require ruby gem specific versionZatvoreno25.07.2009

Akcije
Akcije #1

Izmjenjeno od Ernad Husremović prije skoro 17 godina

bringout@nmraka-2:~/devel/git/upstream/carrierwave$ rake features

(in /home/bringout/devel/git/upstream/carrierwave)
/usr/bin/ruby1.8 -I "/home/bringout/.gem/ruby/1.8/gems/cucumber-0.3.90/lib:lib" "/home/bringout/.gem/ruby/1.8/gems/cucumber-0.3.90/bin/cucumber" --profile default features/versions_overridden_filename.feature features/mount_datamapper.feature features/file_storage_reversing_processor.feature features/file_storage_overridden_filename.feature features/versions_overriden_store_dir.feature features/caching.feature features/file_storage.feature features/file_storage_overridden_store_dir.feature features/versions_nested_versions.feature features/versions_basics.feature features/mount_activerecord.feature

...
42 scenarios (42 passed)
428 steps (428 passed)
0m2.085s

jedan feature:

bringout@nmraka-2:~/devel/git/upstream/carrierwave$ cucumber features/mount_activerecord.feature

Feature: Mount an Uploader on ActiveRecord class
  In order to easily attach files to a form
  As a web developer using CarrierWave
  I want to mount an uploader on an ActiveRecord class

  Background:                                                # features/mount_activerecord.feature:6
    Given an uploader class that uses the 'file' storage     # features/step_definitions/general_steps.rb:3
    And an activerecord class that uses the 'users' table    # features/step_definitions/activerecord_steps.rb:3
    And the uploader class is mounted on the 'avatar' column # features/step_definitions/mount_steps.rb:7
    And an instance of the activerecord class                # features/step_definitions/activerecord_steps.rb:8

  Scenario: assign a file                                                                                                           # features/mount_activerecord.feature:12
    When I assign the file 'fixtures/bork.txt' to the 'avatar' column                                                               # features/step_definitions/mount_steps.rb:3
    Then there should be a file called 'bork.txt' somewhere in a subdirectory of 'public/uploads/tmp'                               # features/step_definitions/file_steps.rb:14
    And the file called 'bork.txt' in a subdirectory of 'public/uploads/tmp' should be identical to the file at 'fixtures/bork.txt' # features/step_definitions/file_steps.rb:29

  Scenario: assign a file and save the record                                                        # features/mount_activerecord.feature:17
    When I assign the file 'fixtures/bork.txt' to the 'avatar' column                                # features/step_definitions/mount_steps.rb:3
    And I save the active record                                                                     # features/step_definitions/activerecord_steps.rb:12
    Then there should be a file at 'public/uploads/bork.txt'                                         # features/step_definitions/file_steps.rb:6
    And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' # features/step_definitions/file_steps.rb:21
    And the url for the column 'avatar' should be '/uploads/bork.txt'                                # features/step_definitions/mount_steps.rb:17

  Scenario: assign a file and retrieve it from cache                                                 # features/mount_activerecord.feature:24
    When I assign the file 'fixtures/bork.txt' to the 'avatar' column                                # features/step_definitions/mount_steps.rb:3
    And I retrieve the file later from the cache name for the column 'avatar'                        # features/step_definitions/mount_steps.rb:11
    And I save the active record                                                                     # features/step_definitions/activerecord_steps.rb:12
    Then there should be a file at 'public/uploads/bork.txt'                                         # features/step_definitions/file_steps.rb:6
    And the file at 'public/uploads/bork.txt' should be identical to the file at 'fixtures/bork.txt' # features/step_definitions/file_steps.rb:21
    And the url for the column 'avatar' should be '/uploads/bork.txt'                                # features/step_definitions/mount_steps.rb:17

  Scenario: store a file and retrieve it later                                # features/mount_activerecord.feature:32
    When I assign the file 'fixtures/bork.txt' to the 'avatar' column         # features/step_definitions/mount_steps.rb:3
    And I retrieve the file later from the cache name for the column 'avatar' # features/step_definitions/mount_steps.rb:11
    And I save the active record                                              # features/step_definitions/activerecord_steps.rb:12
    Then there should be a file at 'public/uploads/bork.txt'                  # features/step_definitions/file_steps.rb:6
    When I reload the active record                                           # features/step_definitions/activerecord_steps.rb:16
    Then the url for the column 'avatar' should be '/uploads/bork.txt'        # features/step_definitions/mount_steps.rb:17

  Scenario: store a file and delete the record                                # features/mount_activerecord.feature:40
    When I assign the file 'fixtures/bork.txt' to the 'avatar' column         # features/step_definitions/mount_steps.rb:3
    And I retrieve the file later from the cache name for the column 'avatar' # features/step_definitions/mount_steps.rb:11
    And I save the active record                                              # features/step_definitions/activerecord_steps.rb:12
    Then there should be a file at 'public/uploads/bork.txt'                  # features/step_definitions/file_steps.rb:6
CarrierWave: removing file
    When I delete the active record                                           # features/step_definitions/activerecord_steps.rb:20
    Then there should not be a file at 'public/uploads/bork.txt'              # features/step_definitions/file_steps.rb:10

5 scenarios (5 passed)
46 steps (46 passed)
0m0.796s

Akcije #2

Izmjenjeno od Ernad Husremović prije skoro 17 godina

od čega se to sastoji

features fajlovi - opisi onoga što želimo dobiti

bringout@nmraka-2:~/devel/git/upstream/carrierwave$ ls features

caching.feature                            file_storage_reversing_processor.feature  step_definitions                  versions_overridden_filename.feature
file_storage.feature                       fixtures                                  support                           versions_overriden_store_dir.feature
file_storage_overridden_filename.feature   mount_activerecord.feature                versions_basics.feature
file_storage_overridden_store_dir.feature  mount_datamapper.feature                  versions_nested_versions.feature

definicije pojedinih koraka - steps

bringout@nmraka-2:~/devel/git/upstream/carrierwave$ ls features/step_definitions/

activerecord_steps.rb  caching_steps.rb  datamapper_steps.rb  file_steps.rb  general_steps.rb  mount_steps.rb  store_steps.rb

klase rade konkretne funkcije

bringout@nmraka-2:~/devel/git/upstream/carrierwave$ ls features/support

activerecord.rb  datamapper.rb  env.rb

testni podaci

bringout@nmraka-2:~/devel/git/upstream/carrierwave$ ls features/fixtures
bork.txt monkey.txt

Akcije #3

Izmjenjeno od Ernad Husremović prije skoro 17 godina

uz pomoć ovog 3.5minutnog videa fino sam skontao cucumber, pa sam na osnovu njega

napravio svoj cucumber lab

u lab-u sam postupno (iz više commit-a) došao do finih rezultata:
  1. kako se kreiraju step-ovi (cucumber mi pomaže)
  2. kako se postupno implementira ono što sa car.feature i car_steps.rb očekujem
  3. i na kraju refactoring

Tom prilikom sam još jednom posvjedočio kako je ruby cool language

Akcije #4

Izmjenjeno od Ernad Husremović prije oko 16 godina

  • Naslov promijenjeno iz cucumber u TDD, BDD: cucumber, spork test server

spork test server

http://github.com/timcharper/spork

Spork is Tim Harper’s implementation of test server (similar to the script/spec_server provided by rspec-rails), except rather than using the Rails constant unloading to reload your files, it forks a copy of the server each time you run your tests. The result? Spork runs more solid: it doesn’t get corrupted over time, and it properly handles modules and any voo-doo meta programming you may have put in your app.

Spork runs on POSIX systems using fork. It also runs on windows by pre-populating a pool of ready processes (referred to here as the "magazine" strategy).

Supported Testing Frameworks
  • Rspec
  • Cucumber
  • Test::Unit (via ‘gem install spork-testunit’)
Akcije #5

Izmjenjeno od Ernad Husremović prije oko 16 godina

  • Status promijenjeno iz Dodijeljeno u Zatvoreno
Akcije

Također dostupno kao Atom PDF