Rick DeNatale
2008-Dec-02 17:01 UTC
[rspec-users] Setup for autospec for non-rails project
I brought this up some time ago. I''m trying to use autotest to run specs in a non-rails project. FWIW the project is structured using the bones gem. $ spec -v rspec 1.1.11 k$ gem list zentest *** LOCAL GEMS *** ZenTest (3.11.0, 3.9.1, 3.9.0, 3.8.0, 3.7.1, 3.7.0, 3.6.1) $ cat .autotest Autotest.add_hook :initialize do |at| %w{.svn .hg .git .bzr}.each { |exception| at.add_exception(exception) } at.clear_mappings at.add_mapping(%r%^(spec/(spec_helper|shared/.*)|config/(boot|environment(s/test)?))\.rb$%) { at.files_matching %r%^spec/(models|controllers|views|helpers)/.*_spec\.rb$% } at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| ["spec/lib/#{m[1]}_spec.rb"] } end Autotest.add_discovery do "rspec" if File.directory?(''spec'') && ENV[''RSPEC''] end $ autospec loading autotest/rspec /opt/local/bin/ruby -S spec/lib/v_date_time_property_spec.rb spec/lib/v_date_property_spec.rb spec/lib/v_property_spec.rb spec/lib/parser_spec.rb spec/lib/t_z_info_vtimezone_spec.rb spec/lib/v_date_time_property_spec.rb:8: warning: parenthesize argument(s) for future version spec/lib/v_date_time_property_spec.rb:12: warning: parenthesize argument(s) for future version spec/lib/v_date_time_property_spec.rb:4: undefined method `describe'' for main:Object (NoMethodError) For some reason, it''s running the specs as plain old ruby files and the RSpec framework doesn''t seem to be being intialized. I''ve done lots of googling about this, and everything about running autotest for RSpec for non-rails projects seems to be quite old. I did find one old post which recommended making a .autotest file in the project with mappings based on the rspec-rails mappings, which is what I tried above, but no joy. Any insight? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081202/84aa8a0d/attachment-0001.html>
On Tue, Dec 2, 2008 at 9:01 AM, Rick DeNatale <rick.denatale at gmail.com>wrote:> $ autospec > loading autotest/rspec > /opt/local/bin/ruby -S spec/lib/v_date_time_property_spec.rb > spec/lib/v_date_property_spec.rb spec/lib/v_property_spec.rb > spec/lib/parser_spec.rb spec/lib/t_z_info_vtimezone_spec.rb > spec/lib/v_date_time_property_spec.rb:8: warning: parenthesize argument(s) > for future version > spec/lib/v_date_time_property_spec.rb:12: warning: parenthesize argument(s) > for future version > spec/lib/v_date_time_property_spec.rb:4: undefined method `describe'' for > main:Object (NoMethodError) >Are you requiring ''spec'' anywhere? ///ark -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081202/be9597c6/attachment.html>
Rick DeNatale
2008-Dec-02 18:05 UTC
[rspec-users] Setup for autospec for non-rails project
On Tue, Dec 2, 2008 at 12:12 PM, Mark Wilden <mark at mwilden.com> wrote:> On Tue, Dec 2, 2008 at 9:01 AM, Rick DeNatale <rick.denatale at gmail.com>wrote: > > >> $ autospec >> loading autotest/rspec >> /opt/local/bin/ruby -S spec/lib/v_date_time_property_spec.rb >> spec/lib/v_date_property_spec.rb spec/lib/v_property_spec.rb >> spec/lib/parser_spec.rb spec/lib/t_z_info_vtimezone_spec.rb >> spec/lib/v_date_time_property_spec.rb:8: warning: parenthesize argument(s) >> for future version >> spec/lib/v_date_time_property_spec.rb:12: warning: parenthesize >> argument(s) for future version >> spec/lib/v_date_time_property_spec.rb:4: undefined method `describe'' for >> main:Object (NoMethodError) >> > > Are you requiring ''spec'' anywhere? >Adding require ''spec'' at the top of the .autospec file doesn''t change anything. I didn''t mention (this time) that the specs run fine if I use: * cmd-R in Textmate to run them via the RSpec bundle. * using rake spec * individually using the spec command. The problem seems to lie in something missing in the autotest/autospec setup. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081202/3ed7a41d/attachment.html>
Rick DeNatale
2008-Dec-02 18:18 UTC
[rspec-users] Setup for autospec for non-rails project
Okay, If I add this to my .autospec file class Autotest::Rspec def make_test_cmd(files_to_test) return '''' if files_to_test.empty? return "spec #{files_to_test.keys.flatten.join('' '')} #{add_options_if_present}" end end It works. This replaces a method defined in the rspec gem in lib/autotest/rspec.rb def make_test_cmd(files_to_test) return '''' if files_to_test.empty? return "#{ruby} -S #{files_to_test.keys.flatten.join('' '')} #{add_options_if_present}" end I guess I need to file a bug report?!? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081202/4ada8968/attachment.html>
Rick DeNatale
2008-Dec-02 18:27 UTC
[rspec-users] Setup for autospec for non-rails project
On Tue, Dec 2, 2008 at 1:18 PM, Rick DeNatale <rick.denatale at gmail.com>wrote:> Okay, > > If I add this to my .autospec file > > class Autotest::Rspec > > def make_test_cmd(files_to_test) > return '''' if files_to_test.empty? > return "spec #{files_to_test.keys.flatten.join('' '')} > #{add_options_if_present}" > end > end > > It works. > > This replaces a method defined in the rspec gem in lib/autotest/rspec.rb > > def make_test_cmd(files_to_test) > return '''' if files_to_test.empty? > return "#{ruby} -S #{files_to_test.keys.flatten.join('' '')} > #{add_options_if_present}" > end > > > I guess I need to file a bug report?!? >After investigating github, it looks like a slightly different fix for this is already in the works. http://github.com/dchelimsky/rspec/commit/d6029bd91a08ce87ad10c917bfb7b4c75645bf79 although it will only work if it''s in the gem code rather than in .autotest (it finds the spec command file path relative to the source file). So for the time being, I''ll just use my .autotest patch -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081202/356f9ee5/attachment.html>