[rspec-users] how to write complex matchers

Phlip phlip2005 at gmail.com
Sun Feb 15 23:12:02 EST 2009


Yury Kotlyarov wrote:
> Phlip wrote:
>> Yury Kotlyarov wrote:
>>
>>>>>>> http://github.com/yura/howto-rspec-custom-matchers/
>>
>>> The project aims to encourage feedback on the best practices of 
>>> creating custom expectation matchers and specs for them.
>>>
>>> Does it make sense?
>>
>> That just says it's a "project".
>>
>> One git clone later... It is a Rails 2.3.0 website!
>>
>> TX; I will now go spelunking down inside it for a while. Wish me luck! 
>> (-;
> 
> Yes, rails 2.3 app is just an environment to custom matchers 
> spec'ing/development. You can clone the git repo and just `rake spec` to 
> see my issues...

Special-needs programmer that I am, I declined to obtain the unreleased 2.3.0 of 
Rails. I tweaked environment.rb back to 2.2.2.

That lead to a curious issue that an RSpec maintainer might understand:

----8<-----------------------------------------------------

$ rake spec 

(in /home/phlip/projects/howto-rspec-custom-matchers) 

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`gem_original_require': no such file to load -- application (MissingSourceFile) 

         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in 
`require'
         from 
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in 
`require'
         from 
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:262:in 
`require_or_load'
         from 
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:221:in 
`depend_on'
         from 
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:133:in 
`require_dependency'
         from 
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/dispatcher.rb:18:in 
`define_dispatcher_callbacks'
         from 
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:182:in 
`call'
         from 
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/callbacks.rb:182:in 
`evaluate_method'
          ... 19 levels...
         from 
/home/phlip/projects/howto-rspec-custom-matchers/vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:14:in 
`load_files'
         from 
/home/phlip/projects/howto-rspec-custom-matchers/vendor/plugins/rspec/lib/spec/runner/options.rb:84:in 
`run_examples'
         from 
/home/phlip/projects/howto-rspec-custom-matchers/vendor/plugins/rspec/lib/spec/runner/command_line.rb:9:in 
`run'
         from 
/home/phlip/projects/howto-rspec-custom-matchers/vendor/plugins/rspec/bin/spec:4

----8<-----------------------------------------------------

Apologies for the ugly unformattable stack trace, but I don't know which lines 
are important.

I fixed the "missing application.rb" error via brute force: cp `find . -name 
application.rb`.

With a copy of application.rb in the root folder, 'rake spec' now works, and I 
can see some "Not Yet Implemented" issues...

> Those matchers (spec/lib/custom_ui_matchers/*) will be used in my real 
> project tho. But I still have minor issues which are listed in Open 
> questions section. Comments/remarks on the specs/code/etc are welcome!

Well, the rake spec generally passed, so someone else will have to tell you 
whatever it was you did wrong! (-:

-- 
   Phlip
   http://flea.sourceforge.net/PiglegToo_1.html



More information about the rspec-users mailing list