You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@buildr.apache.org by Antoine Toulme <an...@lunar-ocean.com> on 2009/02/18 15:48:22 UTC

Running a test suite against Buildr with Cucumber

Howdy guys,

we are developing Buildr4eclipse and we made the switch to Cucumber to run
our tests. We have a hard time interfacing with Buildr.

What we did so far:
1. We used braid, as Assaf had recommended, to hook ourselves against a
working copy of Buildr.
2. We require the spec/spec_helpers.rb file so we have access to Buildr
internals.

We run our test suite with this assertion:
define('foo').compile.compiler.should eql(:pdec)

Which fails with this error:
undefined method `from' for <Rake::Task compile => []>:Rake::Task
(NoMethodError)

/Users/antoine/perso/buildr4eclipse/buildr/lib/buildr/core/compile.rb:533:in
`compile'

This happens because the before_define hook defined in the Compile module is
not executed. The Compile module is present on the Buildr::Project class
though.

Does this ring a bell ? Note that we reproduce the problem even after
uninstalling all Buildr gems from our system.

Thanks,

Antoine

Re: Running a test suite against Buildr with Cucumber

Posted by Assaf Arkin <ar...@intalio.com>.
On Wed, Feb 18, 2009 at 11:34 AM, Ketan Padegaonkar <
ketanpadegaonkar@gmail.com> wrote:

> Antoine pointed out to a hidden gem[1] that allows running a scenario in a
> controlled 'world'.
>
> All we needed to do was:
>
> World do |world|
>  world.extend(SpecHelpers)
> end
>
> Our specs[2] now run fine and we hope to post our experiences with buildr.


BDD is about software design. You start out by specifying how your software
should behave, then fleshing out ways to test these specifications, and then
writing code that behaves according to that specification.

Sometimes you just need to make a lot of statements, like "should not
compile project with no source files" or "should skip tests when test=no".
 These are called specs, and are at about the same level of abstraction as
unit tests.

Sometimes you need to write our more elaborate, multi-step scenarios, like
your classical "I log in. I add product to cart. I check out. I confirm
payment. I receive an invoice". These are called scenarios or stories, and
they deal with broader designs that would be lost if reduced to specs.

The very short example [1] looks more like specs then scenarios. Also
overusing of the define shorthand will lead to overuse of conjunctions [2].
And when you have something that's possibly a conjunction ("containing") in
50% of your scenarios, might be sign you're using the wrong framework.

Assaf


[1]
http://github.com/ketan/buildr4eclipse/blob/9c785b548acad5adc3efbb5555f07f61df94f7c9/features/my.feature
[2]
http://wiki.github.com/aslakhellesoy/cucumber/conjunction-steps-antipattern


>
>
> [1] http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world
> [2]
> http://github.com/ketan/buildr4eclipse/blob/9c785b548acad5adc3efbb5555f07f61df94f7c9/features/step_definitions/steps.rb
>
>
> -- Ketan
>
>
>
> On 18/2/09 23:51, Antoine Toulme wrote:
>
>> I am wondering, are we missing the equivalent of this ? (at the end of
>> spec_helpers.rb)
>>
>> Spec::Runner.configure do |config|
>>     # Make all Buildr methods accessible from test cases, and add various
>> helper methods.
>>     config.include Buildr, SpecHelpers
>>
>>     # Sanbdox Buildr for each test.
>>     config.include Sandbox
>>   end
>>
>>

Re: Running a test suite against Buildr with Cucumber

Posted by Ketan Padegaonkar <ke...@gmail.com>.
Antoine pointed out to a hidden gem[1] that allows running a scenario in 
a controlled 'world'.

All we needed to do was:

World do |world|
   world.extend(SpecHelpers)
end

Our specs[2] now run fine and we hope to post our experiences with buildr.

[1] http://wiki.github.com/aslakhellesoy/cucumber/a-whole-new-world
[2] 
http://github.com/ketan/buildr4eclipse/blob/9c785b548acad5adc3efbb5555f07f61df94f7c9/features/step_definitions/steps.rb


-- Ketan


