[rspec-users] Variance in behaviour: rake features vs. autotest

James Byrne lists at ruby-forum.com
Thu Nov 27 10:52:19 EST 2008

James Byrne wrote:

> So, depending upon the way cucumber is invoked, either all the tests 
> pass, all the tests are skipped, or some of the tests pass and some fail 
> one way and others pass and fail when invoked another way.  This seems 
> problematic for testing and it is far beyond my modest abilities to 
> explain or rectify.

Well, I have localized the source of the error and I have resolved one 
of the causes.

One of the feature tests was to assure that the test table was empty to 
begin with.  This was passing under cucumber and rake features while 
failing under autotest.  It failed because the testunit tests were 
loading a fixture into that table.  This I resolved by changing the 
feature step to destroy_all that table.

The four remaining failures are all located in a test that uses a "More 
Examples" construct.  So, in fact, there is just one failing test that 
is hit four times.  This test follows:

 Scenario: The common name should display with initial capitals
    Given one valid entity
      And I am on the edit entity page
    When I fill in "Common Name" with "  ANYThing   WronG wITh tHiS? "
      And I commit the update
    Then I should see "Anything Wrong With This?"
     And I should see an update success confirmation

  More Examples:


def build_valid_entities(n=1)
  Entity.transaction do
    n.to_i.times do |n|
      Entity.create!  :entity_name => "Entity #{n}",
        :entity_legal_name => "Entity #{n} Legal Name",
        :entity_legal_form => "CORP"

Given /(\d+) valid entit/ do |n|

Given /one valid entity/ do

Given /I am on the edit entity page/ do
  visits "/entities/1/edit"

The error is that there exists no entity with id=1.  Ideas?


Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list