Hi experts, I picked up a copy of the rspec book and wrote some tests in spec/lib and spec/models for my Rails 2.3.8 code. I was using rspec 2.5.1, rspec-core 2.5.0, rspec-expectations 2.5.0 et. al. But I realised that the rspec-rails version I am using is meant for Rails3. Which version of rspec-rails should I use for Rails 2.3.8? Best, Radhesh -- Posted via http://www.ruby-forum.com/.
On Fri, Feb 25, 2011 at 4:30 PM, Radhesh Kamath <lists at ruby-forum.com>wrote:> Which version of rspec-rails should I use for Rails 2.3.8?rspec-rails 1.3.3 is currently the latest release for Rails 2.3.x. Regards, Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110225/77787d49/attachment.html>
On Fri, Feb 25, 2011 at 2:30 PM, Radhesh Kamath <lists at ruby-forum.com>wrote:> Hi experts, > > I picked up a copy of the rspec book and wrote some tests in spec/lib > and spec/models for my Rails 2.3.8 code. > > I was using rspec 2.5.1, rspec-core 2.5.0, rspec-expectations 2.5.0 et. > al. > > But I realised that the rspec-rails version I am using is meant for > Rails3. > > Which version of rspec-rails should I use for Rails 2.3.8? > > Best, > Radhesh > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >You would need to use version 1.3.3 https://github.com/dchelimsky/rspec-rails If I were you I would try to upgrade to Rails 3 because RSpec 2 is really, really nice. Upgrading to Rails 3 is easy and not bad at all unless you have some non-upgradable gems, like searchlogic for example, then it might be a pain. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110225/5f217208/attachment.html>
Craig Demyanovich wrote in post #983991:> On Fri, Feb 25, 2011 at 4:30 PM, Radhesh Kamath > <lists at ruby-forum.com>wrote: > >> Which version of rspec-rails should I use for Rails 2.3.8? > > > rspec-rails 1.3.3 is currently the latest release for Rails 2.3.x. >I am getting this error with my current setup, which I think, should not happen: Failure/Error: non_uniq_agg.should have(2).errors_on(:name) NoMethodError: undefined method `errors_on'' for #<Aggregate:0x383fe1aa> where ''Aggregate'' is a model I am testing. My gem list looks like so: *** LOCAL GEMS *** abstract (1.0.0) actionmailer (2.3.8) actionpack (2.3.8) activerecord (2.3.8) activerecord-jdbc-adapter (1.1.1) activerecord-jdbcmysql-adapter (1.1.1) activeresource (2.3.8) activesupport (2.3.8) backports (1.18.2) bouncy-castle-java (1.5.0145.2) builder (2.1.2) columnize (0.3.1) diff-lcs (1.1.2) erubis (2.6.6) facets (2.9.1) i18n (0.4.0) ipaddress (0.7.0) jdbc-mysql (5.1.13) jruby-openssl (0.7.3) macaddr (1.0.0) rack (1.2.1, 1.1.0) rack-mount (0.6.13) rack-test (0.5.7) rails (2.3.8) rake (0.8.7) rspec (2.5.0, 1.3.1) rspec-core (2.5.1) rspec-expectations (2.5.0) rspec-mocks (2.5.0) rspec-rails (1.3.3) ruby-debug (0.10.3) ruby-debug-base (0.10.3.2) sources (0.0.1) thor (0.14.6) tzinfo (0.3.24) uuid (2.3.1) And my spec_helper looks like so: ENV["RAILS_ENV"] ||= ''development'' require File.expand_path("../../config/environment", __FILE__) # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} RSpec.configure do |config| # == Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: # # config.mock_with :mocha # config.mock_with :flexmock # config.mock_with :rr config.mock_with :rspec # Remove this line if you''re not using ActiveRecord or ActiveRecord fixtures #config.fixture_path = "#{::Rails.root}/spec/fixtures" # If you''re not using ActiveRecord, or you''d prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. #config.use_transactional_fixtures = true end Is there something else I should be including?> Regards, > Craig-- Posted via http://www.ruby-forum.com/.
On Feb 25, 2011, at 4:19 PM, Radhesh Kamath wrote:> Craig Demyanovich wrote in post #983991: >> On Fri, Feb 25, 2011 at 4:30 PM, Radhesh Kamath >> <lists at ruby-forum.com>wrote: >> >>> Which version of rspec-rails should I use for Rails 2.3.8? >> >> >> rspec-rails 1.3.3 is currently the latest release for Rails 2.3.x. >> > > I am getting this error with my current setup, which I think, should not > happen: > > Failure/Error: non_uniq_agg.should have(2).errors_on(:name) > NoMethodError: > undefined method `errors_on'' for #<Aggregate:0x383fe1aa> > > where ''Aggregate'' is a model I am testing. > > My gem list looks like so: > > *** LOCAL GEMS *** > > abstract (1.0.0) > actionmailer (2.3.8) > actionpack (2.3.8) > activerecord (2.3.8) > activerecord-jdbc-adapter (1.1.1) > activerecord-jdbcmysql-adapter (1.1.1) > activeresource (2.3.8) > activesupport (2.3.8) > backports (1.18.2) > bouncy-castle-java (1.5.0145.2) > builder (2.1.2) > columnize (0.3.1) > diff-lcs (1.1.2) > erubis (2.6.6) > facets (2.9.1) > i18n (0.4.0) > ipaddress (0.7.0) > jdbc-mysql (5.1.13) > jruby-openssl (0.7.3) > macaddr (1.0.0) > rack (1.2.1, 1.1.0) > rack-mount (0.6.13) > rack-test (0.5.7) > rails (2.3.8) > rake (0.8.7) > rspec (2.5.0, 1.3.1) > rspec-core (2.5.1) > rspec-expectations (2.5.0) > rspec-mocks (2.5.0) > rspec-rails (1.3.3) > ruby-debug (0.10.3) > ruby-debug-base (0.10.3.2) > sources (0.0.1) > thor (0.14.6) > tzinfo (0.3.24) > uuid (2.3.1) > > And my spec_helper looks like so: > > ENV["RAILS_ENV"] ||= ''development'' > require File.expand_path("../../config/environment", __FILE__) > > # Requires supporting ruby files with custom matchers and macros, etc, > # in spec/support/ and its subdirectories. > Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} > > RSpec.configure do |config|If you''re using rspec-rails-1.3.3, this line ^^ should raise an error since the RSpec constant wasn''t introduced until rspec-2.0. I''m guessing that the rails app is not correctly configured to use rspec-rails-1.3.3. What''s in config/environment.rb? Are you using bundler? If so, what''s in Gemfile?> # == Mock Framework > # > # If you prefer to use mocha, flexmock or RR, uncomment the > appropriate line: > # > # config.mock_with :mocha > # config.mock_with :flexmock > # config.mock_with :rr > config.mock_with :rspec > > # Remove this line if you''re not using ActiveRecord or ActiveRecord > fixtures > #config.fixture_path = "#{::Rails.root}/spec/fixtures" > > # If you''re not using ActiveRecord, or you''d prefer not to run each of > your > # examples within a transaction, remove the following line or assign > false > # instead of true. > #config.use_transactional_fixtures = true > end > > Is there something else I should be including? > >> Regards, >> Craig > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-usersCheers, David
David Chelimsky wrote in post #984311:> On Feb 25, 2011, at 4:19 PM, Radhesh Kamath wrote: > >> I am getting this error with my current setup, which I think, should not >> *** LOCAL GEMS *** >> bouncy-castle-java (1.5.0145.2) >> rack (1.2.1, 1.1.0) >> ruby-debug-base (0.10.3.2) >> # Requires supporting ruby files with custom matchers and macros, etc, >> # in spec/support/ and its subdirectories. >> Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} >> >> RSpec.configure do |config| > > If you''re using rspec-rails-1.3.3, this line ^^ should raise an error > since the RSpec constant wasn''t introduced until rspec-2.0. > > I''m guessing that the rails app is not correctly configured to use > rspec-rails-1.3.3. > > What''s in config/environment.rb? Are you using bundler? If so, what''s in > Gemfile?Do not worry about it... I just moved to Rails 3.0.4, because I was facing some other issues with my Rails 2.3.8 application. I am using the following gems now, but I still get an error saying this: Failure/Error: non_uniq_agg.should have(1).error_on(:name) NoMethodError: undefined method `error_on'' for #<Aggregate:0x53ef1aa4> There are failures for errors_on as well, which leads me to think that I am not requiring the proper stuff still. Here''s my latest gem list: *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.4) actionpack (3.0.4) activemodel (3.0.4) activerecord (3.0.4) activerecord-jdbc-adapter (1.1.1) activerecord-jdbcmysql-adapter (1.1.1) activeresource (3.0.4) activesupport (3.0.4) acts_as_tree_rails3 (0.1.0) arel (2.0.9) backports (1.18.2) bouncy-castle-java (1.5.0145.2) builder (2.1.2) bundler (1.0.10) columnize (0.3.2) diff-lcs (1.1.2) erubis (2.6.6) facets (2.9.1) glassfish (1.0.3 universal-java, 1.0.2 universal-java) hoe (2.9.1, 2.7.0) i18n (0.4.0) ipaddress (0.7.0) jdbc-mysql (5.1.13) jruby-openssl (0.7.3, 0.7.1) json_pure (1.4.6) macaddr (1.0.0) mail (2.2.15) mime-types (1.16) polyglot (0.3.1) rack (1.2.1) rack-mount (0.6.13) rack-test (0.5.7) rails (3.0.4) railties (3.0.4) rake (0.8.7) rspec (2.5.0, 1.3.1) rspec-core (2.5.1) rspec-expectations (2.5.0) rspec-mocks (2.5.0) rspec-rails (2.5.0) ruby-debug (0.10.4) ruby-debug-base (0.10.4 java) rubyforge (2.0.4) sources (0.0.1) SyslogLogger (1.4.0) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.24) uuid (2.3.1) My Ruby version: jruby 1.6.0.RC2 (ruby 1.8.7 patchlevel 330) (2011-02-09 5434c72) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_19) [linux-amd64-java] spec_helper.rb looks like so: ENV["RAILS_ENV"] ||= ''development'' require File.expand_path("../../config/environment", __FILE__) # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} RSpec.configure do |config| # == Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: # # config.mock_with :mocha # config.mock_with :flexmock # config.mock_with :rr config.mock_with :rspec # Remove this line if you''re not using ActiveRecord or ActiveRecord fixtures #config.fixture_path = "#{::Rails.root}/spec/fixtures" # If you''re not using ActiveRecord, or you''d prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. #config.use_transactional_fixtures = true end> >> # Remove this line if you''re not using ActiveRecord or ActiveRecord >> >> http://rubyforge.org/mailman/listinfo/rspec-users > Cheers, > David-- Posted via http://www.ruby-forum.com/.
P.S.: I looked at this error and used the workaround you have suggested, but it would be nice to use the errors_on, error_on etc. matchers (which is why I moved to Rails 3 in the first place :)) https://rspec.lighthouseapp.com/projects/5645/tickets/962-missing-error_on-method-with-rails-3 -- Posted via http://www.ruby-forum.com/.
Radhesh Kamath wrote in post #985062:> spec_helper.rb looks like so: > ENV["RAILS_ENV"] ||= ''development'' > require File.expand_path("../../config/environment", __FILE__) > > # Requires supporting ruby files with custom matchers and macros, etc, > # in spec/support/ and its subdirectories. > Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} >Sorry about the trouble, folks. It was my mistake. Adding require ''rspec/rails'' fixed my problem. Thanks, Radhesh -- Posted via http://www.ruby-forum.com/.