[rspec-users] Spec'ing via features

Andrew Premdas apremdas at gmail.com
Wed Nov 26 17:32:19 EST 2008


Fixtures = yuk!!

Try object_daddy or maybe factory_girl instead :)

Andrew

2008/11/26 Tim Walker <walketim at gmail.com>:
> Great post James. Very, helpful. Perhaps should be on the cucumber
> Wiki? I hope someone follows up on the load fixtures question. Lots to
> go play with now!!! Tim
>
> On Wed, Nov 26, 2008 at 11:04 AM, James Byrne <lists at ruby-forum.com> wrote:
>> Tim Walker wrote:
>>> Question: In Cucumber when you're writing code to satisfy steps and
>>> accessing the model objects directly, what support for asserts,
>>> responses, etc.
>>> do people use. (the equivalent of ActionController::TestCase and
>>> ActiveSupport::TestCase), Fixtures, etc.
>>>
>>> Thanks,
>>>
>>> T
>>
>> This question prompted a really interesting journey through cucumber for
>> me.  I now have a much firmer, if still very limited, grasp of what is
>> happening.
>>
>> When one uses "ruby script/generate cucumber" at the rails project root
>> then the script generates (among other things) a features/support/env.rb
>> file.  This file contains (in part):
>>
>> require 'cucumber/rails/world'
>> require 'cucumber/rails/rspec'
>>
>> The cucumber gem location lib/cucumber/rails/rspec contains
>>
>> rspec.rb
>> world.rb
>>
>> and rspec.rb has this:
>>
>> require 'spec'
>> require 'spec/rails'
>>
>> Next, world.rb makes a conditional reference (almost universally met in
>> a Rails project - Do you use ActiveRecord?) to testunit via
>> /usr/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/test_help.rb. Now that file
>> contains:
>>
>> require 'test/unit'
>> require 'active_support/test_case'
>> require 'active_record/fixtures'
>> require 'action_controller/test_case'
>> require 'action_controller/integration'
>> require 'action_mailer/test_case' if defined?(ActionMailer)
>>
>> So, it appears that when you generate the cucumber infrastructure via
>> the rails generator then you get rspec 'should' 'should_not' and rails
>> testunit assert_* support.  As previously discussed in this thread,
>> adding other testing harnesses is a fairly straight forward procedure
>> best done in the aforementioned support/env.rb.  For example, adding
>> watir gem support is done via this:
>>
>> require 'webrat' if !defined?(Webrat)
>>
>> I gather from allusions made elsewhere that if watir is installed as a
>> plugin within the rail project then it gets picked up automatically and
>> the default watir.steps generated by the rails generator work without
>> further modification to the env.rb file.
>>
>> I was unable to discover how to employ fixtures.  I found and read this
>> thread: http://www.ruby-forum.com/topic/167716 but the final
>> recommendation "Fixtures.create_fixtures("spec/fixtures", "entities")"
>> did not work for me.  It did not raise an error but it did not load the
>> fixture either.  The TestUnit syntax of "fixtures :model" throws an
>> undefined method error which is passing strange given test_help.rb's
>> require 'active_record/fixtures'.  Nonetheless, TestUnit syntax like
>> assert_something(argument,...argument,message) works fine.
>>
>> Anyway, a most enlightening code crawl.
>> --
>> Posted via http://www.ruby-forum.com/.
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list