On 18/2/09 23:51, Antoine Toulme wrote:
> I am wondering, are we missing the equivalent of this ? (at the end of
> spec_helpers.rb)
>
> Spec::Runner.configure do |config|
>      # Make all Buildr methods accessible from test cases, and add various
> helper methods.
>      config.include Buildr, SpecHelpers
>
>      # Sanbdox Buildr for each test.
>      config.include Sandbox
>    end
>

Re: Running a test suite against Buildr with Cucumber

Posted by Antoine Toulme <an...@lunar-ocean.com>.
On Wed, Feb 18, 2009 at 6:02 PM, Assaf Arkin <ar...@intalio.com> wrote:

> On Wed, Feb 18, 2009 at 6:48 AM, Antoine Toulme <an...@lunar-ocean.com>wrote:
>
>> Howdy guys,
>>
>> we are developing Buildr4eclipse and we made the switch to Cucumber to run
>> our tests. We have a hard time interfacing with Buildr.
>>
>> What we did so far:
>> 1. We used braid, as Assaf had recommended, to hook ourselves against a
>> working copy of Buildr.
>> 2. We require the spec/spec_helpers.rb file so we have access to Buildr
>> internals.
>>
>> We run our test suite with this assertion:
>> define('foo').compile.compiler.should eql(:pdec)
>>
>> Which fails with this error:
>> undefined method `from' for <Rake::Task compile => []>:Rake::Task
>> (NoMethodError)
>>
>>
>> /Users/antoine/perso/buildr4eclipse/buildr/lib/buildr/core/compile.rb:533:in
>> `compile'
>>
>> This happens because the before_define hook defined in the Compile module
>> is
>> not executed. The Compile module is present on the Buildr::Project class
>> though.
>>
>> Does this ring a bell ? Note that we reproduce the problem even after
>> uninstalling all Buildr gems from our system.
>
>
> All the Buildr specs are written to use the define method introduced by
> spec/spec_helper.rb, which defines a project and immediately evaluates it,
> so you can write something like define('foo').result.should expected. I'm
> going to suspect that your code is calling the real define method.
>
That must be it. Placing a debugger call inside that method shows it isn't
called when we call define.

I am wondering, are we missing the equivalent of this ? (at the end of
spec_helpers.rb)

Spec::Runner.configure do |config|
    # Make all Buildr methods accessible from test cases, and add various
helper methods.
    config.include Buildr, SpecHelpers

    # Sanbdox Buildr for each test.
    config.include Sandbox
  end

>
> Assaf
>
>
>>
>>
>> Thanks,
>>
>> Antoine
>>
>
>

Re: Running a test suite against Buildr with Cucumber

Posted by Assaf Arkin <ar...@intalio.com>.
On Wed, Feb 18, 2009 at 6:48 AM, Antoine Toulme <an...@lunar-ocean.com>wrote:

> Howdy guys,
>
> we are developing Buildr4eclipse and we made the switch to Cucumber to run
> our tests. We have a hard time interfacing with Buildr.
>
> What we did so far:
> 1. We used braid, as Assaf had recommended, to hook ourselves against a
> working copy of Buildr.
> 2. We require the spec/spec_helpers.rb file so we have access to Buildr
> internals.
>
> We run our test suite with this assertion:
> define('foo').compile.compiler.should eql(:pdec)
>
> Which fails with this error:
> undefined method `from' for <Rake::Task compile => []>:Rake::Task
> (NoMethodError)
>
>
> /Users/antoine/perso/buildr4eclipse/buildr/lib/buildr/core/compile.rb:533:in
> `compile'
>
> This happens because the before_define hook defined in the Compile module
> is
> not executed. The Compile module is present on the Buildr::Project class
> though.
>
> Does this ring a bell ? Note that we reproduce the problem even after
> uninstalling all Buildr gems from our system.


All the Buildr specs are written to use the define method introduced by
spec/spec_helper.rb, which defines a project and immediately evaluates it,
so you can write something like define('foo').result.should expected. I'm
going to suspect that your code is calling the real define method.

Assaf


>
>
> Thanks,
>
> Antoine
>