[rspec-users] Including matchers in Cucumber

aslak hellesoy aslak.hellesoy at gmail.com
Mon Sep 22 07:30:59 EDT 2008


On Mon, Sep 22, 2008 at 1:21 PM, Ashley Moran
<ashley.moran at patchspace.co.uk> wrote:
> Hi
>
> Where do you include matcher modules in Cucumber so they don't pollute
> Object?  ie so
>
>  module TwitterMatchers
>    class HaveUserStatus
>      # ...
>    end
>
>    def have_user_status(user, status)
>      HaveUserStatus.new(user, status)
>    end
>  end
>
> is only visible in
>
>  Then "it should push an announcement to Twitter" do
>    t = Twitter::Base.new("dummy_user", "secret", :api_host => "localhost",
> :api_port => 7002)
>    t.should have_user_status("followme_ann", "Story title #@num_stories")
>  end
>
> (Actually I'm not convinced it's necessary in this case, but anyway.)
>
> I had a look at the Cucumber examples but none of them use custom matchers.
>

# Put this in steps/env.rb
World do
  w = Object.new
  w.extend(TwitterMatchers)
  w
end

Aslak

> Thanks
> Ashley
>
>
> --
> http://www.patchspace.co.uk/
> http://aviewfromafar.net/
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list