From lists at ruby-forum.com Sat Jan 1 02:12:21 2011 From: lists at ruby-forum.com (Kevin Lochner) Date: Sat, 01 Jan 2011 08:12:21 +0100 Subject: [rspec-users] my helper stubs aren't working (rspec2, rails3) In-Reply-To: References: Message-ID: David Chelimsky wrote in post #971734: > > Can you post your Gemfile and spec/spec_helper.rb files? I'm guessing > there's a configuration problem of some sort. > > Cheers, > David David - thanks for following up so quickly, and happy new year. #Gemfile: source 'http://rubygems.org' gem 'rails', '3.0.3' gem 'mysql2' gem 'activerecord-import' gem 'htmldoc', '0.2.1' gem 'moomerman-twitter_oauth', '0.2.1', :require => 'twitter_oauth' gem 'twitter', '0.4.2' gem 'roo', '1.2.3' gem 'hashie' gem 'ruby-hmac', :require => 'hmac-sha2' gem 'httparty' gem 'ruby-debug' gem 'bitly' gem 'soap4r' gem 'rack-openid' gem 'will_paginate', '~> 3.0.pre2' gem "rake" gem "hoe" gem "rcov" gem "right_http_connection" group :test do gem 'webrat' gem 'factory_girl_rails' gem "rspec" gem "rspec-mocks" gem 'rspec-rails' gem 'remarkable' gem "remarkable_activerecord" gem "shoulda" end #spec/spec_helper.rb ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'shoulda' # 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} include AuthenticatedTestHelper 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 config.global_fixtures = :users end -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sat Jan 1 12:20:00 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 1 Jan 2011 11:20:00 -0600 Subject: [rspec-users] can't get RSpec 2.3.1 to work in Rails 3.0.3 - uninitialized constant Rails (NameError) In-Reply-To: <444335fc-0e31-47e6-93f2-35684f3cc34c@r16g2000prh.googlegroups.com> References: <444335fc-0e31-47e6-93f2-35684f3cc34c@r16g2000prh.googlegroups.com> Message-ID: <3A875267-5BA2-4DF1-914A-20225EE0BFC6@gmail.com> On Dec 30, 2010, at 4:37 PM, Kurt wrote: > I just installed rspec-rails 2.3.1 gem into a new Rails 3.0.3 app, ran > the rspec:install generator, but the system doesn't see any other > RSpec generators (like rspec_controller), There is an rspec:controller generator, but Rails hides it from you because it is intended (by Rails) to be run with the Rails controller generator. When you run `rails generate controller Accounts name:string`, Rails generates the controller file and then delegates to RSpec to run the spec file. > and the server will no longer start. The server? What command are you typing? > Both report this error: > > /.rvm/gems/ruby-1.9.2-p0 at rails3/gems/rspec-rails-2.3.1/lib/rspec- > rails.rb:3:in `': uninitialized constant Rails > (NameError) > > Here's a clip of the file referenced by the error: > > module RSpec > module Rails > class Railtie < ::Rails::Railtie > > > I've used RSpec 2.0 and 2.1 with Rails 3 before without problems. Any > suggestions greatly appreciated.. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Cheers, David From dchelimsky at gmail.com Sat Jan 1 12:40:48 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 1 Jan 2011 11:40:48 -0600 Subject: [rspec-users] my helper stubs aren't working (rspec2, rails3) In-Reply-To: References: Message-ID: On Sat, Jan 1, 2011 at 1:12 AM, Kevin Lochner wrote: > David Chelimsky wrote in post #971734: > >> >> Can you post your Gemfile and spec/spec_helper.rb files? I'm guessing >> there's a configuration problem of some sort. >> >> Cheers, >> David > > David - thanks for following up so quickly, and happy new year. To you as well. > #Gemfile: > source 'http://rubygems.org' > > gem 'rails', '3.0.3' > gem 'mysql2' > gem 'activerecord-import' > gem 'htmldoc', '0.2.1' > gem 'moomerman-twitter_oauth', '0.2.1', :require => 'twitter_oauth' > gem 'twitter', '0.4.2' > gem 'roo', '1.2.3' > gem 'hashie' > gem 'ruby-hmac', :require => 'hmac-sha2' > gem 'httparty' > gem 'ruby-debug' > gem 'bitly' > gem 'soap4r' > gem 'rack-openid' > gem 'will_paginate', '~> 3.0.pre2' > gem "rake" > gem "hoe" > gem "rcov" > gem "right_http_connection" > > group :test do > ?gem 'webrat' > ?gem 'factory_girl_rails' > ?gem "rspec" > ?gem "rspec-mocks" > ?gem 'rspec-rails' You only need ^^ rspec-rails here. It requires rspec, which requires rspec-mocks. I'd actually recommend using this format: gem "rspec-rails", "~> 2.3" This will accept updates up to, but not including 3.0. This means you'll get bug fixes and/or new functionality, but no breaking changes. > ?gem 'remarkable' > ?gem "remarkable_activerecord" > ?gem "shoulda" > end > > #spec/spec_helper.rb > ENV["RAILS_ENV"] ||= 'test' > require File.expand_path("../../config/environment", __FILE__) > require 'rspec/rails' > require 'shoulda' > > # 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} > include AuthenticatedTestHelper > > 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 > > ?config.global_fixtures = :users > end Unfortunately, I don't see anything here right out of the gate that would be causing this. Would you try bootstrapping a new app and see if the same thing happens? When I run this I get the following output: ThingsHelper supports stubs Finished in 0.0257 seconds 1 example, 0 failures From dchelimsky at gmail.com Sat Jan 1 12:43:58 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 1 Jan 2011 11:43:58 -0600 Subject: [rspec-users] helper spec problems In-Reply-To: <8cb168ff-24df-4d24-9bfd-ccf6a3560af3@z19g2000yqb.googlegroups.com> References: <8cb168ff-24df-4d24-9bfd-ccf6a3560af3@z19g2000yqb.googlegroups.com> Message-ID: On Thu, Dec 30, 2010 at 3:02 PM, klochner wrote: > Using: rspec 2.3 with rails3 > > I'm unable to stub out the current_user method in my helper, not sure > what I'm doing wrong: > > ?describe "link_to_current_user, When logged in" do > ? ?it "should link to the given user" do > ? ? ?helper.stub!(:current_user).and_return(@user) > > helper.should_receive(:user_profile_path).at_least(:once).and_return('/ > user/profiles/1') > ? ? ?helper.link_to_current_user.should have_selector("a[href='/user/ > profiles/1']") > ? ?end > ?end > > ?7) UsersHelper link_to_current_user, When logged in should link to > the given user > ? ? Failure/Error: helper.link_to_current_user.should > have_selector("a[href='/user/profiles/1']") > ? ? undefined local variable or method `current_user' for > # > ? ? # ./app/helpers/users_helper.rb:84:in `link_to_current_user' > ? ? # ./spec/helpers/users_helper_spec.rb:89 > > and lines 83/84 from users_helper.rb: > > ?def link_to_current_user(options={}) > ? ?if current_user I'm guessing this is the same issue as http://groups.google.com/group/rspec/browse_thread/thread/db5a43ee63157768, yes? From lists at ruby-forum.com Sat Jan 1 15:49:37 2011 From: lists at ruby-forum.com (Kevin Lochner) Date: Sat, 01 Jan 2011 21:49:37 +0100 Subject: [rspec-users] my helper stubs aren't working (rspec2, rails3) In-Reply-To: References: Message-ID: David Chelimsky wrote in post #971793: > You only need ^^ rspec-rails here. It requires rspec, which requires > rspec-mocks. I'd actually recommend using this format: > > gem "rspec-rails", "~> 2.3" > > This will accept updates up to, but not including 3.0. This means > you'll get bug fixes and/or new functionality, but no breaking > changes. thanks, will do. > Unfortunately, I don't see anything here right out of the gate that > would be causing this. > > Would you try bootstrapping a new app and see if the same thing happens? Unfortunately that worked: ThingsHelper supports stubs . . . so there's something weird going on with my app. Any other suggestions before I start wrestling with it? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sat Jan 1 16:06:03 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 1 Jan 2011 15:06:03 -0600 Subject: [rspec-users] my helper stubs aren't working (rspec2, rails3) In-Reply-To: References: Message-ID: <1A3879E3-FC5D-483C-919F-FB6DE3B8531D@gmail.com> On Jan 1, 2011, at 2:49 PM, Kevin Lochner wrote: > David Chelimsky wrote in post #971793: > >> You only need ^^ rspec-rails here. It requires rspec, which requires >> rspec-mocks. I'd actually recommend using this format: >> >> gem "rspec-rails", "~> 2.3" >> >> This will accept updates up to, but not including 3.0. This means >> you'll get bug fixes and/or new functionality, but no breaking >> changes. > > thanks, will do. > >> Unfortunately, I don't see anything here right out of the gate that >> would be causing this. >> >> Would you try bootstrapping a new app and see if the same thing happens? > > Unfortunately that worked: > > ThingsHelper > supports stubs > > . . . so there's something weird going on with my app. > > Any other suggestions before I start wrestling with it? It's New Year's Day. Start with a pint, and then go from there :) From lists at ruby-forum.com Sat Jan 1 16:10:55 2011 From: lists at ruby-forum.com (Kevin Lochner) Date: Sat, 01 Jan 2011 22:10:55 +0100 Subject: [rspec-users] my helper stubs aren't working (rspec2, rails3) In-Reply-To: References: Message-ID: Kevin Lochner wrote in post #971805: > David Chelimsky wrote in post #971793: > > Unfortunately that worked: > > ThingsHelper > supports stubs > > . . . so there's something weird going on with my app. It seems that I left out a critical detail :) I was using incorrect syntax to stub a different method in a before block: before do stub(:some_other_method).and_return(val) end Which appears to silently break stubbing. Try the following: describe ThingsHelper do it "supports stubs" do stub!(:bar) {"foobar"} helper.stub(:foo) { "bar" } helper.foo.should eq("bar") end end that gives me: 1) ThingsHelper supports stubs Failure/Error: helper.foo.should eq("bar") undefined method `foo' for # -- Posted via http://www.ruby-forum.com/. From kmandrup at gmail.com Sun Jan 2 06:42:03 2011 From: kmandrup at gmail.com (Kristian Mandrup) Date: Sun, 2 Jan 2011 03:42:03 -0800 (PST) Subject: [rspec-users] undefined method `run_all' for []:Array Message-ID: I'm using the latest ruby 1.9.3-head and recently whenever I run rspec (2.2+) I get the following error: I have seen others have run into this issue, but to resolve it just rolled back to a previous version of rspec or it there a better way? ruby-1.9.3-head/gems/rspec-core-2.3.1/lib/rspec/core/hooks.rb:116:in `run_hook_filtered': undefined method `run_all' for []:Array (NoMethodError) from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/example_group.rb:215:in `eval_after_alls' from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/example_group.rb:237:in `run' from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/command_line.rb:27:in `block (2 levels) in run' from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/command_line.rb:27:in `map' from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/command_line.rb:27:in `block in run' from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/reporter.rb:12:in `report' from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/command_line.rb:24:in `run' from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/runner.rb:55:in `run_in_process' from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/runner.rb:46:in `run' from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- core-2.3.1/lib/rspec/core/runner.rb:10:in `block in autorun' From matt at mattwynne.net Sun Jan 2 08:55:19 2011 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 2 Jan 2011 13:55:19 +0000 Subject: [rspec-users] Fantastic Thread on Mock Objects Message-ID: <138E9459-D88B-4CE7-9181-EA5EBA851C45@mattwynne.net> This is a classic, with some terrific insights from Steve Freeman and Nat Pryce, two of the finest practitioners of TDD that I know: http://groups.google.com/group/growing-object-oriented-software/t/af0c4251123fde43 cheers, Matt matt at mattwynne.net 07974 430184 From matt at mattwynne.net Sun Jan 2 11:21:08 2011 From: matt at mattwynne.net (Matt Wynne) Date: Sun, 2 Jan 2011 16:21:08 +0000 Subject: [rspec-users] Specing Ajaxy Views In-Reply-To: <755efa7e2154182fcf22bc569c73b840@shealevy.com> References: <755efa7e2154182fcf22bc569c73b840@shealevy.com> Message-ID: <06F31E75-0E17-4980-A610-D8E7717E77AE@mattwynne.net> On 30 Dec 2010, at 03:43, Shea Levy wrote: > Hi all, > > I am working on a feature to allow administrators of an online store to rearrange the order in which their product categories show up on the site. I want to use a simple implementation of sortable_lists (madrobby.github.com/scriptaculous/sortable-lists-demo/) to allow the administrators to just drag and drop the categories into the desired order. I have already written a cucumber feature that I hope expresses the desired function (does anyone know if Capybara+Selenium's drag_to method will work with sortable_lists?), and have gotten to red on the Cucumber level, but I'm at a loss as to how to continue. The Cucumber scenario goes to the page, drags each category to the desired spot, then reloads the page to check that the categories are in the right order. The When (dragging each category) passes (though the dragging doesn't actually do anything, since the sortable_list is not set up yet), but the Then (checking the categories) fails because nothing was actually changed. I think my next step should be a view spec, but I'm not sure exactly how to proceed. I think what I want to check on the view level is a) that clicking and dragging updates the document and b) that the proper AJAX request is sent to the controller, but I don't know how to do either. Once I got those working, the next step (specing the controller which responds to the request) seems easier, but I don't know how to get past this part. > > Also, it occurs to me that, since I didn't write the sortable_list code myself, maybe I should view it as an external API and my view spec should just check that the view is set up properly to interact with the API. Does that make more sense? How would I do that? In general, if I want to add Javascript functionality to a view, should I treat the scripting itself as a separate component to be "speced" with something like JsUnit as part of the inner circle of the BDD cycle, along with specing views, controllers, and models, or is there ever a time when Javascript specs should be considered the responsibility of the view spec? > > In general, when I'm in a situation where I'm not sure how to test drive something, I will create a branch in git and implement it as a spike. I might well use Cucumber to help me drive the spike. Then I'll reflect on what I would want tests for: what am I worried could break, and how would I want to be notified? Sometimes I decide that there's so little code that I don't need any specs, and I can just rely on the Cucumber test. In that case I'll merge the branch into master and move on. > Cheers, > Shea > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users cheers, Matt matt at mattwynne.net 07974 430184 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 2 13:32:55 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Jan 2011 12:32:55 -0600 Subject: [rspec-users] undefined method `run_all' for []:Array In-Reply-To: References: Message-ID: On Sun, Jan 2, 2011 at 5:42 AM, Kristian Mandrup wrote: > I'm using the latest ruby 1.9.3-head and recently whenever I run rspec > (2.2+) I get the following error: > > I have seen others have run into this issue, but to resolve it just > rolled back to a previous version of rspec or it there a better way? Better is to wait to upgrade to the next version of rspec that fixes the bug: https://github.com/rspec/rspec-core/issues/closed#issue/258 To be released as part of rspec-core-2.4 within the next day or so. Cheers, David > > ruby-1.9.3-head/gems/rspec-core-2.3.1/lib/rspec/core/hooks.rb:116:in > `run_hook_filtered': undefined method `run_all' for []:Array > (NoMethodError) > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/example_group.rb:215:in `eval_after_alls' > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/example_group.rb:237:in `run' > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/command_line.rb:27:in `block (2 levels) in > run' > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/command_line.rb:27:in `map' > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/command_line.rb:27:in `block in run' > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/reporter.rb:12:in `report' > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/command_line.rb:24:in `run' > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/runner.rb:55:in `run_in_process' > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/runner.rb:46:in `run' > ? ? ? ?from /Users/kristianconsult/.rvm/gems/ruby-1.9.3-head/gems/rspec- > core-2.3.1/lib/rspec/core/runner.rb:10:in `block in autorun' > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Sun Jan 2 17:42:33 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Jan 2011 16:42:33 -0600 Subject: [rspec-users] rspec-rails-2.4.0 is released! Message-ID: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> ### rspec-rails-2.4.0 / 2011-01-02 [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...2.4.0) * Enhancements * include ApplicationHelper in helper object in helper specs * include request spec extensions in files in spec/integration * include controller spec extensions in groups that use :type => :controller * same for :model, :view, :helper, :mailer, :request, :routing * Bug fixes * restore global config.render_views so you only need to say it once * support overriding render_views in nested groups * matchers that delegate to Rails' assertions capture ActiveSupport::TestCase::Assertion (so they work properly now with should_not in Ruby 1.8.7 and 1.9.1) * Deprecations * `include_self_when_dir_matches` From dchelimsky at gmail.com Sun Jan 2 17:42:30 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Jan 2011 16:42:30 -0600 Subject: [rspec-users] rspec-2.4.0 is released! Message-ID: Changes to rspec-core listed below. There are no functional changes to rspec-mocks or rspec-expectations for this release. Happy New Year! Cheers, David ### rspec-core-2.4.0 / 2011-01-02 [full changelog](http://github.com/rspec/rspec-core/compare/v2.3.1...v2.4.0) * Enhancements * start the debugger on -d so the stack trace is visible when it stops (Clifford Heath) * apply hook filtering to examples as well as groups (Myron Marston) * support multiple formatters, each with their own output * show exception classes in failure messages unless they come from RSpec matchers or message expectations * before(:all) { pending } sets all examples to pending * Bug fixes * fix bug due to change in behavior of reject in Ruby 1.9.3-dev (Shota Fukumori) * fix bug when running in jruby: be explicit about passing block to super (John Firebaugh) * rake task doesn't choke on paths with quotes (Janmejay Singh) * restore --options option from rspec-1 * require 'ostruct' to fix bug with its([key]) (Kim Burgestrand) * --configure option generates .rspec file instead of autotest/discover.rb From wolfmanjm at gmail.com Sun Jan 2 22:09:26 2011 From: wolfmanjm at gmail.com (Jim Morris) Date: Sun, 2 Jan 2011 19:09:26 -0800 (PST) Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> Message-ID: <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> I just upgraded from 2.3.1 and I now get this error on all my specs... Nothing else changed and the Upgrade.md does not indicate any backward compatibilities unless I missed something. (in /home/morris/work/ruby/rails3/wolfmanblog) /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby -S bundle exec rspec ./ spec/controllers/posts_controller_spec.rb [sequel] Setting up the "test" environment: /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined method `setup' for # (NoMethodError) from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:in `append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ actionpack-3.0.3/lib/action_controller/test_case.rb:439 from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:in `append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `configure_group' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `configure_group' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' from /home/morris/work/ruby/rails3/wolfmanblog/spec/ controllers/posts_controller_spec.rb:3 from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/bin/ rspec:19 rake aborted! ruby -S bundle exec rspec ./spec/controllers/posts_controller_spec.rb failed (See full trace by running task with --trace) On Jan 2, 2:42?pm, David Chelimsky wrote: > ### rspec-rails-2.4.0 / 2011-01-02 > > [full changelog](http://github.com/rspec/rspec-rails/compare/v2.3.1...2.4.0) > > * Enhancements > ? * include ApplicationHelper in helper object in helper specs > ? * include request spec extensions in files in spec/integration > ? * include controller spec extensions in groups that use :type => :controller > ? ? * same for :model, :view, :helper, :mailer, :request, :routing > > * Bug fixes > ? * restore global config.render_views so you only need to say it once > ? * support overriding render_views in nested groups > ? * matchers that delegate to Rails' assertions capture > ? ? ActiveSupport::TestCase::Assertion (so they work properly now with > ? ? should_not in Ruby 1.8.7 and 1.9.1) > > * Deprecations > ? * `include_self_when_dir_matches` > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Jan 2 22:46:04 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Jan 2011 21:46:04 -0600 Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> Message-ID: On Sun, Jan 2, 2011 at 9:09 PM, Jim Morris wrote: > I just upgraded from 2.3.1 and I now get this error on all my specs... > Nothing else changed and the Upgrade.md does not indicate any backward > compatibilities unless I missed something. > > (in /home/morris/work/ruby/rails3/wolfmanblog) > /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby -S bundle exec rspec ./ > spec/controllers/posts_controller_spec.rb > [sequel] Setting up the "test" environment: > /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined > method `setup' for # (NoMethodError) > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:52:in > `append_features' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > actionpack-3.0.3/lib/action_controller/test_case.rb:439 > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:52:in > `append_features' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in > `append_features' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in > `append_features' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in > `configure_group' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in > `configure_group' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' > ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ > controllers/posts_controller_spec.rb:3 > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/bin/ > rspec:19 > rake aborted! > ruby -S bundle exec rspec ./spec/controllers/posts_controller_spec.rb > failed I'm not seeing this in any of my apps. Seems like a configuration or load order problem. Can you post your Gemfile and spec/spec_helper.rb? From wolfmanjm at gmail.com Sun Jan 2 23:12:15 2011 From: wolfmanjm at gmail.com (Jim Morris) Date: Sun, 2 Jan 2011 20:12:15 -0800 (PST) Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> Message-ID: <59f22461-d827-4e62-8151-adc5d05b8f69@q8g2000prm.googlegroups.com> Yes I can, the full app is on https://github.com/wolfmanjm/wolfmanblog_rails although I downgraded back to rspec-rails 2.3.1, before I did that my Gemfile.lock looked like... GEM remote: http://rubygems.org/ specs: abstract (1.0.0) actionmailer (3.0.3) actionpack (= 3.0.3) mail (~> 2.2.9) actionpack (3.0.3) activemodel (= 3.0.3) activesupport (= 3.0.3) builder (~> 2.1.2) erubis (~> 2.6.6) i18n (~> 0.4) rack (~> 1.2.1) rack-mount (~> 0.6.13) rack-test (~> 0.5.6) tzinfo (~> 0.3.23) activemodel (3.0.3) activesupport (= 3.0.3) builder (~> 2.1.2) i18n (~> 0.4) activerecord (3.0.3) activemodel (= 3.0.3) activesupport (= 3.0.3) arel (~> 2.0.2) tzinfo (~> 0.3.23) activeresource (3.0.3) activemodel (= 3.0.3) activesupport (= 3.0.3) activesupport (3.0.3) arel (2.0.6) builder (2.1.2) cells (3.4.2) diff-lcs (1.1.2) erubis (2.6.6) abstract (>= 1.0.0) factory_girl (1.3.2) factory_girl_rails (1.0) factory_girl (~> 1.3) rails (>= 3.0.0.beta4) haml (3.0.24) i18n (0.5.0) mail (2.2.12) activesupport (>= 2.3.6) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.16) nokogiri (1.4.4) pg (0.10.0) polyglot (0.3.1) rack (1.2.1) rack-mount (0.6.13) rack (>= 1.0.0) rack-test (0.5.7) rack (>= 1.0) rails (3.0.3) actionmailer (= 3.0.3) actionpack (= 3.0.3) activerecord (= 3.0.3) activeresource (= 3.0.3) activesupport (= 3.0.3) bundler (~> 1.0) railties (= 3.0.3) railties (3.0.3) actionpack (= 3.0.3) activesupport (= 3.0.3) rake (>= 0.8.7) thor (~> 0.14.4) rake (0.8.7) rdiscount (1.6.5) rspec (2.4.0) rspec-core (~> 2.4.0) rspec-expectations (~> 2.4.0) rspec-mocks (~> 2.4.0) rspec-cells (0.0.2) cells (~> 3.4) rails (~> 3.0) rspec-rails (~> 2.2) rspec-core (2.4.0) rspec-expectations (2.4.0) diff-lcs (~> 1.1.2) rspec-mocks (2.4.0) rspec-rails (2.4.0) actionpack (~> 3.0) activesupport (~> 3.0) railties (~> 3.0) rspec (~> 2.4.0) sequel (3.17.0) sequel-rails (0.1.8) actionpack (~> 3.0.0) activesupport (~> 3.0.0) railties (~> 3.0.0) sequel (~> 3.13) stringex (1.2.0) thor (0.14.6) treetop (1.4.9) polyglot (>= 0.3.1) tzinfo (0.3.23) uuidtools (2.1.1) webrat (0.7.2) nokogiri (>= 1.2.0) rack (>= 1.0) rack-test (>= 0.5.3) PLATFORMS ruby DEPENDENCIES cells factory_girl_rails haml pg rails (= 3.0.3) rdiscount rspec-cells rspec-rails (~> 2.3) sequel-rails stringex uuidtools webrat Using rake (0.8.7) Using abstract (1.0.0) Using activesupport (3.0.3) Using builder (2.1.2) Using i18n (0.5.0) Using activemodel (3.0.3) Using erubis (2.6.6) Using rack (1.2.1) Using rack-mount (0.6.13) Using rack-test (0.5.7) Using tzinfo (0.3.23) Using actionpack (3.0.3) Using mime-types (1.16) Using polyglot (0.3.1) Using treetop (1.4.9) Using mail (2.2.12) Using actionmailer (3.0.3) Using arel (2.0.6) Using activerecord (3.0.3) Using activeresource (3.0.3) Using bundler (1.0.3) Using cells (3.4.2) Using diff-lcs (1.1.2) Using factory_girl (1.3.2) Using thor (0.14.6) Using railties (3.0.3) Using rails (3.0.3) Using factory_girl_rails (1.0) Using haml (3.0.24) Using nokogiri (1.4.4) Using pg (0.10.0) Using rdiscount (1.6.5) Using rspec-core (2.4.0) Using rspec-expectations (2.4.0) Using rspec-mocks (2.4.0) Using rspec (2.4.0) Using rspec-rails (2.4.0) Using rspec-cells (0.0.2) Using sequel (3.17.0) Using sequel-rails (0.1.8) Using stringex (1.2.0) Using uuidtools (2.1.1) Using webrat (0.7.2) and spec_helper.rb looked like... # This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' # 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 # setup transactional factory for sequel, when running transactional tests config.around(:each, :transactional => true) do |example| Sequel::DATABASES.first.transaction do example.run raise Sequel::Error::Rollback end end end # to make factory girl run with sequel class Sequel::Model def save! save(:validate=>false) end end On Jan 2, 7:46?pm, David Chelimsky wrote: > On Sun, Jan 2, 2011 at 9:09 PM, Jim Morris wrote: > > I just upgraded from 2.3.1 and I now get this error on all my specs... > > Nothing else changed and the Upgrade.md does not indicate any backward > > compatibilities unless I missed something. > > > (in /home/morris/work/ruby/rails3/wolfmanblog) > > /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby -S bundle exec rspec ./ > > spec/controllers/posts_controller_spec.rb > > [sequel] Setting up the "test" environment: > > /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined > > method `setup' for # (NoMethodError) > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:52:in > > `append_features' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > actionpack-3.0.3/lib/action_controller/test_case.rb:439 > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:52:in > > `append_features' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in > > `append_features' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in > > `append_features' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in > > `configure_group' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in > > `configure_group' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' > > ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ > > controllers/posts_controller_spec.rb:3 > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > > `load_spec_files' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > > `load_spec_files' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/bin/ > > rspec:19 > > rake aborted! > > ruby -S bundle exec rspec ./spec/controllers/posts_controller_spec.rb > > failed > > I'm not seeing this in any of my apps. Seems like a configuration or > load order problem. Can you post your Gemfile and spec/spec_helper.rb? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From wolfmanjm at gmail.com Sun Jan 2 23:20:05 2011 From: wolfmanjm at gmail.com (Jim Morris) Date: Sun, 2 Jan 2011 20:20:05 -0800 (PST) Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> Message-ID: I forgot to mention that I did get a deprecation warning from rspec- cells (they haven't updated it yet), but I fixed it by doing what the deprecation warning said. I don't think that has anything to do with the error I am getting though. On Jan 2, 7:46?pm, David Chelimsky wrote: > On Sun, Jan 2, 2011 at 9:09 PM, Jim Morris wrote: > > I just upgraded from 2.3.1 and I now get this error on all my specs... > > Nothing else changed and the Upgrade.md does not indicate any backward > > compatibilities unless I missed something. > > > (in /home/morris/work/ruby/rails3/wolfmanblog) > > /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby -S bundle exec rspec ./ > > spec/controllers/posts_controller_spec.rb > > [sequel] Setting up the "test" environment: > > /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined > > method `setup' for # (NoMethodError) > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:52:in > > `append_features' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > actionpack-3.0.3/lib/action_controller/test_case.rb:439 > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:52:in > > `append_features' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in > > `append_features' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > activesupport-3.0.3/lib/active_support/concern.rb:48:in > > `append_features' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in > > `configure_group' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in > > `configure_group' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' > > ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ > > controllers/posts_controller_spec.rb:3 > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > > `load_spec_files' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > > `load_spec_files' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/bin/ > > rspec:19 > > rake aborted! > > ruby -S bundle exec rspec ./spec/controllers/posts_controller_spec.rb > > failed > > I'm not seeing this in any of my apps. Seems like a configuration or > load order problem. Can you post your Gemfile and spec/spec_helper.rb? > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Jan 2 23:45:59 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Jan 2011 22:45:59 -0600 Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: <59f22461-d827-4e62-8151-adc5d05b8f69@q8g2000prm.googlegroups.com> References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> <59f22461-d827-4e62-8151-adc5d05b8f69@q8g2000prm.googlegroups.com> Message-ID: On Sun, Jan 2, 2011 at 10:12 PM, Jim Morris wrote: > Yes I can, the full app is on https://github.com/wolfmanjm/wolfmanblog_rails > although I downgraded back to rspec-rails 2.3.1, before I did that my > Gemfile.lock looked like... Thanks for that. The problem is with rspec-cells, but I'm not clear yet on the root cause. Something to do with the way it's hooking itself into the framework is failing. I'll follow up if/when I have some new information, but it might be a day or two. From dchelimsky at gmail.com Sun Jan 2 23:59:45 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Jan 2011 22:59:45 -0600 Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> Message-ID: On Sun, Jan 2, 2011 at 10:20 PM, Jim Morris wrote: > I forgot to mention that I did get a deprecation warning from rspec- > cells (they haven't updated it yet), but I fixed it by doing what the > deprecation warning said. I don't think that has anything to do with > the error I am getting though. I didn't realize other libs were using it. Now that I know they are I may consider reversing the deprecation, though I'm not convinced it's really the best API, so I'll have to give that some thought. That aside, the commit that made that method obsolete within rspec-rails was: https://github.com/rspec/rspec-rails/commit/fc5cdbb603f0e66f9f3d19a0a60a775e124fb218 If you have some time to investigate, please see if reversing that commit solves the problem. Should point us in the right direction. > > On Jan 2, 7:46?pm, David Chelimsky wrote: >> On Sun, Jan 2, 2011 at 9:09 PM, Jim Morris wrote: >> > I just upgraded from 2.3.1 and I now get this error on all my specs... >> > Nothing else changed and the Upgrade.md does not indicate any backward >> > compatibilities unless I missed something. >> >> > (in /home/morris/work/ruby/rails3/wolfmanblog) >> > /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby -S bundle exec rspec ./ >> > spec/controllers/posts_controller_spec.rb >> > [sequel] Setting up the "test" environment: >> > /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined >> > method `setup' for # (NoMethodError) >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > activesupport-3.0.3/lib/active_support/concern.rb:52:in >> > `append_features' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > actionpack-3.0.3/lib/action_controller/test_case.rb:439 >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > activesupport-3.0.3/lib/active_support/concern.rb:52:in >> > `append_features' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > activesupport-3.0.3/lib/active_support/concern.rb:48:in >> > `append_features' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > activesupport-3.0.3/lib/active_support/concern.rb:48:in >> > `append_features' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in >> > `configure_group' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in >> > `configure_group' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' >> > ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ >> > controllers/posts_controller_spec.rb:3 >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> > `load_spec_files' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> > `load_spec_files' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' >> > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/bin/ >> > rspec:19 >> > rake aborted! >> > ruby -S bundle exec rspec ./spec/controllers/posts_controller_spec.rb >> > failed >> >> I'm not seeing this in any of my apps. Seems like a configuration or >> load order problem. Can you post your Gemfile and spec/spec_helper.rb? >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From wolfmanjm at gmail.com Mon Jan 3 00:01:32 2011 From: wolfmanjm at gmail.com (Jim Morris) Date: Sun, 2 Jan 2011 21:01:32 -0800 (PST) Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: <59f22461-d827-4e62-8151-adc5d05b8f69@q8g2000prm.googlegroups.com> References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> <59f22461-d827-4e62-8151-adc5d05b8f69@q8g2000prm.googlegroups.com> Message-ID: <29b37bb2-106b-41d2-8943-82f85ecfb90e@29g2000prb.googlegroups.com> Ok I re installed rspec-rails 2.4.0 looks like my request specs run, and my model specs run but my controller specs and helper specs do not run, and throw that error. I have that config.around.. in my spec_helper which applies to most request specs but not to the helper specs or controller specs (which use mocks), so that is a difference, the around does NOT run when the helpers or controller specs run, but I don't see how that would cause this error. I removed the rspec-cells gem but that did not do anything to help. So if you were to checkout my project and change the Gemfile to get rspec 2.4.0 then run... rspec spec/controllers/posts_controller_spec.rb you should get this dump... [sequel] Setting up the "test" environment: /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined method `setup' for # (NoMethodError) from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:in `append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ actionpack-3.0.3/lib/action_controller/test_case.rb:439 from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:52:in `append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ activesupport-3.0.3/lib/active_support/concern.rb:48:in `append_features' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `configure_group' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `configure_group' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' from /home/morris/work/ruby/rails3/wolfmanblog/spec/ controllers/posts_controller_spec.rb:3 from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' from /opt/ruby-enterprise-1.8.7-2010.02/bin/rspec:19 On Jan 2, 8:12?pm, Jim Morris wrote: > Yes I can, the full app is onhttps://github.com/wolfmanjm/wolfmanblog_rails > although I downgraded back to rspec-rails 2.3.1, before I did that my > Gemfile.lock looked like... > > GEM > ? remote:http://rubygems.org/ > ? specs: > ? ? abstract (1.0.0) > ? ? actionmailer (3.0.3) > ? ? ? actionpack (= 3.0.3) > ? ? ? mail (~> 2.2.9) > ? ? actionpack (3.0.3) > ? ? ? activemodel (= 3.0.3) > ? ? ? activesupport (= 3.0.3) > ? ? ? builder (~> 2.1.2) > ? ? ? erubis (~> 2.6.6) > ? ? ? i18n (~> 0.4) > ? ? ? rack (~> 1.2.1) > ? ? ? rack-mount (~> 0.6.13) > ? ? ? rack-test (~> 0.5.6) > ? ? ? tzinfo (~> 0.3.23) > ? ? activemodel (3.0.3) > ? ? ? activesupport (= 3.0.3) > ? ? ? builder (~> 2.1.2) > ? ? ? i18n (~> 0.4) > ? ? activerecord (3.0.3) > ? ? ? activemodel (= 3.0.3) > ? ? ? activesupport (= 3.0.3) > ? ? ? arel (~> 2.0.2) > ? ? ? tzinfo (~> 0.3.23) > ? ? activeresource (3.0.3) > ? ? ? activemodel (= 3.0.3) > ? ? ? activesupport (= 3.0.3) > ? ? activesupport (3.0.3) > ? ? arel (2.0.6) > ? ? builder (2.1.2) > ? ? cells (3.4.2) > ? ? diff-lcs (1.1.2) > ? ? erubis (2.6.6) > ? ? ? abstract (>= 1.0.0) > ? ? factory_girl (1.3.2) > ? ? factory_girl_rails (1.0) > ? ? ? factory_girl (~> 1.3) > ? ? ? rails (>= 3.0.0.beta4) > ? ? haml (3.0.24) > ? ? i18n (0.5.0) > ? ? mail (2.2.12) > ? ? ? activesupport (>= 2.3.6) > ? ? ? i18n (>= 0.4.0) > ? ? ? mime-types (~> 1.16) > ? ? ? treetop (~> 1.4.8) > ? ? mime-types (1.16) > ? ? nokogiri (1.4.4) > ? ? pg (0.10.0) > ? ? polyglot (0.3.1) > ? ? rack (1.2.1) > ? ? rack-mount (0.6.13) > ? ? ? rack (>= 1.0.0) > ? ? rack-test (0.5.7) > ? ? ? rack (>= 1.0) > ? ? rails (3.0.3) > ? ? ? actionmailer (= 3.0.3) > ? ? ? actionpack (= 3.0.3) > ? ? ? activerecord (= 3.0.3) > ? ? ? activeresource (= 3.0.3) > ? ? ? activesupport (= 3.0.3) > ? ? ? bundler (~> 1.0) > ? ? ? railties (= 3.0.3) > ? ? railties (3.0.3) > ? ? ? actionpack (= 3.0.3) > ? ? ? activesupport (= 3.0.3) > ? ? ? rake (>= 0.8.7) > ? ? ? thor (~> 0.14.4) > ? ? rake (0.8.7) > ? ? rdiscount (1.6.5) > ? ? rspec (2.4.0) > ? ? ? rspec-core (~> 2.4.0) > ? ? ? rspec-expectations (~> 2.4.0) > ? ? ? rspec-mocks (~> 2.4.0) > ? ? rspec-cells (0.0.2) > ? ? ? cells (~> 3.4) > ? ? ? rails (~> 3.0) > ? ? ? rspec-rails (~> 2.2) > ? ? rspec-core (2.4.0) > ? ? rspec-expectations (2.4.0) > ? ? ? diff-lcs (~> 1.1.2) > ? ? rspec-mocks (2.4.0) > ? ? rspec-rails (2.4.0) > ? ? ? actionpack (~> 3.0) > ? ? ? activesupport (~> 3.0) > ? ? ? railties (~> 3.0) > ? ? ? rspec (~> 2.4.0) > ? ? sequel (3.17.0) > ? ? sequel-rails (0.1.8) > ? ? ? actionpack (~> 3.0.0) > ? ? ? activesupport (~> 3.0.0) > ? ? ? railties (~> 3.0.0) > ? ? ? sequel (~> 3.13) > ? ? stringex (1.2.0) > ? ? thor (0.14.6) > ? ? treetop (1.4.9) > ? ? ? polyglot (>= 0.3.1) > ? ? tzinfo (0.3.23) > ? ? uuidtools (2.1.1) > ? ? webrat (0.7.2) > ? ? ? nokogiri (>= 1.2.0) > ? ? ? rack (>= 1.0) > ? ? ? rack-test (>= 0.5.3) > > PLATFORMS > ? ruby > > DEPENDENCIES > ? cells > ? factory_girl_rails > ? haml > ? pg > ? rails (= 3.0.3) > ? rdiscount > ? rspec-cells > ? rspec-rails (~> 2.3) > ? sequel-rails > ? stringex > ? uuidtools > ? webrat > > Using rake (0.8.7) > Using abstract (1.0.0) > Using activesupport (3.0.3) > Using builder (2.1.2) > Using i18n (0.5.0) > Using activemodel (3.0.3) > Using erubis (2.6.6) > Using rack (1.2.1) > Using rack-mount (0.6.13) > Using rack-test (0.5.7) > Using tzinfo (0.3.23) > Using actionpack (3.0.3) > Using mime-types (1.16) > Using polyglot (0.3.1) > Using treetop (1.4.9) > Using mail (2.2.12) > Using actionmailer (3.0.3) > Using arel (2.0.6) > Using activerecord (3.0.3) > Using activeresource (3.0.3) > Using bundler (1.0.3) > Using cells (3.4.2) > Using diff-lcs (1.1.2) > Using factory_girl (1.3.2) > Using thor (0.14.6) > Using railties (3.0.3) > Using rails (3.0.3) > Using factory_girl_rails (1.0) > Using haml (3.0.24) > Using nokogiri (1.4.4) > Using pg (0.10.0) > Using rdiscount (1.6.5) > Using rspec-core (2.4.0) > Using rspec-expectations (2.4.0) > Using rspec-mocks (2.4.0) > Using rspec (2.4.0) > Using rspec-rails (2.4.0) > Using rspec-cells (0.0.2) > Using sequel (3.17.0) > Using sequel-rails (0.1.8) > Using stringex (1.2.0) > Using uuidtools (2.1.1) > Using webrat (0.7.2) > > and spec_helper.rb looked like... > > # This file is copied to spec/ when you run 'rails generate > rspec:install' > ENV["RAILS_ENV"] ||= 'test' > require File.expand_path("../../config/environment", __FILE__) > require 'rspec/rails' > > # 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 > > ? # setup transactional factory for sequel, when running transactional > tests > ? config.around(:each, :transactional => true) do |example| > ? ? Sequel::DATABASES.first.transaction do > ? ? ? example.run > ? ? ? raise Sequel::Error::Rollback > ? ? end > ? end > > end > > # to make factory girl run with sequel > class Sequel::Model > ? def save! > ? ? save(:validate=>false) > ? end > end > > On Jan 2, 7:46?pm, David Chelimsky wrote: > > > On Sun, Jan 2, 2011 at 9:09 PM, Jim Morris wrote: > > > I just upgraded from 2.3.1 and I now get this error on all my specs... > > > Nothing else changed and the Upgrade.md does not indicate any backward > > > compatibilities unless I missed something. > > > > (in /home/morris/work/ruby/rails3/wolfmanblog) > > > /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby -S bundle exec rspec ./ > > > spec/controllers/posts_controller_spec.rb > > > [sequel] Setting up the "test" environment: > > > /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined > > > method `setup' for # (NoMethodError) > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > activesupport-3.0.3/lib/active_support/concern.rb:52:in > > > `append_features' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > actionpack-3.0.3/lib/action_controller/test_case.rb:439 > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > activesupport-3.0.3/lib/active_support/concern.rb:52:in > > > `append_features' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > activesupport-3.0.3/lib/active_support/concern.rb:48:in > > > `append_features' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > activesupport-3.0.3/lib/active_support/concern.rb:48:in > > > `append_features' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in > > > `configure_group' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in > > > `configure_group' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' > > > ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ > > > controllers/posts_controller_spec.rb:3 > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > > > `load_spec_files' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > > > `load_spec_files' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' > > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > > > rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' > > > ? ? ? ?from > > ... > > read more ? From wolfmanjm at gmail.com Mon Jan 3 00:07:13 2011 From: wolfmanjm at gmail.com (Jim Morris) Date: Sun, 2 Jan 2011 21:07:13 -0800 (PST) Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> <59f22461-d827-4e62-8151-adc5d05b8f69@q8g2000prm.googlegroups.com> Message-ID: <22650398-759a-4aed-b1da-b1efbe76bd66@21g2000prv.googlegroups.com> > The problem is with rspec-cells, but I'm not clear yet on the root > cause. Something to do with the way it's hooking itself into the > framework is failing. I totally removed rspec-cells from my gems and bundle, but I still get the same failure, so I'm not convinced it is rspec-cells, it did give a deprecation error but that is easily fixed. From dchelimsky at gmail.com Mon Jan 3 00:51:45 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 2 Jan 2011 23:51:45 -0600 Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: <29b37bb2-106b-41d2-8943-82f85ecfb90e@29g2000prb.googlegroups.com> References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> <59f22461-d827-4e62-8151-adc5d05b8f69@q8g2000prm.googlegroups.com> <29b37bb2-106b-41d2-8943-82f85ecfb90e@29g2000prb.googlegroups.com> Message-ID: On Sun, Jan 2, 2011 at 11:01 PM, Jim Morris wrote: > Ok I re installed rspec-rails 2.4.0 looks like my request specs run, > and my model specs run but my > controller specs and helper specs do not run, and throw that error. > > I have that config.around.. in my spec_helper which applies to most > request specs but not to the helper specs or controller specs (which > use mocks), so that is a difference, the around does NOT run when the > helpers or controller specs run, but I don't see how that would cause > this error. > > I removed the rspec-cells gem but that did not do anything to help. > > So if you were to checkout my project and change the Gemfile to get > rspec 2.4.0 then run... > > ?rspec spec/controllers/posts_controller_spec.rb > > you should get this dump... The around hook is a red herring too. This is very odd. I'm not sure what it is yet, but it's something to do with the load order of modules. I can't reproduce this in my apps, but I can in yours with no problem. Onward ... > > [sequel] Setting up the "test" environment: > /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined > method `setup' for # (NoMethodError) > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:52:in > `append_features' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > actionpack-3.0.3/lib/action_controller/test_case.rb:439 > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:52:in > `append_features' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in > `append_features' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > activesupport-3.0.3/lib/active_support/concern.rb:48:in > `append_features' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in > `configure_group' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in > `configure_group' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' > ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ > controllers/posts_controller_spec.rb:3 > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/bin/rspec:19 > > > On Jan 2, 8:12?pm, Jim Morris wrote: >> Yes I can, the full app is onhttps://github.com/wolfmanjm/wolfmanblog_rails >> although I downgraded back to rspec-rails 2.3.1, before I did that my >> Gemfile.lock looked like... >> >> GEM >> ? remote:http://rubygems.org/ >> ? specs: >> ? ? abstract (1.0.0) >> ? ? actionmailer (3.0.3) >> ? ? ? actionpack (= 3.0.3) >> ? ? ? mail (~> 2.2.9) >> ? ? actionpack (3.0.3) >> ? ? ? activemodel (= 3.0.3) >> ? ? ? activesupport (= 3.0.3) >> ? ? ? builder (~> 2.1.2) >> ? ? ? erubis (~> 2.6.6) >> ? ? ? i18n (~> 0.4) >> ? ? ? rack (~> 1.2.1) >> ? ? ? rack-mount (~> 0.6.13) >> ? ? ? rack-test (~> 0.5.6) >> ? ? ? tzinfo (~> 0.3.23) >> ? ? activemodel (3.0.3) >> ? ? ? activesupport (= 3.0.3) >> ? ? ? builder (~> 2.1.2) >> ? ? ? i18n (~> 0.4) >> ? ? activerecord (3.0.3) >> ? ? ? activemodel (= 3.0.3) >> ? ? ? activesupport (= 3.0.3) >> ? ? ? arel (~> 2.0.2) >> ? ? ? tzinfo (~> 0.3.23) >> ? ? activeresource (3.0.3) >> ? ? ? activemodel (= 3.0.3) >> ? ? ? activesupport (= 3.0.3) >> ? ? activesupport (3.0.3) >> ? ? arel (2.0.6) >> ? ? builder (2.1.2) >> ? ? cells (3.4.2) >> ? ? diff-lcs (1.1.2) >> ? ? erubis (2.6.6) >> ? ? ? abstract (>= 1.0.0) >> ? ? factory_girl (1.3.2) >> ? ? factory_girl_rails (1.0) >> ? ? ? factory_girl (~> 1.3) >> ? ? ? rails (>= 3.0.0.beta4) >> ? ? haml (3.0.24) >> ? ? i18n (0.5.0) >> ? ? mail (2.2.12) >> ? ? ? activesupport (>= 2.3.6) >> ? ? ? i18n (>= 0.4.0) >> ? ? ? mime-types (~> 1.16) >> ? ? ? treetop (~> 1.4.8) >> ? ? mime-types (1.16) >> ? ? nokogiri (1.4.4) >> ? ? pg (0.10.0) >> ? ? polyglot (0.3.1) >> ? ? rack (1.2.1) >> ? ? rack-mount (0.6.13) >> ? ? ? rack (>= 1.0.0) >> ? ? rack-test (0.5.7) >> ? ? ? rack (>= 1.0) >> ? ? rails (3.0.3) >> ? ? ? actionmailer (= 3.0.3) >> ? ? ? actionpack (= 3.0.3) >> ? ? ? activerecord (= 3.0.3) >> ? ? ? activeresource (= 3.0.3) >> ? ? ? activesupport (= 3.0.3) >> ? ? ? bundler (~> 1.0) >> ? ? ? railties (= 3.0.3) >> ? ? railties (3.0.3) >> ? ? ? actionpack (= 3.0.3) >> ? ? ? activesupport (= 3.0.3) >> ? ? ? rake (>= 0.8.7) >> ? ? ? thor (~> 0.14.4) >> ? ? rake (0.8.7) >> ? ? rdiscount (1.6.5) >> ? ? rspec (2.4.0) >> ? ? ? rspec-core (~> 2.4.0) >> ? ? ? rspec-expectations (~> 2.4.0) >> ? ? ? rspec-mocks (~> 2.4.0) >> ? ? rspec-cells (0.0.2) >> ? ? ? cells (~> 3.4) >> ? ? ? rails (~> 3.0) >> ? ? ? rspec-rails (~> 2.2) >> ? ? rspec-core (2.4.0) >> ? ? rspec-expectations (2.4.0) >> ? ? ? diff-lcs (~> 1.1.2) >> ? ? rspec-mocks (2.4.0) >> ? ? rspec-rails (2.4.0) >> ? ? ? actionpack (~> 3.0) >> ? ? ? activesupport (~> 3.0) >> ? ? ? railties (~> 3.0) >> ? ? ? rspec (~> 2.4.0) >> ? ? sequel (3.17.0) >> ? ? sequel-rails (0.1.8) >> ? ? ? actionpack (~> 3.0.0) >> ? ? ? activesupport (~> 3.0.0) >> ? ? ? railties (~> 3.0.0) >> ? ? ? sequel (~> 3.13) >> ? ? stringex (1.2.0) >> ? ? thor (0.14.6) >> ? ? treetop (1.4.9) >> ? ? ? polyglot (>= 0.3.1) >> ? ? tzinfo (0.3.23) >> ? ? uuidtools (2.1.1) >> ? ? webrat (0.7.2) >> ? ? ? nokogiri (>= 1.2.0) >> ? ? ? rack (>= 1.0) >> ? ? ? rack-test (>= 0.5.3) >> >> PLATFORMS >> ? ruby >> >> DEPENDENCIES >> ? cells >> ? factory_girl_rails >> ? haml >> ? pg >> ? rails (= 3.0.3) >> ? rdiscount >> ? rspec-cells >> ? rspec-rails (~> 2.3) >> ? sequel-rails >> ? stringex >> ? uuidtools >> ? webrat >> >> Using rake (0.8.7) >> Using abstract (1.0.0) >> Using activesupport (3.0.3) >> Using builder (2.1.2) >> Using i18n (0.5.0) >> Using activemodel (3.0.3) >> Using erubis (2.6.6) >> Using rack (1.2.1) >> Using rack-mount (0.6.13) >> Using rack-test (0.5.7) >> Using tzinfo (0.3.23) >> Using actionpack (3.0.3) >> Using mime-types (1.16) >> Using polyglot (0.3.1) >> Using treetop (1.4.9) >> Using mail (2.2.12) >> Using actionmailer (3.0.3) >> Using arel (2.0.6) >> Using activerecord (3.0.3) >> Using activeresource (3.0.3) >> Using bundler (1.0.3) >> Using cells (3.4.2) >> Using diff-lcs (1.1.2) >> Using factory_girl (1.3.2) >> Using thor (0.14.6) >> Using railties (3.0.3) >> Using rails (3.0.3) >> Using factory_girl_rails (1.0) >> Using haml (3.0.24) >> Using nokogiri (1.4.4) >> Using pg (0.10.0) >> Using rdiscount (1.6.5) >> Using rspec-core (2.4.0) >> Using rspec-expectations (2.4.0) >> Using rspec-mocks (2.4.0) >> Using rspec (2.4.0) >> Using rspec-rails (2.4.0) >> Using rspec-cells (0.0.2) >> Using sequel (3.17.0) >> Using sequel-rails (0.1.8) >> Using stringex (1.2.0) >> Using uuidtools (2.1.1) >> Using webrat (0.7.2) >> >> and spec_helper.rb looked like... >> >> # This file is copied to spec/ when you run 'rails generate >> rspec:install' >> ENV["RAILS_ENV"] ||= 'test' >> require File.expand_path("../../config/environment", __FILE__) >> require 'rspec/rails' >> >> # 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 >> >> ? # setup transactional factory for sequel, when running transactional >> tests >> ? config.around(:each, :transactional => true) do |example| >> ? ? Sequel::DATABASES.first.transaction do >> ? ? ? example.run >> ? ? ? raise Sequel::Error::Rollback >> ? ? end >> ? end >> >> end >> >> # to make factory girl run with sequel >> class Sequel::Model >> ? def save! >> ? ? save(:validate=>false) >> ? end >> end >> >> On Jan 2, 7:46?pm, David Chelimsky wrote: >> >> > On Sun, Jan 2, 2011 at 9:09 PM, Jim Morris wrote: >> > > I just upgraded from 2.3.1 and I now get this error on all my specs... >> > > Nothing else changed and the Upgrade.md does not indicate any backward >> > > compatibilities unless I missed something. >> >> > > (in /home/morris/work/ruby/rails3/wolfmanblog) >> > > /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby -S bundle exec rspec ./ >> > > spec/controllers/posts_controller_spec.rb >> > > [sequel] Setting up the "test" environment: >> > > /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined >> > > method `setup' for # (NoMethodError) >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > activesupport-3.0.3/lib/active_support/concern.rb:52:in >> > > `append_features' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > actionpack-3.0.3/lib/action_controller/test_case.rb:439 >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > activesupport-3.0.3/lib/active_support/concern.rb:52:in >> > > `append_features' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in >> > > `append_features' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in >> > > `append_features' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in >> > > `configure_group' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in >> > > `configure_group' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' >> > > ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ >> > > controllers/posts_controller_spec.rb:3 >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> > > `load_spec_files' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> > > `load_spec_files' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' >> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> > > rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' >> > > ? ? ? ?from >> >> ... >> >> read more ? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Jan 3 01:15:50 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Jan 2011 00:15:50 -0600 Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> <59f22461-d827-4e62-8151-adc5d05b8f69@q8g2000prm.googlegroups.com> <29b37bb2-106b-41d2-8943-82f85ecfb90e@29g2000prb.googlegroups.com> Message-ID: On Sun, Jan 2, 2011 at 11:51 PM, David Chelimsky wrote: > On Sun, Jan 2, 2011 at 11:01 PM, Jim Morris wrote: >> Ok I re installed rspec-rails 2.4.0 looks like my request specs run, >> and my model specs run but my >> controller specs and helper specs do not run, and throw that error. >> >> I have that config.around.. in my spec_helper which applies to most >> request specs but not to the helper specs or controller specs (which >> use mocks), so that is a difference, the around does NOT run when the >> helpers or controller specs run, but I don't see how that would cause >> this error. >> >> I removed the rspec-cells gem but that did not do anything to help. >> >> So if you were to checkout my project and change the Gemfile to get >> rspec 2.4.0 then run... >> >> ?rspec spec/controllers/posts_controller_spec.rb >> >> you should get this dump... > > The around hook is a red herring too. > > This is very odd. I'm not sure what it is yet, but it's something to > do with the load order of modules. I can't reproduce this in my apps, > but I can in yours with no problem. > > Onward ... Found it. Will release a bug fix release of rspec-rails shortly. I don't understand why I hadn't seen it in any of my apps, or in rspec's own spec suite, but it boils down to the order in which RSpec::Rails::RailsExampleGroup and ActionController::TestCase::Behavior are declared. > >> >> [sequel] Setting up the "test" environment: >> /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined >> method `setup' for # (NoMethodError) >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> activesupport-3.0.3/lib/active_support/concern.rb:52:in >> `append_features' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> actionpack-3.0.3/lib/action_controller/test_case.rb:439 >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> activesupport-3.0.3/lib/active_support/concern.rb:52:in >> `append_features' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> activesupport-3.0.3/lib/active_support/concern.rb:48:in >> `append_features' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> activesupport-3.0.3/lib/active_support/concern.rb:48:in >> `append_features' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in >> `configure_group' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in >> `configure_group' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' >> ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ >> controllers/posts_controller_spec.rb:3 >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> `load_spec_files' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> `load_spec_files' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >> rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/bin/rspec:19 >> >> >> On Jan 2, 8:12?pm, Jim Morris wrote: >>> Yes I can, the full app is onhttps://github.com/wolfmanjm/wolfmanblog_rails >>> although I downgraded back to rspec-rails 2.3.1, before I did that my >>> Gemfile.lock looked like... >>> >>> GEM >>> ? remote:http://rubygems.org/ >>> ? specs: >>> ? ? abstract (1.0.0) >>> ? ? actionmailer (3.0.3) >>> ? ? ? actionpack (= 3.0.3) >>> ? ? ? mail (~> 2.2.9) >>> ? ? actionpack (3.0.3) >>> ? ? ? activemodel (= 3.0.3) >>> ? ? ? activesupport (= 3.0.3) >>> ? ? ? builder (~> 2.1.2) >>> ? ? ? erubis (~> 2.6.6) >>> ? ? ? i18n (~> 0.4) >>> ? ? ? rack (~> 1.2.1) >>> ? ? ? rack-mount (~> 0.6.13) >>> ? ? ? rack-test (~> 0.5.6) >>> ? ? ? tzinfo (~> 0.3.23) >>> ? ? activemodel (3.0.3) >>> ? ? ? activesupport (= 3.0.3) >>> ? ? ? builder (~> 2.1.2) >>> ? ? ? i18n (~> 0.4) >>> ? ? activerecord (3.0.3) >>> ? ? ? activemodel (= 3.0.3) >>> ? ? ? activesupport (= 3.0.3) >>> ? ? ? arel (~> 2.0.2) >>> ? ? ? tzinfo (~> 0.3.23) >>> ? ? activeresource (3.0.3) >>> ? ? ? activemodel (= 3.0.3) >>> ? ? ? activesupport (= 3.0.3) >>> ? ? activesupport (3.0.3) >>> ? ? arel (2.0.6) >>> ? ? builder (2.1.2) >>> ? ? cells (3.4.2) >>> ? ? diff-lcs (1.1.2) >>> ? ? erubis (2.6.6) >>> ? ? ? abstract (>= 1.0.0) >>> ? ? factory_girl (1.3.2) >>> ? ? factory_girl_rails (1.0) >>> ? ? ? factory_girl (~> 1.3) >>> ? ? ? rails (>= 3.0.0.beta4) >>> ? ? haml (3.0.24) >>> ? ? i18n (0.5.0) >>> ? ? mail (2.2.12) >>> ? ? ? activesupport (>= 2.3.6) >>> ? ? ? i18n (>= 0.4.0) >>> ? ? ? mime-types (~> 1.16) >>> ? ? ? treetop (~> 1.4.8) >>> ? ? mime-types (1.16) >>> ? ? nokogiri (1.4.4) >>> ? ? pg (0.10.0) >>> ? ? polyglot (0.3.1) >>> ? ? rack (1.2.1) >>> ? ? rack-mount (0.6.13) >>> ? ? ? rack (>= 1.0.0) >>> ? ? rack-test (0.5.7) >>> ? ? ? rack (>= 1.0) >>> ? ? rails (3.0.3) >>> ? ? ? actionmailer (= 3.0.3) >>> ? ? ? actionpack (= 3.0.3) >>> ? ? ? activerecord (= 3.0.3) >>> ? ? ? activeresource (= 3.0.3) >>> ? ? ? activesupport (= 3.0.3) >>> ? ? ? bundler (~> 1.0) >>> ? ? ? railties (= 3.0.3) >>> ? ? railties (3.0.3) >>> ? ? ? actionpack (= 3.0.3) >>> ? ? ? activesupport (= 3.0.3) >>> ? ? ? rake (>= 0.8.7) >>> ? ? ? thor (~> 0.14.4) >>> ? ? rake (0.8.7) >>> ? ? rdiscount (1.6.5) >>> ? ? rspec (2.4.0) >>> ? ? ? rspec-core (~> 2.4.0) >>> ? ? ? rspec-expectations (~> 2.4.0) >>> ? ? ? rspec-mocks (~> 2.4.0) >>> ? ? rspec-cells (0.0.2) >>> ? ? ? cells (~> 3.4) >>> ? ? ? rails (~> 3.0) >>> ? ? ? rspec-rails (~> 2.2) >>> ? ? rspec-core (2.4.0) >>> ? ? rspec-expectations (2.4.0) >>> ? ? ? diff-lcs (~> 1.1.2) >>> ? ? rspec-mocks (2.4.0) >>> ? ? rspec-rails (2.4.0) >>> ? ? ? actionpack (~> 3.0) >>> ? ? ? activesupport (~> 3.0) >>> ? ? ? railties (~> 3.0) >>> ? ? ? rspec (~> 2.4.0) >>> ? ? sequel (3.17.0) >>> ? ? sequel-rails (0.1.8) >>> ? ? ? actionpack (~> 3.0.0) >>> ? ? ? activesupport (~> 3.0.0) >>> ? ? ? railties (~> 3.0.0) >>> ? ? ? sequel (~> 3.13) >>> ? ? stringex (1.2.0) >>> ? ? thor (0.14.6) >>> ? ? treetop (1.4.9) >>> ? ? ? polyglot (>= 0.3.1) >>> ? ? tzinfo (0.3.23) >>> ? ? uuidtools (2.1.1) >>> ? ? webrat (0.7.2) >>> ? ? ? nokogiri (>= 1.2.0) >>> ? ? ? rack (>= 1.0) >>> ? ? ? rack-test (>= 0.5.3) >>> >>> PLATFORMS >>> ? ruby >>> >>> DEPENDENCIES >>> ? cells >>> ? factory_girl_rails >>> ? haml >>> ? pg >>> ? rails (= 3.0.3) >>> ? rdiscount >>> ? rspec-cells >>> ? rspec-rails (~> 2.3) >>> ? sequel-rails >>> ? stringex >>> ? uuidtools >>> ? webrat >>> >>> Using rake (0.8.7) >>> Using abstract (1.0.0) >>> Using activesupport (3.0.3) >>> Using builder (2.1.2) >>> Using i18n (0.5.0) >>> Using activemodel (3.0.3) >>> Using erubis (2.6.6) >>> Using rack (1.2.1) >>> Using rack-mount (0.6.13) >>> Using rack-test (0.5.7) >>> Using tzinfo (0.3.23) >>> Using actionpack (3.0.3) >>> Using mime-types (1.16) >>> Using polyglot (0.3.1) >>> Using treetop (1.4.9) >>> Using mail (2.2.12) >>> Using actionmailer (3.0.3) >>> Using arel (2.0.6) >>> Using activerecord (3.0.3) >>> Using activeresource (3.0.3) >>> Using bundler (1.0.3) >>> Using cells (3.4.2) >>> Using diff-lcs (1.1.2) >>> Using factory_girl (1.3.2) >>> Using thor (0.14.6) >>> Using railties (3.0.3) >>> Using rails (3.0.3) >>> Using factory_girl_rails (1.0) >>> Using haml (3.0.24) >>> Using nokogiri (1.4.4) >>> Using pg (0.10.0) >>> Using rdiscount (1.6.5) >>> Using rspec-core (2.4.0) >>> Using rspec-expectations (2.4.0) >>> Using rspec-mocks (2.4.0) >>> Using rspec (2.4.0) >>> Using rspec-rails (2.4.0) >>> Using rspec-cells (0.0.2) >>> Using sequel (3.17.0) >>> Using sequel-rails (0.1.8) >>> Using stringex (1.2.0) >>> Using uuidtools (2.1.1) >>> Using webrat (0.7.2) >>> >>> and spec_helper.rb looked like... >>> >>> # This file is copied to spec/ when you run 'rails generate >>> rspec:install' >>> ENV["RAILS_ENV"] ||= 'test' >>> require File.expand_path("../../config/environment", __FILE__) >>> require 'rspec/rails' >>> >>> # 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 >>> >>> ? # setup transactional factory for sequel, when running transactional >>> tests >>> ? config.around(:each, :transactional => true) do |example| >>> ? ? Sequel::DATABASES.first.transaction do >>> ? ? ? example.run >>> ? ? ? raise Sequel::Error::Rollback >>> ? ? end >>> ? end >>> >>> end >>> >>> # to make factory girl run with sequel >>> class Sequel::Model >>> ? def save! >>> ? ? save(:validate=>false) >>> ? end >>> end >>> >>> On Jan 2, 7:46?pm, David Chelimsky wrote: >>> >>> > On Sun, Jan 2, 2011 at 9:09 PM, Jim Morris wrote: >>> > > I just upgraded from 2.3.1 and I now get this error on all my specs... >>> > > Nothing else changed and the Upgrade.md does not indicate any backward >>> > > compatibilities unless I missed something. >>> >>> > > (in /home/morris/work/ruby/rails3/wolfmanblog) >>> > > /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby -S bundle exec rspec ./ >>> > > spec/controllers/posts_controller_spec.rb >>> > > [sequel] Setting up the "test" environment: >>> > > /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined >>> > > method `setup' for # (NoMethodError) >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > activesupport-3.0.3/lib/active_support/concern.rb:52:in >>> > > `append_features' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > actionpack-3.0.3/lib/action_controller/test_case.rb:439 >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > activesupport-3.0.3/lib/active_support/concern.rb:52:in >>> > > `append_features' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in >>> > > `append_features' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > activesupport-3.0.3/lib/active_support/concern.rb:48:in >>> > > `append_features' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in >>> > > `configure_group' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in >>> > > `configure_group' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' >>> > > ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ >>> > > controllers/posts_controller_spec.rb:3 >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >>> > > `load_spec_files' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >>> > > `load_spec_files' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' >>> > > ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ >>> > > rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' >>> > > ? ? ? ?from >>> >>> ... >>> >>> read more ? >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > From dchelimsky at gmail.com Mon Jan 3 01:59:45 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 3 Jan 2011 00:59:45 -0600 Subject: [rspec-users] rspec-rails-2.4.1 is released! Message-ID: <6A9E65B5-9CE6-42B8-A390-2ED923DA93C3@gmail.com> This is a bug fix release recommended for all users who have upgraded to rspec-rails-2.4. ### rspec-rails-2.4.1 / 2011-01-03 [full changelog](http://github.com/rspec/rspec-rails/compare/v2.4.0...v2.4.1) * Bug fixes * fixed bug caused by including some Rails modules before RSpec's RailsExampleGroup From wolfmanjm at gmail.com Mon Jan 3 02:06:26 2011 From: wolfmanjm at gmail.com (Jim Morris) Date: Sun, 2 Jan 2011 23:06:26 -0800 (PST) Subject: [rspec-users] rspec-rails-2.4.0 is released! In-Reply-To: References: <4D308867-8A86-4157-8A1E-4E80D9E11666@gmail.com> <441bf106-5017-435e-ad14-ec24e25a06be@f21g2000prn.googlegroups.com> <59f22461-d827-4e62-8151-adc5d05b8f69@q8g2000prm.googlegroups.com> <29b37bb2-106b-41d2-8943-82f85ecfb90e@29g2000prb.googlegroups.com> Message-ID: Good job ;) I was looking around to see where stuff was required, figured it may have something to do with the fact I don't use require 'rails/all' in my application.rb, but break out stuff so I don't include activerecord but do include sequel, maybe active record which is usually loaded first pulls something in that you needed? Thanks On Jan 2, 10:15?pm, David Chelimsky wrote: > On Sun, Jan 2, 2011 at 11:51 PM, David Chelimsky wrote: > > On Sun, Jan 2, 2011 at 11:01 PM, Jim Morris wrote: > >> Ok I re installed rspec-rails 2.4.0 looks like my request specs run, > >> and my model specs run but my > >> controller specs and helper specs do not run, and throw that error. > > >> I have that config.around.. in my spec_helper which applies to most > >> request specs but not to the helper specs or controller specs (which > >> use mocks), so that is a difference, the around does NOT run when the > >> helpers or controller specs run, but I don't see how that would cause > >> this error. > > >> I removed the rspec-cells gem but that did not do anything to help. > > >> So if you were to checkout my project and change the Gemfile to get > >> rspec 2.4.0 then run... > > >> ?rspec spec/controllers/posts_controller_spec.rb > > >> you should get this dump... > > > The around hook is a red herring too. > > > This is very odd. I'm not sure what it is yet, but it's something to > > do with the load order of modules. I can't reproduce this in my apps, > > but I can in yours with no problem. > > > Onward ... > > Found it. Will release a bug fix release of rspec-rails shortly. > > I don't understand why I hadn't seen it in any of my apps, or in > rspec's own spec suite, but it boils down to the order in which > RSpec::Rails::RailsExampleGroup and > ActionController::TestCase::Behavior are declared. > > > > >> [sequel] Setting up the "test" environment: > >> /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> actionpack-3.0.3/lib/action_controller/test_case.rb:10: undefined > >> method `setup' for # (NoMethodError) > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> activesupport-3.0.3/lib/active_support/concern.rb:52:in > >> `append_features' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> actionpack-3.0.3/lib/action_controller/test_case.rb:439:in `include' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> actionpack-3.0.3/lib/action_controller/test_case.rb:439 > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> activesupport-3.0.3/lib/active_support/concern.rb:52:in `class_eval' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> activesupport-3.0.3/lib/active_support/concern.rb:52:in > >> `append_features' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> activesupport-3.0.3/lib/active_support/concern.rb:48:in `include' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> activesupport-3.0.3/lib/active_support/concern.rb:48:in `send' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> activesupport-3.0.3/lib/active_support/concern.rb:48:in > >> `append_features' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> activesupport-3.0.3/lib/active_support/concern.rb:48:in `each' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> activesupport-3.0.3/lib/active_support/concern.rb:48:in > >> `append_features' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `include' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in `send' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:372:in > >> `configure_group' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in `each' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:369:in > >> `configure_group' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/world.rb:35:in `configure_group' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/example_group.rb:153:in `set_it_up' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/example_group.rb:130:in `subclass' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/example_group.rb:118:in `describe' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/extensions/object.rb:6:in `describe' > >> ? ? ? ?from /home/morris/work/ruby/rails3/wolfmanblog/spec/ > >> controllers/posts_controller_spec.rb:3 > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > >> `load_spec_files' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > >> `load_spec_files' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/ > >> rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' > >> ? ? ? ?from /opt/ruby-enterprise-1.8.7-2010.02/bin/rspec:19 > > >> On Jan 2, 8:12?pm, Jim Morris wrote: > >>> Yes I can, the full app is onhttps://github.com/wolfmanjm/wolfmanblog_rails > >>> although I downgraded back to rspec-rails 2.3.1, before I did that my > >>> Gemfile.lock looked like... > > >>> GEM > >>> ? remote:http://rubygems.org/ > >>> ? specs: > >>> ? ? abstract (1.0.0) > >>> ? ? actionmailer (3.0.3) > >>> ? ? ? actionpack (= 3.0.3) > >>> ? ? ? mail (~> 2.2.9) > >>> ? ? actionpack (3.0.3) > >>> ? ? ? activemodel (= 3.0.3) > >>> ? ? ? activesupport (= 3.0.3) > >>> ? ? ? builder (~> 2.1.2) > >>> ? ? ? erubis (~> 2.6.6) > >>> ? ? ? i18n (~> 0.4) > >>> ? ? ? rack (~> 1.2.1) > >>> ? ? ? rack-mount (~> 0.6.13) > >>> ? ? ? rack-test (~> 0.5.6) > >>> ? ? ? tzinfo (~> 0.3.23) > >>> ? ? activemodel (3.0.3) > >>> ? ? ? activesupport (= 3.0.3) > >>> ? ? ? builder (~> 2.1.2) > >>> ? ? ? i18n (~> 0.4) > >>> ? ? activerecord (3.0.3) > >>> ? ? ? activemodel (= 3.0.3) > >>> ? ? ? activesupport (= 3.0.3) > >>> ? ? ? arel (~> 2.0.2) > >>> ? ? ? tzinfo (~> 0.3.23) > >>> ? ? activeresource (3.0.3) > >>> ? ? ? activemodel (= 3.0.3) > >>> ? ? ? activesupport (= 3.0.3) > >>> ? ? activesupport (3.0.3) > >>> ? ? arel (2.0.6) > >>> ? ? builder (2.1.2) > >>> ? ? cells (3.4.2) > >>> ? ? diff-lcs (1.1.2) > >>> ? ? erubis (2.6.6) > >>> ? ? ? abstract (>= 1.0.0) > >>> ? ? factory_girl (1.3.2) > >>> ? ? factory_girl_rails (1.0) > >>> ? ? ? factory_girl (~> 1.3) > >>> ? ? ? rails (>= 3.0.0.beta4) > >>> ? ? haml (3.0.24) > >>> ? ? i18n (0.5.0) > >>> ? ? mail (2.2.12) > >>> ? ? ? activesupport (>= 2.3.6) > >>> ? ? ? i18n (>= 0.4.0) > >>> ? ? ? mime-types (~> 1.16) > >>> ? ? ? treetop (~> 1.4.8) > >>> ? ? mime-types (1.16) > >>> ? ? nokogiri (1.4.4) > >>> ? ? pg (0.10.0) > >>> ? ? polyglot (0.3.1) > >>> ? ? rack (1.2.1) > >>> ? ? rack-mount (0.6.13) > >>> ? ? ? rack (>= 1.0.0) > >>> ? ? rack-test (0.5.7) > >>> ? ? ? rack (>= 1.0) > >>> ? ? rails (3.0.3) > >>> ? ? ? actionmailer (= 3.0.3) > >>> ? ? ? actionpack (= 3.0.3) > >>> ? ? ? activerecord (= 3.0.3) > >>> ? ? ? activeresource (= 3.0.3) > >>> ? ? ? activesupport (= 3.0.3) > >>> ? ? ? bundler (~> 1.0) > >>> ? ? ? railties (= 3.0.3) > >>> ? ? railties (3.0.3) > >>> ? ? ? actionpack (= 3.0.3) > >>> ? ? ? activesupport (= 3.0.3) > >>> ? ? ? rake (>= 0.8.7) > >>> ? ? ? thor (~> 0.14.4) > >>> ? ? rake (0.8.7) > >>> ? ? rdiscount (1.6.5) > >>> ? ? rspec (2.4.0) > >>> ? ? ? rspec-core (~> 2.4.0) > >>> ? ? ? rspec-expectations (~> 2.4.0) > >>> ? ? ? rspec-mocks (~> 2.4.0) > >>> ? ? rspec-cells (0.0.2) > >>> ? ? ? cells (~> 3.4) > >>> ? ? ? rails (~> 3.0) > >>> ? ? ? rspec-rails (~> 2.2) > >>> ? ? rspec-core (2.4.0) > >>> ? ? rspec-expectations (2.4.0) > >>> ? ? ? diff-lcs (~> 1.1.2) > >>> ? ? rspec-mocks (2.4.0) > >>> ? ? rspec-rails (2.4.0) > >>> ? ? ? actionpack (~> 3.0) > >>> ? ? ? activesupport (~> 3.0) > >>> ? ? ? railties (~> 3.0) > >>> ? ? ? rspec (~> 2.4.0) > >>> ? ? sequel (3.17.0) > >>> ? ? sequel-rails (0.1.8) > >>> ? ? ? actionpack (~> 3.0.0) > >>> ? ? ? activesupport (~> 3.0.0) > >>> ? ? ? railties (~> 3.0.0) > >>> ? ? ? sequel (~> 3.13) > >>> ? ? stringex (1.2.0) > >>> ? ? thor (0.14.6) > >>> ? ? treetop (1.4.9) > >>> ? ? ? polyglot (>= 0.3.1) > >>> ? ? tzinfo (0.3.23) > >>> ? ? uuidtools (2.1.1) > >>> ? ? webrat (0.7.2) > >>> ? ? ? nokogiri (>= 1.2.0) > >>> ? ? ? rack (>= 1.0) > >>> ? ? ? rack-test (>= 0.5.3) > > >>> PLATFORMS > >>> ? ruby > > >>> DEPENDENCIES > >>> ? cells > >>> ? factory_girl_rails > >>> ? haml > >>> ? pg > >>> ? rails (= 3.0.3) > >>> ? rdiscount > >>> ? rspec-cells > >>> ? rspec-rails (~> 2.3) > >>> ? sequel-rails > >>> ? stringex > >>> ? uuidtools > >>> ? webrat > > >>> Using rake (0.8.7) > >>> Using abstract (1.0.0) > >>> Using activesupport (3.0.3) > >>> Using builder (2.1.2) > >>> Using i18n (0.5.0) > >>> Using activemodel > > ... > > read more ? From node.js99 at gmail.com Tue Jan 4 10:31:48 2011 From: node.js99 at gmail.com (Nadal) Date: Tue, 4 Jan 2011 07:31:48 -0800 (PST) Subject: [rspec-users] Looking for a gem which uses rspec for testing and tests need to deal with database Message-ID: <418f4f01-498c-425f-862c-2e5bb5f9cd32@r19g2000prm.googlegroups.com> Let's say that I develop a gem which adds a new method to ActiveRecord . Now I want to test this method using rspec. I am able to get started but not sure where to put the database.yml for testing purpose. I was wondering if there is a gem out there which uses rspec for testing and has to interact to database for testing. Thanks From nick at deadorange.com Tue Jan 4 11:32:15 2011 From: nick at deadorange.com (Nick) Date: Tue, 4 Jan 2011 08:32:15 -0800 (PST) Subject: [rspec-users] Looking for a gem which uses rspec for testing and tests need to deal with database In-Reply-To: <418f4f01-498c-425f-862c-2e5bb5f9cd32@r19g2000prm.googlegroups.com> Message-ID: <23737794.2016.1294158735854.JavaMail.geo-discussion-forums@yqng23> How about vestal_versions? https://github.com/laserlemon/vestal_versions I found it by going to Ruby Toolbox, and looking at the ActiveRecord-related gems. http://ruby-toolbox.com/categories.html Good luck! Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From node.js99 at gmail.com Tue Jan 4 12:54:00 2011 From: node.js99 at gmail.com (Nadal) Date: Tue, 4 Jan 2011 09:54:00 -0800 (PST) Subject: [rspec-users] Looking for a gem which uses rspec for testing and tests need to deal with database In-Reply-To: <23737794.2016.1294158735854.JavaMail.geo-discussion-forums@yqng23> References: <23737794.2016.1294158735854.JavaMail.geo-discussion-forums@yqng23> Message-ID: Thank you Nick. That's exactly what I was looking for. Also I keep forgetting about ruby-toolbox.com so thanks for pointing that out too. On Jan 4, 11:32?am, Nick wrote: > How about vestal_versions?https://github.com/laserlemon/vestal_versions > > I found it by going to Ruby Toolbox, and looking at the ActiveRecord-related > gems.http://ruby-toolbox.com/categories.html > > Good luck! > Nick > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From gurufrequent at gmail.com Wed Jan 5 02:54:36 2011 From: gurufrequent at gmail.com (Guru Prasad) Date: Wed, 5 Jan 2011 13:24:36 +0530 Subject: [rspec-users] after changing text in "it" block -e and -l options not working Message-ID: hi guys ! I am pretty new to rspec and I am still learning. I tried to change the text in "it" block and then run the rspec with -e and -l flag with appropriate values. But it dint work. What i can think of is rspec must have stored the earlier information which is not updated. here is what i got ================================================================== C:\work>jruby -S rspec specification\xyz\install_spec.rb -l 105 Run filtered using {:line_number=>105} F Failures: 1) #POST_OPERATIONS should stop machine Failure/Error: if not $pre_arr.has_key?(k.to_s) then NoMethodError: undefined method `has_key?' for "0":String # ./specification/xyz/install_spec.rb:26:in `get_id' # ./specification/xyz/install_spec.rb:25:in `each' # ./specification/xyz/install_spec.rb:25:in `get_id' # ./specification/xyz/install_spec.rb:60 # ./specification/xyz/install_spec.rb:106:in `call' # ./specification/xyz/install_spec.rb:106 # :1 Finished in 4.41 seconds 1 example, 1 failure ================================================================= please help !! Thanks & Regards Guru Prasad ~guru -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jan 5 10:59:29 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Jan 2011 09:59:29 -0600 Subject: [rspec-users] after changing text in "it" block -e and -l options not working In-Reply-To: References: Message-ID: On Jan 5, 2011, at 1:54 AM, Guru Prasad wrote: > hi guys ! > I am pretty new to rspec and I am still learning. > I tried to change the text in "it" block and then run the rspec with -e and -l flag with appropriate values. > > But it dint work. > > What i can think of is rspec must have stored the earlier information which is not updated. RSpec does not do anything like that between runs. Are you saying you had a passing example at first, and then you changed it, and then it failed? What was the content of the example (the "it" block) before and after the change? > > here is what i got > ================================================================== > C:\work>jruby -S rspec specification\xyz\install_spec.rb -l 105 > Run filtered using {:line_number=>105} > F > > Failures: > > 1) #POST_OPERATIONS should stop machine > Failure/Error: if not $pre_arr.has_key?(k.to_s) then > NoMethodError: > undefined method `has_key?' for "0":String > # ./specification/xyz/install_spec.rb:26:in `get_id' > # ./specification/xyz/install_spec.rb:25:in `each' > # ./specification/xyz/install_spec.rb:25:in `get_id' > # ./specification/xyz/install_spec.rb:60 > # ./specification/xyz/install_spec.rb:106:in `call' > # ./specification/xyz/install_spec.rb:106 > # :1 > > Finished in 4.41 seconds > 1 example, 1 failure > ================================================================= > > please help !! > > Thanks & Regards > Guru Prasad > ~guru > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed Jan 5 17:06:28 2011 From: lists at ruby-forum.com (Steve Hull) Date: Wed, 05 Jan 2011 23:06:28 +0100 Subject: [rspec-users] Error Testing a view in RSpec 2 In-Reply-To: <3752FDCE-3422-460C-8B54-0FA1A6D50BF9@gmail.com> References: <2eff9aff-febb-48e2-b152-f5a2a7c0a21b@k10g2000yqa.googlegroups.com> <0237F3DE-8757-4066-A8EF-2C27EB36B129@gmail.com> <569c16f7-64af-40b2-914a-08395589a54c@28g2000yqm.googlegroups.com> <3C6FE6CE-3E68-46AA-B822-1CF44B5DD22A@gmail.com> <0fcd3227-5d2d-4b81-a378-ea8aa5309bd2@j18g2000yqd.googlegroups.com> <3752FDCE-3422-460C-8B54-0FA1A6D50BF9@gmail.com> Message-ID: <952abc3f32f4325fb9c6013fa105e311@ruby-forum.com> David Chelimsky wrote in post #949683: > have_tag wrapped assert_select in a way that was very brittle. Also > Webrat and Capybara matchers are better :) Any tips on how we can use the Capybara matchers in our helper specs? Seems like a reasonable thing to want to do, since helpers are typically used to put together pieces of html. -Steve -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Jan 5 17:23:01 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 5 Jan 2011 16:23:01 -0600 Subject: [rspec-users] Error Testing a view in RSpec 2 In-Reply-To: <952abc3f32f4325fb9c6013fa105e311@ruby-forum.com> References: <2eff9aff-febb-48e2-b152-f5a2a7c0a21b@k10g2000yqa.googlegroups.com> <0237F3DE-8757-4066-A8EF-2C27EB36B129@gmail.com> <569c16f7-64af-40b2-914a-08395589a54c@28g2000yqm.googlegroups.com> <3C6FE6CE-3E68-46AA-B822-1CF44B5DD22A@gmail.com> <0fcd3227-5d2d-4b81-a378-ea8aa5309bd2@j18g2000yqd.googlegroups.com> <3752FDCE-3422-460C-8B54-0FA1A6D50BF9@gmail.com> <952abc3f32f4325fb9c6013fa105e311@ruby-forum.com> Message-ID: <7DC5E4D1-EADF-4162-B46C-623202B0A836@gmail.com> On Jan 5, 2011, at 4:06 PM, Steve Hull wrote: > David Chelimsky wrote in post #949683: >> have_tag wrapped assert_select in a way that was very brittle. Also >> Webrat and Capybara matchers are better :) > > Any tips on how we can use the Capybara matchers in our helper specs? > Seems like a reasonable thing to want to do, since helpers are typically > used to put together pieces of html. Capybara does not support them yet. It's in the works though. Check the Capybara tracker for more info. > > -Steve > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From antsmailinglist at gmail.com Thu Jan 6 15:39:16 2011 From: antsmailinglist at gmail.com (Ants Pants) Date: Thu, 6 Jan 2011 21:39:16 +0100 Subject: [rspec-users] Feedback Requested (pretty please) Message-ID: I have dabbled with RSpec with the Beta books but am only now getting my teeth in to it. Because of this and because I have no one to ask/bounce ideas off, I am asking for a kind soul to look at what I've done for my first example. Am I on the right track with the way I'm thinking? My first attempt at testing my real live thing was the following (comments included to help) describe "GET edit" do context "the product cutoff time has passed" do it "prevents editing of the product" do ## ProductType object must be received on an edit ProductType.should_receive(:find).with("1").and_return(ProductType) ProductType.should_receive(:products).and_return(Product) Product.stub(:find).with("1").and_return(Product) ## this is the thing I really want to test Product.should_receive(:product_cutoff_passed?).and_return(true) ## before filters controller.stub(:authorise_is_admin).and_return(true) controller.stub(:require_user).and_return(user) get :edit, :product_type_id => 1, :id => 1 flash[:notice].should == "The product is closed for editing" response.should redirect_to(products_path) end end end I got the above example passing and then went about refactoring it and this is what I have now def require_user controller.stub(:require_user).and_return(User) end def authorise_is_admin controller.stub(:authorise_is_admin).and_return(true) end describe ProductsController do ## this is required for all actions in this controller before(:each) do require_user end let(:product_type) { mock_model(ProductType).as_null_object } let(:product) { mock_model(Product).as_null_object } describe "GET edit" do ## this is required for this action before(:each) do authorise_is_admin end ## this now has its own test as it is fundamental to the action it "creates a ProductType object" do ## message expectation ProductType.should_receive(:find).with("1").and_return(product_type)45 get :edit, :product_type_id => 1, :id => 1 end ## the message expectations in my first example are now stubs in this example ## as they are not the main focus of this test context "the product cutoff time has passed" do it "prevents editing of the product" do ProductType.stub(:find).with("1").and_return(product_type) ## would like to use stub_chain but one of the stubs receives arguments product_type.stub(:products).and_return(product) product.stub(:find).with("1").and_return(product) ## message expectation product.should_receive(:product_cutoff_passed?).and_return(true) get :edit, :product_type_id => 1, :id => 1 flash[:notice].should == "The product is closed for editing" response.should redirect_to(products_path) end end end end I hope you don;t mind if I do this as I will need your feedback to get me in the right way of thinking. Thank you -ants -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Jan 7 09:41:23 2011 From: lists at ruby-forum.com (Sarah Allen) Date: Fri, 07 Jan 2011 15:41:23 +0100 Subject: [rspec-users] Configuring RSpec for Integration Test In-Reply-To: References: <80F2BC20-1356-462C-8348-AED473C716C6@gmail.com> <7a66bb5738cf176fa0c670b0964e9645@ruby-forum.com> Message-ID: Getting back to this after the holidays... David Chelimsky wrote in post #969342: > If you need to use spec/integration instead, then you'll need to tell > RSpec to include RSpec::Rails::RequestExampleGroup in those examples. > You can do that on a per group basis, like this: > > describe "something" do > include RSpec::Rails::RequestExampleGroup > ... > end > > Or globally like this: > > RSpec.configure do |config| > config.include RSpec::Rails::RequestExampleGroup, > :example_group => { > :file_path => /spec\/integration/ > } > end I tried the approach with an include and it worked fine, which I pushed to a branch here: https://github.com/blazingcloud/rspec-capybara/tree/simple_custom_spec_directory_config Also, just changing the directory name to "requests" worked fine too: https://github.com/blazingcloud/rspec-capybara I couldn't find anywhere this was documented. Did I miss a page? If so, maybe we can write a blog post post and improve the SEO on this basic bit of info. Or point to where it should be documented and maybe we can help with that. Thanks! Sarah -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Jan 7 10:01:37 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 7 Jan 2011 09:01:37 -0600 Subject: [rspec-users] Configuring RSpec for Integration Test In-Reply-To: References: <80F2BC20-1356-462C-8348-AED473C716C6@gmail.com> <7a66bb5738cf176fa0c670b0964e9645@ruby-forum.com> Message-ID: <6D263F5D-68DA-407F-A4E3-D9526F0F0774@gmail.com> On Jan 7, 2011, at 8:41 AM, Sarah Allen wrote: > Getting back to this after the holidays... > > David Chelimsky wrote in post #969342: >> If you need to use spec/integration instead, then you'll need to tell >> RSpec to include RSpec::Rails::RequestExampleGroup in those examples. >> You can do that on a per group basis, like this: >> >> describe "something" do >> include RSpec::Rails::RequestExampleGroup >> ... >> end >> >> Or globally like this: >> >> RSpec.configure do |config| >> config.include RSpec::Rails::RequestExampleGroup, >> :example_group => { >> :file_path => /spec\/integration/ >> } >> end > > I tried the approach with an include and it worked fine, which I pushed > to a branch here: > https://github.com/blazingcloud/rspec-capybara/tree/simple_custom_spec_directory_config > > Also, just changing the directory name to "requests" worked fine too: > https://github.com/blazingcloud/rspec-capybara In the 2.4 release it works for spec/integration as well: http://blog.davidchelimsky.net/2011/01/02/rspec-240-is-released/ > I couldn't find anywhere this was documented. Did I miss a page? If so, > maybe we can write a blog post post and improve the SEO on this basic > bit of info. Or point to where it should be documented and maybe we can > help with that. Should be documented here: http://relishapp.com/rspec/rspec-rails Info on contributing/helping is here: http://blog.davidchelimsky.net/2010/12/23/rspec-2-documentation-2/ Any help would be wonderful! Cheers, David > > Thanks! > Sarah From lists at ruby-forum.com Fri Jan 7 10:12:30 2011 From: lists at ruby-forum.com (Sarah Allen) Date: Fri, 07 Jan 2011 16:12:30 +0100 Subject: [rspec-users] Configuring RSpec for Integration Test In-Reply-To: References: Message-ID: I don't see any cucumber scenarios on integration testing with webrat or capybara. Did I miss those? or should we add some? We have a couple of volunteer interns at Blazing Cloud who are learning TDD and may be able to help with docs. I just want to be sure to steep them in the right direction. Thanks! Sarah -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Jan 7 10:21:30 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 7 Jan 2011 09:21:30 -0600 Subject: [rspec-users] Configuring RSpec for Integration Test In-Reply-To: References: Message-ID: <4ABC1A12-4112-4E73-A5A9-3F5B1E80A0D8@gmail.com> On Jan 7, 2011, at 9:12 AM, Sarah Allen wrote: > I don't see any cucumber scenarios on integration testing with webrat or > capybara. Did I miss those? You did not! They are just missing. > or should we add some? Yes! Please!!!!!!!!!! > We have a couple of volunteer interns at Blazing Cloud who are learning > TDD and may be able to help with docs. I just want to be sure to steep > them in the right direction. Awesome. TIA. Cheers, David > > Thanks! > Sarah From spocksplanet at gmail.com Fri Jan 7 12:34:42 2011 From: spocksplanet at gmail.com (Volkan Unsal) Date: Fri, 7 Jan 2011 09:34:42 -0800 (PST) Subject: [rspec-users] "No route matches" error? Message-ID: <908a637a-3e77-4cc3-8a42-0e5e1bf0854e@z19g2000yqb.googlegroups.com> I am new Rspec and just started by generating a new controller on Rails 3. It generates some Rspec tests by default. I have a question about how to make them pass though. As it stands, I see this test in my terminal" > 1) BuildingsController GET 'show' > should be successful > Failure/Error: get 'show' > No route matches {:controller=>"buildings", :action=>"show"} > # ./spec/controllers/buildings_controller_spec.rb:17:in `block (3 levels) in ' However, I don't understand why it's coming up because I already have this route created ("resources :buildings"), and I ran `rake routes` and made sure it's there. > building GET /buildings/:id(.:format) {:action=>"show", :controller=>"buildings"} What is necessary to make this pass? Here is the test by the way: describe "GET 'show'" do it "should be successful" do get 'show' response.should be_success end end From antsmailinglist at gmail.com Fri Jan 7 12:58:52 2011 From: antsmailinglist at gmail.com (Ants Pants) Date: Fri, 7 Jan 2011 18:58:52 +0100 Subject: [rspec-users] Stumped with nil Class error Message-ID: I'm really, really confused about the use of instance variables in my controller and their relationship to my controller spec. I'm trying to spec a controller that has a before_filter :require_member (it's Authlogic and set up in ApplicationController. It in turn calls current_member - which returns/creates the @member variable ) and a before_filter :find_product The find_product method is thus ... def find_product @product = (params[:id]) ? @member.products.find(params[:id]) : Product.new end No matter what I try and in what order, I get the error message .... NoMethodError in 'ProductsController PUT edit Product cut-off has passed creates a product object' undefined method `products' for nil:NilClass and it points to the find_product method and it's the @member that is nil I thought that the controller.stub(:require_member).and_return(member) would suffice for the require_member stuff but I'm obviously wrong. I've even replaced the member for @member in my spec but to no avail. Here's the describe example .... describe "PUT edit" do context "Product cut-off has passed" do let(:member) { mock_model(Member).as_null_object } let(:product) { mock_model(Product).as_null_object } ## I just want it to create a @product object from it "creates a product object" do controller.stub(:require_member).and_return(member) member.should_receive(:products) get :edit, :id => "1" end end end If anyone would be able to untangle me, I'd be greatly appreciative. CIA -ants -------------- next part -------------- An HTML attachment was scrubbed... URL: From dolzenko at gmail.com Fri Jan 7 12:59:21 2011 From: dolzenko at gmail.com (Evgeniy Dolzhenko) Date: Fri, 07 Jan 2011 20:59:21 +0300 Subject: [rspec-users] "No route matches" error? In-Reply-To: <908a637a-3e77-4cc3-8a42-0e5e1bf0854e@z19g2000yqb.googlegroups.com> References: <908a637a-3e77-4cc3-8a42-0e5e1bf0854e@z19g2000yqb.googlegroups.com> Message-ID: <4D275479.4010709@gmail.com> You need to pass :id param as well to get the route recognized: describe "GET 'show'" do it "should be successful" do get 'show', :id => '55' response.should be_success end end On 1/7/2011 8:34 PM, Volkan Unsal wrote: > I am new Rspec and just started by generating a new controller on > Rails 3. It generates some Rspec tests by default. I have a question > about how to make them pass though. As it stands, I see this test in > my terminal" > >> 1) BuildingsController GET 'show' >> should be successful >> Failure/Error: get 'show' >> No route matches {:controller=>"buildings", :action=>"show"} >> # ./spec/controllers/buildings_controller_spec.rb:17:in `block (3 levels) in' > However, I don't understand why it's coming up because I already have > this route created ("resources :buildings"), and I ran `rake routes` > and made sure it's there. > >> building GET /buildings/:id(.:format) {:action=>"show", :controller=>"buildings"} > > What is necessary to make this pass? Here is the test by the way: > > describe "GET 'show'" do > it "should be successful" do > get 'show' > response.should be_success > end > end > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Jan 7 13:01:43 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 7 Jan 2011 12:01:43 -0600 Subject: [rspec-users] "No route matches" error? In-Reply-To: <908a637a-3e77-4cc3-8a42-0e5e1bf0854e@z19g2000yqb.googlegroups.com> References: <908a637a-3e77-4cc3-8a42-0e5e1bf0854e@z19g2000yqb.googlegroups.com> Message-ID: <74AA6BD9-13C4-4DC3-BB37-B047D4DA9280@gmail.com> On Jan 7, 2011, at 11:34 AM, Volkan Unsal wrote: > I am new Rspec and just started by generating a new controller on > Rails 3. It generates some Rspec tests by default. I have a question > about how to make them pass though. As it stands, I see this test in > my terminal" > >> 1) BuildingsController GET 'show' >> should be successful > >> Failure/Error: get 'show' >> No route matches {:controller=>"buildings", :action=>"show"} >> # ./spec/controllers/buildings_controller_spec.rb:17:in `block (3 levels) in ' > > However, I don't understand why it's coming up because I already have > this route created ("resources :buildings"), and I ran `rake routes` > and made sure it's there. > >> building GET /buildings/:id(.:format) {:action=>"show", :controller=>"buildings"} > > > What is necessary to make this pass? Here is the test by the way: > > describe "GET 'show'" do > it "should be successful" do > get 'show' building = Building.create! get 'show', :id => building.id > response.should be_success HTH, David > end > end > > From spocksplanet at gmail.com Fri Jan 7 18:17:15 2011 From: spocksplanet at gmail.com (Volkan Unsal) Date: Fri, 7 Jan 2011 15:17:15 -0800 (PST) Subject: [rspec-users] How to test scripts in the lib directory of Rails? Message-ID: I have a script called query.rb inside my lib folder in Rails 3. I am writing a spec test for it. Though I'm no sure how to reference the Query class from my tests. Whenever I use Query, RSpec complain that it's not able to find it. This is how I wrote it: before(:each) do query = Query.new end How can I make sure that Query is accessible by the spec? From nick at deadorange.com Fri Jan 7 19:13:10 2011 From: nick at deadorange.com (Nick) Date: Fri, 7 Jan 2011 16:13:10 -0800 (PST) Subject: [rspec-users] How to test scripts in the lib directory of Rails? In-Reply-To: Message-ID: <26171411.2444.1294445590481.JavaMail.geo-discussion-forums@yqcj39> Hey Volkan. Make sure to "require" the file that your Query class is in. Usually this is done at the top of query_spec.rb , or in spec_helper.rb . Cheers, Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From spocksplanet at gmail.com Fri Jan 7 19:44:05 2011 From: spocksplanet at gmail.com (Volkan Unsal) Date: Fri, 7 Jan 2011 16:44:05 -0800 (PST) Subject: [rspec-users] How to test scripts in the lib directory of Rails? In-Reply-To: <26171411.2444.1294445590481.JavaMail.geo-discussion-forums@yqcj39> References: <26171411.2444.1294445590481.JavaMail.geo-discussion-forums@yqcj39> Message-ID: <26c34448-edc6-4caa-86ec-28ad590388e7@y31g2000vbt.googlegroups.com> D'oh! Thanks Nick! On Jan 7, 7:13?pm, Nick wrote: > Hey Volkan. Make sure to "require" the file that your Query class is in. > Usually this is done at the top of query_spec.rb , or in spec_helper.rb . > > Cheers, > Nick > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From mmazur at gmail.com Fri Jan 7 21:40:13 2011 From: mmazur at gmail.com (Mike Mazur) Date: Sat, 8 Jan 2011 10:40:13 +0800 Subject: [rspec-users] Stumped with nil Class error In-Reply-To: References: Message-ID: Hi, On Sat, Jan 8, 2011 at 01:58, Ants Pants wrote: > I thought that the?controller.stub(:require_member).and_return(member) would > suffice for the require_member stuff but I'm obviously wrong. I've even > replaced the member for @member in my spec but to no avail. > Here's the describe example .... > ??describe "PUT edit" do > ?? ?context "Product cut-off has passed" do > ?? ? ?let(:member) { mock_model(Member).as_null_object } > ?? ? ?let(:product) { mock_model(Product).as_null_object } > ?? ? ?## I just want it to create a @product object from > ?? ? ?it "creates a product object" do > ?? ? ? ?controller.stub(:require_member).and_return(member) > ?? ? ? ?member.should_receive(:products) > ?? ? ? ?get :edit, :id => "1" > ?? ? ?end > ?? ?end > ??end > If anyone would be able to untangle me, I'd be greatly appreciative. Your stub returns member, but require_member sets the @member instance variable. Try modifying your stub to something like this (untested): controller.stub(:require_member) { assigns(:member) = member } HTH, Mike From antsmailinglist at gmail.com Sun Jan 9 08:58:57 2011 From: antsmailinglist at gmail.com (Ants Pants) Date: Sun, 9 Jan 2011 14:58:57 +0100 Subject: [rspec-users] Stumped with nil Class error In-Reply-To: References: Message-ID: Thanks for the reply but I've sorted it. I implemented this http://iain.nl/2008/11/authlogic-is-awesome/ I think the instance variables in this example replicate how they will look in the actual controller (thus enabling me to stub them/set message expectations. Anyway, I eventually got it working and can now press on. Again, thanks for taking the time to reply. On 8 January 2011 03:40, Mike Mazur wrote: > Hi, > > On Sat, Jan 8, 2011 at 01:58, Ants Pants > wrote: > > I thought that the controller.stub(:require_member).and_return(member) > would > > suffice for the require_member stuff but I'm obviously wrong. I've even > > replaced the member for @member in my spec but to no avail. > > Here's the describe example .... > > describe "PUT edit" do > > context "Product cut-off has passed" do > > let(:member) { mock_model(Member).as_null_object } > > let(:product) { mock_model(Product).as_null_object } > > ## I just want it to create a @product object from > > it "creates a product object" do > > controller.stub(:require_member).and_return(member) > > member.should_receive(:products) > > get :edit, :id => "1" > > end > > end > > end > > If anyone would be able to untangle me, I'd be greatly appreciative. > > Your stub returns member, but require_member sets the @member instance > variable. Try modifying your stub to something like this (untested): > > controller.stub(:require_member) { assigns(:member) = member } > > HTH, > Mike > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Jan 9 17:24:12 2011 From: lists at ruby-forum.com (Rob Slifka) Date: Sun, 09 Jan 2011 23:24:12 +0100 Subject: [rspec-users] Trouble making rspec-rails 2 work with webrat. In-Reply-To: <634C9D72-D1EA-43B1-995E-23EB9F08EB54@gmail.com> References: <2b3d260d-1431-494c-a003-89489f443425@c39g2000yqi.googlegroups.com> <877C79A4-D07C-48B6-AF91-503122CA0785@gmail.com> <2183E0A5-56B1-4BC5-AF27-4B597218F18D@gmail.com> <704c2777-746b-4d82-b772-71929bb3ddd3@fl7g2000vbb.googlegroups.com> <634C9D72-D1EA-43B1-995E-23EB9F08EB54@gmail.com> Message-ID: <72624fafc55e07bfba784885703148c3@ruby-forum.com> > > I was able to get things to work by moving "include Rack::Test::Methods" > into the configure block: > > RSpec.configure do |config| > config.include Rack::Test::Methods > ... > end > > You should _not_, however, have to do any such thing, so I'll look into > it and if I can address this in rspec-rails I will and have a bug-fix > release out soon. For others reading this, this was fixed. I was on rspec 2.1.0 and all I had to do was to upgrade to the latest (2.4.0) and no changes from the vanilla rspec install spec_helper are required to run Webrat. Hope to save everyone the 40 minutes I spent not realizing a simple upgrade fixed it :) Rob -- Posted via http://www.ruby-forum.com/. From abhikp at gmail.com Wed Jan 5 12:11:27 2011 From: abhikp at gmail.com (Abhik Pramanik) Date: Wed, 5 Jan 2011 09:11:27 -0800 (PST) Subject: [rspec-users] Writing a matcher that accepts a block Message-ID: <29760548.3149.1294247487831.JavaMail.geo-discussion-forums@prnp16> Hi all, I'm trying to emulate the have_tag matcher that used to be in rspec-rails. How would I do that with the rspec 2 interface? html.should have_tag("div") do with_tag("span") end RSpec::Matchers.define won't let me pass in a block. I could extend the RSpec::Matchers module but I'm not sure if that's the way to do it anymore. Any guidance would be helpful! Abhik -------------- next part -------------- An HTML attachment was scrubbed... URL: From jason.nah at gmail.com Thu Jan 6 18:27:23 2011 From: jason.nah at gmail.com (Jason N.) Date: Thu, 6 Jan 2011 15:27:23 -0800 (PST) Subject: [rspec-users] View specs - best practices Message-ID: <2f764089-85ab-4a86-ab63-13459120d1ab@o23g2000prh.googlegroups.com> Howdy, I'm trying to test some mailer views (which is no different to normal views in terms of specs)... ran into the following problem... In adherence to the "one expectation per 'spec'"... I'm trying to write the following describe "auth/mailer/signup.html.erb" do before(:each) do @user = Factory.build(:user) assign(:user, @user) render end subject { rendered } it { should include(@user.email) } it { should... it { should... end Before long, if you keep this up, your spec goes from quick to very slow. Turns out, calling render takes a bit of effort and the before(:each) tells rspec to call render before each "it" call. SO... is there a way to cache this, so that the rendered output is available to each spec to avoid re-rendering? Each "it" item, really describes expectations on the output, which doesn't change for every run. I could default back down to a single it, but that would defeat the purpose of writing small tests. I've tried before(:all), but rspec doesn't like it. It generates the following error: Failure/Error: render NoMethodError: undefined method `example_group' for nil:NilClass Cheers, Jason From marko at renderedtext.com Wed Jan 5 12:54:43 2011 From: marko at renderedtext.com (Marko Anastasov) Date: Wed, 5 Jan 2011 09:54:43 -0800 (PST) Subject: [rspec-users] Cookie value set in spec, but controller can't read it Message-ID: Hello, I set a value in controller spec using @request.cookies: https://gist.github.com/371356ba0a19666fd3b5 but when the controller reads it, it's nil somehow, as this screenshot from the debugger shows: http://dl.dropbox.com/u/830772/p/Selection_033.jpeg This does not occur in development environment. I'm using RSpec 2.4 and Rails 3. Does someone have an idea what I am doing wrong / how to solve this? From tashfeen.ekram at gmail.com Thu Jan 6 20:49:24 2011 From: tashfeen.ekram at gmail.com (tashfeen.ekram) Date: Thu, 6 Jan 2011 17:49:24 -0800 (PST) Subject: [rspec-users] no such file to load -- spec/rake/spectask Message-ID: <92551e68-99d1-4d39-88e2-3a25752318ad@j32g2000prh.googlegroups.com> I am sorry but it seems like this should be a simple answer. when i run a any rake command i get the following error: no such file to load -- spec/rake/spectask i amusing bundler and have the latest rspec installed. any idea? make dev tough when you can not do any rake tasks... From dchelimsky at gmail.com Sun Jan 9 23:05:16 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 9 Jan 2011 22:05:16 -0600 Subject: [rspec-users] Cookie value set in spec, but controller can't read it In-Reply-To: References: Message-ID: <7017E159-120D-45E4-83BE-AEF2F19BDF29@gmail.com> On Jan 5, 2011, at 11:54 AM, Marko Anastasov wrote: > Hello, > > I set a value in controller spec using @request.cookies: > https://gist.github.com/371356ba0a19666fd3b5 > > but when the controller reads it, it's nil somehow, as this screenshot > from the debugger shows: > http://dl.dropbox.com/u/830772/p/Selection_033.jpeg > > This does not occur in development environment. I'm using RSpec 2.4 > and Rails 3. > > Does someone have an idea what I am doing wrong / how to solve this? That looks like it should work, and I don't think you're doing anything wrong. What's happening is that the object returned by @request.cookies is a Hash, but the object returned by cookies() in the controller is an ActionDispatch::Cookies::CookieJar. If you print them both out with .inspect, they'll both say they are {:lastfm_username => "rj"}, but the answer differently to other questions: # in spec @request.cookies[:lastfm_username] # => "rj" @request.cookies["lastfm_username"] # => nil # in controller cookies[:lastfm_username] # => nil cookies["lastfm_username"] # => nil You'll see exactly the same behavior, btw, in a Rails functional test (which an RSpec controller spec wraps), so this is happening in the Rails test infrastructure, not RSpec. Care to log a bug report in the Rails tracker? https://rails.lighthouseapp.com/ Thx, David From dchelimsky at gmail.com Sun Jan 9 23:07:43 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 9 Jan 2011 22:07:43 -0600 Subject: [rspec-users] Writing a matcher that accepts a block In-Reply-To: <29760548.3149.1294247487831.JavaMail.geo-discussion-forums@prnp16> References: <29760548.3149.1294247487831.JavaMail.geo-discussion-forums@prnp16> Message-ID: <73D4CF85-816D-498C-9DE9-D5346FE81BA4@gmail.com> On Jan 5, 2011, at 11:11 AM, Abhik Pramanik wrote: > Hi all, > > I'm trying to emulate the have_tag matcher that used to be in rspec-rails. How would I do that with the rspec 2 interface? > > html.should have_tag("div") do > with_tag("span") > end > > RSpec::Matchers.define won't let me pass in a block. I could extend the RSpec::Matchers module but I'm not sure if that's the way to do it anymore. Any guidance would be helpful! I'd recommend not doing this. Webrat and Capybara matchers both work very well for this and there is no need to roll your own by hacking RSpec. html.should have_selector("div span") FWIW, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 9 23:09:17 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 9 Jan 2011 22:09:17 -0600 Subject: [rspec-users] no such file to load -- spec/rake/spectask In-Reply-To: <92551e68-99d1-4d39-88e2-3a25752318ad@j32g2000prh.googlegroups.com> References: <92551e68-99d1-4d39-88e2-3a25752318ad@j32g2000prh.googlegroups.com> Message-ID: <633B9458-32CA-4761-B17A-3C0A021ABA6C@gmail.com> On Jan 6, 2011, at 7:49 PM, tashfeen.ekram wrote: > I am sorry but it seems like this should be a simple answer. > > when i run a any rake command i get the following error: > > no such file to load -- spec/rake/spectask See http://relishapp.com/rspec/rspec-core/v/2-4/file/upgrade require 'rspec/core/rake_task' (not require 'spec/rake/spectask', which was the location in RSpec-1). HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From abhikp at gmail.com Sun Jan 9 23:27:00 2011 From: abhikp at gmail.com (Abhik Pramanik) Date: Sun, 9 Jan 2011 20:27:00 -0800 (PST) Subject: [rspec-users] Writing a matcher that accepts a block In-Reply-To: <9847093.2363.1294633502263.JavaMail.geo-discussion-forums@prfn5> Message-ID: <7270165.1303.1294633620478.JavaMail.geo-discussion-forums@prmr35> Anyways I got it working, so no need for help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From abhikp at gmail.com Sun Jan 9 23:25:02 2011 From: abhikp at gmail.com (Abhik Pramanik) Date: Sun, 9 Jan 2011 20:25:02 -0800 (PST) Subject: [rspec-users] Writing a matcher that accepts a block In-Reply-To: <73D4CF85-816D-498C-9DE9-D5346FE81BA4@gmail.com> Message-ID: <9847093.2363.1294633502263.JavaMail.geo-discussion-forums@prfn5> Yah I know. They're not available in view tests. Someone had posted a question about this on the Capybara users group and the response was to write your own. Abhik -------------- next part -------------- An HTML attachment was scrubbed... URL: From marko at renderedtext.com Mon Jan 10 09:27:23 2011 From: marko at renderedtext.com (Marko Anastasov) Date: Mon, 10 Jan 2011 15:27:23 +0100 Subject: [rspec-users] Cookie value set in spec, but controller can't read it In-Reply-To: <7017E159-120D-45E4-83BE-AEF2F19BDF29@gmail.com> References: <7017E159-120D-45E4-83BE-AEF2F19BDF29@gmail.com> Message-ID: On Mon, Jan 10, 2011 at 05:05, David Chelimsky wrote: > On Jan 5, 2011, at 11:54 AM, Marko Anastasov wrote: > >> Hello, >> >> I set a value in controller spec using @request.cookies: >> https://gist.github.com/371356ba0a19666fd3b5 >> >> but when the controller reads it, it's nil somehow, as this screenshot >> from the debugger shows: >> http://dl.dropbox.com/u/830772/p/Selection_033.jpeg >> >> This does not occur in development environment. I'm using RSpec 2.4 >> and Rails 3. >> >> Does someone have an idea what I am doing wrong / how to solve this? > > That looks like it should work, and I don't think you're doing anything wrong. > > What's happening is that the object returned by @request.cookies is a Hash, but the object returned by cookies() in the controller is an ActionDispatch::Cookies::CookieJar. If you print them both out with .inspect, they'll both say they are {:lastfm_username => "rj"}, but the answer differently to other questions: > > # in spec > @request.cookies[:lastfm_username] # => "rj" > @request.cookies["lastfm_username"] # => nil > > # in controller > cookies[:lastfm_username] # => nil > cookies["lastfm_username"] # => nil > > You'll see exactly the same behavior, btw, in a Rails functional test (which an RSpec controller spec wraps), so this is happening in the Rails test infrastructure, not RSpec. Care to log a bug report in the Rails tracker? > > https://rails.lighthouseapp.com/ > Thanks for your explanation David. I created Rails ticket #6272. Later I found a workaround of using request.cookies in the controller, but it would be nice if it would just work with cookies. Btw I was also not sure when to use symbols, and when keys. Eg if I set a value in controller: cookies.permanent[:lastfm_username] = username then in spec, I need to obtain the value with a string: cookies["lastfm_username"].should == "rj" Marko From dolzenko at gmail.com Mon Jan 10 11:40:21 2011 From: dolzenko at gmail.com (Evgeniy Dolzhenko) Date: Mon, 10 Jan 2011 19:40:21 +0300 Subject: [rspec-users] View specs - best practices In-Reply-To: <2f764089-85ab-4a86-ab63-13459120d1ab@o23g2000prh.googlegroups.com> References: <2f764089-85ab-4a86-ab63-13459120d1ab@o23g2000prh.googlegroups.com> Message-ID: <4D2B3675.2060007@gmail.com> +1, interested in the solution as well. We have the same issue with controller specs/Shoulda, e.g.: describe 'GET google_apps (with invalid credentials)' do before do ... get :google_apps end it { should respond_with(:ok) } it { should render_template("sessions/new") } it { should set_the_flash.to(/Could not authorize you from Google Apps because/) } end Will call the controller code 3 times without any particular reason to. Probably some caching could be added in Shoulda? On 1/7/2011 2:27 AM, Jason N. wrote: > Howdy, > > I'm trying to test some mailer views (which is no different to normal > views in terms of specs)... ran into the following problem... > > In adherence to the "one expectation per 'spec'"... I'm trying to > write the following > > describe "auth/mailer/signup.html.erb" do > before(:each) do > @user = Factory.build(:user) > assign(:user, @user) > render > end > > subject { rendered } > > it { should include(@user.email) } > it { should... > it { should... > end > > > Before long, if you keep this up, your spec goes from quick to very > slow. Turns out, calling render takes a bit of effort and the > before(:each) tells rspec to call render before each "it" call. > > SO... is there a way to cache this, so that the rendered output is > available to each spec to avoid re-rendering? Each "it" item, really > describes expectations on the output, which doesn't change for every > run. > > I could default back down to a single it, but that would defeat the > purpose of writing small tests. > > I've tried before(:all), but rspec doesn't like it. It generates the > following error: > > Failure/Error: render > NoMethodError: > undefined method `example_group' for nil:NilClass > > > Cheers, > Jason > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From RichardDummyMailbox58407 at USComputerGurus.com Mon Jan 10 16:37:46 2011 From: RichardDummyMailbox58407 at USComputerGurus.com (RichardOnRails) Date: Mon, 10 Jan 2011 13:37:46 -0800 (PST) Subject: [rspec-users] RSpec newbie ran rspec 2.4 on WinXP, got HOME undefined Message-ID: Hi, I'm running WinXP-Pro/SP3 & Ruby 1.8.6 I just got the RSpec Book and successfully ran gem install rspec --version 2.0.0 per the book's suggestion. In a Command window, I ran K:\>rspec -v and got: K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rspec- core-2.4.0/lib/rspec/core/configuration_options.rb:9:couldn't find HOME environment -- expanding `~' (ArgumentError) I ran "gem install rspec -v 2.4.0" successfully and got the same symptom, except this time the intermediate portions of the error message referred to gems/1.8/gems/rspec-core-2.4.0 I checked my environment variables for HOME; it is undefined. Could it be that RSpec relies on some Ruby 1.9 functionality? Any advice would be gratefully received. -- Richard From freakguard at gmail.com Mon Jan 10 17:39:47 2011 From: freakguard at gmail.com (Simon Hafner) Date: Mon, 10 Jan 2011 23:39:47 +0100 Subject: [rspec-users] RSpec newbie ran rspec 2.4 on WinXP, got HOME undefined In-Reply-To: References: Message-ID: <201101102339.47469.hafnersimon@gmail.com> On Monday 10 January 2011 22.37:46 RichardOnRails wrote: > Hi, > > I'm running WinXP-Pro/SP3 & Ruby 1.8.6 > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rspec- > core-2.4.0/lib/rspec/core/configuration_options.rb:9:couldn't find > HOME environment -- expanding `~' (ArgumentError) > > I checked my environment variables for HOME; it is undefined. Sounds like rspec is relying on some *NIX stuff here (HOME is usually pointing to a users home directory). Google how to set environment variables and set HOME to the folder containing your home directory (usually something like C:\documents and settings\). > Any advice would be gratefully received. > -- > Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From RichardDummyMailbox58407 at USComputerGurus.com Mon Jan 10 21:48:20 2011 From: RichardDummyMailbox58407 at USComputerGurus.com (RichardOnRails) Date: Mon, 10 Jan 2011 18:48:20 -0800 (PST) Subject: [rspec-users] RSpec newbie ran rspec 2.4 on WinXP, got HOME undefined In-Reply-To: <201101102339.47469.hafnersimon@gmail.com> References: <201101102339.47469.hafnersimon@gmail.com> Message-ID: <6a590fdf-c093-4a91-bbc9-5d22d46576ab@j25g2000vbs.googlegroups.com> Hi Simon, > Sounds like rspec is relying on some *NIX stuff here Yeah, I recognized that it was looking for a home directory on a *nix box, but I couldn't think of a counterpart on Windows, because I've only got a slew of partitions (C:\, D:\ ...) but no home. You came up with a good insight. I tried my admin subdir in Documents and Settings and noted that one of the subdirectories was gem. That sounded good, but no prize. So I did a search of DandS for rspec. Found a good subdir with lots of rspec entries. Set HOME to that via the control panel. Started a new Command Window so that the new settings would be read in and got. K:\>rspec -v 2.4.0 Mission Accomplished. Thanks for your keen insights. Richard K:\> On Jan 10, 5:39?pm, Simon Hafner wrote: > On Monday 10 January 2011 22.37:46 RichardOnRails wrote: > > > Hi, > > > I'm running WinXP-Pro/SP3 & Ruby 1.8.6 > > > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rspec- > > core-2.4.0/lib/rspec/core/configuration_options.rb:9:couldn't find > > HOME environment -- expanding `~' (ArgumentError) > > > I checked my environment variables for HOME; it is undefined. > > Sounds like rspec is relying on some *NIX stuff here (HOME is usually pointing > to a users home directory). Google how to set environment variables and set > HOME to the folder containing your home directory (usually something like > C:\documents and settings\). > > > Any advice would be gratefully received. > > -- > > Richard > > > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From luislavena at gmail.com Tue Jan 11 06:39:54 2011 From: luislavena at gmail.com (Luis Lavena) Date: Tue, 11 Jan 2011 08:39:54 -0300 Subject: [rspec-users] RSpec newbie ran rspec 2.4 on WinXP, got HOME undefined In-Reply-To: References: Message-ID: On Mon, Jan 10, 2011 at 6:37 PM, RichardOnRails wrote: > Hi, > > I'm running WinXP-Pro/SP3 & Ruby 1.8.6 > > I just got the RSpec Book and successfully ran > gem install rspec --version 2.0.0 > per the book's suggestion. > > In a Command window, I ran > K:\>rspec -v > and got: > K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rspec- > core-2.4.0/lib/rspec/core/configuration_options.rb:9:couldn't find > HOME environment -- expanding `~' (ArgumentError) > > I ran "gem install rspec -v 2.4.0" successfully and got the same > symptom, > except this time the intermediate portions of the error message > referred to > gems/1.8/gems/rspec-core-2.4.0 > > I checked my environment variables for HOME; it is undefined. > > Could it be that RSpec relies on some Ruby 1.9 functionality? File.expand_path("~") That could trigger the issue. expand_path on 1.8.x depends on HOME been defined. Ruby 1.9 already workaround that properly checking for HOMEDRIVE+HOMEPATH, USERPROFILE and HOME You can avoid that setting HOME to HOMEDRIVE+HOMEPATH: SET HOME=%HOMEDRIVE%%HOMEPATH% And put that in your user environment variables. No other workaround for tilde expansion for 1.8.x -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From lists at ruby-forum.com Tue Jan 11 07:51:28 2011 From: lists at ruby-forum.com (Andrea Reginato) Date: Tue, 11 Jan 2011 13:51:28 +0100 Subject: [rspec-users] autotest giving error when having shared example in specs In-Reply-To: References: Message-ID: <5803f2c1769b083f3d405754408af2c9@ruby-forum.com> I'm sure is not the best solution, but I solved the problem creating an Initializer monkey patching the method giving the error. I'm pretty new on Ruby and company, as always scratching the surface, and only now getting into the deep, but I hope it will help. # extract config/initializers/rspec_hacks.rb module RSpec module Core module SharedExampleGroup private def ensure_shared_example_group_name_not_taken(name) end end end end -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Jan 11 11:33:38 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 11 Jan 2011 10:33:38 -0600 Subject: [rspec-users] Cookie value set in spec, but controller can't read it In-Reply-To: References: <7017E159-120D-45E4-83BE-AEF2F19BDF29@gmail.com> Message-ID: <9795E8A0-EC82-42DB-864A-561E4BF5BCE7@gmail.com> On Jan 10, 2011, at 8:27 AM, Marko Anastasov wrote: > On Mon, Jan 10, 2011 at 05:05, David Chelimsky wrote: >> On Jan 5, 2011, at 11:54 AM, Marko Anastasov wrote: >> >>> Hello, >>> >>> I set a value in controller spec using @request.cookies: >>> https://gist.github.com/371356ba0a19666fd3b5 >>> >>> but when the controller reads it, it's nil somehow, as this screenshot >>> from the debugger shows: >>> http://dl.dropbox.com/u/830772/p/Selection_033.jpeg >>> >>> This does not occur in development environment. I'm using RSpec 2.4 >>> and Rails 3. >>> >>> Does someone have an idea what I am doing wrong / how to solve this? >> >> That looks like it should work, and I don't think you're doing anything wrong. >> >> What's happening is that the object returned by @request.cookies is a Hash, but the object returned by cookies() in the controller is an ActionDispatch::Cookies::CookieJar. If you print them both out with .inspect, they'll both say they are {:lastfm_username => "rj"}, but the answer differently to other questions: >> >> # in spec >> @request.cookies[:lastfm_username] # => "rj" >> @request.cookies["lastfm_username"] # => nil >> >> # in controller >> cookies[:lastfm_username] # => nil >> cookies["lastfm_username"] # => nil >> >> You'll see exactly the same behavior, btw, in a Rails functional test (which an RSpec controller spec wraps), so this is happening in the Rails test infrastructure, not RSpec. Care to log a bug report in the Rails tracker? >> >> https://rails.lighthouseapp.com/ >> > > Thanks for your explanation David. I created Rails ticket #6272. > > Later I found a workaround of using request.cookies in the controller, > but it would be nice if it would just work with cookies. > > Btw I was also not sure when to use symbols, and when keys. Eg if I > set a value in controller: > cookies.permanent[:lastfm_username] = username > > then in spec, I need to obtain the value with a string: > cookies["lastfm_username"].should == "rj" My understanding is that it's a HashWithIndifferentAccess, which means you can use string or symbol keys. That said, however, when the app is running the cookies come from the rack environment and are always string keys, so I'd recommend sticking w/ that for consistency, but that's a pretty subjective thing. HTH, David From lille.penguini at gmail.com Tue Jan 11 13:32:01 2011 From: lille.penguini at gmail.com (Lille) Date: Tue, 11 Jan 2011 10:32:01 -0800 (PST) Subject: [rspec-users] when using command line -l, why do tests from other describe blocks run? Message-ID: <0e725306-5321-448c-b338-16836fbb3588@s9g2000vby.googlegroups.com> Hi, I frequently use the -l option to run only tests of interest, but it's messy in a way I don't understand... describe SomeModel do describe "#some_method" do it... # let's call this line 20 end describe "#some_other_method" do it... # here's some other test end end If I enter 'spec -l 20 spec/models/some_model_spec.rb' on the command line, I get my line 20 test and others -- say the other test, above -- why? Thanks, Lille From mmazur at gmail.com Tue Jan 11 18:09:36 2011 From: mmazur at gmail.com (Mike Mazur) Date: Wed, 12 Jan 2011 07:09:36 +0800 Subject: [rspec-users] when using command line -l, why do tests from other describe blocks run? In-Reply-To: <0e725306-5321-448c-b338-16836fbb3588@s9g2000vby.googlegroups.com> References: <0e725306-5321-448c-b338-16836fbb3588@s9g2000vby.googlegroups.com> Message-ID: Hi, On Wed, Jan 12, 2011 at 02:32, Lille wrote: > I frequently use the -l option to run only tests of interest, but it's > messy in a way I don't understand... > > describe SomeModel do > > ?describe "#some_method" do > > ? ? it... # let's call this line 20 > > ?end > > ?describe "#some_other_method" do > > ? ?it... # here's some other test > > ?end > > end > > If I enter 'spec -l 20 spec/models/some_model_spec.rb' on the command > line, I get my line 20 test and others -- say the other test, above -- > why? I think that's because line 20 is contained within another group (ie: inside describe "#some_method" do), so all examples from this group are run. Try running your tests with -l 21 (ie: the first line contained within the it of the test you want to run); that should run only that test. Mike From lists at ruby-forum.com Wed Jan 12 02:45:45 2011 From: lists at ruby-forum.com (Amit Kulkarni) Date: Wed, 12 Jan 2011 08:45:45 +0100 Subject: [rspec-users] Results in rspec 2.4.0 Message-ID: <01c914d551085ac7e48043b6da7a1817@ruby-forum.com> Hi, I am running rspec spec for Rails 3.The version for rspec is 2.4.0 When running the script i am getting output as User Profile should not be created if name is blank Failure/Error: @contact_detail.should be_valid expected valid? to return true, got false # ./spec/models/merchant_spec.rb:79 for every failed spec. >From the above result it is not clear actually what is the error where as in rspec version 1.2.9 we would get like "user_name cannot be blank" I am running the spec as "bundle exec rspec spec/models/user_spec.rb" Is there any other way of running the spec so that i can get a better result My Gemfile contains following gems: gem "rspec-rails", ">= 2.0.0.beta" gem "autotest" gem "autotest-rails" -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Jan 12 03:19:05 2011 From: lists at ruby-forum.com (Amit Kulkarni) Date: Wed, 12 Jan 2011 09:19:05 +0100 Subject: [rspec-users] Installing rspec 2 for Rails 3 Message-ID: <2c3202768db9f2b03db1bdf1319cc38c@ruby-forum.com> Hi, I have successfully installed rspec 2 for Rails 3 by visiting the following link http://lindsaar.net/2010/4/14/installing_rspec_for_rails_3 In this post it is mentioned taht when i do "rails g rspec:install" then it should install exist lib create lib/tasks/rspec.rake exist config/initializers create config/initializers/rspec_generator.rb exist spec create spec/spec_helper.rb create autotest create autotest/discover.rb but when i run the command then it creates only .rspec,spec/spec_helper Is there something wrong with the command?Or is there any other way of installing rspec. Also please suggest good link for starting rspec 2 for rails 3 -- Posted via http://www.ruby-forum.com/. From marko at renderedtext.com Wed Jan 12 05:55:22 2011 From: marko at renderedtext.com (Marko Anastasov) Date: Wed, 12 Jan 2011 11:55:22 +0100 Subject: [rspec-users] Installing rspec 2 for Rails 3 In-Reply-To: <2c3202768db9f2b03db1bdf1319cc38c@ruby-forum.com> References: <2c3202768db9f2b03db1bdf1319cc38c@ruby-forum.com> Message-ID: On Wed, Jan 12, 2011 at 09:19, Amit Kulkarni wrote: > Hi, > I have successfully installed rspec 2 for Rails 3 by visiting the > following ?link > http://lindsaar.net/2010/4/14/installing_rspec_for_rails_3 > In this post it is mentioned taht when i do "rails g rspec:install" > then it should install > exist ?lib > ? ? ?create ?lib/tasks/rspec.rake > ? ? ? exist ?config/initializers > ? ? ?create ?config/initializers/rspec_generator.rb > ? ? ? exist ?spec > ? ? ?create ?spec/spec_helper.rb > ? ? ?create ?autotest > ? ? ?create ?autotest/discover.rb > > but when i run the command then it creates only .rspec,spec/spec_helper > > Is there something wrong with the command?Or is there any other way of > installing rspec. > Also please suggest good link for starting rspec 2 for rails 3 That blog post references an old version of rspec-rails. AFAIK the current does not generate some of the files it mentiones (lib/tasks/rspec.rake, config/initializers/rspec_generator.rb); also be aware that autotest and autotest-rails are optional. I'd suggest that you always look at the project's page on github first: https://github.com/rspec/rspec-rails From marko at renderedtext.com Wed Jan 12 06:02:20 2011 From: marko at renderedtext.com (Marko Anastasov) Date: Wed, 12 Jan 2011 12:02:20 +0100 Subject: [rspec-users] Cookie value set in spec, but controller can't read it In-Reply-To: <9795E8A0-EC82-42DB-864A-561E4BF5BCE7@gmail.com> References: <7017E159-120D-45E4-83BE-AEF2F19BDF29@gmail.com> <9795E8A0-EC82-42DB-864A-561E4BF5BCE7@gmail.com> Message-ID: On Tue, Jan 11, 2011 at 17:33, David Chelimsky wrote: > > On Jan 10, 2011, at 8:27 AM, Marko Anastasov wrote: > >> On Mon, Jan 10, 2011 at 05:05, David Chelimsky wrote: >>> On Jan 5, 2011, at 11:54 AM, Marko Anastasov wrote: >>> >>>> Hello, >>>> >>>> I set a value in controller spec using @request.cookies: >>>> https://gist.github.com/371356ba0a19666fd3b5 >>>> >>>> but when the controller reads it, it's nil somehow, as this screenshot >>>> from the debugger shows: >>>> http://dl.dropbox.com/u/830772/p/Selection_033.jpeg >>>> >>>> This does not occur in development environment. I'm using RSpec 2.4 >>>> and Rails 3. >>>> >>>> Does someone have an idea what I am doing wrong / how to solve this? >>> >>> That looks like it should work, and I don't think you're doing anything wrong. >>> >>> What's happening is that the object returned by @request.cookies is a Hash, but the object returned by cookies() in the controller is an ActionDispatch::Cookies::CookieJar. If you print them both out with .inspect, they'll both say they are {:lastfm_username => "rj"}, but the answer differently to other questions: >>> >>> # in spec >>> @request.cookies[:lastfm_username] # => "rj" >>> @request.cookies["lastfm_username"] # => nil >>> >>> # in controller >>> cookies[:lastfm_username] # => nil >>> cookies["lastfm_username"] # => nil >>> >>> You'll see exactly the same behavior, btw, in a Rails functional test (which an RSpec controller spec wraps), so this is happening in the Rails test infrastructure, not RSpec. Care to log a bug report in the Rails tracker? >>> >>> https://rails.lighthouseapp.com/ >>> >> >> Thanks for your explanation David. I created Rails ticket #6272. >> >> Later I found a workaround of using request.cookies in the controller, >> but it would be nice if it would just work with cookies. >> >> Btw I was also not sure when to use symbols, and when keys. Eg if I >> set a value in controller: >> cookies.permanent[:lastfm_username] = username >> >> then in spec, I need to obtain the value with a string: >> cookies["lastfm_username"].should == "rj" > > My understanding is that it's a HashWithIndifferentAccess, which means you can use string or symbol keys. That said, however, when the app is running the cookies come from the rack environment and are always string keys, so I'd recommend sticking w/ that for consistency, but that's a pretty subjective thing. > When I inspected spec's cookies' class in debugger, it was Hash. In any case, I will remember that they're always in string keys when coming rack. As I read your reply I connected this with the observation that I needed to add an OR to use string keys in cucumber environment within the controller. Thanks. From mmazur at gmail.com Wed Jan 12 06:14:06 2011 From: mmazur at gmail.com (Mike Mazur) Date: Wed, 12 Jan 2011 19:14:06 +0800 Subject: [rspec-users] Results in rspec 2.4.0 In-Reply-To: <01c914d551085ac7e48043b6da7a1817@ruby-forum.com> References: <01c914d551085ac7e48043b6da7a1817@ruby-forum.com> Message-ID: Hi, On Wed, Jan 12, 2011 at 15:45, Amit Kulkarni wrote: > When running the script i am getting output as > User Profile should not be created if name is blank > ? ? Failure/Error: @contact_detail.should be_valid > ? ? ? expected valid? to return true, got false > ? ? # ./spec/models/merchant_spec.rb:79 > > for every failed spec. > >From the above result it is not clear actually what is the error where > as in rspec version 1.2.9 we would get like "user_name cannot be blank" I'm not sure what things were like in 1.2.9 and how well your existing 1.2.9 specs are supported in 2.4.0. Testing for specific errors can be done like this: @contact_detail.should have(1).error_on(:user_name) See this excellent presentation for more gems: http://kerryb.github.com/iprug-rspec-presentation Mike From lists at ruby-forum.com Wed Jan 12 07:33:08 2011 From: lists at ruby-forum.com (Amit Kulkarni) Date: Wed, 12 Jan 2011 13:33:08 +0100 Subject: [rspec-users] Installing rspec 2 for Rails 3 In-Reply-To: References: <2c3202768db9f2b03db1bdf1319cc38c@ruby-forum.com> Message-ID: <6f76ca1dabe868227bc88de93d995ac5@ruby-forum.com> Thanks a lot.Will look into it. -- Posted via http://www.ruby-forum.com/. From cremes.devlist at mac.com Wed Jan 12 10:52:58 2011 From: cremes.devlist at mac.com (Chuck Remes) Date: Wed, 12 Jan 2011 09:52:58 -0600 Subject: [rspec-users] Can you control $stdout when specs are running? In-Reply-To: <99e250bd-bcfe-41e2-8fc9-ee16423b3791@28g2000yqm.googlegroups.com> References: <99e250bd-bcfe-41e2-8fc9-ee16423b3791@28g2000yqm.googlegroups.com> Message-ID: On Sep 30, 2010, at 10:06 AM, GregD wrote: > Hi all, > > I'm testing java classed using rspec and jruby. The java super class > is trapping an exception and sending a custom message to stdout along > with the original exception meaasage. The original exception is a > SAXParseException, if that really matters. Well, my test is to see if > the child object class can handle a garbled XML message a certain > way. The test passes, but I get the nasty java exception stuff that > is being sent to stdout when the tests are running, yuk. I tried > closing and opening stdout before and after that particular test and > that did not work or I did it wrong. And I'm not sure this is > desirable if the test fails. Any ideas on this other than to replace > the java with ruby or have the java not to dump to stdout? ;-) Both > of which, I can not do. But, I can live with the nastiness of this, > if there is no possible way around it. I'd like to bump this message because I am facing a similar situation. What's a good technique for spec'ing code that prints to STDOUT yet keeps the spec output nice and clean? cr From groups at hjdivad.com Wed Jan 12 12:29:08 2011 From: groups at hjdivad.com (David J. Hamilton) Date: Wed, 12 Jan 2011 09:29:08 -0800 Subject: [rspec-users] Can you control $stdout when specs are running? In-Reply-To: References: <99e250bd-bcfe-41e2-8fc9-ee16423b3791@28g2000yqm.googlegroups.com> Message-ID: <1294852921-sup-6961@nyx.local> Excerpts from Chuck Remes's message of Wed Jan 12 07:52:58 -0800 2011: > I'd like to bump this message because I am facing a similar situation. > > What's a good technique for spec'ing code that prints to STDOUT yet keeps the spec output nice and clean? I can't promise that what follows is a ?good? technique for this, but it works for me. At the moment, I can't quite recall why this doesn't get in the way of rspec's own output. The stuff outside of the configure block is not strictly necessary, but helpful if you want to be able to debug specs without the output of ruby-debug being sent to your buffers. # spec/spec_helper.rb Rspec.configure do |c| # capture output @output = '' @err = '' $stdout.stub!( :write ) { |*args| @output.<<( *args )} $stderr.stub!( :write ) { |*args| @err.<<( *args )} end # Track original $stdout, $stderr write methods so we can restore them for # debugging class << $stdout alias_method :real_write, :write end class << $stderr alias_method :real_write, :write end class Object def debug # For debugging, restore stubbed write class << $stdout alias_method :write, :real_write end class << $stderr alias_method :write, :real_write end require 'ruby-debug' debugger end end -- med v?nlig h?lsning David J. Hamilton From node.js99 at gmail.com Wed Jan 12 12:42:03 2011 From: node.js99 at gmail.com (Nadal) Date: Wed, 12 Jan 2011 09:42:03 -0800 (PST) Subject: [rspec-users] No examples were matched. Message-ID: I am using rspec-rails 2.4.1 on a rails3 (3.0.3) app. I have around 20 specs. When I run rake spec all 20 specs run fine. However when I do bundle exec rspec then I get this message. No examples were matched. Perhaps {:unless=>#, :if=>#} is excluding everything? From shea at shealevy.com Wed Jan 12 12:46:53 2011 From: shea at shealevy.com (shea at shealevy.com) Date: Wed, 12 Jan 2011 09:46:53 -0800 Subject: [rspec-users] Can you control $stdout when specs are running? In-Reply-To: References: <99e250bd-bcfe-41e2-8fc9-ee16423b3791@28g2000yqm.googlegroups.com> Message-ID: <53370a9fe57925dc9d582e4a84a92493.squirrel@webmail.shealevy.com> Why not stub System.out.println, possibly with message expectations if necessary? > > On Sep 30, 2010, at 10:06 AM, GregD wrote: > >> Hi all, >> >> I'm testing java classed using rspec and jruby. The java super class >> is trapping an exception and sending a custom message to stdout along >> with the original exception meaasage. The original exception is a >> SAXParseException, if that really matters. Well, my test is to see if >> the child object class can handle a garbled XML message a certain >> way. The test passes, but I get the nasty java exception stuff that >> is being sent to stdout when the tests are running, yuk. I tried >> closing and opening stdout before and after that particular test and >> that did not work or I did it wrong. And I'm not sure this is >> desirable if the test fails. Any ideas on this other than to replace >> the java with ruby or have the java not to dump to stdout? ;-) Both >> of which, I can not do. But, I can live with the nastiness of this, >> if there is no possible way around it. > > I'd like to bump this message because I am facing a similar situation. > > What's a good technique for spec'ing code that prints to STDOUT yet keeps > the spec output nice and clean? > > cr > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Jan 12 13:42:00 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 12 Jan 2011 12:42:00 -0600 Subject: [rspec-users] Can you control $stdout when specs are running? In-Reply-To: References: <99e250bd-bcfe-41e2-8fc9-ee16423b3791@28g2000yqm.googlegroups.com> Message-ID: On Jan 12, 2011, at 9:52 AM, Chuck Remes wrote: > > On Sep 30, 2010, at 10:06 AM, GregD wrote: > >> Hi all, >> >> I'm testing java classed using rspec and jruby. The java super class >> is trapping an exception and sending a custom message to stdout along >> with the original exception meaasage. The original exception is a >> SAXParseException, if that really matters. Well, my test is to see if >> the child object class can handle a garbled XML message a certain >> way. The test passes, but I get the nasty java exception stuff that >> is being sent to stdout when the tests are running, yuk. I tried >> closing and opening stdout before and after that particular test and >> that did not work or I did it wrong. And I'm not sure this is >> desirable if the test fails. Any ideas on this other than to replace >> the java with ruby or have the java not to dump to stdout? ;-) Both >> of which, I can not do. But, I can live with the nastiness of this, >> if there is no possible way around it. > > I'd like to bump this message because I am facing a similar situation. > > What's a good technique for spec'ing code that prints to STDOUT yet keeps the spec output nice and clean? I prefer to avoid printing directly to STDOUT, and pass in an IO object to the constructor of the object doing the printing. class Foo def initialize(output=$stdout) @output = output end def do_something_that_prints @output.puts "blah, de blah" end end Now implementation code can just use a Foo.new, but specs can use a Foo.new(output) where output is a StringIO, stub, whatever. Make sense? From ks at cissor.com Wed Jan 12 20:04:17 2011 From: ks at cissor.com (Kurt) Date: Wed, 12 Jan 2011 17:04:17 -0800 (PST) Subject: [rspec-users] Spec output no longer displays with results Message-ID: <2c34c33b-88eb-4053-9bce-dba1fdb2e58e@j25g2000vbs.googlegroups.com> In RSpec 1.x, a print statement in the spec would print out with the results from that spec. In RSpec 2.x, the print statements are separated from the spec results. Is there a way to restore the 1.x behavior, so quick debugging work we do with print statements can easily be associated with the test that generated them? This is having a big impact on our productivity. Thanks for RSpec2! P.S. We have tried --format nested, but this is inferior to the original format, and this format cannot be used in RubyMine at all. It would be very helpful to have the original format back. From jason.nah at gmail.com Thu Jan 13 00:39:21 2011 From: jason.nah at gmail.com (Jason Nah) Date: Thu, 13 Jan 2011 16:39:21 +1100 Subject: [rspec-users] RSpec 2.4, named/restful routes falling apart... Message-ID: Guys, This could be me, but I thought I'd check For some reason, when I spec controllers, I run into this problem (intermittently it would seem). Right now, I have a spec that fails predictably. I'm using * Rspec 2.4.0 * Rspec-rails 2.4.1 * Rails 3 * Mocha 0.9.10 I have the following defined in my routes file resources :users And a controller: class UsersController < ApplicationController before_filter :load_user def show redirect_to(user_path(@user)) end private def load_user @user = User.find(params[:id]) end end and a spec describe UsersController do before(:each) do @user = Factory.build(:user, :id => '12341234') User.expects(:find).returns(@user) get "show", :id => @user.id end subject { response } it { should redirect_to(user_path(@user)) } end The spec fails with the following Failures: 1) UsersController Failure/Error: get "show", :id => @user.id ActionController::RoutingError: No route matches {:controller=>"users", :action=>"show", :id=>#} # ./app/controllers/users_controller.rb:17:in `show' # ./spec/controllers/users_controller_spec.rb:50 Could somebody explain what's going on???? It would appear that for some reason, my controllers don't know a thing about routing. Either that or something's wacky. The annoying thing about this is that it works perfectly fine when you use a browser to test. Cheers, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Jan 13 08:01:34 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 Jan 2011 07:01:34 -0600 Subject: [rspec-users] RSpec 2.4, named/restful routes falling apart... In-Reply-To: References: Message-ID: <998DD4F2-2732-4D51-AF22-91C8DA8413C5@gmail.com> On Jan 12, 2011, at 11:39 PM, Jason Nah wrote: > Guys, > > This could be me, but I thought I'd check > > For some reason, when I spec controllers, I run into this problem (intermittently it would seem). Right now, I have a spec that fails predictably. > > I'm using > * Rspec 2.4.0 > * Rspec-rails 2.4.1 > * Rails 3 > * Mocha 0.9.10 > > I have the following defined in my routes file > > resources :users > > And a controller: > > class UsersController < ApplicationController > before_filter :load_user > > def show > redirect_to(user_path(@user)) > end > > private > def load_user > @user = User.find(params[:id]) > end > end > > and a spec > > describe UsersController do > before(:each) do > @user = Factory.build(:user, :id => '12341234') > User.expects(:find).returns(@user) > get "show", :id => @user.id > end > subject { response } > it { should redirect_to(user_path(@user)) } > end > > > The spec fails with the following > > Failures: > > 1) UsersController > Failure/Error: get "show", :id => @user.id > ActionController::RoutingError: > No route matches {:controller=>"users", :action=>"show", :id=>#} > # ./app/controllers/users_controller.rb:17:in `show' > # ./spec/controllers/users_controller_spec.rb:50 > > > Could somebody explain what's going on???? > > It would appear that for some reason, my controllers don't know a thing about routing. Either that or something's wacky. The annoying thing about this is that it works perfectly fine when you use a browser to test. What happens if you write the spec as a stock rails functional test? $ rails generate test_unit:controller Users show # in test/functionals/users_controller_test.rb require "test_helper" class UsersControllerTest < ActionController::TestCase test "show redirects to user path" do @user = Factory.build(:user, :id => '12341234') User.expects(:find).returns(@user) get "show", :id => @user.id assert_redirected_to user_path(@user) end end -------------- next part -------------- An HTML attachment was scrubbed... URL: From mmazur at gmail.com Thu Jan 13 08:31:10 2011 From: mmazur at gmail.com (Mike Mazur) Date: Thu, 13 Jan 2011 21:31:10 +0800 Subject: [rspec-users] RSpec 2.4, named/restful routes falling apart... In-Reply-To: References: Message-ID: Hi, On Thu, Jan 13, 2011 at 13:39, Jason Nah wrote: > I have the following defined in my routes file > > resources :users > > And a controller: > class UsersController < ApplicationController > ?? before_filter :load_user > > ?? def show > ?? ? ?redirect_to(user_path(@user)) > ?? end > ?? private > ?? def load_user > ?? ? ?@user = User.find(params[:id]) > ?? end > end Perhaps I'm missing something here, but doesn't this UsersController#show redirect to itself the way this code is written? Mike From lists at ruby-forum.com Thu Jan 13 09:06:54 2011 From: lists at ruby-forum.com (Amit Kulkarni) Date: Thu, 13 Jan 2011 15:06:54 +0100 Subject: [rspec-users] Results in rspec 2.4.0 In-Reply-To: References: <01c914d551085ac7e48043b6da7a1817@ruby-forum.com> Message-ID: <5cc34add3ce6dcfd56e77e811676b49c@ruby-forum.com> Hey, Thanks a lot for the presentation.It was really helpful. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jan 13 09:08:51 2011 From: lists at ruby-forum.com (Amit Kulkarni) Date: Thu, 13 Jan 2011 15:08:51 +0100 Subject: [rspec-users] Preloading of data in rspec2 Message-ID: <4a5ff339477849b255e698c3bb9ad7a4@ruby-forum.com> Hello, I had used Fixtures and factory girl for preloading of data in earlier version rspec. Is there any new thing for loading of data in rspec 2 or do we have to use the same. Also is there any documentation link where i can get nice info about rspec 2 -- Posted via http://www.ruby-forum.com/. From asimic at gmail.com Thu Jan 13 10:13:45 2011 From: asimic at gmail.com (Aleksandar Simic) Date: Thu, 13 Jan 2011 15:13:45 +0000 Subject: [rspec-users] Preloading of data in rspec2 In-Reply-To: <4a5ff339477849b255e698c3bb9ad7a4@ruby-forum.com> References: <4a5ff339477849b255e698c3bb9ad7a4@ruby-forum.com> Message-ID: On Thu, Jan 13, 2011 at 2:08 PM, Amit Kulkarni wrote: > Hello, > I had used Fixtures and factory girl for preloading of data in earlier > version rspec. > Is there any new thing for loading of data in rspec 2 or do we have to > use the same. > Also is there any documentation link where i can get nice info about > rspec 2 Not official, but nicely put together: http://kerryb.github.com/iprug-rspec-presentation/ Hope it helps, Aleksandar From ks at cissor.com Thu Jan 13 13:36:50 2011 From: ks at cissor.com (Kurt) Date: Thu, 13 Jan 2011 10:36:50 -0800 (PST) Subject: [rspec-users] Notes on upgrading from RSpec 1 to RSpec 2 In-Reply-To: <3e26c20f-cabf-4b1b-b2d6-fd8a9879c16a@z26g2000prf.googlegroups.com> References: <3e26c20f-cabf-4b1b-b2d6-fd8a9879c16a@z26g2000prf.googlegroups.com> Message-ID: <25e0965e-27e3-4502-8d0d-0adba7132b55@v17g2000vbo.googlegroups.com> Hi -- Thanks for sharing all your tips. I couldn't understand your line about what replaces have_text, however. I don't see a method called "matches" or "match"... I think your list might be the start of an effort by users to document RSpec2 the hard way, since a lot has changed that the core team has not documented anywhere. We've found that the Rails3 upgrade is some work, but the advantages over Rails 2 are clear. RSpec2, however, is so poorly documented, useful features have been removed for no apparent reason, and any advantages over RSpec1 have not become clear yet (our test suite runs 3 times slower than it did in RSpec1!). On Dec 4 2010, 3:22?pm, Jim Morris wrote: > I am trying to upgrade a Rails 2.2.2 app to Rails3, its ?a pain ;) > > Part of this is I need to upgrade all my Specs to RSpec2, as this info > does not seem to be in any one place, here is a summary of what I > needed to do... > > * needed to rename all my views from .haml to .html.haml, > (or .html.erb) although > ? Rails3 seemed ok with the old naming RSpec2 view specs failed to > find the templates with the old name. > > * rewrite all my view specs... > ? - change `... at controller.template.` to `view.` > > ? - ?change `have_tag` to `have_selector` and change the parameters > ? ? ?- place holders not supported, need to use #{} > ? ? ?- add :content => for any text in second parameter > > ? - change `assign[:blah]= :blod` to `assign(:blag, :blod)` > > ? - change the describe ... do to have the path to the view rather > than text description > > ? - change the render '/show' to just render or render :file => 'full > template spec' > > ? - changehave_textto matches(/../) > > ? - change response.should to rendered.shoul > > * modify the controller specs > ? - controller_name is no longer supported, so need to nest all my > ? ? describes under a top level describe that has the controller > name. > ? ? ?describe 'UsersController' do > ? ? ?or use subject {SomeController.new} ?(not tested yet) > > ? ?- when using post/delete/put :something, :id => 1 passing in an > integer id used to work, now it needs to > ? ? ?be a string (probably a rails3 thing) > ? ? ?delete :destroy, :id => "1" > > * helper specs only needed minor changes > ? - change have_tag to have_selector > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From ks at cissor.com Thu Jan 13 14:04:46 2011 From: ks at cissor.com (Kurt) Date: Thu, 13 Jan 2011 11:04:46 -0800 (PST) Subject: [rspec-users] response.should have_text leads to undefined method `has_text?' In-Reply-To: Message-ID: <17425755.1189.1294945486919.JavaMail.geo-discussion-forums@yqhy19> Where are the changes to RSpec2 documented? I haven't been able to find a list of changes that would include something like this removal of have_text. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Jan 13 14:11:36 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 Jan 2011 13:11:36 -0600 Subject: [rspec-users] Notes on upgrading from RSpec 1 to RSpec 2 In-Reply-To: <25e0965e-27e3-4502-8d0d-0adba7132b55@v17g2000vbo.googlegroups.com> References: <3e26c20f-cabf-4b1b-b2d6-fd8a9879c16a@z26g2000prf.googlegroups.com> <25e0965e-27e3-4502-8d0d-0adba7132b55@v17g2000vbo.googlegroups.com> Message-ID: <0869CA82-68F6-4BE9-9F7F-2237D9B83653@gmail.com> On Jan 13, 2011, at 12:36 PM, Kurt wrote: > Hi -- Thanks for sharing all your tips. I couldn't understand your > line about what replaces have_text, however. I don't see a method > called "matches" or "match"... > > I think your list might be the start of an effort by users to document > RSpec2 the hard way, since a lot has changed that the core team has > not documented anywhere. We've found that the Rails3 upgrade is some > work, but the advantages over Rails 2 are clear. RSpec2, however, is > so poorly documented, useful features have been removed for no > apparent reason, and any advantages over RSpec1 have not become clear > yet (our test suite runs 3 times slower than it did in RSpec1!). re: speed, you be sure to upgrade to rspec-rails-2.2 (I'd go for the latest, 2.4.1), which sped things up considerably. As for docs - official docs are at http://relishapp.com/rspec. Info about contributing to the docs can be found there and at http://blog.davidchelimsky.net/2010/12/23/rspec-2-documentation-2/. Thanks in advance for your help. Cheers, David > On Dec 4 2010, 3:22 pm, Jim Morris wrote: >> I am trying to upgrade a Rails 2.2.2 app to Rails3, its a pain ;) >> >> Part of this is I need to upgrade all my Specs to RSpec2, as this info >> does not seem to be in any one place, here is a summary of what I >> needed to do... >> >> * needed to rename all my views from .haml to .html.haml, >> (or .html.erb) although >> Rails3 seemed ok with the old naming RSpec2 view specs failed to >> find the templates with the old name. >> >> * rewrite all my view specs... >> - change `... at controller.template.` to `view.` >> >> - change `have_tag` to `have_selector` and change the parameters >> - place holders not supported, need to use #{} >> - add :content => for any text in second parameter >> >> - change `assign[:blah]= :blod` to `assign(:blag, :blod)` >> >> - change the describe ... do to have the path to the view rather >> than text description >> >> - change the render '/show' to just render or render :file => 'full >> template spec' >> >> - changehave_textto matches(/../) >> >> - change response.should to rendered.shoul >> >> * modify the controller specs >> - controller_name is no longer supported, so need to nest all my >> describes under a top level describe that has the controller >> name. >> describe 'UsersController' do >> or use subject {SomeController.new} (not tested yet) >> >> - when using post/delete/put :something, :id => 1 passing in an >> integer id used to work, now it needs to >> be a string (probably a rails3 thing) >> delete :destroy, :id => "1" >> >> * helper specs only needed minor changes >> - change have_tag to have_selector >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Jan 13 14:19:10 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 Jan 2011 13:19:10 -0600 Subject: [rspec-users] response.should have_text leads to undefined method `has_text?' In-Reply-To: <17425755.1189.1294945486919.JavaMail.geo-discussion-forums@yqhy19> References: <17425755.1189.1294945486919.JavaMail.geo-discussion-forums@yqhy19> Message-ID: <4FE1EA7B-37B7-4490-A688-AF6CA2BE05AC@gmail.com> On Jan 13, 2011, at 1:04 PM, Kurt wrote: > Where are the changes to RSpec2 documented? I haven't been able to find a list of changes that would include something like this removal of have_text. Thanks. have_text being pulled is not documented yet. Oversight on my part. Just added an issue for it: https://github.com/rspec/rspec-rails/issues/issue/305 per other email on this list: official docs are at http://relishapp.com/rspec. Info about contributing to the docs can be found there and at http://blog.davidchelimsky.net/2010/12/23/rspec-2-documentation-2/. From wolfmanjm at gmail.com Thu Jan 13 15:35:16 2011 From: wolfmanjm at gmail.com (Jim Morris) Date: Thu, 13 Jan 2011 12:35:16 -0800 (PST) Subject: [rspec-users] Notes on upgrading from RSpec 1 to RSpec 2 In-Reply-To: <25e0965e-27e3-4502-8d0d-0adba7132b55@v17g2000vbo.googlegroups.com> References: <3e26c20f-cabf-4b1b-b2d6-fd8a9879c16a@z26g2000prf.googlegroups.com> <25e0965e-27e3-4502-8d0d-0adba7132b55@v17g2000vbo.googlegroups.com> Message-ID: <4fa16be3-87bf-4628-b5c4-fe6fe5a48354@d7g2000vbv.googlegroups.com> On Jan 13, 10:36?am, Kurt wrote: > Hi -- Thanks for sharing all your tips. ?I couldn't understand your > line about what replaces have_text, however. ?I don't see a method > called "matches" or "match"... Sorry that should be... response.body.should match(/../) it is the standard text regexp match. also response.body.should =~ /.../ should work too. From mguterl at gmail.com Thu Jan 13 16:17:06 2011 From: mguterl at gmail.com (Michael Guterl) Date: Thu, 13 Jan 2011 16:17:06 -0500 Subject: [rspec-users] `rake spec` with rails 3.0.3 and rspec-rails 2.4.1 Message-ID: We're upgrading a rails 2.3.x application to Rails 3. When running `rake spec` no specs are running. $ rake spec --trace (in /Users/michaelguterl/code/rm/board) ** Invoke spec (first_time, not_needed) $ gem list | grep rspec rspec (2.4.0) rspec-core (2.4.0) rspec-expectations (2.4.0) rspec-mocks (2.4.0) rspec-rails (2.4.1) $ rails -v Rails 3.0.3 lib/tasks/rspec.rake is now gone because as I understand it rake tasks can be loaded through railtie integration in rails 3, which I believe rspec takes advantage of. Any pointers would be appreciated. Best, Michael Guterl From dchelimsky at gmail.com Thu Jan 13 16:40:57 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 Jan 2011 15:40:57 -0600 Subject: [rspec-users] `rake spec` with rails 3.0.3 and rspec-rails 2.4.1 In-Reply-To: References: Message-ID: On Jan 13, 2011, at 3:17 PM, Michael Guterl wrote: > We're upgrading a rails 2.3.x application to Rails 3. When running > `rake spec` no specs are running. > > $ rake spec --trace > (in /Users/michaelguterl/code/rm/board) > ** Invoke spec (first_time, not_needed) > > $ gem list | grep rspec > rspec (2.4.0) > rspec-core (2.4.0) > rspec-expectations (2.4.0) > rspec-mocks (2.4.0) > rspec-rails (2.4.1) > > $ rails -v > Rails 3.0.3 > > lib/tasks/rspec.rake is now gone because as I understand it rake tasks > can be loaded through railtie integration in rails 3, which I believe > rspec takes advantage of. > > Any pointers would be appreciated. Did you include rspec-rails in the :development group? http://relishapp.com/rspec/rspec-rails From mguterl at gmail.com Thu Jan 13 17:17:25 2011 From: mguterl at gmail.com (Michael Guterl) Date: Thu, 13 Jan 2011 17:17:25 -0500 Subject: [rspec-users] `rake spec` with rails 3.0.3 and rspec-rails 2.4.1 In-Reply-To: References: Message-ID: On Thu, Jan 13, 2011 at 4:40 PM, David Chelimsky wrote: > > On Jan 13, 2011, at 3:17 PM, Michael Guterl wrote: > >> We're upgrading a rails 2.3.x application to Rails 3. ?When running >> `rake spec` no specs are running. >> >> $ rake spec --trace >> (in /Users/michaelguterl/code/rm/board) >> ** Invoke spec (first_time, not_needed) >> >> $ gem list | grep rspec >> rspec (2.4.0) >> rspec-core (2.4.0) >> rspec-expectations (2.4.0) >> rspec-mocks (2.4.0) >> rspec-rails (2.4.1) >> >> $ rails -v >> Rails 3.0.3 >> >> lib/tasks/rspec.rake is now gone because as I understand it rake tasks >> can be loaded through railtie integration in rails 3, which I believe >> rspec takes advantage of. >> >> Any pointers would be appreciated. > > Did you include rspec-rails in the :development group? > > http://relishapp.com/rspec/rspec-rails Thanks David, despite pouring over that doc and the upgrade doc many times, I just kept missing it. From dchelimsky at gmail.com Thu Jan 13 17:40:28 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 13 Jan 2011 16:40:28 -0600 Subject: [rspec-users] `rake spec` with rails 3.0.3 and rspec-rails 2.4.1 In-Reply-To: References: Message-ID: On Jan 13, 2011, at 4:17 PM, Michael Guterl wrote: > On Thu, Jan 13, 2011 at 4:40 PM, David Chelimsky wrote: >> >> On Jan 13, 2011, at 3:17 PM, Michael Guterl wrote: >> >>> We're upgrading a rails 2.3.x application to Rails 3. When running >>> `rake spec` no specs are running. >>> >>> $ rake spec --trace >>> (in /Users/michaelguterl/code/rm/board) >>> ** Invoke spec (first_time, not_needed) >>> >>> $ gem list | grep rspec >>> rspec (2.4.0) >>> rspec-core (2.4.0) >>> rspec-expectations (2.4.0) >>> rspec-mocks (2.4.0) >>> rspec-rails (2.4.1) >>> >>> $ rails -v >>> Rails 3.0.3 >>> >>> lib/tasks/rspec.rake is now gone because as I understand it rake tasks >>> can be loaded through railtie integration in rails 3, which I believe >>> rspec takes advantage of. >>> >>> Any pointers would be appreciated. >> >> Did you include rspec-rails in the :development group? >> >> http://relishapp.com/rspec/rspec-rails > > Thanks David, despite pouring over that doc and the upgrade doc many > times, I just kept missing it. I'll make sure it's more clear. From mmazur at gmail.com Thu Jan 13 18:12:15 2011 From: mmazur at gmail.com (Mike Mazur) Date: Fri, 14 Jan 2011 07:12:15 +0800 Subject: [rspec-users] Preloading of data in rspec2 In-Reply-To: <4a5ff339477849b255e698c3bb9ad7a4@ruby-forum.com> References: <4a5ff339477849b255e698c3bb9ad7a4@ruby-forum.com> Message-ID: Hi, On Thu, Jan 13, 2011 at 22:08, Amit Kulkarni wrote: > I had used Fixtures and factory girl for preloading of data in earlier > version rspec. > Is there any new thing for loading of data in rspec 2 or do we have to > use the same. I have a spec/fixtures/ directory containing YAML files with my fixture data, which I guess is what you're used to. I like fixture_builder[1] for generating those fixtures for me from Factories if you have them, or just plain old Model.create! calls. > Also is there any documentation link where i can get nice info about > rspec 2 There is also some good documentation at http://relishapp.com/rspec Mike [1] https://github.com/rdy/fixture_builder From lille.penguini at gmail.com Thu Jan 13 20:30:16 2011 From: lille.penguini at gmail.com (Lille) Date: Thu, 13 Jan 2011 17:30:16 -0800 (PST) Subject: [rspec-users] when using command line -l, why do tests from other describe blocks run? In-Reply-To: References: <0e725306-5321-448c-b338-16836fbb3588@s9g2000vby.googlegroups.com> Message-ID: Still can't get consistent behavior with -l, consider the following.. test_spec.rb > describe SomeModule > it # special it > describe "some method of the module" > it... # 'lonely it' > it... # 'lonely it' > it... # 'special it' > context... > it... # 'context it' ... (...where carets indicate nesting levels.) So, when I enter -l [the line for 'describe SomeModule'], the lines commented 'special it' and all my 'context it' tests run but not lines commented 'lonely it'. And when I enter -l [the line for 'describe "some method of the module"'] I get all the enclosed tests, except those in the context block (and even some tests from another module tested below SomeModule!) When I run test_spec.rb, I get everything. I'm trying to draw a takeaway from this, but all I can come up with is: 'If you use nested blocks in your RSpec tests, do not expect -l to test everything in the block you're targeting.' Lille On Jan 11, 6:09?pm, Mike Mazur wrote: > Hi, > > > > On Wed, Jan 12, 2011 at 02:32, Lille wrote: > > I frequently use the -l option to run only tests of interest, but it's > > messy in a way I don't understand... > > > describe SomeModel do > > > ?describe "#some_method" do > > > ? ? it... # let's call this line 20 > > > ?end > > > ?describe "#some_other_method" do > > > ? ?it... # here's some other test > > > ?end > > > end > > > If I enter 'spec -l 20 spec/models/some_model_spec.rb' on the command > > line, I get my line 20 test and others -- say the other test, above -- > > why? > > I think that's because line 20 is contained within another group (ie: > inside ?describe "#some_method" do), so all examples from this group > are run. > > Try running your tests with -l 21 (ie: the first line contained within > the it of the test you want to run); that should run only that test. > > Mike > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From norisuke3 at gmail.com Fri Jan 14 01:19:07 2011 From: norisuke3 at gmail.com (Nori Hamamoto) Date: Fri, 14 Jan 2011 02:19:07 -0400 Subject: [rspec-users] found some inconsistently behavior on its method. Message-ID: Hi there, I've just started using rspec and rspec-rails (both are the newest version on git repository). I met some inconsistently behavior on it method and its method. The following is the way to reproduce it: command line: > script/generate spec_controller product show Modify a file spec/products_controller_spec.rb like the following: require 'spec_helper' describe ProductsController do describe Array do subject { Array.new } it { should be_empty } its(:size) { should == 0 } end end Then, when I run spec, the first example (it { should be_empty }) pass the test, but not the second one(its(:size){ should == 0 }). How so? I've found a similar issue: describe 10 do it { should == 10 } its(:to_s) { should == "10" } end The first one passes, but not for the second one. Is this a bug on rspec 1.3.1? Another example: describe Array do its(:empty?) { should be_true } # pass end describe [] do its(:empty?) { should be_true } # not pass end The first one passes the test where as the second one doesn't pass. So, what's going on on its method?? Thank you, norisuke3 at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jan 14 07:44:07 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 14 Jan 2011 06:44:07 -0600 Subject: [rspec-users] found some inconsistently behavior on its method. In-Reply-To: References: Message-ID: <5B73CD1E-3715-43E8-B616-517A7769D349@gmail.com> On Jan 14, 2011, at 12:19 AM, Nori Hamamoto wrote: > Hi there, > > I've just started using rspec and rspec-rails (both are the newest version on git repository). > I met some inconsistently behavior on it method and its method. > The following is the way to reproduce it: > > command line: > > > script/generate spec_controller product show > > Modify a file spec/products_controller_spec.rb like the following: > > require 'spec_helper' > > describe ProductsController do > describe Array do > subject { Array.new } > it { should be_empty } > its(:size) { should == 0 } > end > end > > Then, when I run spec, the first example (it { should be_empty }) pass the test, but not the second one(its(:size){ should == 0 }). > How so? > > I've found a similar issue: > > describe 10 do > it { should == 10 } > its(:to_s) { should == "10" } > end > > The first one passes, but not for the second one. > Is this a bug on rspec 1.3.1? > > Another example: > > describe Array do > its(:empty?) { should be_true } # pass > end > > describe [] do > its(:empty?) { should be_true } # not pass > end > > The first one passes the test where as the second one doesn't pass. > So, what's going on on its method?? All of these pass in rspec-2, but it looks like there are some inconsistencies in rspec-1. You're welcome to file bug reports for this, but I can tell you that unless somebody else submits patches for it it's unlikely to get fixed. Bug reports for rspec-1 live at http://rspec.lighthouseapp.com. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From norisuke3 at gmail.com Fri Jan 14 08:29:06 2011 From: norisuke3 at gmail.com (Nori Hamamoto) Date: Fri, 14 Jan 2011 09:29:06 -0400 Subject: [rspec-users] found some inconsistently behavior on its method. In-Reply-To: <5B73CD1E-3715-43E8-B616-517A7769D349@gmail.com> References: <5B73CD1E-3715-43E8-B616-517A7769D349@gmail.com> Message-ID: I said I'm using the newest version on the repository, but I mean that the newest version of rspec1's repository. I didn't try it on rspec2 because according to rspec2's git repository, it doesn't support rails 2 and I'm using rails 2. Sorry about the lack of the information in my report. Cheers, Nori On Fri, Jan 14, 2011 at 8:44 AM, David Chelimsky wrote: > On Jan 14, 2011, at 12:19 AM, Nori Hamamoto wrote: > > Hi there, > > I've just started using rspec and rspec-rails (both are the newest version > on git repository). > I met some inconsistently behavior on it method and its method. > The following is the way to reproduce it: > > command line: > > > script/generate spec_controller product show > > Modify a file spec/products_controller_spec.rb like the following: > > require 'spec_helper' > > describe ProductsController do > describe Array do > subject { Array.new } > it { should be_empty } > its(:size) { should == 0 } > end > end > > Then, when I run spec, the first example (it { should be_empty }) pass the > test, but not the second one(its(:size){ should == 0 }). > How so? > > I've found a similar issue: > > describe 10 do > it { should == 10 } > its(:to_s) { should == "10" } > end > > The first one passes, but not for the second one. > Is this a bug on rspec 1.3.1? > > Another example: > > describe Array do > its(:empty?) { should be_true } # pass > end > > describe [] do > its(:empty?) { should be_true } # not pass > end > > The first one passes the test where as the second one doesn't pass. > So, what's going on on its method?? > > > All of these pass in rspec-2, but it looks like there are some > inconsistencies in rspec-1. You're welcome to file bug reports for this, but > I can tell you that unless somebody else submits patches for it it's > unlikely to get fixed. > > Bug reports for rspec-1 live at http://rspec.lighthouseapp.com. > > Cheers, > David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jan 14 09:57:14 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 14 Jan 2011 08:57:14 -0600 Subject: [rspec-users] found some inconsistently behavior on its method. In-Reply-To: References: <5B73CD1E-3715-43E8-B616-517A7769D349@gmail.com> Message-ID: <2EDBA73C-B671-4DAD-A05F-EA2D6BB25D49@gmail.com> On Jan 14, 2011, at 7:29 AM, Nori Hamamoto wrote: > I said I'm using the newest version on the repository, but I mean that the newest version of rspec1's repository. > I didn't try it on rspec2 because according to rspec2's git repository, it doesn't support rails 2 and I'm using rails 2. > Sorry about the lack of the information in my report. No apology necessary. There are a couple of projects in the works to make rspec 2 work with rails 2, but I don't think any are ready for general consumption. > Cheers, > Nori > > On Fri, Jan 14, 2011 at 8:44 AM, David Chelimsky wrote: > On Jan 14, 2011, at 12:19 AM, Nori Hamamoto wrote: > >> Hi there, >> >> I've just started using rspec and rspec-rails (both are the newest version on git repository). >> I met some inconsistently behavior on it method and its method. >> The following is the way to reproduce it: >> >> command line: >> >> > script/generate spec_controller product show >> >> Modify a file spec/products_controller_spec.rb like the following: >> >> require 'spec_helper' >> >> describe ProductsController do >> describe Array do >> subject { Array.new } >> it { should be_empty } >> its(:size) { should == 0 } >> end >> end >> >> Then, when I run spec, the first example (it { should be_empty }) pass the test, but not the second one(its(:size){ should == 0 }). >> How so? >> >> I've found a similar issue: >> >> describe 10 do >> it { should == 10 } >> its(:to_s) { should == "10" } >> end >> >> The first one passes, but not for the second one. >> Is this a bug on rspec 1.3.1? >> >> Another example: >> >> describe Array do >> its(:empty?) { should be_true } # pass >> end >> >> describe [] do >> its(:empty?) { should be_true } # not pass >> end >> >> The first one passes the test where as the second one doesn't pass. >> So, what's going on on its method?? > > All of these pass in rspec-2, but it looks like there are some inconsistencies in rspec-1. You're welcome to file bug reports for this, but I can tell you that unless somebody else submits patches for it it's unlikely to get fixed. > > Bug reports for rspec-1 live at http://rspec.lighthouseapp.com. > > Cheers, > David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From mguterl at gmail.com Fri Jan 14 10:56:52 2011 From: mguterl at gmail.com (Michael Guterl) Date: Fri, 14 Jan 2011 10:56:52 -0500 Subject: [rspec-users] rspec 2.4 incorrect time reported Message-ID: I keep seeing strange run times for our specs: Finished in -348317500.25314 seconds Any thoughts are much appreciated. Best, Michael Guterl From dchelimsky at gmail.com Fri Jan 14 11:05:03 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 14 Jan 2011 10:05:03 -0600 Subject: [rspec-users] rspec 2.4 incorrect time reported In-Reply-To: References: Message-ID: <81E8FF39-69AB-45FA-AEF4-78387552847B@gmail.com> On Jan 14, 2011, at 9:56 AM, Michael Guterl wrote: > I keep seeing strange run times for our specs: > > Finished in -348317500.25314 seconds > > Any thoughts are much appreciated. Are you stubbing Time.now anywhere? From mguterl at gmail.com Fri Jan 14 11:15:53 2011 From: mguterl at gmail.com (Michael Guterl) Date: Fri, 14 Jan 2011 11:15:53 -0500 Subject: [rspec-users] Rails 3 / RSpec 2 use_transactional_fixtures and after_commit Message-ID: We're migrating a Rails 2.3.x application to Rails 3 and RSpec 2.x. In Rails 2.3.x we were using https://github.com/freelancing-god/after_commit to provide after_commit functionality (now provided by Rails 3). The plugin version of after_commit came with some helpers to make testing with `use_transactional_fixtures = true` work. From: https://github.com/freelancing-god/after_commit "Keep in mind that transactions are finicky at best in tests, and so there?s a helper module to make after_commit play nicely in your testing context. You?ll need to add these two lines to your spec/test helper:" ActiveRecord::Base.send(:include, AfterCommit::AfterSavepoint) ActiveRecord::Base.include_after_savepoint_extensions Anyone else ran into this? Best, Michael Guterl From norisuke3 at gmail.com Fri Jan 14 11:18:47 2011 From: norisuke3 at gmail.com (Nori Hamamoto) Date: Fri, 14 Jan 2011 12:18:47 -0400 Subject: [rspec-users] found some inconsistently behavior on its method. In-Reply-To: <2EDBA73C-B671-4DAD-A05F-EA2D6BB25D49@gmail.com> References: <5B73CD1E-3715-43E8-B616-517A7769D349@gmail.com> <2EDBA73C-B671-4DAD-A05F-EA2D6BB25D49@gmail.com> Message-ID: Sounds good!! Nori On Fri, Jan 14, 2011 at 10:57 AM, David Chelimsky wrote: > On Jan 14, 2011, at 7:29 AM, Nori Hamamoto wrote: > > I said I'm using the newest version on the repository, but I mean that the > newest version of rspec1's repository. > I didn't try it on rspec2 because according to rspec2's git repository, it > doesn't support rails 2 and I'm using rails 2. > Sorry about the lack of the information in my report. > > > No apology necessary. There are a couple of projects in the works to make > rspec 2 work with rails 2, but I don't think any are ready for general > consumption. > > Cheers, > Nori > > On Fri, Jan 14, 2011 at 8:44 AM, David Chelimsky < > dchelimsky at gmail.com> wrote: > >> On Jan 14, 2011, at 12:19 AM, Nori Hamamoto wrote: >> >> Hi there, >> >> I've just started using rspec and rspec-rails (both are the newest version >> on git repository). >> I met some inconsistently behavior on it method and its method. >> The following is the way to reproduce it: >> >> command line: >> >> > script/generate spec_controller product show >> >> Modify a file spec/products_controller_spec.rb like the following: >> >> require 'spec_helper' >> >> describe ProductsController do >> describe Array do >> subject { Array.new } >> it { should be_empty } >> its(:size) { should == 0 } >> end >> end >> >> Then, when I run spec, the first example (it { should be_empty }) pass the >> test, but not the second one(its(:size){ should == 0 }). >> How so? >> >> I've found a similar issue: >> >> describe 10 do >> it { should == 10 } >> its(:to_s) { should == "10" } >> end >> >> The first one passes, but not for the second one. >> Is this a bug on rspec 1.3.1? >> >> Another example: >> >> describe Array do >> its(:empty?) { should be_true } # pass >> end >> >> describe [] do >> its(:empty?) { should be_true } # not pass >> end >> >> The first one passes the test where as the second one doesn't pass. >> So, what's going on on its method?? >> >> >> All of these pass in rspec-2, but it looks like there are some >> inconsistencies in rspec-1. You're welcome to file bug reports for this, but >> I can tell you that unless somebody else submits patches for it it's >> unlikely to get fixed. >> >> Bug reports for rspec-1 live at >> http://rspec.lighthouseapp.com. >> >> Cheers, >> David >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From norisuke3 at gmail.com Fri Jan 14 11:29:52 2011 From: norisuke3 at gmail.com (Nori Hamamoto) Date: Fri, 14 Jan 2011 12:29:52 -0400 Subject: [rspec-users] autospec on rails keep rerunning on failed case, and never stop. Message-ID: Hi there, I met a problem when I'm using RSpec(1.3.0) on rails. I installed rspec(1.3.1) and rspec-rails(1.3.3) installed through rails script/plugin install from github. I run autospec at $RAILS_ROOT, and if the test goes successful, it's no problem, but once I get failed case, it keep running the test repeatedly and never stop. I'm using MacOSX, so I'm configured it connecting to Growl to show the test result. Therefore, the failed indication on growl is also shown up repeatedly until I stop autspec process. All configuration I did is that I made .autotest file on ~ directory, and put the following one line in it. require 'autotest/growl' Also, I installed RSpec using gem intall to my Mac. Do you have any idea? Thank you, Nori -------------- next part -------------- An HTML attachment was scrubbed... URL: From norisuke3 at gmail.com Fri Jan 14 11:31:15 2011 From: norisuke3 at gmail.com (Nori Hamamoto) Date: Fri, 14 Jan 2011 12:31:15 -0400 Subject: [rspec-users] autospec on rails keep rerunning on failed case, and never stop. In-Reply-To: References: Message-ID: Additionally, this problem doesn't happen when I use autospec on simple ruby rb file, but only happens with rails. On Fri, Jan 14, 2011 at 12:29 PM, Nori Hamamoto wrote: > Hi there, > > I met a problem when I'm using RSpec(1.3.0) on rails. > I installed rspec(1.3.1) and rspec-rails(1.3.3) installed through rails > script/plugin install from github. > > I run autospec at $RAILS_ROOT, and if the test goes successful, it's no > problem, but once I get failed case, it keep running the test repeatedly and > never stop. > I'm using MacOSX, so I'm configured it connecting to Growl to show the test > result. Therefore, the failed indication on growl is also shown up > repeatedly until I stop autspec process. > > All configuration I did is that I made .autotest file on ~ directory, and > put the following one line in it. > > require 'autotest/growl' > > Also, I installed RSpec using gem intall to my Mac. > > Do you have any idea? > > Thank you, > Nori > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mguterl at gmail.com Fri Jan 14 12:13:45 2011 From: mguterl at gmail.com (Michael Guterl) Date: Fri, 14 Jan 2011 12:13:45 -0500 Subject: [rspec-users] rspec 2.4 incorrect time reported In-Reply-To: <81E8FF39-69AB-45FA-AEF4-78387552847B@gmail.com> References: <81E8FF39-69AB-45FA-AEF4-78387552847B@gmail.com> Message-ID: On Fri, Jan 14, 2011 at 11:05 AM, David Chelimsky wrote: > On Jan 14, 2011, at 9:56 AM, Michael Guterl wrote: > >> I keep seeing strange run times for our specs: >> >> Finished in -348317500.25314 seconds >> >> Any thoughts are much appreciated. > > Are you stubbing Time.now anywhere? Yes we are, makes sense, I'll be sure to reset the stub. Best, Michael Guterl From norisuke3 at gmail.com Fri Jan 14 15:39:55 2011 From: norisuke3 at gmail.com (Nori Hamamoto) Date: Fri, 14 Jan 2011 16:39:55 -0400 Subject: [rspec-users] found some inconsistently behavior on its method. In-Reply-To: References: <5B73CD1E-3715-43E8-B616-517A7769D349@gmail.com> <2EDBA73C-B671-4DAD-A05F-EA2D6BB25D49@gmail.com> Message-ID: Hi David, I've sent a patch for this problem via github. Please check it out. Thank you, Nori On Fri, Jan 14, 2011 at 12:18 PM, Nori Hamamoto wrote: > Sounds good!! > > Nori > > On Fri, Jan 14, 2011 at 10:57 AM, David Chelimsky wrote: > >> On Jan 14, 2011, at 7:29 AM, Nori Hamamoto wrote: >> >> I said I'm using the newest version on the repository, but I mean that the >> newest version of rspec1's repository. >> I didn't try it on rspec2 because according to rspec2's git repository, it >> doesn't support rails 2 and I'm using rails 2. >> Sorry about the lack of the information in my report. >> >> >> No apology necessary. There are a couple of projects in the works to make >> rspec 2 work with rails 2, but I don't think any are ready for general >> consumption. >> >> Cheers, >> Nori >> >> On Fri, Jan 14, 2011 at 8:44 AM, David Chelimsky < >> dchelimsky at gmail.com> wrote: >> >>> On Jan 14, 2011, at 12:19 AM, Nori Hamamoto wrote: >>> >>> Hi there, >>> >>> I've just started using rspec and rspec-rails (both are the newest >>> version on git repository). >>> I met some inconsistently behavior on it method and its method. >>> The following is the way to reproduce it: >>> >>> command line: >>> >>> > script/generate spec_controller product show >>> >>> Modify a file spec/products_controller_spec.rb like the following: >>> >>> require 'spec_helper' >>> >>> describe ProductsController do >>> describe Array do >>> subject { Array.new } >>> it { should be_empty } >>> its(:size) { should == 0 } >>> end >>> end >>> >>> Then, when I run spec, the first example (it { should be_empty }) pass >>> the test, but not the second one(its(:size){ should == 0 }). >>> How so? >>> >>> I've found a similar issue: >>> >>> describe 10 do >>> it { should == 10 } >>> its(:to_s) { should == "10" } >>> end >>> >>> The first one passes, but not for the second one. >>> Is this a bug on rspec 1.3.1? >>> >>> Another example: >>> >>> describe Array do >>> its(:empty?) { should be_true } # pass >>> end >>> >>> describe [] do >>> its(:empty?) { should be_true } # not pass >>> end >>> >>> The first one passes the test where as the second one doesn't pass. >>> So, what's going on on its method?? >>> >>> >>> All of these pass in rspec-2, but it looks like there are some >>> inconsistencies in rspec-1. You're welcome to file bug reports for this, but >>> I can tell you that unless somebody else submits patches for it it's >>> unlikely to get fixed. >>> >>> Bug reports for rspec-1 live at >>> http://rspec.lighthouseapp.com. >>> >>> Cheers, >>> David >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lille.penguini at gmail.com Fri Jan 14 22:57:43 2011 From: lille.penguini at gmail.com (Lille) Date: Fri, 14 Jan 2011 19:57:43 -0800 (PST) Subject: [rspec-users] [rspec-rails] how to test module behavior once and then confirm that controllers implement it? Message-ID: Hi, I'm using rspec-rails (1.3.2), and wondering how to save myself the trouble of testing filters for ActionControllers when those filters call methods included from modules. Specifically, what is the recommended structure for the test of the module filter; next, how can I confirm that the controller classes that have included the module and are properly calling its methods as filters. Cracking this could save me from duplicating the testing of the full behavior of the filters in several instances, in several ActionController classes. Thanks, Lille From nick at deadorange.com Sat Jan 15 00:29:58 2011 From: nick at deadorange.com (Nick) Date: Fri, 14 Jan 2011 21:29:58 -0800 (PST) Subject: [rspec-users] [rspec-rails] how to test module behavior once and then confirm that controllers implement it? In-Reply-To: Message-ID: <13275984.499.1295069398735.JavaMail.geo-discussion-forums@yqmb9> Hey Lille. > Specifically, what is the recommended structure for the test of the > module filter; > How about creating a shared example group, and referencing that? http://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shared-example-groups-in-rspec-2/ > next, how can I confirm that the controller classes > that have included the module and are properly calling its methods as > filters. > You can check if a class included a module like this: Foo.should include Bar When an object calls a method that was mixed in, the method's called as though it truly is a part of the class. So you can just do: Module Bar def baz; end end Class Foo include Bar def something baz end end f = Foo.new f.should_receive(:baz).and_return nil f.something In the rest of your specs, it's just a matter of stubbing out the call to "baz". > Cracking this could save me from duplicating the testing of the full > behavior of the filters in several instances, in several > ActionController classes. > I hope that helps! Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: From lille.penguini at gmail.com Sat Jan 15 10:45:41 2011 From: lille.penguini at gmail.com (Lille) Date: Sat, 15 Jan 2011 07:45:41 -0800 (PST) Subject: [rspec-users] [rspec-rails] how to test module behavior once and then confirm that controllers implement it? In-Reply-To: <13275984.499.1295069398735.JavaMail.geo-discussion-forums@yqmb9> References: <13275984.499.1295069398735.JavaMail.geo-discussion-forums@yqmb9> Message-ID: <4c62deec-ab06-459f-8053-3fbd15484d07@n11g2000yqh.googlegroups.com> Thanks Nick, that was helpful. I'm wondering if it's possible to test module behavior and then test that the module behavior of interest is invoked from the before/after filter enclosing the controller action under test. To me, it seems that I'm missing a step if I don't fill in my 4), below: 1) test included module behavior 2) test that module is included in controller class 3) test that the module methods are responsive from the host class 4) [test that the module method(s) invoked in before/after filters for actions in the host are called when their enclosed actions are.] Maybe it would be helpful to note that my module behavior is redirection. Thanks, Lille On Jan 15, 12:29?am, Nick wrote: > Hey Lille. > > > Specifically, what is the recommended structure for the test of the > > module filter; > > How about creating a shared example group, and referencing that?http://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shar... > > > next, how can I confirm that the controller classes > > that have included the module and are properly calling its methods as > > filters. > > You can check if a class included a module like this: > ? ? Foo.should include Bar > > When an object calls a method that was mixed in, the method's called as > though it truly is a part of the class. So you can just do: > > Module Bar > ? def baz; end > end > > Class Foo > ? include Bar > > ? def something > ? ? baz > ? end > end > > f = Foo.new > f.should_receive(:baz).and_return nil > f.something > > In the rest of your specs, it's just a matter of stubbing out the call to > "baz". > > > Cracking this could save me from duplicating the testing of the full > > behavior of the filters in several instances, in several > > ActionController classes. > > I hope that helps! > Nick > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat Jan 15 13:34:18 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 15 Jan 2011 12:34:18 -0600 Subject: [rspec-users] [rspec-rails] how to test module behavior once and then confirm that controllers implement it? In-Reply-To: <4c62deec-ab06-459f-8053-3fbd15484d07@n11g2000yqh.googlegroups.com> References: <13275984.499.1295069398735.JavaMail.geo-discussion-forums@yqmb9> <4c62deec-ab06-459f-8053-3fbd15484d07@n11g2000yqh.googlegroups.com> Message-ID: On Jan 15, 2011, at 9:45 AM, Lille wrote: > Thanks Nick, that was helpful. > > I'm wondering if it's possible to test module behavior and then test > that the module behavior of interest is invoked from the before/after > filter enclosing the controller action under test. > > To me, it seems that I'm missing a step if I don't fill in my 4), > below: > > 1) test included module behavior > 2) test that module is included in controller class > 3) test that the module methods are responsive from the host class > 4) [test that the module method(s) invoked in before/after filters for > actions in the host are called when their enclosed actions are.] > > Maybe it would be helpful to note that my module behavior is > redirection. Then _that_ ^^ is what you want to specify!!!!!!!!!!! Not 1 or 2. Maybe 3 and/or 4, but they are expressed in very procedural/structural ways. Paraphrasing myself from The RSpec Book: BDD is about behavior, not structure. It is about what code _does_, not what code _is_. In this case, the behavior is: Given these conditions When I visit one page Then I should be redirected to other page Expressed in RSpec: describe SomeController do describe "the action" do context "in some context" do post :the_action response.should redirect_to("other") end end end Please give http://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shared-example-groups-in-rspec-2/ a read and let us know if you agree/disagree with the approach. Cheers, David > > Thanks, > > Lille > > On Jan 15, 12:29 am, Nick wrote: >> Hey Lille. >> >>> Specifically, what is the recommended structure for the test of the >>> module filter; >> >> How about creating a shared example group, and referencing that?http://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shar... >> >>> next, how can I confirm that the controller classes >>> that have included the module and are properly calling its methods as >>> filters. >> >> You can check if a class included a module like this: >> Foo.should include Bar >> >> When an object calls a method that was mixed in, the method's called as >> though it truly is a part of the class. So you can just do: >> >> Module Bar >> def baz; end >> end >> >> Class Foo >> include Bar >> >> def something >> baz >> end >> end >> >> f = Foo.new >> f.should_receive(:baz).and_return nil >> f.something >> >> In the rest of your specs, it's just a matter of stubbing out the call to >> "baz". >> >>> Cracking this could save me from duplicating the testing of the full >>> behavior of the filters in several instances, in several >>> ActionController classes. >> >> I hope that helps! >> Nick >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Cheers, David From lille.penguini at gmail.com Sat Jan 15 15:40:18 2011 From: lille.penguini at gmail.com (Lille) Date: Sat, 15 Jan 2011 12:40:18 -0800 (PST) Subject: [rspec-users] [rspec-rails] how to test module behavior once and then confirm that controllers implement it? In-Reply-To: References: <13275984.499.1295069398735.JavaMail.geo-discussion-forums@yqmb9> <4c62deec-ab06-459f-8053-3fbd15484d07@n11g2000yqh.googlegroups.com> Message-ID: <00e75ca3-a861-4eef-9a56-a05c314cdc6f@d7g2000vbv.googlegroups.com> David, Thanks (and, yes, I consult "The RSpec Book" often). I had familiarized myself with your reference. I guess I depart from the BDD line, because I feel that if I test a module and I test that the host implements it when expected, then that should be enough. For example, if I have a module whose single method has four possible results and then I implement it in 4 hosts, I might have to have as much as 16 tests versus my approach's 8, alternatively. Of course, it seems like testing the invocations of the module has no facility in RSpec, due, perhaps, to the BDD approach, which, I allow, I may come to see as wiser, with more experience. Thanks for your helpful comments. Lille On Jan 15, 1:34?pm, David Chelimsky wrote: > On Jan 15, 2011, at 9:45 AM, Lille wrote: > > > > > Thanks Nick, that was helpful. > > > I'm wondering if it's possible to test module behavior and then test > > that the module behavior of interest is invoked from the before/after > > filter enclosing the controller action under test. > > > To me, it seems that I'm missing a step if I don't fill in my 4), > > below: > > > 1) test included module behavior > > 2) test that module is included in controller class > > 3) test that the module methods are responsive from the host class > > 4) [test that the module method(s) invoked in before/after filters for > > actions in the host are called when their enclosed actions are.] > > > Maybe it would be helpful to note that my module behavior is > > redirection. > > Then _that_ ^^ is what you want to specify!!!!!!!!!!! Not 1 or 2. Maybe 3 and/or 4, but they are expressed in very procedural/structural ways. > > Paraphrasing myself from The RSpec Book: BDD is about behavior, not structure. It is about what code _does_, not what code _is_. > > In this case, the behavior is: > > ? Given these conditions > ? When I visit one page > ? Then I should be redirected to other page > > Expressed in RSpec: > > ? describe SomeController do > ? ? describe "the action" do > ? ? ? context "in some context" do > ? ? ? ? post :the_action > ? ? ? ? response.should redirect_to("other") > ? ? ? end > ? ? end > ? end > > Please givehttp://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shar...a read and let us know if you agree/disagree with the approach. > > Cheers, > David > > > > > > > Thanks, > > > Lille > > > On Jan 15, 12:29 am, Nick wrote: > >> Hey Lille. > > >>> Specifically, what is the recommended structure for the test of the > >>> module filter; > > >> How about creating a shared example group, and referencing that?http://blog.davidchelimsky.net/2010/11/07/specifying-mixins-with-shar... > > >>> next, how can I confirm that the controller classes > >>> that have included the module and are properly calling its methods as > >>> filters. > > >> You can check if a class included a module like this: > >> ? ? Foo.should include Bar > > >> When an object calls a method that was mixed in, the method's called as > >> though it truly is a part of the class. So you can just do: > > >> Module Bar > >> ? def baz; end > >> end > > >> Class Foo > >> ? include Bar > > >> ? def something > >> ? ? baz > >> ? end > >> end > > >> f = Foo.new > >> f.should_receive(:baz).and_return nil > >> f.something > > >> In the rest of your specs, it's just a matter of stubbing out the call to > >> "baz". > > >>> Cracking this could save me from duplicating the testing of the full > >>> behavior of the filters in several instances, in several > >>> ActionController classes. > > >> I hope that helps! > >> Nick > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > Cheers, > David > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From katrina.owen at gmail.com Sat Jan 15 17:05:56 2011 From: katrina.owen at gmail.com (Katrina Owen) Date: Sat, 15 Jan 2011 23:05:56 +0100 Subject: [rspec-users] [rspec-rails] how to test module behavior once and then confirm that controllers implement it? In-Reply-To: <00e75ca3-a861-4eef-9a56-a05c314cdc6f@d7g2000vbv.googlegroups.com> References: <13275984.499.1295069398735.JavaMail.geo-discussion-forums@yqmb9> <4c62deec-ab06-459f-8053-3fbd15484d07@n11g2000yqh.googlegroups.com> <00e75ca3-a861-4eef-9a56-a05c314cdc6f@d7g2000vbv.googlegroups.com> Message-ID: On Sat, Jan 15, 2011 at 9:40 PM, Lille wrote: > I guess I depart from the BDD line, because I feel that if I test a > module and I test that the host implements it when expected, then that > should be enough. For example, if I have a module whose single method > has four possible results and then I implement it in 4 hosts, I might > have to have as much as 16 tests versus my approach's 8, > alternatively. (snip) > Of course, it seems like testing the invocations of the module has no > facility in RSpec, due, perhaps, to the BDD approach, which, I allow, > I may come to see as wiser, with more experience. RSpec provides easy access to message expectations for things like that. In the case of a single module included in several places, I would probably specify the behavior in one place (either directly against the model, or using a fake wrapper if necessary), and then use a message expectation to check that you've hooked everything up. E.g.: require 'spec_helper' class FilterTesterController < ApplicationController before_filter :some_filter, :only => [:wrap_some_filter] def wrap_some_filter # whatever end end describe FilterTesterController, "#some_filter" do before(:each) do MyApp::Application.routes.draw do get :wrap_some_filter, :to => 'filter_tester#wrap_some_filter', :as => 'originating' end end after(:each) do MyApp::Application.reload_routes! end it "does what I expect it to" do get :wrap_some_filter # expectation end end describe "One or all of your other classes that include the module" do it "is hooked up" do YourModule.should_receive(:the_method).with :some_params get :some_action # or YourClass.new.some_method or whatever end end Cheers, Katrina From ruben.grunge84 at gmail.com Sat Jan 15 19:56:48 2011 From: ruben.grunge84 at gmail.com (rdavila) Date: Sat, 15 Jan 2011 16:56:48 -0800 (PST) Subject: [rspec-users] Problem with output at running specs Message-ID: Hi folks, I'm using rspec-rails 1.3.3 with a rails 2.3.2 app, I'm setting up the test environment, an every time that I run the specs I get this weird output: http://codepad.org/3bGWsENn Do you know how I can get rid of this ugly output? I just want to view my spec output not sql related one. Thanks in advance. From mulder.patrick at gmail.com Sun Jan 16 04:46:40 2011 From: mulder.patrick at gmail.com (poseid) Date: Sun, 16 Jan 2011 01:46:40 -0800 (PST) Subject: [rspec-users] Rspec2 partial view gives nil:NilClass. Why? Message-ID: Hello, I am trying to get going with development of view components with Rspec2 and Rails3. However, I make the following observation, and I don't understand what is going on, and how to fix this. In my spec I define: describe "main/index.html.erb" do it "displays a photo url in products partial" do assign(:designs, [stub_model(Design, :name => "test", :photo => "photo_url")]) render rendered.should contain("photo_url") end end When I run: rspec spec/view/main_spec.rb I get this error: 1) main/index.html.erb displays a photo url in products partial Failure/Error: render ActionView::Template::Error: undefined method `photo' for nil:NilClass # ./app/views/main/_design.html.erb:3:in `_app_views_main__design_html_erb__2937334847274155273_2170841960__1566661024965846011' # ./app/views/main/index.html.erb:25:in `_app_views_main_index_html_erb__837234277009287876_2170861440__898201527838028543' # ./spec/views/main_spec.rb:7:in `block (2 levels) in ' However, if I only 'access' a local photo object in my partial everything passes. This is: in _design.html.erb: <%= design %> ---> PASS <%= design.photo %> ---> FAIL In my view I call my partial as follows: main.html.erb <%= render "design", :locals => { :designs => @designs } %> What am I missing. Thank you for your help! From akleak at gmail.com Sun Jan 16 14:35:06 2011 From: akleak at gmail.com (andyl) Date: Sun, 16 Jan 2011 11:35:06 -0800 (PST) Subject: [rspec-users] formatting of one-line specs - question Message-ID: <44909091-22dd-418f-93a8-d77bc4281e16@l22g2000vbp.googlegroups.com> For easy editing, I love one-line specs, like this: specify { 1.should == 1 } But when using '--format documentation', one-line specs don't always render useful documentation. A solution is to write one-line specs using do/end: it "succeeds with do/end" do 1.should == 1 end That's ok - but its difficult to visually parse. One-line specs with braces would be better IMHO. Here's a first example with braces ( this doesn't work ): it "should work this way, but doesn't" { 1.should == 1 } Here's a second example with braces ( this works ): it("works this way") { 1.should == 1 } Is there any way to make the first 'braces' format work?? ( I'm using Ruby 1.8.7 / Rspec 2.4.0 / Ubuntu 10.10 ) Thanks, Andy From dchelimsky at gmail.com Sun Jan 16 16:53:09 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 Jan 2011 15:53:09 -0600 Subject: [rspec-users] formatting of one-line specs - question In-Reply-To: <44909091-22dd-418f-93a8-d77bc4281e16@l22g2000vbp.googlegroups.com> References: <44909091-22dd-418f-93a8-d77bc4281e16@l22g2000vbp.googlegroups.com> Message-ID: On Jan 16, 2011, at 1:35 PM, andyl wrote: > For easy editing, I love one-line specs, like this: > > specify { 1.should == 1 } > > But when using '--format documentation', one-line specs don't always > render useful documentation. > > A solution is to write one-line specs using do/end: > > it "succeeds with do/end" do 1.should == 1 end > > That's ok - but its difficult to visually parse. One-line specs with > braces would be better IMHO. > > Here's a first example with braces ( this doesn't work ): > > it "should work this way, but doesn't" { 1.should == 1 } > > Here's a second example with braces ( this works ): > > it("works this way") { 1.should == 1 } > > Is there any way to make the first 'braces' format work?? AFAIK, no. That's just the way the Ruby parser works. From rich at gandalf.ws Sun Jan 16 17:47:04 2011 From: rich at gandalf.ws (Rich Price) Date: Sun, 16 Jan 2011 16:47:04 -0600 Subject: [rspec-users] Sudden rspec problem Message-ID: <4D337568.1000203@gandalf.ws> I was using rspec 2.4.0 to test some code and it was working fine then suddenly I get rich at richlaptop2:~/Documents/fakemap/rspec$ rspec block.rb /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': ../code/fmutil.rb:145: class/module name must be CONSTANT (SyntaxError) from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require' from /home/rich/Documents/fakemap/rspec/block.rb:1 from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' from /var/lib/gems/1.8/rspec:19 rich at richlaptop2:~/Documents/fakemap/rspec$ This is for code that was ENTIRELY unchanged from a previous successful test. Now any use that I make of rspec produces these errors! Has anyone seen behavior like this? Is theis a known bug with rspec? -- Rich Price rich at gandalf.ws From mmazur at gmail.com Sun Jan 16 18:51:46 2011 From: mmazur at gmail.com (Mike Mazur) Date: Mon, 17 Jan 2011 07:51:46 +0800 Subject: [rspec-users] Sudden rspec problem In-Reply-To: <4D337568.1000203@gandalf.ws> References: <4D337568.1000203@gandalf.ws> Message-ID: Hi, On Mon, Jan 17, 2011 at 06:47, Rich Price wrote: > I was using rspec 2.4.0 to test some code > and it was working fine then suddenly I get > > rich at richlaptop2:~/Documents/fakemap/rspec$ rspec block.rb > /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': > ../code/fmutil.rb:145: class/module name must be CONSTANT (SyntaxError) > ? ? ? ?from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require' > ? ? ? ?from /home/rich/Documents/fakemap/rspec/block.rb:1 > ? ? ? ?from > /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load' > ? ? ? ?from > /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files' > ? ? ? ?from > /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `map' > ? ? ? ?from > /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files' > ? ? ? ?from > /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in > `run' > ? ? ? ?from > /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in > `run_in_process' > ? ? ? ?from > /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' > ? ? ? ?from > /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in > `autorun' > ? ? ? ?from /var/lib/gems/1.8/rspec:19 > rich at richlaptop2:~/Documents/fakemap/rspec$ > > This is for code that was ENTIRELY unchanged > from a previous successful test. > > Now any use that I make of rspec produces these errors! > > Has anyone seen behavior like this? > Is theis a known bug with rspec? I notice the error happens in rubygems/custom_require.rb and that you're using rspec-core from a global gem directory. Could it be that you upgraded some gems recently? Perhaps this gem is also a dependency for your project and it has a bug. What does /home/rich/Documents/fakemap/rspec/block.rb line 1 contain? Mike From wilkerlucio at gmail.com Sun Jan 16 18:52:59 2011 From: wilkerlucio at gmail.com (Wilker) Date: Sun, 16 Jan 2011 20:52:59 -0300 Subject: [rspec-users] Aidmock - safe mocking Message-ID: Hi guys, I launched some days ago a new project that aims to make the use of mocks safer. This is the URL of project: https://github.com/wilkerlucio/aidmock The basic idea is to make user define interfaces of classes, when user defines the class interface (which is something like defining method signatures on C or Java) Aidmock automatic generate some sanity check specs, these specs will verify if class has the method defined, and if it respect arity of interface. And more important, when user create mocks while developing specs, it will verify all defined mocks, and check if they are respecting defined interface. You can saw more about project motivation here(with some example of why it exists): https://github.com/wilkerlucio/aidmock/wiki/Motivation This project is a kind of experimental one, with a different idea, and any feedback will be really welcome. Thanks --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 16 19:14:27 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 Jan 2011 18:14:27 -0600 Subject: [rspec-users] Sudden rspec problem In-Reply-To: <4D337568.1000203@gandalf.ws> References: <4D337568.1000203@gandalf.ws> Message-ID: <28AEB3FF-2BA1-4055-9B9D-D588208F7EDC@gmail.com> On Jan 16, 2011, at 4:47 PM, Rich Price wrote: > I was using rspec 2.4.0 to test some code > and it was working fine then suddenly I get > > rich at richlaptop2:~/Documents/fakemap/rspec$ rspec block.rb > /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': ../code/fmutil.rb:145: class/module name must be CONSTANT (SyntaxError) > from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require' > from /home/rich/Documents/fakemap/rspec/block.rb:1 > from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' > from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' > from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' > from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' > from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' > from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' > from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' > from /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' > from /var/lib/gems/1.8/rspec:19 > rich at richlaptop2:~/Documents/fakemap/rspec$ > > This is for code that was ENTIRELY unchanged > from a previous successful test. > > Now any use that I make of rspec produces these errors! > > Has anyone seen behavior like this? > Is theis a known bug with rspec? What's on line 1 of block.rb? From rich at gandalf.ws Sun Jan 16 19:48:13 2011 From: rich at gandalf.ws (Rich Price) Date: Sun, 16 Jan 2011 18:48:13 -0600 Subject: [rspec-users] Sudden rspec problem In-Reply-To: References: <4D337568.1000203@gandalf.ws> Message-ID: <4D3391CD.3040108@gandalf.ws> The first two lines are: require '../code/fmutil.rb' require '../code/fmgrid.rb' I had not updated any gems between the test that worked and the one that produced these results. On 01/16/2011 05:51 PM, Mike Mazur wrote: > Hi, > > On Mon, Jan 17, 2011 at 06:47, Rich Price wrote: >> I was using rspec 2.4.0 to test some code >> and it was working fine then suddenly I get >> >> rich at richlaptop2:~/Documents/fakemap/rspec$ rspec block.rb >> /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': >> ../code/fmutil.rb:145: class/module name must be CONSTANT (SyntaxError) >> from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require' >> from /home/rich/Documents/fakemap/rspec/block.rb:1 >> from >> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> `load' >> from >> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> `load_spec_files' >> from >> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> `map' >> from >> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >> `load_spec_files' >> from >> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in >> `run' >> from >> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in >> `run_in_process' >> from >> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' >> from >> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in >> `autorun' >> from /var/lib/gems/1.8/rspec:19 >> rich at richlaptop2:~/Documents/fakemap/rspec$ >> >> This is for code that was ENTIRELY unchanged >> from a previous successful test. >> >> Now any use that I make of rspec produces these errors! >> >> Has anyone seen behavior like this? >> Is theis a known bug with rspec? > > I notice the error happens in rubygems/custom_require.rb and that > you're using rspec-core from a global gem directory. Could it be that > you upgraded some gems recently? Perhaps this gem is also a dependency > for your project and it has a bug. What does > /home/rich/Documents/fakemap/rspec/block.rb line 1 contain? > > Mike > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rich at gandalf.ws Sun Jan 16 20:10:31 2011 From: rich at gandalf.ws (Rich Price) Date: Sun, 16 Jan 2011 19:10:31 -0600 Subject: [rspec-users] Sudden rspec problem In-Reply-To: <4D3391CD.3040108@gandalf.ws> References: <4D337568.1000203@gandalf.ws> <4D3391CD.3040108@gandalf.ws> Message-ID: <4D339707.3010407@gandalf.ws> OK - I found the problem. While correcting the spelling of a class name in fmutil.rb I lost the leading capital letter. Oh! The embarrassment! Thanks. On 01/16/2011 06:48 PM, Rich Price wrote: > The first two lines are: > require '../code/fmutil.rb' > require '../code/fmgrid.rb' > > I had not updated any gems between the test that worked and the > one that produced these results. > > On 01/16/2011 05:51 PM, Mike Mazur wrote: >> Hi, >> >> On Mon, Jan 17, 2011 at 06:47, Rich Price wrote: >>> I was using rspec 2.4.0 to test some code >>> and it was working fine then suddenly I get >>> >>> rich at richlaptop2:~/Documents/fakemap/rspec$ rspec block.rb >>> /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in >>> `gem_original_require': >>> ../code/fmutil.rb:145: class/module name must be CONSTANT (SyntaxError) >>> from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require' >>> from /home/rich/Documents/fakemap/rspec/block.rb:1 >>> from >>> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >>> >>> `load' >>> from >>> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >>> >>> `load_spec_files' >>> from >>> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >>> >>> `map' >>> from >>> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in >>> >>> `load_spec_files' >>> from >>> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in >>> >>> `run' >>> from >>> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in >>> `run_in_process' >>> from >>> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' >>> >>> from >>> /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in >>> `autorun' >>> from /var/lib/gems/1.8/rspec:19 >>> rich at richlaptop2:~/Documents/fakemap/rspec$ >>> >>> This is for code that was ENTIRELY unchanged >>> from a previous successful test. >>> >>> Now any use that I make of rspec produces these errors! >>> >>> Has anyone seen behavior like this? >>> Is theis a known bug with rspec? >> >> I notice the error happens in rubygems/custom_require.rb and that >> you're using rspec-core from a global gem directory. Could it be that >> you upgraded some gems recently? Perhaps this gem is also a dependency >> for your project and it has a bug. What does >> /home/rich/Documents/fakemap/rspec/block.rb line 1 contain? >> >> Mike >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sun Jan 16 23:45:10 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 16 Jan 2011 22:45:10 -0600 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: References: Message-ID: On Jan 16, 2011, at 5:52 PM, Wilker wrote: > Hi guys, > > I launched some days ago a new project that aims to make the use of mocks > safer. > This is the URL of project: https://github.com/wilkerlucio/aidmock > > The basic idea is to make user define interfaces of classes, when user > defines the class interface (which is something like defining method > signatures on C or Java) Aidmock automatic generate some sanity check > specs, these specs will verify if class has the method defined, and if > it respect arity of interface. > > And more important, when user create mocks while developing specs, it > will verify all defined mocks, and check if they are respecting > defined interface. > > You can saw more about project motivation here(with some example of > why it exists): https://github.com/wilkerlucio/aidmock/wiki/Motivation > > This project is a kind of experimental one, with a different idea, and > any feedback will be really welcome. Hi Wilker, There have been numerous requests for a tool that would warn when mocking method that don't exist, and I think it is great that you are working on aidmock. In the Motivation wiki page, you say that you recommend using real objects instead of mocks in all cases. I don't agree with this, as an important basis for mock objects is the idea that we should mock roles, not objects [1]. I imagine that aidmock could work equally well with real objects and mock objects if there were a hook to tell a mock what interfaces it is allowed to stub. Something like: account = double('account').constrained_to(MyInterface) WDYT? [1] http://static.mockobjects.com/files/mockrolesnotobjects.pdf -------------- next part -------------- An HTML attachment was scrubbed... URL: From wilkerlucio at gmail.com Mon Jan 17 07:53:00 2011 From: wilkerlucio at gmail.com (Wilker) Date: Mon, 17 Jan 2011 09:53:00 -0300 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: References: Message-ID: You are right Dave, I was thinking about it, but with a different interface, like: Aidmock.double(Interface) but I mean your is cooler, and user will be able to apply mocks/stubs directly I will work on it today :) Thanks --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Mon, Jan 17, 2011 at 1:45 AM, David Chelimsky wrote: > On Jan 16, 2011, at 5:52 PM, Wilker wrote: > > Hi guys, > > I launched some days ago a new project that aims to make the use of mocks > safer. > This is the URL of project: https://github.com/wilkerlucio/aidmock > > The basic idea is to make user define interfaces of classes, when user > defines the class interface (which is something like defining method > signatures on C or Java) Aidmock automatic generate some sanity check > specs, these specs will verify if class has the method defined, and if > it respect arity of interface. > > And more important, when user create mocks while developing specs, it > will verify all defined mocks, and check if they are respecting > defined interface. > > You can saw more about project motivation here(with some example of > why it exists): https://github.com/wilkerlucio/aidmock/wiki/Motivation > > This project is a kind of experimental one, with a different idea, and > any feedback will be really welcome. > > > Hi Wilker, > > There have been numerous requests for a tool that would warn when mocking > method that don't exist, and I think it is great that you are working on > aidmock. > > In the Motivation wiki page, you say that you recommend using real objects > instead of mocks in all cases. I don't agree with this, as an important > basis for mock objects is the idea that we should mock roles, not objects > [1]. > > I imagine that aidmock could work equally well with real objects and mock > objects if there were a hook to tell a mock what interfaces it is allowed to > stub. Something like: > > account = double('account').constrained_to(MyInterface) > > WDYT? > > [1] http://static.mockobjects.com/files/mockrolesnotobjects.pdf > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wilkerlucio at gmail.com Mon Jan 17 10:11:35 2011 From: wilkerlucio at gmail.com (Wilker) Date: Mon, 17 Jan 2011 12:11:35 -0300 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: References: Message-ID: Dave, I just updated the gem and documentation, now supporting constrained_to on mocks :) You have any other suggestions for now? --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Mon, Jan 17, 2011 at 9:53 AM, Wilker wrote: > You are right Dave, > > I was thinking about it, but with a different interface, like: > > Aidmock.double(Interface) > > but I mean your is cooler, and user will be able to apply mocks/stubs > directly > > I will work on it today :) > > Thanks > --- > Wilker L?cio > http://about.me/wilkerlucio/bio > Kajabi Consultant > +55 81 82556600 > > > > On Mon, Jan 17, 2011 at 1:45 AM, David Chelimsky wrote: > >> On Jan 16, 2011, at 5:52 PM, Wilker wrote: >> >> Hi guys, >> >> I launched some days ago a new project that aims to make the use of mocks >> safer. >> This is the URL of project: https://github.com/wilkerlucio/aidmock >> >> The basic idea is to make user define interfaces of classes, when user >> defines the class interface (which is something like defining method >> signatures on C or Java) Aidmock automatic generate some sanity check >> specs, these specs will verify if class has the method defined, and if >> it respect arity of interface. >> >> And more important, when user create mocks while developing specs, it >> will verify all defined mocks, and check if they are respecting >> defined interface. >> >> You can saw more about project motivation here(with some example of >> why it exists): https://github.com/wilkerlucio/aidmock/wiki/Motivation >> >> This project is a kind of experimental one, with a different idea, and >> any feedback will be really welcome. >> >> >> Hi Wilker, >> >> There have been numerous requests for a tool that would warn when mocking >> method that don't exist, and I think it is great that you are working on >> aidmock. >> >> In the Motivation wiki page, you say that you recommend using real objects >> instead of mocks in all cases. I don't agree with this, as an important >> basis for mock objects is the idea that we should mock roles, not objects >> [1]. >> >> I imagine that aidmock could work equally well with real objects and mock >> objects if there were a hook to tell a mock what interfaces it is allowed to >> stub. Something like: >> >> account = double('account').constrained_to(MyInterface) >> >> WDYT? >> >> [1] http://static.mockobjects.com/files/mockrolesnotobjects.pdf >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From solrane.altari at gmail.com Mon Jan 17 10:34:57 2011 From: solrane.altari at gmail.com (Edward Monical-Vuylsteke) Date: Mon, 17 Jan 2011 09:34:57 -0600 Subject: [rspec-users] autospec on rails keep rerunning on failed case, and never stop. In-Reply-To: References: Message-ID: Have you configured your .autotest file with an Autotest hook? This is from the cucumber Autotest Integration, but, I'm not certain if its appropriate for Rails 1.3.3 Autotest.add_hook :initialize do |at| # Ignore files in tmp/ at.add_exception %r%^\./tmp% end I was running into the same issue myself. On Fri, Jan 14, 2011 at 10:31 AM, Nori Hamamoto wrote: > Additionally, this problem doesn't happen when I use autospec on simple > ruby rb file, but only happens with rails. > > > On Fri, Jan 14, 2011 at 12:29 PM, Nori Hamamoto wrote: > >> Hi there, >> >> I met a problem when I'm using RSpec(1.3.0) on rails. >> I installed rspec(1.3.1) and rspec-rails(1.3.3) installed through rails >> script/plugin install from github. >> >> I run autospec at $RAILS_ROOT, and if the test goes successful, it's no >> problem, but once I get failed case, it keep running the test repeatedly and >> never stop. >> I'm using MacOSX, so I'm configured it connecting to Growl to show the >> test result. Therefore, the failed indication on growl is also shown up >> repeatedly until I stop autspec process. >> >> All configuration I did is that I made .autotest file on ~ directory, and >> put the following one line in it. >> >> require 'autotest/growl' >> >> Also, I installed RSpec using gem intall to my Mac. >> >> Do you have any idea? >> >> Thank you, >> Nori >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- "Nothing great can be done without small steps." --- Edward Monical-Vuylsteke -------------- next part -------------- An HTML attachment was scrubbed... URL: From antsmailinglist at gmail.com Mon Jan 17 10:48:04 2011 From: antsmailinglist at gmail.com (Ants Pants) Date: Mon, 17 Jan 2011 16:48:04 +0100 Subject: [rspec-users] Best Practice for Controllers Message-ID: Hello all, >From what I've seen, this type of question doesn't really seem to get an answer on this list as most of the replies relate to failures of RSpec. If this is the case, where is the best place to go to get advice about best practices etc? I have a question about best practice. In some of my controllers only an admin user can perform edit, update, show etc. So I have a before filter in those controllers; ApplicationController#authorise_is_admin The ApplicationController#authorise_is_admin throws an AccessDenied exception and that is caught in ApplicationController#access_denied My question is, in the spec for the calling controller, let's say ProductGroups, what should I spec? I have a context "user is admin" and that's easy to spec, but the context "user is not admin" is where I'm stuck as no actions are performed in that controller but I would just like to cover that failure somehow. Any advice? Thanks in advance. -ants -------------- next part -------------- An HTML attachment was scrubbed... URL: From dk at structuralartistry.com Mon Jan 17 11:16:31 2011 From: dk at structuralartistry.com (David Kahn) Date: Mon, 17 Jan 2011 10:16:31 -0600 Subject: [rspec-users] Best Practice for Controllers In-Reply-To: References: Message-ID: On Mon, Jan 17, 2011 at 9:48 AM, Ants Pants wrote: > Hello all, > > From what I've seen, this type of question doesn't really seem to get an > answer on this list as most of the replies relate to failures of RSpec. If > this is the case, where is the best place to go to get advice about best > practices etc? > > I have a question about best practice. In some of my controllers only an > admin user can perform edit, update, show etc. So I have a before filter in > those controllers; ApplicationController#authorise_is_admin > > The ApplicationController#authorise_is_admin throws an AccessDenied > exception and that is caught in ApplicationController#access_denied > > My question is, in the spec for the calling controller, let's say > ProductGroups, what should I spec? > > I have a context "user is admin" and that's easy to spec, but the context > "user is not admin" is where I'm stuck as no actions are performed in that > controller but I would just like to cover that failure somehow. > > Interesting question. I had the same dilemma and decided that it took too much effort and test code to test this at the controller level. What I do (and this may or may not work for you depending on your apps security needs), is to have an authorize method in the User model. It returns success or failure based on the controller and action passed. The model looks something like this: def authorize(controller_name, action_name) if self.role current_role = self.role.name else # guest user is empty user current_role = 'guest' end case controller_name when 'activations' if current_role != 'guest' return set_autorize_failure_value("You are already logged in to the system. If you are activating a new user please log out first and try again.") end return authorize_success_message when 'feedback_supports' if current_role == 'guest' || current_role == 'sysadmin' return set_autorize_failure_value(LOGIN_NOTICE) end return authorize_success_message ... end Then in the spec it is real easy: describe "user authorization - guest role" do it "is authorized to access certain pages only" do user = User.new user.authorize('activations', 'create')[:success].should == true user.authorize('home', 'index')[:success].should == false .... end end This might not be everyone's cup of tea and I am sure I can refactor and make this less verbose, but what I like is having the 'dna' of all my access rights app wide in one place. > Any advice? > > Thanks in advance. > > -ants > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anonymousleggingsgenie at gmail.com Thu Jan 13 16:53:33 2011 From: anonymousleggingsgenie at gmail.com (SpringChicken) Date: Thu, 13 Jan 2011 13:53:33 -0800 (PST) Subject: [rspec-users] Rspec Nested Resources: Can someone offer an 'update' example? Message-ID: <9b86302a-d67c-440e-9eda-985746b5866c@z5g2000yqb.googlegroups.com> Hi folks, I've just spent a day trying to write up a basic update spec for a nested resource - all without avail. I'm quite new to RSpec & not sure what I'm doing wrong. I can't seem to get a stub that recognises the required association to the parent object. I've tried factories and outright database calls, none of which seem to catch the should_receive. If anyone could offer a basic example of the nested equivalent of something like the following, I'd be very appreciative. it "updates the requested post" do Post.stub(:find).with("14") { mock_post } mock_post.should_receive(:update_attributes).with({'these' => 'params'}) put :update, :id => "14", :post => {'these' => 'params'} end Controller action here: def update @comment = Comment.find(params[:id]) respond_to do |format| if @comment.update_attributes(params[:comment]) flash[:notice] = 'Post successfully updated' format.html { redirect_to(@comment.post) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @comment.errors, :status => :unprocessable_entity } end end end From ruben.grunge84 at gmail.com Thu Jan 13 17:10:27 2011 From: ruben.grunge84 at gmail.com (rdavila) Date: Thu, 13 Jan 2011 14:10:27 -0800 (PST) Subject: [rspec-users] Problem with output at running specs Message-ID: <2210574f-a3bf-4c8d-9be8-1d6935100f71@b25g2000vbz.googlegroups.com> Hi folks, I'm using rspec-rails 1.3.3 with a rails 2.3.2 app, I'm setting up the test environment, an every time that I run the specs I get this weird output: http://codepad.org/3bGWsENn Do you know how I can get rid of this ugly output? I want to just view my spec output not sql related one. Thanks in advance. From Rob.aldred at stardotstar.com Fri Jan 14 05:07:06 2011 From: Rob.aldred at stardotstar.com (Rob Aldred) Date: Fri, 14 Jan 2011 10:07:06 +0000 Subject: [rspec-users] session variable not available in global before(:each, :type => :controller) Message-ID: <0C3EC70C-0C96-44D0-AF4F-EC158E864238@stardotstar.com> Hi, I'm refactoring some specs, in controller specs I have a before(:each) which sets up things required in the session, wanted to avoid duplication and put the initial setup global for each controller spec my before filter is... config.before(:each, :type => :controller) do #... session[:current_user] = @user session[:instance] = @instance #... end @user and @instance are also set in this before(:each) i've just hidden them for readability here I get the following error when running the controller tests undefined method `session' for nil:NilClass I would expect the global before callbacks to have the same things as the ones in the individual tests but I guess maybe they are loaded before the rails environment has been initialised? Thanks -- Rob Aldred Software Developer rob at stardotstar.com twitter: stardotstar 47 Newton Street, Manchester, M1 1FT T: +44 (0) 161 236 9740 ___________________________________________________ This email and any files or ideas transmitted within it are sent in confidence and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager at info at stardotstar.com From evanchaney at gmail.com Sun Jan 16 21:29:48 2011 From: evanchaney at gmail.com (Evan) Date: Sun, 16 Jan 2011 18:29:48 -0800 (PST) Subject: [rspec-users] Performance tests using Rspec Message-ID: 1) Know of any guides to writing performance tests using Rspec? 2) Does Rspec have the capability to run specs in benchmarking or profiling mode similar to the way Rails has performance tests that run in these modes (http://guides.rubyonrails.org/ performance_testing.html)? From dchelimsky at gmail.com Mon Jan 17 13:06:03 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 17 Jan 2011 12:06:03 -0600 Subject: [rspec-users] session variable not available in global before(:each, :type => :controller) In-Reply-To: <0C3EC70C-0C96-44D0-AF4F-EC158E864238@stardotstar.com> References: <0C3EC70C-0C96-44D0-AF4F-EC158E864238@stardotstar.com> Message-ID: On Fri, Jan 14, 2011 at 4:07 AM, Rob Aldred wrote: > Hi, I'm refactoring some specs, in controller specs I have a before(:each) which sets up things required in the session, wanted to avoid duplication and put the initial setup global for each controller spec > > my before filter is... > > config.before(:each, :type => :controller) do > ?#... > ?session[:current_user] = @user > ?session[:instance] = @instance > ?#... > end > > @user and @instance are also set in this before(:each) i've just hidden them for readability here > > I get the following error when running the controller tests > > undefined method `session' for nil:NilClass > I would expect the global before callbacks to have the same things as the ones in the individual tests but I guess maybe they are loaded before the rails environment has been initialised? That's correct. I think this is a bug. Please report to http://github.com/rspec/rspec-rails/issues. Thx, David From nick at deadorange.com Mon Jan 17 13:23:44 2011 From: nick at deadorange.com (Nick) Date: Mon, 17 Jan 2011 10:23:44 -0800 (PST) Subject: [rspec-users] Problem with output at running specs In-Reply-To: Message-ID: <12672258.177.1295288624300.JavaMail.geo-discussion-forums@yqhy19> On Saturday, January 15, 2011 7:56:48 PM UTC-5, rdavila wrote: > > Hi folks, I'm using rspec-rails 1.3.3 with a rails 2.3.2 app, I'm > setting up the test environment, an every time that I run the specs I > get this weird output: http://codepad.org/3bGWsENn > > Do you know how I can get rid of this ugly output? I just want to view > my spec output not sql related one. > > Thanks in advance. > Try recreating your test DB: $ rake db:test:prepare -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Mon Jan 17 13:33:27 2011 From: nick at deadorange.com (Nick) Date: Mon, 17 Jan 2011 10:33:27 -0800 (PST) Subject: [rspec-users] Best Practice for Controllers In-Reply-To: Message-ID: <25265696.20.1295289207522.JavaMail.geo-discussion-forums@yqng23> That behaviour exists in ApplicationController. Since ProductGroupsController inherits that behaviour from ApplicationController, the specs for ProductGroupsController should cover that behaviour. To keep your code DRY, create a shared example group that can be used in multiple controller specs. Eg: http://pastie.org/1470751 -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe at fixieconsulting.com Mon Jan 17 13:40:06 2011 From: joe at fixieconsulting.com (Joe Van Dyk) Date: Mon, 17 Jan 2011 10:40:06 -0800 Subject: [rspec-users] Using integrate_views for all controller specs Message-ID: Is there a way to always use integrate_views for all controller specs? I hate having to remember to insert that line into each one. Thanks, Joe From norisuke3 at gmail.com Mon Jan 17 14:07:56 2011 From: norisuke3 at gmail.com (Nori Hamamoto) Date: Mon, 17 Jan 2011 15:07:56 -0400 Subject: [rspec-users] autospec on rails keep rerunning on failed case, and never stop. In-Reply-To: References: Message-ID: Hi Edward, Thank you for your reply. I tried your suggestion put those configuration you mentioned in my .autotest file and now my .autotest is like this: require 'autotest/growl' Autotest.add_hook :initialize do |at| # Ignore files in tmp/ at.add_exception %r%^\./tmp% end but the same problem has happend to me. Nori On Mon, Jan 17, 2011 at 11:34 AM, Edward Monical-Vuylsteke < solrane.altari at gmail.com> wrote: > Have you configured your .autotest file with an Autotest hook? > > This is from the cucumber Autotest Integration, but, I'm not certain if its > appropriate for Rails 1.3.3 > > Autotest.add_hook :initialize do |at| > > # Ignore files in tmp/ > at.add_exception %r%^\./tmp% > end > > I was running into the same issue myself. > > On Fri, Jan 14, 2011 at 10:31 AM, Nori Hamamoto wrote: > >> Additionally, this problem doesn't happen when I use autospec on simple >> ruby rb file, but only happens with rails. >> >> >> On Fri, Jan 14, 2011 at 12:29 PM, Nori Hamamoto wrote: >> >>> Hi there, >>> >>> I met a problem when I'm using RSpec(1.3.0) on rails. >>> I installed rspec(1.3.1) and rspec-rails(1.3.3) installed through rails >>> script/plugin install from github. >>> >>> I run autospec at $RAILS_ROOT, and if the test goes successful, it's no >>> problem, but once I get failed case, it keep running the test repeatedly and >>> never stop. >>> I'm using MacOSX, so I'm configured it connecting to Growl to show the >>> test result. Therefore, the failed indication on growl is also shown up >>> repeatedly until I stop autspec process. >>> >>> All configuration I did is that I made .autotest file on ~ directory, and >>> put the following one line in it. >>> >>> require 'autotest/growl' >>> >>> Also, I installed RSpec using gem intall to my Mac. >>> >>> Do you have any idea? >>> >>> Thank you, >>> Nori >>> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > "Nothing great can be done without small steps." > > --- > Edward Monical-Vuylsteke > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From norisuke3 at gmail.com Mon Jan 17 14:14:47 2011 From: norisuke3 at gmail.com (Nori Hamamoto) Date: Mon, 17 Jan 2011 15:14:47 -0400 Subject: [rspec-users] autospec on rails keep rerunning on failed case, and never stop. In-Reply-To: References: Message-ID: I've removed my ~/.autotest, but the same problem keep happening. I originally used this file to configure it to connect to growl, so the growl has not shown up on my Mac's screen, but autospec in my console is keep repeating the test until I make the test success. Nori On Mon, Jan 17, 2011 at 3:07 PM, Nori Hamamoto wrote: > Hi Edward, > > Thank you for your reply. > I tried your suggestion put those configuration you mentioned in my > .autotest file and now my .autotest is like this: > > require 'autotest/growl' > > Autotest.add_hook :initialize do |at| > # Ignore files in tmp/ > at.add_exception %r%^\./tmp% > end > > but the same problem has happend to me. > Nori > > > On Mon, Jan 17, 2011 at 11:34 AM, Edward Monical-Vuylsteke < > solrane.altari at gmail.com> wrote: > >> Have you configured your .autotest file with an Autotest hook? >> >> This is from the cucumber Autotest Integration, but, I'm not certain if >> its appropriate for Rails 1.3.3 >> >> Autotest.add_hook :initialize do |at| >> >> >> # Ignore files in tmp/ >> at.add_exception %r%^\./tmp% >> end >> >> I was running into the same issue myself. >> >> On Fri, Jan 14, 2011 at 10:31 AM, Nori Hamamoto wrote: >> >>> Additionally, this problem doesn't happen when I use autospec on simple >>> ruby rb file, but only happens with rails. >>> >>> >>> On Fri, Jan 14, 2011 at 12:29 PM, Nori Hamamoto wrote: >>> >>>> Hi there, >>>> >>>> I met a problem when I'm using RSpec(1.3.0) on rails. >>>> I installed rspec(1.3.1) and rspec-rails(1.3.3) installed through rails >>>> script/plugin install from github. >>>> >>>> I run autospec at $RAILS_ROOT, and if the test goes successful, it's no >>>> problem, but once I get failed case, it keep running the test repeatedly and >>>> never stop. >>>> I'm using MacOSX, so I'm configured it connecting to Growl to show the >>>> test result. Therefore, the failed indication on growl is also shown up >>>> repeatedly until I stop autspec process. >>>> >>>> All configuration I did is that I made .autotest file on ~ directory, >>>> and put the following one line in it. >>>> >>>> require 'autotest/growl' >>>> >>>> Also, I installed RSpec using gem intall to my Mac. >>>> >>>> Do you have any idea? >>>> >>>> Thank you, >>>> Nori >>>> >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> >> -- >> "Nothing great can be done without small steps." >> >> --- >> Edward Monical-Vuylsteke >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon Jan 17 14:17:27 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 17 Jan 2011 13:17:27 -0600 Subject: [rspec-users] Performance tests using Rspec In-Reply-To: References: Message-ID: On Jan 16, 2011, at 8:29 PM, Evan wrote: > 1) Know of any guides to writing performance tests using Rspec? There's nothing built in as of yet, but you can do this pretty easily: require 'benchmark' RSpec::Matchers.define :take_less_than do |n| chain :seconds do; end match do |block| @elapsed = Benchmark.realtime do block.call end @elapsed <= n end end describe "addition" do it "runs fast" do expect do 10000.times { 1 + 2 } end.to take_less_than(0.001).seconds end end > 2) Does Rspec have the capability to run specs in benchmarking or > profiling mode similar to the way Rails has performance tests that run > in these modes (http://guides.rubyonrails.org/ > performance_testing.html)? There is a --profile command line switch: rspec spec --profile which gives you the 10 slowest running examples, but that includes time to run all the before, after, and around hooks as well. My guess is you'd be better off with the matcher above. HTH, David From dchelimsky at gmail.com Mon Jan 17 14:20:57 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 17 Jan 2011 13:20:57 -0600 Subject: [rspec-users] Using integrate_views for all controller specs In-Reply-To: References: Message-ID: <99DBDEB3-0339-4627-99ED-ABF76EF35A4B@gmail.com> On Jan 17, 2011, at 12:40 PM, Joe Van Dyk wrote: > Is there a way to always use integrate_views for all controller specs? > I hate having to remember to insert that line into each one. # rspec-rails-1 Spec::Runner.configure do |c| c.integrate_views end # rspec-rails-2 # Doc'd on http://relishapp.com/rspec/rspec-rails/v/2-4/dir/controller-specs/render-views. RSpec::configure do |c| c.render_views end HTH, David From rtlechow at gmail.com Mon Jan 17 14:42:15 2011 From: rtlechow at gmail.com (R.T.) Date: Mon, 17 Jan 2011 14:42:15 -0500 Subject: [rspec-users] autospec on rails keep rerunning on failed case, and never stop. In-Reply-To: References: Message-ID: Using SQLite? Might be picking up the journal. Try something like: at.add_exception %r{^./db/test\.sqlite3-journal} On Mon, Jan 17, 2011 at 2:07 PM, Nori Hamamoto wrote: > Hi Edward, > > Thank you for your reply. > I tried your suggestion put those configuration you mentioned in my > .autotest file and now my .autotest is like this: > > require 'autotest/growl' > > Autotest.add_hook :initialize do |at| > # Ignore files in tmp/ > at.add_exception %r%^\./tmp% > end > > but the same problem has happend to me. > Nori > > > On Mon, Jan 17, 2011 at 11:34 AM, Edward Monical-Vuylsteke < > solrane.altari at gmail.com> wrote: > >> Have you configured your .autotest file with an Autotest hook? >> >> This is from the cucumber Autotest Integration, but, I'm not certain if >> its appropriate for Rails 1.3.3 >> >> Autotest.add_hook :initialize do |at| >> >> >> # Ignore files in tmp/ >> at.add_exception %r%^\./tmp% >> end >> >> I was running into the same issue myself. >> >> On Fri, Jan 14, 2011 at 10:31 AM, Nori Hamamoto wrote: >> >>> Additionally, this problem doesn't happen when I use autospec on simple >>> ruby rb file, but only happens with rails. >>> >>> >>> On Fri, Jan 14, 2011 at 12:29 PM, Nori Hamamoto wrote: >>> >>>> Hi there, >>>> >>>> I met a problem when I'm using RSpec(1.3.0) on rails. >>>> I installed rspec(1.3.1) and rspec-rails(1.3.3) installed through rails >>>> script/plugin install from github. >>>> >>>> I run autospec at $RAILS_ROOT, and if the test goes successful, it's no >>>> problem, but once I get failed case, it keep running the test repeatedly and >>>> never stop. >>>> I'm using MacOSX, so I'm configured it connecting to Growl to show the >>>> test result. Therefore, the failed indication on growl is also shown up >>>> repeatedly until I stop autspec process. >>>> >>>> All configuration I did is that I made .autotest file on ~ directory, >>>> and put the following one line in it. >>>> >>>> require 'autotest/growl' >>>> >>>> Also, I installed RSpec using gem intall to my Mac. >>>> >>>> Do you have any idea? >>>> >>>> Thank you, >>>> Nori >>>> >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> >> -- >> "Nothing great can be done without small steps." >> >> --- >> Edward Monical-Vuylsteke >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon Jan 17 14:43:17 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 17 Jan 2011 13:43:17 -0600 Subject: [rspec-users] Best Practice for Controllers In-Reply-To: References: Message-ID: <6E186B7A-25F9-40FE-825E-DF9C08A1160D@gmail.com> On Jan 17, 2011, at 10:16 AM, David Kahn wrote: > On Mon, Jan 17, 2011 at 9:48 AM, Ants Pants wrote: > Hello all, > > From what I've seen, this type of question doesn't really seem to get an answer on this list as most of the replies relate to failures of RSpec. If this is the case, where is the best place to go to get advice about best practices etc? > > I have a question about best practice. In some of my controllers only an admin user can perform edit, update, show etc. So I have a before filter in those controllers; ApplicationController#authorise_is_admin > > The ApplicationController#authorise_is_admin throws an AccessDenied exception and that is caught in ApplicationController#access_denied > > My question is, in the spec for the calling controller, let's say ProductGroups, what should I spec? > > I have a context "user is admin" and that's easy to spec, but the context "user is not admin" is where I'm stuck as no actions are performed in that controller but I would just like to cover that failure somehow. > > Interesting question. I had the same dilemma and decided that it took too much effort and test code to test this at the controller level. What I do (and this may or may not work for you depending on your apps security needs), is to have an authorize method in the User model. It returns success or failure based on the controller and action passed. The model looks something like this: > > def authorize(controller_name, action_name) > if self.role > current_role = self.role.name > else > # guest user is empty user > current_role = 'guest' > end > > > case controller_name > when 'activations' > if current_role != 'guest' > return set_autorize_failure_value("You are already logged in to the system. If you are activating a new user please log out first and try again.") > end > return authorize_success_message > > when 'feedback_supports' > if current_role == 'guest' || current_role == 'sysadmin' > return set_autorize_failure_value(LOGIN_NOTICE) > end > return authorize_success_message > ... > > end > > Then in the spec it is real easy: > > describe "user authorization - guest role" do > it "is authorized to access certain pages only" do > user = User.new > user.authorize('activations', 'create')[:success].should == true > user.authorize('home', 'index')[:success].should == false > > .... > > end > end > > This might not be everyone's cup of tea and I am sure I can refactor and make this less verbose, but what I like is having the 'dna' of all my access rights app wide in one place. Definitely agree with the idea of keeping decisions in one place. I don't really like the idea of 'controllers' living inside a model, but change 'controller_name' to 'resource_collection_name' and that solves that problem. I would still want to specify that the controller asks the user for authorization. WDYT? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon Jan 17 14:47:49 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 17 Jan 2011 13:47:49 -0600 Subject: [rspec-users] Rspec Nested Resources: Can someone offer an 'update' example? In-Reply-To: <9b86302a-d67c-440e-9eda-985746b5866c@z5g2000yqb.googlegroups.com> References: <9b86302a-d67c-440e-9eda-985746b5866c@z5g2000yqb.googlegroups.com> Message-ID: <696432DA-3665-421A-8B94-A2050B083C92@gmail.com> On Jan 13, 2011, at 3:53 PM, SpringChicken wrote: > Hi folks, > > I've just spent a day trying to write up a basic update spec for a > nested resource - all without avail. I'm quite new to RSpec & not sure > what I'm doing wrong. I can't seem to get a stub that recognises the > required association to the parent object. I've tried factories and > outright database calls, none of which seem to catch the > should_receive. If anyone could offer a basic example of the nested > equivalent of something like the following, I'd be very appreciative. > > it "updates the requested post" do > Post.stub(:find).with("14") { mock_post } > mock_post.should_receive(:update_attributes).with({'these' > => 'params'}) > put :update, :id => "14", :post => {'these' => 'params'} > end > > Controller action here: > > def update > @comment = Comment.find(params[:id]) > respond_to do |format| > if @comment.update_attributes(params[:comment]) > flash[:notice] = 'Post successfully updated' > format.html { redirect_to(@comment.post) } > format.xml { head :ok } > else > format.html { render :action => "edit" } > format.xml { render :xml => @comment.errors, :status > => :unprocessable_entity } > end > end > > end That looks like it should work. What's the failure message you're getting? From solrane.altari at gmail.com Mon Jan 17 15:00:04 2011 From: solrane.altari at gmail.com (Edward Monical-Vuylsteke) Date: Mon, 17 Jan 2011 14:00:04 -0600 Subject: [rspec-users] autospec on rails keep rerunning on failed case, and never stop. In-Reply-To: References: Message-ID: I think there is a fuller form which loops over a lot more. Autotest.add_hook :initialize do |autotest| %w{.git .svn .hg .DS_Store ._* vendor tmp log doc}.each do |exception| autotest.add_exception(exception) end end This I found on the Getting started with Autotest. I'm really junior at this, but, when I get home, I can see if I can't find my complete Autotest file and post it. I just googled a lot to find it... and, I really don't know all of the potentially created files for Rails 2 apps. I started with Rails 3. On Mon, Jan 17, 2011 at 1:42 PM, R.T. wrote: > Using SQLite? Might be picking up the journal. Try something like: > > at.add_exception %r{^./db/test\.sqlite3-journal} > > > On Mon, Jan 17, 2011 at 2:07 PM, Nori Hamamoto wrote: > >> Hi Edward, >> >> Thank you for your reply. >> I tried your suggestion put those configuration you mentioned in my >> .autotest file and now my .autotest is like this: >> >> require 'autotest/growl' >> >> Autotest.add_hook :initialize do |at| >> # Ignore files in tmp/ >> at.add_exception %r%^\./tmp% >> end >> >> but the same problem has happend to me. >> Nori >> >> >> On Mon, Jan 17, 2011 at 11:34 AM, Edward Monical-Vuylsteke < >> solrane.altari at gmail.com> wrote: >> >>> Have you configured your .autotest file with an Autotest hook? >>> >>> This is from the cucumber Autotest Integration, but, I'm not certain if >>> its appropriate for Rails 1.3.3 >>> >>> Autotest.add_hook :initialize do |at| >>> >>> >>> >>> # Ignore files in tmp/ >>> at.add_exception %r%^\./tmp% >>> end >>> >>> I was running into the same issue myself. >>> >>> On Fri, Jan 14, 2011 at 10:31 AM, Nori Hamamoto wrote: >>> >>>> Additionally, this problem doesn't happen when I use autospec on simple >>>> ruby rb file, but only happens with rails. >>>> >>>> >>>> On Fri, Jan 14, 2011 at 12:29 PM, Nori Hamamoto wrote: >>>> >>>>> Hi there, >>>>> >>>>> I met a problem when I'm using RSpec(1.3.0) on rails. >>>>> I installed rspec(1.3.1) and rspec-rails(1.3.3) installed through rails >>>>> script/plugin install from github. >>>>> >>>>> I run autospec at $RAILS_ROOT, and if the test goes successful, it's no >>>>> problem, but once I get failed case, it keep running the test repeatedly and >>>>> never stop. >>>>> I'm using MacOSX, so I'm configured it connecting to Growl to show the >>>>> test result. Therefore, the failed indication on growl is also shown up >>>>> repeatedly until I stop autspec process. >>>>> >>>>> All configuration I did is that I made .autotest file on ~ directory, >>>>> and put the following one line in it. >>>>> >>>>> require 'autotest/growl' >>>>> >>>>> Also, I installed RSpec using gem intall to my Mac. >>>>> >>>>> Do you have any idea? >>>>> >>>>> Thank you, >>>>> Nori >>>>> >>>> >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> >>> >>> >>> -- >>> "Nothing great can be done without small steps." >>> >>> --- >>> Edward Monical-Vuylsteke >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- "Nothing great can be done without small steps." --- Edward Monical-Vuylsteke -------------- next part -------------- An HTML attachment was scrubbed... URL: From norisuke3 at gmail.com Mon Jan 17 15:10:35 2011 From: norisuke3 at gmail.com (Nori Hamamoto) Date: Mon, 17 Jan 2011 16:10:35 -0400 Subject: [rspec-users] autospec on rails keep rerunning on failed case, and never stop. In-Reply-To: References: Message-ID: Oh, I see. What I understand from you guys' suggestion is that there is a possibility of autotest picking up updated files unnecessarily somewhere in my rails app directory, right? So, I tried to make the exceptions suit to my environment, and the following: Autotest.add_hook :initialize do |at| at.add_exception %r{^\./db} at.add_exception %r{^\./log} end made the unnecessary repetition stopped. You guys gave me the idea of it. Thank you, Nori On Mon, Jan 17, 2011 at 4:00 PM, Edward Monical-Vuylsteke < solrane.altari at gmail.com> wrote: > I think there is a fuller form which loops over a lot more. > > Autotest.add_hook :initialize do |autotest| > > %w{.git .svn .hg .DS_Store ._* vendor tmp log doc}.each do |exception| > > autotest.add_exception(exception) > end > end > > This I found on the Getting started with Autotest. I'm really junior at > this, but, when I get home, I can see if I can't find my complete Autotest > file and post it. I just googled a lot to find it... and, I really don't > know all of the potentially created files for Rails 2 apps. I started with > Rails 3. > > > > On Mon, Jan 17, 2011 at 1:42 PM, R.T. wrote: > >> Using SQLite? Might be picking up the journal. Try something like: >> >> at.add_exception %r{^./db/test\.sqlite3-journal} >> >> >> On Mon, Jan 17, 2011 at 2:07 PM, Nori Hamamoto wrote: >> >>> Hi Edward, >>> >>> Thank you for your reply. >>> I tried your suggestion put those configuration you mentioned in my >>> .autotest file and now my .autotest is like this: >>> >>> require 'autotest/growl' >>> >>> Autotest.add_hook :initialize do |at| >>> # Ignore files in tmp/ >>> at.add_exception %r%^\./tmp% >>> end >>> >>> but the same problem has happend to me. >>> Nori >>> >>> >>> On Mon, Jan 17, 2011 at 11:34 AM, Edward Monical-Vuylsteke < >>> solrane.altari at gmail.com> wrote: >>> >>>> Have you configured your .autotest file with an Autotest hook? >>>> >>>> This is from the cucumber Autotest Integration, but, I'm not certain if >>>> its appropriate for Rails 1.3.3 >>>> >>>> Autotest.add_hook :initialize do |at| >>>> >>>> >>>> >>>> >>>> # Ignore files in tmp/ >>>> at.add_exception %r%^\./tmp% >>>> end >>>> >>>> I was running into the same issue myself. >>>> >>>> On Fri, Jan 14, 2011 at 10:31 AM, Nori Hamamoto wrote: >>>> >>>>> Additionally, this problem doesn't happen when I use autospec on simple >>>>> ruby rb file, but only happens with rails. >>>>> >>>>> >>>>> On Fri, Jan 14, 2011 at 12:29 PM, Nori Hamamoto wrote: >>>>> >>>>>> Hi there, >>>>>> >>>>>> I met a problem when I'm using RSpec(1.3.0) on rails. >>>>>> I installed rspec(1.3.1) and rspec-rails(1.3.3) installed through >>>>>> rails script/plugin install from github. >>>>>> >>>>>> I run autospec at $RAILS_ROOT, and if the test goes successful, it's >>>>>> no problem, but once I get failed case, it keep running the test repeatedly >>>>>> and never stop. >>>>>> I'm using MacOSX, so I'm configured it connecting to Growl to show the >>>>>> test result. Therefore, the failed indication on growl is also shown up >>>>>> repeatedly until I stop autspec process. >>>>>> >>>>>> All configuration I did is that I made .autotest file on ~ directory, >>>>>> and put the following one line in it. >>>>>> >>>>>> require 'autotest/growl' >>>>>> >>>>>> Also, I installed RSpec using gem intall to my Mac. >>>>>> >>>>>> Do you have any idea? >>>>>> >>>>>> Thank you, >>>>>> Nori >>>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> >>>> >>>> >>>> -- >>>> "Nothing great can be done without small steps." >>>> >>>> --- >>>> Edward Monical-Vuylsteke >>>> >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > "Nothing great can be done without small steps." > > --- > Edward Monical-Vuylsteke > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rfwatson at gmail.com Mon Jan 17 17:14:06 2011 From: rfwatson at gmail.com (Rob Watson) Date: Mon, 17 Jan 2011 22:14:06 +0000 Subject: [rspec-users] Redis and RSpec: Redis returning wildly inconsistent results Message-ID: Hi list I use Redis heavily in my application, and perform all of my unit testing using RSpec. So very often during my tests, I am hitting Redis repeatedly. I find that Redis repeatedly returns inconsistent and unexpected values for keys in my test environment. So every time I run a suite of specs, a few of them fail, seemingly randomly. The specs are usually very simple, and often just testing the contents of simple string keys in Redis. The results *seem* like they might come from a different object or instance variable of the same type/name: so they're always seemingly valid values, but don't actually relate to the spec currently being performed. So the spec fails. This is really reducing the value of my tests, because I can never tell if they're really failing or not without digging into them. I've tried all sorts of things to fix this so far, including setting the :thread_safe option for Redis in my test environment (no difference), and forcing a reconnection to Redis before each suite of specs (no difference). I'm pretty sure this is a problem with the connection between RSpec and Redis, or some kind of threading issue, but I can't be 100% sure even of that. I'm at a little bit of a loss. Anybody experienced anything similar? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ruben.grunge84 at gmail.com Mon Jan 17 17:43:13 2011 From: ruben.grunge84 at gmail.com (=?UTF-8?B?UnViw6luIETDoXZpbGE=?=) Date: Mon, 17 Jan 2011 17:43:13 -0500 Subject: [rspec-users] Problem with output at running specs In-Reply-To: <12672258.177.1295288624300.JavaMail.geo-discussion-forums@yqhy19> References: <12672258.177.1295288624300.JavaMail.geo-discussion-forums@yqhy19> Message-ID: Hi Nick, I get the same result after recreating the database. Thanks. From luislavena at gmail.com Mon Jan 17 18:13:15 2011 From: luislavena at gmail.com (Luis Lavena) Date: Mon, 17 Jan 2011 20:13:15 -0300 Subject: [rspec-users] Redis and RSpec: Redis returning wildly inconsistent results In-Reply-To: References: Message-ID: On Mon, Jan 17, 2011 at 7:14 PM, Rob Watson wrote: > Hi list > > I find that Redis repeatedly returns inconsistent and unexpected values for keys in my test environment. So every time I > run a suite of specs, a few of them fail, seemingly randomly. The specs are usually very simple, and often just testing > the contents of simple string keys in Redis. The results *seem* like they might come from a different object or instance > variable of the same type/name: so they're always seemingly valid values, but don't actually relate to the spec currently > being performed. So the spec fails. > [snip] > Anybody experienced anything similar? This happened to me but before I setup redis to use a different database for my test environment. I have a specific redis.yml that contains this: development: url: redis://localhost:6769/0 test: url: redis://localhost:6769/1 In that way, databases are keep separated from each other. It is also important that you flush all the keys of your redis instance between tests. Similar to what RSpec does for your database, you need to perform it for redis. I do it using a before(:each) { $redis.flushall } Just to ensure integrity and no leftover from my previous test. Will be great if you can show a little bit about your specs (exact spec code) and configuration so we can try replicate. Sometimes the error is there, but hidden somewhere else. -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From mmazur at gmail.com Mon Jan 17 18:54:09 2011 From: mmazur at gmail.com (Mike Mazur) Date: Tue, 18 Jan 2011 07:54:09 +0800 Subject: [rspec-users] Rspec Nested Resources: Can someone offer an 'update' example? In-Reply-To: <9b86302a-d67c-440e-9eda-985746b5866c@z5g2000yqb.googlegroups.com> References: <9b86302a-d67c-440e-9eda-985746b5866c@z5g2000yqb.googlegroups.com> Message-ID: Hi, On Fri, Jan 14, 2011 at 05:53, SpringChicken wrote: > I've just spent a day trying to write up a basic update spec for a > nested resource - all without avail. I'm quite new to RSpec & not sure > what I'm doing wrong. I can't seem to get a stub that recognises the > required association to the parent object. I've tried factories and > outright database calls, none of which seem to catch the > should_receive. If anyone could offer a basic example of the nested > equivalent of something like the following, I'd be very appreciative. > > ? ? ? ?it "updates the requested post" do > ? ? ? ? ?Post.stub(:find).with("14") { mock_post } > ? ? ? ? ?mock_post.should_receive(:update_attributes).with({'these' > => 'params'}) > ? ? ? ? ?put :update, :id => "14", :post => {'these' => 'params'} > ? ? ? ?end > > Controller action here: > > ?def update > ? ?@comment = Comment.find(params[:id]) > ? ?respond_to do |format| > ? ? ?if @comment.update_attributes(params[:comment]) > ? ? ? ?flash[:notice] = 'Post successfully updated' > ? ? ? ?format.html { redirect_to(@comment.post) } > ? ? ? ?format.xml ?{ head :ok } > ? ? ?else > ? ? ? ?format.html { render :action => "edit" } > ? ? ? ?format.xml ?{ render :xml => @comment.errors, :status > => :unprocessable_entity } > ? ? ?end > ? ?end > > ?end In your spec you are stubbing Post so that Post.find(14) returns mock_post. Then you pass 14 as the :id parameter to the update action. In the update action, you use the :id parameter to find a *Comment* not a Post. So, mock_post is never actually used and the should_receive is thus never triggered. Mike From antsmailinglist at gmail.com Tue Jan 18 03:30:22 2011 From: antsmailinglist at gmail.com (Ants Pants) Date: Tue, 18 Jan 2011 09:30:22 +0100 Subject: [rspec-users] Best Practice for Controllers In-Reply-To: <6E186B7A-25F9-40FE-825E-DF9C08A1160D@gmail.com> References: <6E186B7A-25F9-40FE-825E-DF9C08A1160D@gmail.com> Message-ID: When I read the David Kahn's response, I thought it strange to have controller code in the model and was going to query him on it so I'm glad that others think the same. As for Nick's response, I will look into it_behaves_like (I remember seeing that in the book with a pizza example) It sounds good to me. Thanks for the replies. -ants On 17 January 2011 20:43, David Chelimsky wrote: > On Jan 17, 2011, at 10:16 AM, David Kahn wrote: > > On Mon, Jan 17, 2011 at 9:48 AM, Ants Pants wrote: > >> Hello all, >> >> From what I've seen, this type of question doesn't really seem to get an >> answer on this list as most of the replies relate to failures of RSpec. If >> this is the case, where is the best place to go to get advice about best >> practices etc? >> >> I have a question about best practice. In some of my controllers only an >> admin user can perform edit, update, show etc. So I have a before filter in >> those controllers; ApplicationController#authorise_is_admin >> >> The ApplicationController#authorise_is_admin throws an AccessDenied >> exception and that is caught in ApplicationController#access_denied >> >> My question is, in the spec for the calling controller, let's say >> ProductGroups, what should I spec? >> >> I have a context "user is admin" and that's easy to spec, but the context >> "user is not admin" is where I'm stuck as no actions are performed in that >> controller but I would just like to cover that failure somehow. >> >> Interesting question. I had the same dilemma and decided that it took too > much effort and test code to test this at the controller level. What I do > (and this may or may not work for you depending on your apps security > needs), is to have an authorize method in the User model. It returns success > or failure based on the controller and action passed. The model looks > something like this: > > def authorize(controller_name, action_name) > if self.role > current_role = self.role.name > else > # guest user is empty user > current_role = 'guest' > end > > > case controller_name > when 'activations' > if current_role != 'guest' > return set_autorize_failure_value("You are already logged in to the > system. If you are activating a new user please log out first and try > again.") > end > return authorize_success_message > > when 'feedback_supports' > if current_role == 'guest' || current_role == 'sysadmin' > return set_autorize_failure_value(LOGIN_NOTICE) > end > return authorize_success_message > ... > > end > > Then in the spec it is real easy: > > describe "user authorization - guest role" do > it "is authorized to access certain pages only" do > user = User.new > user.authorize('activations', 'create')[:success].should == true > user.authorize('home', 'index')[:success].should == false > > .... > > end > end > > This might not be everyone's cup of tea and I am sure I can refactor and > make this less verbose, but what I like is having the 'dna' of all my access > rights app wide in one place. > > > Definitely agree with the idea of keeping decisions in one place. I don't > really like the idea of 'controllers' living inside a model, but change > 'controller_name' to 'resource_collection_name' and that solves that > problem. > > I would still want to specify that the controller asks the user for > authorization. WDYT? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From phillipkoebbe at gmail.com Tue Jan 18 07:28:44 2011 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Tue, 18 Jan 2011 04:28:44 -0800 (PST) Subject: [rspec-users] Best Practice for Controllers In-Reply-To: References: <6E186B7A-25F9-40FE-825E-DF9C08A1160D@gmail.com> Message-ID: <83c4f1ae-2d90-4ee1-9aa8-396529b37fc6@fo10g2000vbb.googlegroups.com> > On 17 January 2011 20:43, David Chelimsky wrote: > > > On Jan 17, 2011, at 10:16 AM, David Kahn wrote: > > > On Mon, Jan 17, 2011 at 9:48 AM, Ants Pants wrote: > > >> Hello all, > > >> From what I've seen, this type of question doesn't really seem to get an > >> answer on this list as most of the replies relate to failures of RSpec. If > >> this is the case, where is the best place to go to get advice about best > >> practices etc? > > >> I have a question about best practice. In some of my controllers only an > >> admin user can perform edit, update, show etc. So I have a before filter in > >> those controllers; ApplicationController#authorise_is_admin > > >> The ApplicationController#authorise_is_admin throws an AccessDenied > >> exception and that is caught in ApplicationController#access_denied > > >> My question is, in the spec for the calling controller, let's say > >> ProductGroups, what should I spec? > > >> I have a context "user is admin" and that's easy to spec, but the context > >> "user is not admin" is where I'm stuck as no actions are performed in that > >> controller but I would just like to cover that failure somehow. > > >> Interesting question. I had the same dilemma and decided that it took too > > much effort and test code to test this at the controller level. What I do > > (and this may or may not work for you depending on your apps security > > needs), is to have an authorize method in the User model. It returns success > > or failure based on the controller and action passed. The model looks > > something like this: > > > ? def authorize(controller_name, action_name) > > ? ? if self.role > > ? ? ? current_role = self.role.name > > ? ? else > > ? ? ? # guest user is empty user > > ? ? ? current_role = 'guest' > > ? ? end > > > ? ? case controller_name > > ? ? when 'activations' > > ? ? ? if current_role != 'guest' > > ? ? ? ? return set_autorize_failure_value("You are already logged in to the > > system. If you are activating a new user please log out first and try > > again.") > > ? ? ? end > > ? ? ? return authorize_success_message > > > ? ? when 'feedback_supports' > > ? ? ? if current_role == 'guest' || current_role == 'sysadmin' > > ? ? ? ? return set_autorize_failure_value(LOGIN_NOTICE) > > ? ? ? end > > ? ? ? return authorize_success_message > > ... > > > end > > > Then in the spec it is real easy: > > > ? describe "user authorization - guest role" do > > ? ? it "is authorized to access certain pages only" do > > ? ? ? user = User.new > > ? ? ? user.authorize('activations', 'create')[:success].should == true > > ? ? ? user.authorize('home', 'index')[:success].should == false > > > ? ? .... > > > ? ? end > > ? end > > > This might not be everyone's cup of tea and I am sure I can refactor and > > make this less verbose, but what I like is having the 'dna' of all my access > > rights app wide in one place. > > > Definitely agree with the idea of keeping decisions in one place. I don't > > really like the idea of 'controllers' living inside a model, but change > > 'controller_name' to 'resource_collection_name' and that solves that > > problem. > > > I would still want to specify that the controller asks the user for > > authorization. WDYT? > On Jan 18, 2:30 am, Ants Pants wrote: > When I read the David Kahn's response, I thought it strange to have > controller code in the model and was going to query him on it so I'm glad > that others think the same. > > As for Nick's response, I will look into it_behaves_like (I remember seeing > that in the book with a pizza example) It sounds good to me. > > Thanks for the replies. > > -ants > One thing you might consider is to separate your admin functionality from your regular user functionality. This isn't for everyone, but it might work out well for you. I used to do it the way you are currently doing it, and it was okay until I ran into some situations in which a regular user and an admin could edit a resource, but only the admin could edit certain attributes. The logic in my controller started putting on a bit of weight. My practice now is to separate appropriate functionality into namespaced controllers. All features available for users not logged in go in the default namespace, all features requiring the user to be logged in (but not administrative) go in the / user/ namespace, and all features that require administrative rights go into the /admin/ namespace. Then, in each namespace, I create a base controller that does the authorization/redirection and all other controllers in the namespace inherit from it. Something like: https://gist.github.com/784363 Doing it this way does create seeming duplication in the views, but partials can be used very easily to deal with that. This method also more or less demands a menu structure that completely separates the functionality of each role, but in the projects that I've been working on, that has been a benefit. To have all of the role-based functionality separated in controllers and menus has provided clear lines that are easy to follow. In short, it has worked out really well. But, as always, your own mileage may vary. Peace. Phillip From dchelimsky at gmail.com Tue Jan 18 09:15:51 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 18 Jan 2011 08:15:51 -0600 Subject: [rspec-users] major release required? Message-ID: Hi all, Since the release of rspec-2.0, I've been following Rubygems' rational versioning [1] as closely as possible. Patch releases (2.4.x) have only had bug fixes, and minor releases (2.x.0) have had new features, but no (intentionally) backward incompatible changes, which should require a major (3.0) release. The autotest extension in rspec-2.0 prefixes the command it generates with 'bundle exec' if it sees a 'Gemfile' in the project root directory. It turns out that this is not universally helpful, so there was a request to have an opt-out. It also turns out that autotest has a bundler plugin that prefixes the command with 'bundle exec'. To use an autotest plugin, you just require it in a .autotest file in the project root. In this case: require 'autotest/bundler' I think the right thing to do is to rely on the autotest plugin, but I also think that this would require a 3.0 release, which feels a bit grand for this situation. My question to you is: do you think this warrants a major (3.0) release, or would it be an acceptable exception to the rule (assuming proper fanfare and documentation)? [1] http://docs.rubygems.org/read/chapter/7 Cheers, David From wilkerlucio at gmail.com Tue Jan 18 09:39:29 2011 From: wilkerlucio at gmail.com (Wilker) Date: Tue, 18 Jan 2011 11:39:29 -0300 Subject: [rspec-users] major release required? In-Reply-To: References: Message-ID: I mean since it's an acceptable exception, since the core parts of RSpec will still same, and autotest is somekind a "plus". Generating an major change, will make people think that RSpec was changed, with a lot of new features and etc... And it's not the case, in current case generate a major change for 3.0 will make a lot of confusion for users. WDYT? --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Tue, Jan 18, 2011 at 11:15 AM, David Chelimsky wrote: > Hi all, > > Since the release of rspec-2.0, I've been following Rubygems' rational > versioning [1] as closely as possible. Patch releases (2.4.x) have only had > bug fixes, and minor releases (2.x.0) have had new features, but no > (intentionally) backward incompatible changes, which should require a major > (3.0) release. > > The autotest extension in rspec-2.0 prefixes the command it generates with > 'bundle exec' if it sees a 'Gemfile' in the project root directory. It turns > out that this is not universally helpful, so there was a request to have an > opt-out. > > It also turns out that autotest has a bundler plugin that prefixes the > command with 'bundle exec'. To use an autotest plugin, you just require it > in a .autotest file in the project root. In this case: > > require 'autotest/bundler' > > I think the right thing to do is to rely on the autotest plugin, but I also > think that this would require a 3.0 release, which feels a bit grand for > this situation. My question to you is: do you think this warrants a major > (3.0) release, or would it be an acceptable exception to the rule (assuming > proper fanfare and documentation)? > > [1] http://docs.rubygems.org/read/chapter/7 > > Cheers, > David > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.hawkins at gmail.com Tue Jan 18 10:34:10 2011 From: martin.hawkins at gmail.com (Martin Hawkins) Date: Tue, 18 Jan 2011 15:34:10 +0000 Subject: [rspec-users] major release required? In-Reply-To: References: Message-ID: I agree with you that to create a major release for this too grand. Suitable fanfare and documentation is fine. On 18 January 2011 14:15, David Chelimsky wrote: > Hi all, > > Since the release of rspec-2.0, I've been following Rubygems' rational > versioning [1] as closely as possible. Patch releases (2.4.x) have only had > bug fixes, and minor releases (2.x.0) have had new features, but no > (intentionally) backward incompatible changes, which should require a major > (3.0) release. > > The autotest extension in rspec-2.0 prefixes the command it generates with > 'bundle exec' if it sees a 'Gemfile' in the project root directory. It turns > out that this is not universally helpful, so there was a request to have an > opt-out. > > It also turns out that autotest has a bundler plugin that prefixes the > command with 'bundle exec'. To use an autotest plugin, you just require it > in a .autotest file in the project root. In this case: > > require 'autotest/bundler' > > I think the right thing to do is to rely on the autotest plugin, but I also > think that this would require a 3.0 release, which feels a bit grand for > this situation. My question to you is: do you think this warrants a major > (3.0) release, or would it be an acceptable exception to the rule (assuming > proper fanfare and documentation)? > > [1] http://docs.rubygems.org/read/chapter/7 > > Cheers, > David > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rick.denatale at gmail.com Tue Jan 18 12:08:23 2011 From: rick.denatale at gmail.com (Rick DeNatale) Date: Tue, 18 Jan 2011 12:08:23 -0500 Subject: [rspec-users] major release required? In-Reply-To: References: Message-ID: On Tue, Jan 18, 2011 at 9:15 AM, David Chelimsky wrote: > Hi all, > > Since the release of rspec-2.0, I've been following Rubygems' rational versioning [1] as closely as possible. Patch releases (2.4.x) have only had bug fixes, and minor releases (2.x.0) have had new features, but no (intentionally) backward incompatible changes, which should require a major (3.0) release. > > The autotest extension in rspec-2.0 prefixes the command it generates with 'bundle exec' if it sees a 'Gemfile' in the project root directory. It turns out that this is not universally helpful, so there was a request to have an opt-out. > > It also turns out that autotest has a bundler plugin that prefixes the command with 'bundle exec'. To use an autotest plugin, you just require it in a .autotest file in the project root. In this case: > > ?require 'autotest/bundler' > > I think the right thing to do is to rely on the autotest plugin, but I also think that this would require a 3.0 release, which feels a bit grand for this situation. My question to you is: do you think this warrants a major (3.0) release, or would it be an acceptable exception to the rule (assuming proper fanfare and documentation)? Can't something be done here as a non-breaking change? I can see two things. 1) add the requested option, I think this is optional 2) in lib/autotest/rspec2.rb def using_bundler? File.exists?('./Gemfile') && !defined Autotest::Bundler # and also check for the option if you decide to do #1 end -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From dchelimsky at gmail.com Tue Jan 18 13:31:59 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 18 Jan 2011 12:31:59 -0600 Subject: [rspec-users] major release required? In-Reply-To: References: Message-ID: <959679BB-A576-45DB-BB31-7BC580393201@gmail.com> On Jan 18, 2011, at 11:08 AM, Rick DeNatale wrote: > On Tue, Jan 18, 2011 at 9:15 AM, David Chelimsky wrote: >> Hi all, >> >> Since the release of rspec-2.0, I've been following Rubygems' rational versioning [1] as closely as possible. Patch releases (2.4.x) have only had bug fixes, and minor releases (2.x.0) have had new features, but no (intentionally) backward incompatible changes, which should require a major (3.0) release. >> >> The autotest extension in rspec-2.0 prefixes the command it generates with 'bundle exec' if it sees a 'Gemfile' in the project root directory. It turns out that this is not universally helpful, so there was a request to have an opt-out. >> >> It also turns out that autotest has a bundler plugin that prefixes the command with 'bundle exec'. To use an autotest plugin, you just require it in a .autotest file in the project root. In this case: >> >> require 'autotest/bundler' >> >> I think the right thing to do is to rely on the autotest plugin, but I also think that this would require a 3.0 release, which feels a bit grand for this situation. My question to you is: do you think this warrants a major (3.0) release, or would it be an acceptable exception to the rule (assuming proper fanfare and documentation)? > > Can't something be done here as a non-breaking change? I can see two things. > > 1) add the requested option, I think this is optional > > 2) in lib/autotest/rspec2.rb > > def using_bundler? > File.exists?('./Gemfile') && !defined Autotest::Bundler # and > also check for the option if you decide to do #1 > end I actually did implement a --skip-bundler option (not yet released), but it has to be passed like this: autotest -- --skip-bundler Considering that this is a total hack, and that I'd be removing it at the next major release anyway, I really don't want to introduce a hack on top of a hack. I'd sooner do a 3.0 release now. > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Github: http://github.com/rubyredrick > Twitter: @RickDeNatale > WWR: http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn: http://www.linkedin.com/in/rickdenatale > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From wilkerlucio at gmail.com Tue Jan 18 15:03:03 2011 From: wilkerlucio at gmail.com (Wilker) Date: Tue, 18 Jan 2011 17:03:03 -0300 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: References: Message-ID: David Also, will be nice if in the future you and other mock frameworks authors support some kind of reflection on defined doubles (or even better, I can define an "Aidmock support guideline" to you implement support by yourselves). If you take a look at current RSpec Mocks driver on Aidmock[1] you will see that I need to use a lot of "instance_variable_get" to accomplish the work, and it has a serious risk to broke in any rspec-mocks update... WDYT? [1] https://github.com/wilkerlucio/aidmock/blob/master/lib/aidmock/frameworks/rspec.rb --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Mon, Jan 17, 2011 at 12:11 PM, Wilker wrote: > Dave, I just updated the gem and documentation, now supporting > constrained_to on mocks :) > > You have any other suggestions for now? > > --- > Wilker L?cio > http://about.me/wilkerlucio/bio > Kajabi Consultant > +55 81 82556600 > > > > On Mon, Jan 17, 2011 at 9:53 AM, Wilker wrote: > >> You are right Dave, >> >> I was thinking about it, but with a different interface, like: >> >> Aidmock.double(Interface) >> >> but I mean your is cooler, and user will be able to apply mocks/stubs >> directly >> >> I will work on it today :) >> >> Thanks >> --- >> Wilker L?cio >> http://about.me/wilkerlucio/bio >> Kajabi Consultant >> +55 81 82556600 >> >> >> >> On Mon, Jan 17, 2011 at 1:45 AM, David Chelimsky wrote: >> >>> On Jan 16, 2011, at 5:52 PM, Wilker wrote: >>> >>> Hi guys, >>> >>> I launched some days ago a new project that aims to make the use of mocks >>> safer. >>> This is the URL of project: https://github.com/wilkerlucio/aidmock >>> >>> The basic idea is to make user define interfaces of classes, when user >>> defines the class interface (which is something like defining method >>> signatures on C or Java) Aidmock automatic generate some sanity check >>> specs, these specs will verify if class has the method defined, and if >>> it respect arity of interface. >>> >>> And more important, when user create mocks while developing specs, it >>> will verify all defined mocks, and check if they are respecting >>> defined interface. >>> >>> You can saw more about project motivation here(with some example of >>> why it exists): https://github.com/wilkerlucio/aidmock/wiki/Motivation >>> >>> This project is a kind of experimental one, with a different idea, and >>> any feedback will be really welcome. >>> >>> >>> Hi Wilker, >>> >>> There have been numerous requests for a tool that would warn when mocking >>> method that don't exist, and I think it is great that you are working on >>> aidmock. >>> >>> In the Motivation wiki page, you say that you recommend using real >>> objects instead of mocks in all cases. I don't agree with this, as an >>> important basis for mock objects is the idea that we should mock roles, not >>> objects [1]. >>> >>> I imagine that aidmock could work equally well with real objects and mock >>> objects if there were a hook to tell a mock what interfaces it is allowed to >>> stub. Something like: >>> >>> account = double('account').constrained_to(MyInterface) >>> >>> WDYT? >>> >>> [1] http://static.mockobjects.com/files/mockrolesnotobjects.pdf >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rfwatson at gmail.com Tue Jan 18 15:13:24 2011 From: rfwatson at gmail.com (Rob Watson) Date: Tue, 18 Jan 2011 20:13:24 +0000 Subject: [rspec-users] Redis and RSpec: Redis returning wildly inconsistent results In-Reply-To: References: Message-ID: Thanks Luis I've just run my entire suite of specs 3 times and got 3 identical sets of results for the first time in a long time :-) On 17 January 2011 23:13, Luis Lavena wrote: > On Mon, Jan 17, 2011 at 7:14 PM, Rob Watson wrote: > > Hi list > > > > I find that Redis repeatedly returns inconsistent and unexpected values > for keys in my test environment. So every time I > > run a suite of specs, a few of them fail, seemingly randomly. The specs > are usually very simple, and often just testing > > the contents of simple string keys in Redis. The results *seem* like they > might come from a different object or instance > > variable of the same type/name: so they're always seemingly valid values, > but don't actually relate to the spec currently > > being performed. So the spec fails. > > [snip] > > Anybody experienced anything similar? > > This happened to me but before I setup redis to use a different > database for my test environment. > > I have a specific redis.yml that contains this: > > development: > url: redis://localhost:6769/0 > > test: > url: redis://localhost:6769/1 > > In that way, databases are keep separated from each other. > > It is also important that you flush all the keys of your redis > instance between tests. Similar to what RSpec does for your database, > you need to perform it for redis. > > I do it using a before(:each) { $redis.flushall } > > Just to ensure integrity and no leftover from my previous test. > > Will be great if you can show a little bit about your specs (exact > spec code) and configuration so we can try replicate. Sometimes the > error is there, but hidden somewhere else. > -- > Luis Lavena > AREA 17 > - > Perfection in design is achieved not when there is nothing more to add, > but rather when there is nothing more to take away. > Antoine de Saint-Exup?ry > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jan 18 17:12:23 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 18 Jan 2011 16:12:23 -0600 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: References: Message-ID: On Jan 18, 2011, at 2:03 PM, Wilker wrote: > David > > Also, will be nice if in the future you and other mock frameworks authors support some kind of reflection on defined doubles (or even better, I can define an "Aidmock support guideline" to you implement support by yourselves). If you take a look at current RSpec Mocks driver on Aidmock[1] you will see that I need to use a lot of "instance_variable_get" to accomplish the work, and it has a serious risk to broke in any rspec-mocks update... > > WDYT? I'd be willing to do that in the long run, but I'd want to see how aidmock shapes up in terms of acceptance and usage first. The last thing I want in rspec is a bunch of extra code that nobody is using. > [1] https://github.com/wilkerlucio/aidmock/blob/master/lib/aidmock/frameworks/rspec.rb > --- > Wilker L?cio > http://about.me/wilkerlucio/bio > Kajabi Consultant > +55 81 82556600 > > > > On Mon, Jan 17, 2011 at 12:11 PM, Wilker wrote: > Dave, I just updated the gem and documentation, now supporting constrained_to on mocks :) > > You have any other suggestions for now? > > --- > Wilker L?cio > http://about.me/wilkerlucio/bio > Kajabi Consultant > +55 81 82556600 > > > > On Mon, Jan 17, 2011 at 9:53 AM, Wilker wrote: > You are right Dave, > > I was thinking about it, but with a different interface, like: > > Aidmock.double(Interface) > > but I mean your is cooler, and user will be able to apply mocks/stubs directly > > I will work on it today :) > > Thanks > --- > Wilker L?cio > http://about.me/wilkerlucio/bio > Kajabi Consultant > +55 81 82556600 > > > > On Mon, Jan 17, 2011 at 1:45 AM, David Chelimsky wrote: > On Jan 16, 2011, at 5:52 PM, Wilker wrote: > >> Hi guys, >> >> I launched some days ago a new project that aims to make the use of mocks >> safer. >> This is the URL of project: https://github.com/wilkerlucio/aidmock >> >> The basic idea is to make user define interfaces of classes, when user >> defines the class interface (which is something like defining method >> signatures on C or Java) Aidmock automatic generate some sanity check >> specs, these specs will verify if class has the method defined, and if >> it respect arity of interface. >> >> And more important, when user create mocks while developing specs, it >> will verify all defined mocks, and check if they are respecting >> defined interface. >> >> You can saw more about project motivation here(with some example of >> why it exists): https://github.com/wilkerlucio/aidmock/wiki/Motivation >> >> This project is a kind of experimental one, with a different idea, and >> any feedback will be really welcome. > > Hi Wilker, > > There have been numerous requests for a tool that would warn when mocking method that don't exist, and I think it is great that you are working on aidmock. > > In the Motivation wiki page, you say that you recommend using real objects instead of mocks in all cases. I don't agree with this, as an important basis for mock objects is the idea that we should mock roles, not objects [1]. > > I imagine that aidmock could work equally well with real objects and mock objects if there were a hook to tell a mock what interfaces it is allowed to stub. Something like: > > account = double('account').constrained_to(MyInterface) > > WDYT? > > [1] http://static.mockobjects.com/files/mockrolesnotobjects.pdf > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From wilkerlucio at gmail.com Tue Jan 18 17:30:58 2011 From: wilkerlucio at gmail.com (Wilker) Date: Tue, 18 Jan 2011 19:30:58 -0300 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: References: Message-ID: Yeah, unfortunately I'm not receiving too much feedback about it for now, so, I'm just using for myself and trying to make it better. I will try to spread more and more the idea, so make more people wanna try it, its a different concept and I mean people still a little afraid to try it. But I will keep going on it, I really believe in the idea :) Thanks --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Tue, Jan 18, 2011 at 7:12 PM, David Chelimsky wrote: > On Jan 18, 2011, at 2:03 PM, Wilker wrote: > > David > > Also, will be nice if in the future you and other mock frameworks authors > support some kind of reflection on defined doubles (or even better, I can > define an "Aidmock support guideline" to you implement support by > yourselves). If you take a look at current RSpec Mocks driver on Aidmock[1] > you will see that I need to use a lot of "instance_variable_get" to > accomplish the work, and it has a serious risk to broke in any rspec-mocks > update... > > WDYT? > > > I'd be willing to do that in the long run, but I'd want to see how aidmock > shapes up in terms of acceptance and usage first. The last thing I want in > rspec is a bunch of extra code that nobody is using. > > [1] > https://github.com/wilkerlucio/aidmock/blob/master/lib/aidmock/frameworks/rspec.rb > --- > Wilker L?cio > http://about.me/wilkerlucio/bio > Kajabi Consultant > +55 81 82556600 > > > > On Mon, Jan 17, 2011 at 12:11 PM, Wilker wrote: > >> Dave, I just updated the gem and documentation, now supporting >> constrained_to on mocks :) >> >> You have any other suggestions for now? >> >> --- >> Wilker L?cio >> http://about.me/wilkerlucio/bio >> Kajabi Consultant >> +55 81 82556600 >> >> >> >> On Mon, Jan 17, 2011 at 9:53 AM, Wilker wrote: >> >>> You are right Dave, >>> >>> I was thinking about it, but with a different interface, like: >>> >>> Aidmock.double(Interface) >>> >>> but I mean your is cooler, and user will be able to apply mocks/stubs >>> directly >>> >>> I will work on it today :) >>> >>> Thanks >>> --- >>> Wilker L?cio >>> http://about.me/wilkerlucio/bio >>> Kajabi Consultant >>> +55 81 82556600 >>> >>> >>> >>> On Mon, Jan 17, 2011 at 1:45 AM, David Chelimsky wrote: >>> >>>> On Jan 16, 2011, at 5:52 PM, Wilker wrote: >>>> >>>> Hi guys, >>>> >>>> I launched some days ago a new project that aims to make the use of >>>> mocks >>>> safer. >>>> This is the URL of project: https://github.com/wilkerlucio/aidmock >>>> >>>> The basic idea is to make user define interfaces of classes, when user >>>> defines the class interface (which is something like defining method >>>> signatures on C or Java) Aidmock automatic generate some sanity check >>>> specs, these specs will verify if class has the method defined, and if >>>> it respect arity of interface. >>>> >>>> And more important, when user create mocks while developing specs, it >>>> will verify all defined mocks, and check if they are respecting >>>> defined interface. >>>> >>>> You can saw more about project motivation here(with some example of >>>> why it exists): https://github.com/wilkerlucio/aidmock/wiki/Motivation >>>> >>>> This project is a kind of experimental one, with a different idea, and >>>> any feedback will be really welcome. >>>> >>>> >>>> Hi Wilker, >>>> >>>> There have been numerous requests for a tool that would warn when >>>> mocking method that don't exist, and I think it is great that you are >>>> working on aidmock. >>>> >>>> In the Motivation wiki page, you say that you recommend using real >>>> objects instead of mocks in all cases. I don't agree with this, as an >>>> important basis for mock objects is the idea that we should mock roles, not >>>> objects [1]. >>>> >>>> I imagine that aidmock could work equally well with real objects and >>>> mock objects if there were a hook to tell a mock what interfaces it is >>>> allowed to stub. Something like: >>>> >>>> account = double('account').constrained_to(MyInterface) >>>> >>>> WDYT? >>>> >>>> [1] http://static.mockobjects.com/files/mockrolesnotobjects.pdf >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> >>> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jan 18 17:55:30 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 18 Jan 2011 16:55:30 -0600 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: References: Message-ID: <5A194410-F470-4116-BD4F-B2293BE617FF@gmail.com> On Jan 18, 2011, at 4:30 PM, Wilker wrote: > Yeah, unfortunately I'm not receiving too much feedback about it for now, so, I'm just using for myself and trying to make it better. I will try to spread more and more the idea, so make more people wanna try it, its a different concept and I mean people still a little afraid to try it. But I will keep going on it, I really believe in the idea :) Wilker: not sure what you were expecting, but you just announced it on this list 2 days ago :) Give it a bit more time. Everybody else: come on, people! Many of you have been asking for some sort of auditing tool for mocks that tell you when you're mocking stuff that doesn't exist, and Wilker here is finally offering a workable solution. Feedback, please :) Cheers, David > On Tue, Jan 18, 2011 at 7:12 PM, David Chelimsky wrote: > On Jan 18, 2011, at 2:03 PM, Wilker wrote: > >> David >> >> Also, will be nice if in the future you and other mock frameworks authors support some kind of reflection on defined doubles (or even better, I can define an "Aidmock support guideline" to you implement support by yourselves). If you take a look at current RSpec Mocks driver on Aidmock[1] you will see that I need to use a lot of "instance_variable_get" to accomplish the work, and it has a serious risk to broke in any rspec-mocks update... >> >> WDYT? > > I'd be willing to do that in the long run, but I'd want to see how aidmock shapes up in terms of acceptance and usage first. The last thing I want in rspec is a bunch of extra code that nobody is using. > >> [1] https://github.com/wilkerlucio/aidmock/blob/master/lib/aidmock/frameworks/rspec.rb >> --- >> Wilker L?cio >> http://about.me/wilkerlucio/bio >> Kajabi Consultant >> +55 81 82556600 >> >> >> >> On Mon, Jan 17, 2011 at 12:11 PM, Wilker wrote: >> Dave, I just updated the gem and documentation, now supporting constrained_to on mocks :) >> >> You have any other suggestions for now? >> >> --- >> Wilker L?cio >> http://about.me/wilkerlucio/bio >> Kajabi Consultant >> +55 81 82556600 >> >> >> >> On Mon, Jan 17, 2011 at 9:53 AM, Wilker wrote: >> You are right Dave, >> >> I was thinking about it, but with a different interface, like: >> >> Aidmock.double(Interface) >> >> but I mean your is cooler, and user will be able to apply mocks/stubs directly >> >> I will work on it today :) >> >> Thanks >> --- >> Wilker L?cio >> http://about.me/wilkerlucio/bio >> Kajabi Consultant >> +55 81 82556600 >> >> >> >> On Mon, Jan 17, 2011 at 1:45 AM, David Chelimsky wrote: >> On Jan 16, 2011, at 5:52 PM, Wilker wrote: >> >>> Hi guys, >>> >>> I launched some days ago a new project that aims to make the use of mocks >>> safer. >>> This is the URL of project: https://github.com/wilkerlucio/aidmock >>> >>> The basic idea is to make user define interfaces of classes, when user >>> defines the class interface (which is something like defining method >>> signatures on C or Java) Aidmock automatic generate some sanity check >>> specs, these specs will verify if class has the method defined, and if >>> it respect arity of interface. >>> >>> And more important, when user create mocks while developing specs, it >>> will verify all defined mocks, and check if they are respecting >>> defined interface. >>> >>> You can saw more about project motivation here(with some example of >>> why it exists): https://github.com/wilkerlucio/aidmock/wiki/Motivation >>> >>> This project is a kind of experimental one, with a different idea, and >>> any feedback will be really welcome. >> >> Hi Wilker, >> >> There have been numerous requests for a tool that would warn when mocking method that don't exist, and I think it is great that you are working on aidmock. >> >> In the Motivation wiki page, you say that you recommend using real objects instead of mocks in all cases. I don't agree with this, as an important basis for mock objects is the idea that we should mock roles, not objects [1]. >> >> I imagine that aidmock could work equally well with real objects and mock objects if there were a hook to tell a mock what interfaces it is allowed to stub. Something like: >> >> account = double('account').constrained_to(MyInterface) >> >> WDYT? >> >> [1] http://static.mockobjects.com/files/mockrolesnotobjects.pdf >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Jan 18 20:50:37 2011 From: lists at ruby-forum.com (Steve H.) Date: Wed, 19 Jan 2011 02:50:37 +0100 Subject: [rspec-users] require confusion Message-ID: I'm on Ubuntu 10.10, and I'm trying to figure out what I'm missing in regards to the require statement for RSpec's expectation library. Any code I see on the web requires rspec like: require 'spec/expectations' but to get it to work I always have to change it to require 'rspec/expectations' More of a curiosity than anything else. -- Posted via http://www.ruby-forum.com/. From katrina.owen at gmail.com Wed Jan 19 00:44:02 2011 From: katrina.owen at gmail.com (Katrina Owen) Date: Wed, 19 Jan 2011 06:44:02 +0100 Subject: [rspec-users] require confusion In-Reply-To: References: Message-ID: That sounds suspiciously like something on your system thinks it is RSpec 1.x whereas something else thinks it's RSpec 2.x. Have you tried using rvm to manage your rubies? http://rvm.beginrescueend.com/ What do 'gem list' and 'sudo gem list' tell you? Katrina On Wed, Jan 19, 2011 at 2:50 AM, Steve H. wrote: > I'm on Ubuntu 10.10, and I'm trying to figure out what I'm missing in > regards to the require statement for RSpec's expectation library. > > Any code I see on the web requires rspec like: > require 'spec/expectations' > > but to get it to work I always have to change it to > require 'rspec/expectations' > > More of a curiosity than anything else. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From patmaddox at me.com Wed Jan 19 01:28:58 2011 From: patmaddox at me.com (Pat Maddox) Date: Tue, 18 Jan 2011 22:28:58 -0800 Subject: [rspec-users] require confusion In-Reply-To: References: Message-ID: Yeah 'spec/*' is RSpec 1.x and 'rspec/*' is RSpec 2.x. The stuff you're seeing on the web is referring to RSpec 1.x. On Jan 18, 2011, at 9:44 PM, Katrina Owen wrote: > That sounds suspiciously like something on your system thinks it is > RSpec 1.x whereas something else thinks it's RSpec 2.x. > > Have you tried using rvm to manage your rubies? http://rvm.beginrescueend.com/ > > What do 'gem list' and 'sudo gem list' tell you? > > Katrina > > On Wed, Jan 19, 2011 at 2:50 AM, Steve H. wrote: >> I'm on Ubuntu 10.10, and I'm trying to figure out what I'm missing in >> regards to the require statement for RSpec's expectation library. >> >> Any code I see on the web requires rspec like: >> require 'spec/expectations' >> >> but to get it to work I always have to change it to >> require 'rspec/expectations' >> >> More of a curiosity than anything else. >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From patmaddox at me.com Wed Jan 19 01:30:56 2011 From: patmaddox at me.com (Pat Maddox) Date: Tue, 18 Jan 2011 22:30:56 -0800 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: References: Message-ID: <88595570-CE2E-46AD-AA56-B3039739EA1F@me.com> On Jan 18, 2011, at 2:30 PM, Wilker wrote: > Yeah, unfortunately I'm not receiving too much feedback about it for now, so, I'm just using for myself and trying to make it better. I will try to spread more and more the idea, so make more people wanna try it, its a different concept and I mean people still a little afraid to try it. But I will keep going on it, I really believe in the idea :) I'll give it a good mess around. It looks great. And like David said, please don't be discouraged by the limited adoption after two days ;) Pat From wilkerlucio at gmail.com Wed Jan 19 02:11:25 2011 From: wilkerlucio at gmail.com (Wilker) Date: Wed, 19 Jan 2011 04:11:25 -0300 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: <88595570-CE2E-46AD-AA56-B3039739EA1F@me.com> References: <88595570-CE2E-46AD-AA56-B3039739EA1F@me.com> Message-ID: Thanks guys, When I said I'm not getting so much feedback, I was referring because more time ago I talked about it in a lot of other lists too, but I know it still a lot young, and need a lot of improvement too :) But you know, when we launch a new project we get a lot excited with it and expects more feedback as possible :) Any suggestions, critics, any kind of feedback will be really welcome :) --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Wed, Jan 19, 2011 at 3:30 AM, Pat Maddox wrote: > On Jan 18, 2011, at 2:30 PM, Wilker wrote: > > > Yeah, unfortunately I'm not receiving too much feedback about it for now, > so, I'm just using for myself and trying to make it better. I will try to > spread more and more the idea, so make more people wanna try it, its a > different concept and I mean people still a little afraid to try it. But I > will keep going on it, I really believe in the idea :) > > I'll give it a good mess around. It looks great. > > And like David said, please don't be discouraged by the limited adoption > after two days ;) > > Pat > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pathsny at gmail.com Wed Jan 19 06:49:41 2011 From: pathsny at gmail.com (vishnu) Date: Wed, 19 Jan 2011 17:19:41 +0530 Subject: [rspec-users] capturing screenshots on test failures Message-ID: Hi I'm using rspec to run my functional tests and I'd like to add a hook to be executed every time a spec fails so that I can capture a screenshot. What's the best way to do this? Also I'd like to name my screenshot uniquely by the name of the spec. Does it make sense to use self.example.full_description? thanks Vishnu From rick.denatale at gmail.com Wed Jan 19 07:48:20 2011 From: rick.denatale at gmail.com (Rick DeNatale) Date: Wed, 19 Jan 2011 07:48:20 -0500 Subject: [rspec-users] major release required? In-Reply-To: <959679BB-A576-45DB-BB31-7BC580393201@gmail.com> References: <959679BB-A576-45DB-BB31-7BC580393201@gmail.com> Message-ID: On Tue, Jan 18, 2011 at 1:31 PM, David Chelimsky wrote: > > On Jan 18, 2011, at 11:08 AM, Rick DeNatale wrote: > >> On Tue, Jan 18, 2011 at 9:15 AM, David Chelimsky wrote: >>> Hi all, >>> >>> Since the release of rspec-2.0, I've been following Rubygems' rational versioning [1] as closely as possible. Patch releases (2.4.x) have only had bug fixes, and minor releases (2.x.0) have had new features, but no (intentionally) backward incompatible changes, which should require a major (3.0) release. >>> >>> The autotest extension in rspec-2.0 prefixes the command it generates with 'bundle exec' if it sees a 'Gemfile' in the project root directory. It turns out that this is not universally helpful, so there was a request to have an opt-out. >>> >>> It also turns out that autotest has a bundler plugin that prefixes the command with 'bundle exec'. To use an autotest plugin, you just require it in a .autotest file in the project root. In this case: >>> >>> ?require 'autotest/bundler' >>> >>> I think the right thing to do is to rely on the autotest plugin, but I also think that this would require a 3.0 release, which feels a bit grand for this situation. My question to you is: do you think this warrants a major (3.0) release, or would it be an acceptable exception to the rule (assuming proper fanfare and documentation)? >> >> Can't something be done here as a non-breaking change? ?I can see two things. >> >> 1) add the requested option, I think this is optional >> >> 2) in lib/autotest/rspec2.rb >> >> ? def using_bundler? >> ? ?File.exists?('./Gemfile') && !defined Autotest::Bundler ?# and >> also check for the option if you decide to do #1 >> ?end > > I actually did implement a --skip-bundler option (not yet released), but it has to be passed like this: > > autotest -- --skip-bundler > > Considering that this is a total hack, and that I'd be removing it at the next major release anyway, I really don't want to introduce a hack on top of a hack. I'd sooner do a 3.0 release now. I'm still trying to understand what you are proposing to change, and what it breaks. I guess you are proposing that the rspec autotest extension would never prefix the rspec command with 'bundle exec' and this would break folks using autotest with rspec who haven't changed their .autotest file. And that you think that you should bump the whole rspec suite to version 3 because of this? I guess this is because the autotest 'extension' isn't really an extension, it's in rspec-core. What about those of us using other alternatives to autotest, e.g. guard? I just looked at the guard code and changing rspec as a whole to version 3 would break guard since it checks specifically for rspec version 1 vs. 2 in order to determine whether to use 'spec' or 'rspec' as the base command. If you bump rspec to v3 because of this, it looks like guard users will need to freeze on rspec 2, at least until the author of guard-rspec catches up. I guess that's OK unless the latter takes too long, and rspec continues to improve only on the version 3 branch. That probably wouldn't happen, and if it does I could fork guard-rspec myself I guess. But if you do, I think you should also break out the autotest extension into a separate gem which is NOT required by rspec-core, much like Rails 3 broke out 'most-favored' things like Test::Unit and put alternatives like, say RSpec, and Cucumber on more of an equal footing. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From lists at ruby-forum.com Wed Jan 19 15:54:36 2011 From: lists at ruby-forum.com (Dan F.) Date: Wed, 19 Jan 2011 21:54:36 +0100 Subject: [rspec-users] undefined method `mock' for # References: Message-ID: Please see: https://github.com/rspec/rspec-rails/issues/closed#issue/279 You can't create mocks in before(:all), but it will work in before(:each) -- Posted via http://www.ruby-forum.com/. From ruben.grunge84 at gmail.com Wed Jan 19 16:01:44 2011 From: ruben.grunge84 at gmail.com (rdavila) Date: Wed, 19 Jan 2011 13:01:44 -0800 (PST) Subject: [rspec-users] Problem with output at running specs In-Reply-To: References: <12672258.177.1295288624300.JavaMail.geo-discussion-forums@yqhy19> Message-ID: <37b58405-728b-46d7-ab04-c02901259129@f21g2000prn.googlegroups.com> I've tried reconfiguring rspec from scratch and I get the same problem. I've too many hours trying to resolve this issue, please give me some hint. Here is the output again: http://pastie.org/1478603 Thanks! From wilkerlucio at gmail.com Wed Jan 19 16:12:01 2011 From: wilkerlucio at gmail.com (Wilker) Date: Wed, 19 Jan 2011 18:12:01 -0300 Subject: [rspec-users] undefined method `mock' for # References: Message-ID: Yeah, that is right, because mocks live on a space that is different for each spec (the MockSpace), this is why you can't create it in before :all ;) --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Wed, Jan 19, 2011 at 5:54 PM, Dan F. wrote: > Please see: > https://github.com/rspec/rspec-rails/issues/closed#issue/279 > > You can't create mocks in before(:all), but it will work in > before(:each) > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ruben.grunge84 at gmail.com Wed Jan 19 16:56:06 2011 From: ruben.grunge84 at gmail.com (=?UTF-8?B?UnViw6luIETDoXZpbGE=?=) Date: Wed, 19 Jan 2011 16:56:06 -0500 Subject: [rspec-users] Problem with output at running specs In-Reply-To: <37b58405-728b-46d7-ab04-c02901259129@f21g2000prn.googlegroups.com> References: <12672258.177.1295288624300.JavaMail.geo-discussion-forums@yqhy19> <37b58405-728b-46d7-ab04-c02901259129@f21g2000prn.googlegroups.com> Message-ID: I've found the culprit!. The method add_index was redefined in an initializer and it was writing to the standard output instead of logger. Very thanks! From somaraju at gmail.com Thu Jan 20 00:59:40 2011 From: somaraju at gmail.com (Raghu Somaraju) Date: Wed, 19 Jan 2011 21:59:40 -0800 (PST) Subject: [rspec-users] writing specs for Padrino using RSpec Message-ID: <30716501.post@talk.nabble.com> Hi I am new to RSpec and just started getting introduced to Padrino. I need to write specs for developing a project using Padrino (or Sinatra). Has anyone written such specs? If so can you share it on the public domain (like github or something like that) so that I can look at them and write my own? For Rails, I got help from the RSpec book. But, for Padrino, I am not able to find anything. -- View this message in context: http://old.nabble.com/writing-specs-for-Padrino-using-RSpec-tp30716501p30716501.html Sent from the rspec-users mailing list archive at Nabble.com. From lists at ruby-forum.com Thu Jan 20 07:13:32 2011 From: lists at ruby-forum.com (Misha Ognev) Date: Thu, 20 Jan 2011 13:13:32 +0100 Subject: [rspec-users] Cucumber problems Message-ID: Hello. I know that's not RSpec, but it belong to BDD. I have some problem with cucumber. When I run all commands in cucumber, I read this(see attached image). What's wrong? Ruby -v 1.9.2; Cucumber version 0.10.0. Attachments: http://www.ruby-forum.com/attachment/5768/base.png -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Thu Jan 20 08:16:42 2011 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Thu, 20 Jan 2011 13:16:42 +0000 Subject: [rspec-users] Cucumber problems In-Reply-To: References: Message-ID: Misha, Cucumber has its own mailing list (see http://cukes.info) Please repost your question there. Aslak On Thu, Jan 20, 2011 at 12:13 PM, Misha Ognev wrote: > Hello. I know that's not RSpec, but it belong to BDD. > > I have some problem with cucumber. When I run all commands in cucumber, > I read this(see attached image). What's wrong? > > Ruby -v 1.9.2; Cucumber version 0.10.0. > > Attachments: > http://www.ruby-forum.com/attachment/5768/base.png > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From pathsny at gmail.com Thu Jan 20 09:17:46 2011 From: pathsny at gmail.com (vishnu) Date: Thu, 20 Jan 2011 19:47:46 +0530 Subject: [rspec-users] detecting status of a spec in after block Message-ID: Hi inside an after :each block, whats the best way to find out if the current spec has run? Right now the only solution I have is self.example.instance_variable_get(:@exception).nil?. Is there a better solution? Also, is there an on_error hook I can use instead of an after :each block? thanks Vishnu From dchelimsky at gmail.com Thu Jan 20 10:19:04 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 20 Jan 2011 09:19:04 -0600 Subject: [rspec-users] detecting status of a spec in after block In-Reply-To: References: Message-ID: <6FD8AEE1-ED8C-4208-A2B4-4FD74DAB5425@gmail.com> On Jan 20, 2011, at 8:17 AM, vishnu wrote: > Hi > inside an after :each block, whats the best way to find out if the > current spec has run? If you're in an after block, the current spec has run. No need to query anything. > Right now the only solution I have is > self.example.instance_variable_get(:@exception).nil?. Is there a > better solution? There is not. There is example.metadata[:execution_result], but it doesn't get the exception until after the afters (in case one has an exception). What is it you're trying to do? > Also, is there an on_error hook I can use instead of an after :each block? That's an interesting idea, but again, what are you trying to accomplish? Cheers, David From pathsny at gmail.com Thu Jan 20 12:46:52 2011 From: pathsny at gmail.com (vishnu) Date: Thu, 20 Jan 2011 23:16:52 +0530 Subject: [rspec-users] detecting status of a spec in after block In-Reply-To: <6FD8AEE1-ED8C-4208-A2B4-4FD74DAB5425@gmail.com> References: <6FD8AEE1-ED8C-4208-A2B4-4FD74DAB5425@gmail.com> Message-ID: On Thu, Jan 20, 2011 at 8:49 PM, David Chelimsky wrote: > On Jan 20, 2011, at 8:17 AM, vishnu wrote: > >> Hi >> ? inside an after :each block, whats the best way to find out if the >> current spec has run? > > If you're in an after block, the current spec has run. No need to query anything. > oops, what I meant was succeeded or failed, not run. >> Right now the only solution I have is >> self.example.instance_variable_get(:@exception).nil?. Is there a >> better solution? > > There is not. There is example.metadata[:execution_result], but it doesn't get the exception until after the afters (in case one has an exception). > > What is it you're trying to do? > >> Also, is there an on_error hook I can use instead of an after :each block? > > That's an interesting idea, but again, what are you trying to accomplish? I'm running functional tests (ui driven tests) and whenever a spec has failed, I'd like to grab a screenshot and save it. From lists at ruby-forum.com Thu Jan 20 14:32:33 2011 From: lists at ruby-forum.com (Brian Warner) Date: Thu, 20 Jan 2011 20:32:33 +0100 Subject: [rspec-users] 'require'ing files from other directories Message-ID: I'm going through The RSpec Book and am currently working with the Mastermind game example. But that's besides the point. The way my directories are setup is like so: /mastermind/features/step_definitions... /mastermind/lib/codebreaker/... I have a file in step_definitions that's giving me an error for an uninitialized constant. My guess is I need to 'require' the file where that class is defined. Said files is located in /lib/codebreaker. I am very new to Ruby so this is probably a really simple question but how do I 'require' a file in codebreaker from a file inside step_definitions? -- Posted via http://www.ruby-forum.com/. From wilkerlucio at gmail.com Thu Jan 20 16:20:00 2011 From: wilkerlucio at gmail.com (Wilker) Date: Thu, 20 Jan 2011 18:20:00 -0300 Subject: [rspec-users] 'require'ing files from other directories In-Reply-To: References: Message-ID: Usually you can do some relative path requires, you can do it on your spec/spec_helper.rb require File.expand_path("../../lib/codebreaker", __FILE__) or, another common setup is to add the "lib" into require path list, and them just require the file: $: << File.expand_path("../../lib", __FILE__) require "codebreaker" another hint: you should require only main file of lib (codebreaker), and this file in lib should require the others (also, if you have some time, research about autoload, will be useful too ;)) --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Thu, Jan 20, 2011 at 4:32 PM, Brian Warner wrote: > I'm going through The RSpec Book and am currently working with the > Mastermind game example. > > But that's besides the point. > > The way my directories are setup is like so: > > /mastermind/features/step_definitions... > /mastermind/lib/codebreaker/... > > I have a file in step_definitions that's giving me an error for an > uninitialized constant. My guess is I need to 'require' the file where > that class is defined. Said files is located in /lib/codebreaker. > > I am very new to Ruby so this is probably a really simple question but > how do I 'require' a file in codebreaker from a file inside > step_definitions? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Jan 20 16:51:10 2011 From: lists at ruby-forum.com (wolf volpi) Date: Thu, 20 Jan 2011 22:51:10 +0100 Subject: [rspec-users] No command 'rspec' found Message-ID: I installed rspec on Linux Ubuntu 10.04, but no command 'rspec' is found. Perhaps the PATH is wrong. What is the correct search path? The following was copied from my terminal. Thank you for taking a look: ~$ sudo gem install rspec --version 2.0.0 ~$ gem list --local *** LOCAL GEMS *** rspec (2.0.0) ~$ ls /var/lib/gems/1.8/gems rspec-2.0.0 ~$ printenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games ~$ export PATH=$PATH:/var/lib/gems/1.8/ ~$ printenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/lib/gems/1.8/ ~$ rspec -help No command 'rspec' found, did you mean: Command 'spec' from package 'librspec-ruby1.8' (universe) Command 'tspec' from package 'tendra' (universe) rspec: command not found -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Thu Jan 20 19:58:48 2011 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 21 Jan 2011 00:58:48 +0000 Subject: [rspec-users] 'require'ing files from other directories In-Reply-To: References: Message-ID: <2A3F50E1-2C9D-40F9-9136-C022EE3B1B39@mattwynne.net> On 20 Jan 2011, at 19:32, Brian Warner wrote: > I'm going through The RSpec Book and am currently working with the > Mastermind game example. > > But that's besides the point. > > The way my directories are setup is like so: > > /mastermind/features/step_definitions... > /mastermind/lib/codebreaker/... > > I have a file in step_definitions that's giving me an error for an > uninitialized constant. My guess is I need to 'require' the file where > that class is defined. Said files is located in /lib/codebreaker. > > I am very new to Ruby so this is probably a really simple question but > how do I 'require' a file in codebreaker from a file inside > step_definitions? You could try asking on the RSpec Book's own forum: http://forums.pragprog.com/forums/95 This question is really more Cucumber related so you could also ask on the cukes google group. Your guess is right. The best place to put your require statement is in features/support/env.rb I'm surprised that the book doesn't tell you to do that - did you maybe miss a step? cheers, Matt matt at mattwynne.net 07974 430184 From mulder.patrick at gmail.com Fri Jan 21 05:43:18 2011 From: mulder.patrick at gmail.com (poseid) Date: Fri, 21 Jan 2011 02:43:18 -0800 (PST) Subject: [rspec-users] Rspec2 partial view gives nil:NilClass. Why? In-Reply-To: References: Message-ID: The problem is probably due to assignment of the photo attachment. I got a unit test working with: test "the partial" do design = Design.new :photo => File.new(Rails.root + "test/ fixtures/images/rails.png") p design.photo(:medium) render :partial => "main/design", :locals => { :design => design }, :layout => false assert_select "div.product-img a.product-link img[src^='/designs/ photos//medium_rails.png']" end On Jan 16, 10:46?am, poseid wrote: > Hello, > > I am trying to get going with development of view components with > Rspec2 and Rails3. > However, I make the following observation, and I don't understand what > is going on, and how to fix this. > > In my spec I define: > > ? describe "main/index.html.erb" do > ? ? it "displays a photo url in products partial" do > ? ? ? assign(:designs, [stub_model(Design, :name => "test", :photo => > "photo_url")]) > > ? ? ? render > ? ? ? rendered.should contain("photo_url") > ? ? end > ? end > > When I run: > > ? ? rspec spec/view/main_spec.rb > > I get this error: > > ? ? 1) main/index.html.erb displays a photo url in products partial > ? ? ? ?Failure/Error: render > ? ? ? ?ActionView::Template::Error: > ? ? ? ? ?undefined method `photo' for nil:NilClass > ? ? ? ?# ./app/views/main/_design.html.erb:3:in > `_app_views_main__design_html_erb__2937334847274155273_2170841960__1566661024965846011' > ? ? ? ?# ./app/views/main/index.html.erb:25:in > `_app_views_main_index_html_erb__837234277009287876_2170861440__898201527838028543' > ? ? ? ?# ./spec/views/main_spec.rb:7:in `block (2 levels) in (required)>' > > However, if I only 'access' a local photo object in my partial > everything passes. This is: > > in _design.html.erb: > > ? ? ? <%= design %> ?---> PASS > ? ? ? <%= design.photo %> ?---> FAIL > > In my view I call my partial as follows: > > main.html.erb > > ? ? ?<%= render "design", :locals => { :designs => @designs } %> > > What am I missing. > Thank you for your help! > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From rich at gandalf.ws Fri Jan 21 07:32:55 2011 From: rich at gandalf.ws (Rich Price) Date: Fri, 21 Jan 2011 06:32:55 -0600 Subject: [rspec-users] No command 'rspec' found In-Reply-To: References: Message-ID: <4D397CF7.2070702@gandalf.ws> Make sure that version 1 of rspec is NOT installed! Here is my path: /home/rich/.gem/ruby/1.8:/var/lib/gems/1.8:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin On 01/20/2011 03:51 PM, wolf volpi wrote: > I installed rspec on Linux Ubuntu 10.04, but no command 'rspec' is > found. Perhaps the PATH is wrong. What is the correct search path? > The following was copied from my terminal. Thank you for taking a look: > > ~$ sudo gem install rspec --version 2.0.0 > > ~$ gem list --local > > *** LOCAL GEMS *** > > rspec (2.0.0) > ~$ ls /var/lib/gems/1.8/gems > rspec-2.0.0 > ~$ printenv PATH > /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games > ~$ export PATH=$PATH:/var/lib/gems/1.8/ > ~$ printenv PATH > /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/var/lib/gems/1.8/ > ~$ rspec -help > No command 'rspec' found, did you mean: > Command 'spec' from package 'librspec-ruby1.8' (universe) > Command 'tspec' from package 'tendra' (universe) > rspec: command not found > From seanmcc at gmail.com Wed Jan 19 16:53:49 2011 From: seanmcc at gmail.com (Sean McCleary) Date: Wed, 19 Jan 2011 13:53:49 -0800 (PST) Subject: [rspec-users] parse!: invalid option "--autotest" Message-ID: <2958039d-b8c2-4c8f-9977-f4d685db92a8@r16g2000prh.googlegroups.com> I keep getting the error every time I try to run my specs with "bundle exec rake spec": /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/ core/option_parser.rb:18:in `parse!': invalid option: --autotest (OptionParser::InvalidOption) from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ lib/rspec/core/option_parser.rb:4:in `parse!' from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ lib/rspec/core/configuration_options.rb:104:in `options_from' from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ lib/rspec/core/configuration_options.rb:100:in `global_options' from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ lib/rspec/core/configuration_options.rb:65:in `parse_options' from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ lib/rspec/core/runner.rb:41:in `run' from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ lib/rspec/core/runner.rb:10:in `block in autorun' I have tried multiple versions of rspec and I still get this error. I have tried uninstalling all my rspec and autotest gems and also cleaning up old versions of the gems. gem cleanup rspec rspec-core rspec-expectations rspec-mocks rspec- rails autotest autotest-rails My specs used to run without this error. I do not know what changed. From rob.westgeest at gmail.com Fri Jan 21 05:57:50 2011 From: rob.westgeest at gmail.com (Rob Westgeest) Date: Fri, 21 Jan 2011 02:57:50 -0800 (PST) Subject: [rspec-users] autotest giving error when having shared example in specs In-Reply-To: <35f1161a-a48b-4cfa-bffc-701e13625a12@fl7g2000vbb.googlegroups.com> References: <35f1161a-a48b-4cfa-bffc-701e13625a12@fl7g2000vbb.googlegroups.com> Message-ID: <53d2a6e9-4362-4121-82e4-e0453e7c2d50@w2g2000yqb.googlegroups.com> I am having the same problem. Autotest with rspec seem to differ from rspecs rake task in which files to automatically require. The rake task requires spec/**/*.spec Autotest rspec2 requires spec/**/* As I am sharing example groups in their own files names (shared_*_examples.rb), and require them from *spec.rb files, rake works nicely and autotest fails because of its 'lets require everything' attitude. I presume that there is a way to configure autotests require set, but i haven't found it yet. Anyone? On Nov 22 2010, 9:42?pm, LesFreeman wrote: > I too am having this error > > On Sep 28, 10:42?pm, Amiruddin Nagri wrote: > > > I am having asharedexample'allow authorized actions' for my Rails 3 RSpec > > 2.beta.20 application. Thesharedexamplelooks like > > > share_examples_for 'allow authorized actions' do > > ? ... > > end > > > Thissharedexampleis in file > > spec/controllers/support/authorization_shared_example.rb, which I am > > requiring in spec_helper.rb. I am also using autotest to give me quick > > feedback. Autotest is generating following command to run rspec > > > > ruby>/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/bin/rspec > to rails root>/spec/controllers/support/authorization_shared_example.rb > > > > > Since autotest is also including support file when running rspec, I am > > getting following errors with autotest > > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/shared_example_group.rb:43:in > > `ensure_shared_example_group_name_not_taken':Sharedexamplegroup'allow > > authorized actions'alreadyexists(ArgumentError) > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/shared_example_group.rb:6:in > > `share_examples_for' > > ? ? from > > /Users/arusarh/work/ece/carbonomist/spec/controllers/support/authorization_ shared_example.rb:1:in > > `' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_ support/dependencies.rb:235:in > > `load' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_ support/dependencies.rb:235:in > > `block in load' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_ support/dependencies.rb:227:in > > `load_dependency' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_ support/dependencies.rb:235:in > > `load' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/configuration.rb:302:in > > `block in load_spec_files' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/configuration.rb:302:in > > `map' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/configuration.rb:302:in > > `load_spec_files' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/command_line.rb:18:in > > `run' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/runner.rb:46:in > > `run_in_process' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/runner.rb:37:in > > `run' > > ? ? from > > /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/runner.rb:10:in > > `block in autorun' > > > Any ideas how to not make autotest includesharedexamplefiles loaded > > through command line, but only include files with pattern "*_spec.rb", or > > have anyone else facing same situation. > > > Regards, > > Amiruddin Nagri, > > Bangalore, 560008, KA > > India > > > Y! IM : amir_na... at yahoo.com > > GTalk : amir.na... at gmail.com > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Jan 21 08:21:05 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 21 Jan 2011 07:21:05 -0600 Subject: [rspec-users] Rspec2 partial view gives nil:NilClass. Why? In-Reply-To: References: Message-ID: <3EE28E63-E7B0-46C2-8724-B04FAF35C1C4@gmail.com> On Jan 21, 2011, at 4:43 AM, poseid wrote: > On Jan 16, 10:46 am, poseid wrote: >> Hello, >> >> I am trying to get going with development of view components with >> Rspec2 and Rails3. >> However, I make the following observation, and I don't understand what >> is going on, and how to fix this. >> >> In my spec I define: >> >> describe "main/index.html.erb" do >> it "displays a photo url in products partial" do >> assign(:designs, [stub_model(Design, :name => "test", :photo => >> "photo_url")]) >> >> render >> rendered.should contain("photo_url") >> end >> end >> >> When I run: >> >> rspec spec/view/main_spec.rb >> >> I get this error: >> >> 1) main/index.html.erb displays a photo url in products partial >> Failure/Error: render >> ActionView::Template::Error: >> undefined method `photo' for nil:NilClass >> # ./app/views/main/_design.html.erb:3:in >> `_app_views_main__design_html_erb__2937334847274155273_2170841960__1566661024965846011' >> # ./app/views/main/index.html.erb:25:in >> `_app_views_main_index_html_erb__837234277009287876_2170861440__898201527838028543' >> # ./spec/views/main_spec.rb:7:in `block (2 levels) in > (required)>' >> >> However, if I only 'access' a local photo object in my partial >> everything passes. This is: >> >> in _design.html.erb: >> >> <%= design %> ---> PASS >> <%= design.photo %> ---> FAIL >> >> In my view I call my partial as follows: >> >> main.html.erb >> >> <%= render "design", :locals => { :designs => @designs } %> >> >> What am I missing. >> Thank you for your help! > The problem is probably due to assignment of the photo attachment. > I got a unit test working with: > > test "the partial" do > design = Design.new :photo => File.new(Rails.root + "test/ > fixtures/images/rails.png") > p design.photo(:medium) > render :partial => "main/design", :locals => { :design => > design }, :layout => false > assert_select "div.product-img a.product-link img[src^='/designs/ > photos//medium_rails.png']" > end And the same does not work in a view spec? From dchelimsky at gmail.com Fri Jan 21 08:35:36 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 21 Jan 2011 07:35:36 -0600 Subject: [rspec-users] autotest giving error when having shared example in specs In-Reply-To: <53d2a6e9-4362-4121-82e4-e0453e7c2d50@w2g2000yqb.googlegroups.com> References: <35f1161a-a48b-4cfa-bffc-701e13625a12@fl7g2000vbb.googlegroups.com> <53d2a6e9-4362-4121-82e4-e0453e7c2d50@w2g2000yqb.googlegroups.com> Message-ID: <15BA55FF-3E43-4442-B3B1-B660DECFBFBC@gmail.com> On Jan 21, 2011, at 4:57 AM, Rob Westgeest wrote: > On Nov 22 2010, 9:42 pm, LesFreeman wrote: >> On Sep 28, 10:42 pm, Amiruddin Nagri wrote: >> >>> I am having asharedexample'allow authorized actions' for my Rails 3 RSpec >>> 2.beta.20 application. Thesharedexamplelooks like >> >>> share_examples_for 'allow authorized actions' do >>> ... >>> end >> >>> Thissharedexampleis in file >>> spec/controllers/support/authorization_shared_example.rb, which I am >>> requiring in spec_helper.rb. I am also using autotest to give me quick >>> feedback. Autotest is generating following command to run rspec >> >>> >> ruby>/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/bin/rspec >> to rails root>/spec/controllers/support/authorization_shared_example.rb >>> >> >>> Since autotest is also including support file when running rspec, I am >>> getting following errors with autotest >> >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/shared_example_group.rb:43:in >>> `ensure_shared_example_group_name_not_taken':Sharedexamplegroup'allow >>> authorized actions'alreadyexists(ArgumentError) >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/shared_example_group.rb:6:in >>> `share_examples_for' >>> from >>> /Users/arusarh/work/ece/carbonomist/spec/controllers/support/authorization_ shared_example.rb:1:in >>> `' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_ support/dependencies.rb:235:in >>> `load' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_ support/dependencies.rb:235:in >>> `block in load' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_ support/dependencies.rb:227:in >>> `load_dependency' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_ support/dependencies.rb:235:in >>> `load' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/configuration.rb:302:in >>> `block in load_spec_files' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/configuration.rb:302:in >>> `map' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/configuration.rb:302:in >>> `load_spec_files' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/command_line.rb:18:in >>> `run' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/runner.rb:46:in >>> `run_in_process' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/runner.rb:37:in >>> `run' >>> from >>> /Users/arusarh/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.0.0.beta.20/lib/rs pec/core/runner.rb:10:in >>> `block in autorun' >> >>> Any ideas how to not make autotest includesharedexamplefiles loaded >>> through command line, but only include files with pattern "*_spec.rb", or >>> have anyone else facing same situation. >> I too am having this error > I am having the same problem. > > Autotest with rspec seem to differ from rspecs rake task in which > files to automatically require. > > The rake task requires spec/**/*.spec Close, but not quite. The default pattern is spec/**/*_spec.rb. > Autotest rspec2 requires spec/**/* Again, this incorrect. Autotest fires off shell commands that include a list of files to load based on a set of mappings: if file x changes, run a command with file(s) y. In RSpec, those mappings are defined in Autotest::Rspec2, and they are set to include files that end with _spec.rb, with some additional constraints based on file naming conventions: a change to lib/foo/bar.rb tells RSpec to include spec/foo/bar_spec.rb. > As I am sharing example groups in their own files names > (shared_*_examples.rb), and require them from *spec.rb files, rake > works nicely and autotest fails because of its 'lets require > everything' attitude. I'm not sure where that's coming from, but it's not default settings of rspec or autotest. What versions of rspec and autotest are you using? Is this a rails app? > > I presume that there is a way to configure autotests require set, but > i haven't found it yet. Autotest has a mapping mechanism that you can access in its initialize hook. See http://blog.davidchelimsky.net/2008/01/15/rspec-1-1-2-and-zentest-3-8-0/ for more on this. Cheers, David From dchelimsky at gmail.com Fri Jan 21 08:39:11 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 21 Jan 2011 07:39:11 -0600 Subject: [rspec-users] parse!: invalid option "--autotest" In-Reply-To: <2958039d-b8c2-4c8f-9977-f4d685db92a8@r16g2000prh.googlegroups.com> References: <2958039d-b8c2-4c8f-9977-f4d685db92a8@r16g2000prh.googlegroups.com> Message-ID: <9D27E3F7-0D45-4DDC-852F-8B84E40ED468@gmail.com> On Jan 19, 2011, at 3:53 PM, Sean McCleary wrote: > I keep getting the error every time I try to run my specs with "bundle > exec rake spec": > > /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/lib/rspec/ > core/option_parser.rb:18:in `parse!': invalid option: --autotest > (OptionParser::InvalidOption) > from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ > lib/rspec/core/option_parser.rb:4:in `parse!' > from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ > lib/rspec/core/configuration_options.rb:104:in `options_from' > from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ > lib/rspec/core/configuration_options.rb:100:in `global_options' > from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ > lib/rspec/core/configuration_options.rb:65:in `parse_options' > from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ > lib/rspec/core/runner.rb:41:in `run' > from /Users/sean/.rvm/gems/ruby-1.9.2-p0/gems/rspec-core-2.4.0/ > lib/rspec/core/runner.rb:10:in `block in autorun' > > I have tried multiple versions of rspec and I still get this error. > > I have tried uninstalling all my rspec and autotest gems and also > cleaning up old versions of the gems. > > gem cleanup rspec rspec-core rspec-expectations rspec-mocks rspec- > rails autotest autotest-rails > > My specs used to run without this error. I do not know what changed. What's in your ./.rspec or ~/.rspec files? From dchelimsky at gmail.com Fri Jan 21 08:56:12 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 21 Jan 2011 07:56:12 -0600 Subject: [rspec-users] major release required? In-Reply-To: References: <959679BB-A576-45DB-BB31-7BC580393201@gmail.com> Message-ID: <9BC29C57-BFD7-4C26-8AB0-6BF38F68AE09@gmail.com> On Jan 19, 2011, at 6:48 AM, Rick DeNatale wrote: > On Tue, Jan 18, 2011 at 1:31 PM, David Chelimsky wrote: >> >> On Jan 18, 2011, at 11:08 AM, Rick DeNatale wrote: >> >>> On Tue, Jan 18, 2011 at 9:15 AM, David Chelimsky wrote: >>>> Hi all, >>>> >>>> Since the release of rspec-2.0, I've been following Rubygems' rational versioning [1] as closely as possible. Patch releases (2.4.x) have only had bug fixes, and minor releases (2.x.0) have had new features, but no (intentionally) backward incompatible changes, which should require a major (3.0) release. >>>> >>>> The autotest extension in rspec-2.0 prefixes the command it generates with 'bundle exec' if it sees a 'Gemfile' in the project root directory. It turns out that this is not universally helpful, so there was a request to have an opt-out. >>>> >>>> It also turns out that autotest has a bundler plugin that prefixes the command with 'bundle exec'. To use an autotest plugin, you just require it in a .autotest file in the project root. In this case: >>>> >>>> require 'autotest/bundler' >>>> >>>> I think the right thing to do is to rely on the autotest plugin, but I also think that this would require a 3.0 release, which feels a bit grand for this situation. My question to you is: do you think this warrants a major (3.0) release, or would it be an acceptable exception to the rule (assuming proper fanfare and documentation)? >>> >>> Can't something be done here as a non-breaking change? I can see two things. >>> >>> 1) add the requested option, I think this is optional >>> >>> 2) in lib/autotest/rspec2.rb >>> >>> def using_bundler? >>> File.exists?('./Gemfile') && !defined Autotest::Bundler # and >>> also check for the option if you decide to do #1 >>> end >> >> I actually did implement a --skip-bundler option (not yet released), but it has to be passed like this: >> >> autotest -- --skip-bundler >> >> Considering that this is a total hack, and that I'd be removing it at the next major release anyway, I really don't want to introduce a hack on top of a hack. I'd sooner do a 3.0 release now. > > I'm still trying to understand what you are proposing to change, and > what it breaks. > > I guess you are proposing that the rspec autotest extension would > never prefix the rspec command with 'bundle exec' and this would break > folks using autotest with rspec who haven't changed their .autotest > file. Correct. > And that you think that you should bump the whole rspec suite to > version 3 because of this? I guess this is because the autotest > 'extension' isn't really an extension, it's in rspec-core. Correct. And I'm trying to establish a consistent pattern in releases so people can trust that minor and patch releases won't introduce breaking changes. This one is a bit of an outlier, and I started this thread to see what ppl thought of treating it as such, but the more I think of it, the more I'm convinced that this should not be an exception. > What about those of us using other alternatives to autotest, e.g. > guard? I just looked at the guard code and changing rspec as a whole > to version 3 would break guard since it checks specifically for rspec > version 1 vs. 2 in order to determine whether to use 'spec' or 'rspec' > as the base command. That's unfortunate. Whether or not I do an rspec-3 release now, adherence to Rubygems' rational versioning policy will likely result in an rspec-3 release in much less time than it took us to get to rspec-2. When it comes out, rspec-3 will not represent a major rewrite or significant API or functional changes. It will simply be an indicator that there are backward-incompatible changes in that release and you should accept that upgrade consciously and carefully. > If you bump rspec to v3 because of this, it looks like guard users > will need to freeze on rspec 2, at least until the author of > guard-rspec catches up. I guess that's OK unless the latter takes too > long, and rspec continues to improve only on the version 3 branch. > That probably wouldn't happen, and if it does I could fork guard-rspec > myself I guess. Thanks for being willing to help out. We should probably hit guard-rspec up with this now, though, so when rspec-3 does come along guard users don't have to take a hit at that point. Do you want to drive that? > But if you do, I think you should also break out the autotest > extension into a separate gem which is NOT required by rspec-core, > much like Rails 3 broke out 'most-favored' things like Test::Unit and > put alternatives like, say RSpec, and Cucumber on more of an equal > footing. Definitely in the plan for rspec-3: https://github.com/rspec/rspec-core/issues/issue/285. Cheers, David From rich at gandalf.ws Fri Jan 21 09:12:19 2011 From: rich at gandalf.ws (Rich Price) Date: Fri, 21 Jan 2011 08:12:19 -0600 Subject: [rspec-users] Problem with before(:all) Message-ID: <4D399443.9030203@gandalf.ws> I have a module with two methods for marshaling objects. The following rspec code is used to test this module: ----- Start Code ----- require '../code/fmutil.rb' require '../code/fmgrid.rb' require '../code/serial.rb' # start test of Serial Module describe Serial do describe "Given a grid with the block test pattern" do before(:all) do cfg01 = Fmconfig.new grid01 = Grid.makeempty(cfg01,500,20) cfg01.list[:cellhight].times do |y| cfg01.list[:cellwidth].times do |x| grid01[x,y].elevation = x+10*(y+1) end end end describe "restored serialized grid object" do it "matches origional grid object." do grid02 = Grid.allocate Serial.write(grid01,"testtemp01") grid02 = Serial.read(grid02,"testtemp01") grid01[9,9].elevation.should == grid02[9,9].elevation end end end end ----- End Code ----- But when I run it it seems that the Grid object created in the before(:all) hook is not available to the example [see below]. Why is this? ----- Start Run ----- rich at richlaptop2:~/Documents/fakemap/rspec$ rspec serialgrid.rb Serial Given a grid with the block test pattern restored serialized grid object matches origional grid object. (FAILED - 1) Failures: 1) Serial Given a grid with the block test pattern restored serialized grid object matches origional grid object. Failure/Error: Serial.write(grid01,"testtemp01") NameError: undefined local variable or method `grid01' for # # ./serialgrid.rb:20 Finished in 0.00698 seconds 1 example, 1 failure rich at richlaptop2:~/Documents/fakemap/rspec$ ----- End Run ----- I am running rspec 2.4.0 and ruby 1.8.7 -- Rich Price rich at gandalf.ws From wilkerlucio at gmail.com Fri Jan 21 09:24:22 2011 From: wilkerlucio at gmail.com (Wilker) Date: Fri, 21 Jan 2011 11:24:22 -0300 Subject: [rspec-users] Problem with before(:all) In-Reply-To: <4D399443.9030203@gandalf.ws> References: <4D399443.9030203@gandalf.ws> Message-ID: if you wanna share variables from before filters to specs, you need to use instance variables instead of local ones, example: WRONG: before :all do myvar = 1 end it "should do something" do puts myvar # nil end RIGHT: before :all do @myvar = 1 end it "should do something" do puts @myvar # 1 end --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Fri, Jan 21, 2011 at 11:12 AM, Rich Price wrote: > I have a module with two methods for marshaling objects. > The following rspec code is used to test this module: > > ----- Start Code ----- > require '../code/fmutil.rb' > require '../code/fmgrid.rb' > require '../code/serial.rb' > > # start test of Serial Module > describe Serial do > describe "Given a grid with the block test pattern" do > before(:all) do > cfg01 = Fmconfig.new > grid01 = Grid.makeempty(cfg01,500,20) > cfg01.list[:cellhight].times do |y| > cfg01.list[:cellwidth].times do |x| > grid01[x,y].elevation = x+10*(y+1) > end > end > end > describe "restored serialized grid object" do > it "matches origional grid object." do > grid02 = Grid.allocate > Serial.write(grid01,"testtemp01") > grid02 = Serial.read(grid02,"testtemp01") > grid01[9,9].elevation.should == grid02[9,9].elevation > end > end > end > end > ----- End Code ----- > > But when I run it it seems that the Grid object created in the > before(:all) hook is not available to the example [see below]. > Why is this? > > ----- Start Run ----- > rich at richlaptop2:~/Documents/fakemap/rspec$ rspec serialgrid.rb > > Serial > Given a grid with the block test pattern > restored serialized grid object > matches origional grid object. (FAILED - 1) > > Failures: > > 1) Serial Given a grid with the block test pattern restored serialized > grid object matches origional grid object. > Failure/Error: Serial.write(grid01,"testtemp01") > NameError: > undefined local variable or method `grid01' for > # > # ./serialgrid.rb:20 > > Finished in 0.00698 seconds > 1 example, 1 failure > rich at richlaptop2:~/Documents/fakemap/rspec$ > ----- End Run ----- > > > I am running rspec 2.4.0 and ruby 1.8.7 > > > -- > Rich Price > rich at gandalf.ws > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffdeville at gmail.com Fri Jan 21 10:29:58 2011 From: jeffdeville at gmail.com (JDeville) Date: Fri, 21 Jan 2011 07:29:58 -0800 (PST) Subject: [rspec-users] Test Spies for RSpec 2 In-Reply-To: <68DE6630-29C4-4B64-B94E-E0DC9C331853@gmail.com> References: <0a6bb4e6-775d-41ff-aaad-ce2f5e08c708@j29g2000yqm.googlegroups.com> <68DE6630-29C4-4B64-B94E-E0DC9C331853@gmail.com> Message-ID: <28a95f9f-229a-4e83-8620-6ccab2d3749c@fx12g2000vbb.googlegroups.com> Scott, check out Bourne. It's an add on to mocha that gives you spies. I'm using it, and like it a lot. On Dec 2 2010, 8:53?am, David Chelimsky wrote: > On Dec 2, 2010, at 1:44 AM, Scott Bellware wrote: > > > I've tried three test spy mocking frameworks for RSpec that I know of. > > Presently, all three (Not A Mock, RR, rspec-spies) don't work with > > RSpec 2. > > Have you contacted the maintainers of the projects that offer spies? I'm a bit surprised they haven't updated to support RSpec-2, which was in beta since March (plenty of time for downstream libs to update). > > > Does anyone have a line on any other mocking frameworks for RSpec 2 > > that allow theAAAstyle to be supported? > > I was only aware of those three. > > > I'm really hoping to not have to roll off everything I've learned and > > put into practice about test/spec structure over the past four years > > and fall back to traditional mocking. Any pointers to any hint of a > > possible solution would be greatly helpful. > > Have you considered contributing a patch to your preferred spy extension? The frameworks they depend on (expectations and mocks) didn't really change in any significant way, so I doubt it would be that complicated to get any of them working. > > FWIW, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From rob.westgeest at gmail.com Fri Jan 21 10:30:54 2011 From: rob.westgeest at gmail.com (Rob Westgeest) Date: Fri, 21 Jan 2011 07:30:54 -0800 (PST) Subject: [rspec-users] autotest giving error when having shared example in specs In-Reply-To: <15BA55FF-3E43-4442-B3B1-B660DECFBFBC@gmail.com> References: <35f1161a-a48b-4cfa-bffc-701e13625a12@fl7g2000vbb.googlegroups.com> <53d2a6e9-4362-4121-82e4-e0453e7c2d50@w2g2000yqb.googlegroups.com> <15BA55FF-3E43-4442-B3B1-B660DECFBFBC@gmail.com> Message-ID: <20183e83-13d2-41c2-9dcf-0c255a8f3a9d@d8g2000yqf.googlegroups.com> Thanks for your fast reply David, > > The rake task requires spec/**/*.spec > > Close, but not quite. The default pattern is spec/**/*_spec.rb. Typo sorry > > > Autotest rspec2 requires spec/**/* > > Again, this incorrect. Autotest fires off shell commands that include a list of files to load based on a set of mappings: if file x changes, run a command with file(s) y. > > In RSpec, those mappings are defined in Autotest::Rspec2, and they are set to include files that end with _spec.rb, with some additional constraints based on file naming conventions: a change to lib/foo/bar.rb tells RSpec to include spec/foo/bar_spec.rb. Yeah i saw that in the code. I just could not figure out why files like: spec/models/csv/shared_export_examples.rb end up in the 'bundle exec /usr/bin/ruby1.8 -S /var/lib/gems/1.8/gems/ rspec-core-2.4.0/bin/rspec --tty'.... command line along with all the _spec.rb files. anohter thing that I don't quite understand is that even if i would require this file again, why on earth ruby decides to require it if it already was. For the example above, if I put puts "-------------\n" + caller.join("\n") i get two slightly different stacktraces: ------------- /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:235:in `load' /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:235:in `load' /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:227:in `load_dependency' /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:235:in `load' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/ configuration.rb:387:in `load_spec_files' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/ configuration.rb:387:in `map' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/ configuration.rb:387:in `load_spec_files' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb: 18:in `run' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10 /var/lib/gems/1.8/gems/rspec-core-2.4.0/bin/rspec:4 ------------- /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:239:in `require' /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:239:in `require' /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:227:in `load_dependency' /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:239:in `require' /home/rob/dev/ws/wc-rubyapps/tafelmanager/spec/support/ require_relative.rb:2:in `require_relative' /home/rob/dev/ws/wc-rubyapps/tafelmanager/spec/models/csv/ person_exporter_spec.rb:2 /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:235:in `load' /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:235:in `load' /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:227:in `load_dependency' /var/lib/gems/1.8/gems/activesupport-3.0.3/lib/active_support/ dependencies.rb:235:in `load' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/ configuration.rb:387:in `load_spec_files' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/ configuration.rb:387:in `map' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/ configuration.rb:387:in `load_spec_files' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb: 18:in `run' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' /var/lib/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10 /var/lib/gems/1.8/gems/rspec-core-2.4.0/bin/rspec:4 btw, just in case you wondered what require_relative means: require_relative is: def require_relative(file, requirement) require File.expand_path(File.join(File.dirname(file),requirement)) end > I'm not sure where that's coming from, but it's not default settings of rspec or autotest. What versions of rspec and autotest are you using? Is this a rails app? using: Rails 3.0.3 bundle list yields (a.o.): * ZenTest (4.4.2) * autotest (4.4.6) * autotest-rails (4.1.0) * rspec (2.4.0) * rspec-core (2.4.0) * rspec-expectations (2.4.0) * rspec-mocks (2.4.0) * rspec-rails (2.4.1) > > > > > I presume that there is a way to configure autotests require set, but > > i haven't found it yet. > > Autotest has a mapping mechanism that you can access in its initialize hook. Seehttp://blog.davidchelimsky.net/2008/01/15/rspec-1-1-2-and-zentest-3-8-0/for more on this. Thanks - i'll try to add an exception for the shared.*examples.rb files for now, while looking for the root cause these duplicated requires. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From jeffdeville at gmail.com Fri Jan 21 10:32:59 2011 From: jeffdeville at gmail.com (JDeville) Date: Fri, 21 Jan 2011 07:32:59 -0800 (PST) Subject: [rspec-users] Arrange Act Assert (AAA) style syntax for rspec2 Message-ID: <3100ed9b-36b0-4461-81d1-3cdade05cba2@a10g2000vby.googlegroups.com> I'd like to be able to test w/ this methodology, and i'm having trouble figuring out where to hook in to rspec to do it. Near as I can tell, the flow is this: run all of the before filters in the order of highest to lowest context <<-- I need to run something right here run tests run all of the after filters in the order of highest to lowest context Is there any way to create a before filter that is always run after all of the others? From lists at ruby-forum.com Fri Jan 21 11:22:57 2011 From: lists at ruby-forum.com (Brian Warner) Date: Fri, 21 Jan 2011 17:22:57 +0100 Subject: [rspec-users] 'require'ing files from other directories In-Reply-To: <2A3F50E1-2C9D-40F9-9136-C022EE3B1B39@mattwynne.net> References: <2A3F50E1-2C9D-40F9-9136-C022EE3B1B39@mattwynne.net> Message-ID: <1bf41cd0e466a24e21c65add2a234516@ruby-forum.com> Matt Wynne wrote in post #976412: > On 20 Jan 2011, at 19:32, Brian Warner wrote: > >> I have a file in step_definitions that's giving me an error for an >> uninitialized constant. My guess is I need to 'require' the file where >> that class is defined. Said files is located in /lib/codebreaker. >> >> I am very new to Ruby so this is probably a really simple question but >> how do I 'require' a file in codebreaker from a file inside >> step_definitions? > > You could try asking on the RSpec Book's own forum: > http://forums.pragprog.com/forums/95 > > This question is really more Cucumber related so you could also ask on > the cukes google group. > > Your guess is right. The best place to put your require statement is in > features/support/env.rb > > I'm surprised that the book doesn't tell you to do that - did you maybe > miss a step? > > cheers, > Matt > > matt at mattwynne.net > 07974 430184 The require statement that the book says to put in env.rb is: $: << File.join(File.dirname(__FILE__), "/../lib/") require 'codebreaker' I ended up getting it to work after a co-worker pointed out that I need to add "./lib" to some thing in ruby's list of directories to look in. I don't remember what terminology he used but he did it through the terminal. The require statement I ended up using is require 'codebreaker/game' -- Posted via http://www.ruby-forum.com/. From tom at therye.org Fri Jan 21 12:02:14 2011 From: tom at therye.org (Tom Stuart) Date: Fri, 21 Jan 2011 17:02:14 +0000 Subject: [rspec-users] Test Spies for RSpec 2 In-Reply-To: <28a95f9f-229a-4e83-8620-6ccab2d3749c@fx12g2000vbb.googlegroups.com> References: <0a6bb4e6-775d-41ff-aaad-ce2f5e08c708@j29g2000yqm.googlegroups.com> <68DE6630-29C4-4B64-B94E-E0DC9C331853@gmail.com> <28a95f9f-229a-4e83-8620-6ccab2d3749c@fx12g2000vbb.googlegroups.com> Message-ID: If the idea of having to say 'stubs(:method)' for every method that you're going to call and verify, give my new mocking library Matahari a go: https://github.com/mortice/matahari It's brand new and deficient in many ways but I'm planning on improving it and it sounds like we appreciate the same things about spies, so maybe a good fit. On 21 Jan 2011, at 15:29, JDeville wrote: > Scott, check out Bourne. It's an add on to mocha that gives you > spies. I'm using it, and like it a lot. > > On Dec 2 2010, 8:53 am, David Chelimsky wrote: >> On Dec 2, 2010, at 1:44 AM, Scott Bellware wrote: >> >>> I've tried three test spy mocking frameworks for RSpec that I know of. >>> Presently, all three (Not A Mock, RR, rspec-spies) don't work with >>> RSpec 2. >> >> Have you contacted the maintainers of the projects that offer spies? I'm a bit surprised they haven't updated to support RSpec-2, which was in beta since March (plenty of time for downstream libs to update). >> >>> Does anyone have a line on any other mocking frameworks for RSpec 2 >>> that allow theAAAstyle to be supported? >> >> I was only aware of those three. >> >>> I'm really hoping to not have to roll off everything I've learned and >>> put into practice about test/spec structure over the past four years >>> and fall back to traditional mocking. Any pointers to any hint of a >>> possible solution would be greatly helpful. >> >> Have you considered contributing a patch to your preferred spy extension? The frameworks they depend on (expectations and mocks) didn't really change in any significant way, so I doubt it would be that complicated to get any of them working. >> >> FWIW, >> David >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Fri Jan 21 16:15:12 2011 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 21 Jan 2011 21:15:12 +0000 Subject: [rspec-users] 'require'ing files from other directories In-Reply-To: <1bf41cd0e466a24e21c65add2a234516@ruby-forum.com> References: <2A3F50E1-2C9D-40F9-9136-C022EE3B1B39@mattwynne.net> <1bf41cd0e466a24e21c65add2a234516@ruby-forum.com> Message-ID: On 21 Jan 2011, at 16:22, Brian Warner wrote: > Matt Wynne wrote in post #976412: >> On 20 Jan 2011, at 19:32, Brian Warner wrote: >> >>> I have a file in step_definitions that's giving me an error for an >>> uninitialized constant. My guess is I need to 'require' the file where >>> that class is defined. Said files is located in /lib/codebreaker. >>> >>> I am very new to Ruby so this is probably a really simple question but >>> how do I 'require' a file in codebreaker from a file inside >>> step_definitions? >> >> You could try asking on the RSpec Book's own forum: >> http://forums.pragprog.com/forums/95 >> >> This question is really more Cucumber related so you could also ask on >> the cukes google group. >> >> Your guess is right. The best place to put your require statement is in >> features/support/env.rb >> >> I'm surprised that the book doesn't tell you to do that - did you maybe >> miss a step? >> >> cheers, >> Matt >> >> matt at mattwynne.net >> 07974 430184 > > The require statement that the book says to put in env.rb is: > > $: << File.join(File.dirname(__FILE__), "/../lib/") > require 'codebreaker' > > I ended up getting it to work after a co-worker pointed out that I need > to add "./lib" to some thing in ruby's list of directories to look in. I > don't remember what terminology he used but he did it through the > terminal. He probably called it the 'load path'. That's what the $: means in that snippet - it's an Array of paths where Ruby will search for files when you call require. In the code above, you're pushing the lib directory onto the load path. > The require statement I ended up using is > > require 'codebreaker/game' Maybe the lib/codebreaker file was supposed to do that? cheers, Matt matt at mattwynne.net 07974 430184 From apremdas at gmail.com Fri Jan 21 17:52:57 2011 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 21 Jan 2011 22:52:57 +0000 Subject: [rspec-users] Feedback Requested (pretty please) In-Reply-To: References: Message-ID: On 6 January 2011 20:39, Ants Pants wrote: > I have dabbled with RSpec with the Beta books but am only now getting my > teeth in to it. Because of this and because I have no one to ask/bounce > ideas off, I am asking for a kind soul to look at what I've done for my > first example. Am I on the right track with the way I'm thinking? > > My first attempt at testing my real live thing was the following (comments > included to help) > > describe "GET edit" do > context "the product cutoff time has passed" do > it "prevents editing of the product" do > ## ProductType object must be received on an edit > ProductType.should_receive(:find).with("1").and_return(ProductType) > ProductType.should_receive(:products).and_return(Product) > > Product.stub(:find).with("1").and_return(Product) > > ## this is the thing I really want to test > Product.should_receive(:product_cutoff_passed?).and_return(true) > > ## before filters > controller.stub(:authorise_is_admin).and_return(true) > controller.stub(:require_user).and_return(user) > > get :edit, :product_type_id => 1, :id => 1 > > flash[:notice].should == "The product is closed for editing" > response.should redirect_to(products_path) > > end > end > end > > > I got the above example passing and then went about refactoring it and this > is what I have now > > > def require_user > controller.stub(:require_user).and_return(User) > end > > def authorise_is_admin > controller.stub(:authorise_is_admin).and_return(true) > end > > describe ProductsController do > ## this is required for all actions in this controller > before(:each) do > require_user > end > > let(:product_type) { mock_model(ProductType).as_null_object } > let(:product) { mock_model(Product).as_null_object } > > describe "GET edit" do > ## this is required for this action > before(:each) do > authorise_is_admin > end > > ## this now has its own test as it is fundamental to the action > it "creates a ProductType object" do > ## message expectation > > ProductType.should_receive(:find).with("1").and_return(product_type)45 > get :edit, :product_type_id => 1, :id => 1 > end > > ## the message expectations in my first example are now stubs in this > example > ## as they are not the main focus of this test > context "the product cutoff time has passed" do > it "prevents editing of the product" do > ProductType.stub(:find).with("1").and_return(product_type) > > ## would like to use stub_chain but one of the stubs receives > arguments > product_type.stub(:products).and_return(product) > product.stub(:find).with("1").and_return(product) > > ## message expectation > product.should_receive(:product_cutoff_passed?).and_return(true) > > get :edit, :product_type_id => 1, :id => 1 > > flash[:notice].should == "The product is closed for editing" > response.should redirect_to(products_path) > > end > end > end > end > > I hope you don;t mind if I do this as I will need your feedback to get me > in the right way of thinking. > > Thank you > > -ants > If you are getting started with RSpec don't test Rails Controllers - its the hardest thing to do with RSpec, and probably the most pointless. Instead Google for Jamis Buck's fat model skinny controller blog post, make your controllers do as little as possible and put all logic in the model. Then use rspec to test the public methods in your model. This will give you a much shallower learning curve, and be much more productive. When you've done a fair amount of rspec model testing, and you're feeling a need to test more of the stack, have a look at Cucumber. Don't forget the RSpec book. Do codebreaker line by line, typing in everything (no cut and paste), and you will learn lots. HTH Andrew > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Jan 21 18:13:46 2011 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 21 Jan 2011 23:13:46 +0000 Subject: [rspec-users] major release required? In-Reply-To: <9BC29C57-BFD7-4C26-8AB0-6BF38F68AE09@gmail.com> References: <959679BB-A576-45DB-BB31-7BC580393201@gmail.com> <9BC29C57-BFD7-4C26-8AB0-6BF38F68AE09@gmail.com> Message-ID: On 21 January 2011 13:56, David Chelimsky wrote: > On Jan 19, 2011, at 6:48 AM, Rick DeNatale wrote: > > > On Tue, Jan 18, 2011 at 1:31 PM, David Chelimsky > wrote: > >> > >> On Jan 18, 2011, at 11:08 AM, Rick DeNatale wrote: > >> > >>> On Tue, Jan 18, 2011 at 9:15 AM, David Chelimsky > wrote: > >>>> Hi all, > >>>> > >>>> Since the release of rspec-2.0, I've been following Rubygems' rational > versioning [1] as closely as possible. Patch releases (2.4.x) have only had > bug fixes, and minor releases (2.x.0) have had new features, but no > (intentionally) backward incompatible changes, which should require a major > (3.0) release. > >>>> > >>>> The autotest extension in rspec-2.0 prefixes the command it generates > with 'bundle exec' if it sees a 'Gemfile' in the project root directory. It > turns out that this is not universally helpful, so there was a request to > have an opt-out. > >>>> > >>>> It also turns out that autotest has a bundler plugin that prefixes the > command with 'bundle exec'. To use an autotest plugin, you just require it > in a .autotest file in the project root. In this case: > >>>> > >>>> require 'autotest/bundler' > >>>> > >>>> I think the right thing to do is to rely on the autotest plugin, but I > also think that this would require a 3.0 release, which feels a bit grand > for this situation. My question to you is: do you think this warrants a > major (3.0) release, or would it be an acceptable exception to the rule > (assuming proper fanfare and documentation)? > >>> > >>> Can't something be done here as a non-breaking change? I can see two > things. > >>> > >>> 1) add the requested option, I think this is optional > >>> > >>> 2) in lib/autotest/rspec2.rb > >>> > >>> def using_bundler? > >>> File.exists?('./Gemfile') && !defined Autotest::Bundler # and > >>> also check for the option if you decide to do #1 > >>> end > >> > >> I actually did implement a --skip-bundler option (not yet released), but > it has to be passed like this: > >> > >> autotest -- --skip-bundler > >> > >> Considering that this is a total hack, and that I'd be removing it at > the next major release anyway, I really don't want to introduce a hack on > top of a hack. I'd sooner do a 3.0 release now. > > > > I'm still trying to understand what you are proposing to change, and > > what it breaks. > > > > I guess you are proposing that the rspec autotest extension would > > never prefix the rspec command with 'bundle exec' and this would break > > folks using autotest with rspec who haven't changed their .autotest > > file. > > Correct. > > > And that you think that you should bump the whole rspec suite to > > version 3 because of this? I guess this is because the autotest > > 'extension' isn't really an extension, it's in rspec-core. > > Correct. And I'm trying to establish a consistent pattern in releases so > people can trust that minor and patch releases won't introduce breaking > changes. This one is a bit of an outlier, and I started this thread to see > what ppl thought of treating it as such, but the more I think of it, the > more I'm convinced that this should not be an exception. > > > What about those of us using other alternatives to autotest, e.g. > > guard? I just looked at the guard code and changing rspec as a whole > > to version 3 would break guard since it checks specifically for rspec > > version 1 vs. 2 in order to determine whether to use 'spec' or 'rspec' > > as the base command. > > That's unfortunate. Whether or not I do an rspec-3 release now, adherence > to Rubygems' rational versioning policy will likely result in an rspec-3 > release in much less time than it took us to get to rspec-2. When it comes > out, rspec-3 will not represent a major rewrite or significant API or > functional changes. It will simply be an indicator that there are > backward-incompatible changes in that release and you should accept that > upgrade consciously and carefully. > > > If you bump rspec to v3 because of this, it looks like guard users > > will need to freeze on rspec 2, at least until the author of > > guard-rspec catches up. I guess that's OK unless the latter takes too > > long, and rspec continues to improve only on the version 3 branch. > > That probably wouldn't happen, and if it does I could fork guard-rspec > > myself I guess. > > Thanks for being willing to help out. We should probably hit guard-rspec up > with this now, though, so when rspec-3 does come along guard users don't > have to take a hit at that point. Do you want to drive that? > > > But if you do, I think you should also break out the autotest > > extension into a separate gem which is NOT required by rspec-core, > > much like Rails 3 broke out 'most-favored' things like Test::Unit and > > put alternatives like, say RSpec, and Cucumber on more of an equal > > footing. > > Definitely in the plan for rspec-3: > https://github.com/rspec/rspec-core/issues/issue/285. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Whilst its very noble to try and follow the ruby gems document to the letter, some consideration has to be given to the overall effect of rapidly changing major version numbers on the project. RSpec has a very large user base, a close tie in with Rails major versions, in particular the idea to Rails 3 should use RSpec 2, and a history of changing major versions very infrequently with major consequences to the vast majority of users. This I think is a fair assessment of RSpec's context re version numbers. To move to RSpec 3, for such a small change would be completely out of character for the project. To end up in 4 months time with RSpec 9 would be very detrimental to the projects reputation. So I think the pragmatic approach is a minor release with a big caveat in the history and a big announcement on the mailing list All best Andrew -- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Jan 21 18:17:04 2011 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 21 Jan 2011 23:17:04 +0000 Subject: [rspec-users] 'require'ing files from other directories In-Reply-To: References: <2A3F50E1-2C9D-40F9-9136-C022EE3B1B39@mattwynne.net> <1bf41cd0e466a24e21c65add2a234516@ruby-forum.com> Message-ID: On 21 January 2011 21:15, Matt Wynne wrote: > > On 21 Jan 2011, at 16:22, Brian Warner wrote: > > > Matt Wynne wrote in post #976412: > >> On 20 Jan 2011, at 19:32, Brian Warner wrote: > >> > >>> I have a file in step_definitions that's giving me an error for an > >>> uninitialized constant. My guess is I need to 'require' the file where > >>> that class is defined. Said files is located in /lib/codebreaker. > >>> > >>> I am very new to Ruby so this is probably a really simple question but > >>> how do I 'require' a file in codebreaker from a file inside > >>> step_definitions? > >> > >> You could try asking on the RSpec Book's own forum: > >> http://forums.pragprog.com/forums/95 > >> > >> This question is really more Cucumber related so you could also ask on > >> the cukes google group. > >> > >> Your guess is right. The best place to put your require statement is in > >> features/support/env.rb > >> > >> I'm surprised that the book doesn't tell you to do that - did you maybe > >> miss a step? > >> > >> cheers, > >> Matt > >> > >> matt at mattwynne.net > >> 07974 430184 > > > > The require statement that the book says to put in env.rb is: > > > > $: << File.join(File.dirname(__FILE__), "/../lib/") > > require 'codebreaker' > > > > I ended up getting it to work after a co-worker pointed out that I need > > to add "./lib" to some thing in ruby's list of directories to look in. I > > don't remember what terminology he used but he did it through the > > terminal. > > He probably called it the 'load path'. That's what the $: means in that > snippet - it's an Array of paths where Ruby will search for files when you > call require. In the code above, you're pushing the lib directory onto the > load path. > > > The require statement I ended up using is > > > > require 'codebreaker/game' > > Maybe the lib/codebreaker file was supposed to do that? > > It should, mine currently has require 'codebreaker/game' require 'codebreaker/marker' All best Andrew > > cheers, > Matt > > matt at mattwynne.net > 07974 430184 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Jan 21 18:31:22 2011 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 21 Jan 2011 23:31:22 +0000 Subject: [rspec-users] Best Practice for Controllers In-Reply-To: <83c4f1ae-2d90-4ee1-9aa8-396529b37fc6@fo10g2000vbb.googlegroups.com> References: <6E186B7A-25F9-40FE-825E-DF9C08A1160D@gmail.com> <83c4f1ae-2d90-4ee1-9aa8-396529b37fc6@fo10g2000vbb.googlegroups.com> Message-ID: On 18 January 2011 12:28, Phillip Koebbe wrote: > > > > On 17 January 2011 20:43, David Chelimsky wrote: > > > > > On Jan 17, 2011, at 10:16 AM, David Kahn wrote: > > > > > On Mon, Jan 17, 2011 at 9:48 AM, Ants Pants >wrote: > > > > >> Hello all, > > > > >> From what I've seen, this type of question doesn't really seem to get > an > > >> answer on this list as most of the replies relate to failures of > RSpec. If > > >> this is the case, where is the best place to go to get advice about > best > > >> practices etc? > > > > >> I have a question about best practice. In some of my controllers only > an > > >> admin user can perform edit, update, show etc. So I have a before > filter in > > >> those controllers; ApplicationController#authorise_is_admin > > > > >> The ApplicationController#authorise_is_admin throws an AccessDenied > > >> exception and that is caught in ApplicationController#access_denied > > > > >> My question is, in the spec for the calling controller, let's say > > >> ProductGroups, what should I spec? > > > > >> I have a context "user is admin" and that's easy to spec, but the > context > > >> "user is not admin" is where I'm stuck as no actions are performed in > that > > >> controller but I would just like to cover that failure somehow. > > > > >> Interesting question. I had the same dilemma and decided that it took > too > > > much effort and test code to test this at the controller level. What I > do > > > (and this may or may not work for you depending on your apps security > > > needs), is to have an authorize method in the User model. It returns > success > > > or failure based on the controller and action passed. The model looks > > > something like this: > > > > > def authorize(controller_name, action_name) > > > if self.role > > > current_role = self.role.name > > > else > > > # guest user is empty user > > > current_role = 'guest' > > > end > > > > > case controller_name > > > when 'activations' > > > if current_role != 'guest' > > > return set_autorize_failure_value("You are already logged in to > the > > > system. If you are activating a new user please log out first and try > > > again.") > > > end > > > return authorize_success_message > > > > > when 'feedback_supports' > > > if current_role == 'guest' || current_role == 'sysadmin' > > > return set_autorize_failure_value(LOGIN_NOTICE) > > > end > > > return authorize_success_message > > > ... > > > > > end > > > > > Then in the spec it is real easy: > > > > > describe "user authorization - guest role" do > > > it "is authorized to access certain pages only" do > > > user = User.new > > > user.authorize('activations', 'create')[:success].should == true > > > user.authorize('home', 'index')[:success].should == false > > > > > .... > > > > > end > > > end > > > > > This might not be everyone's cup of tea and I am sure I can refactor > and > > > make this less verbose, but what I like is having the 'dna' of all my > access > > > rights app wide in one place. > > > > > Definitely agree with the idea of keeping decisions in one place. I > don't > > > really like the idea of 'controllers' living inside a model, but change > > > 'controller_name' to 'resource_collection_name' and that solves that > > > problem. > > > > > I would still want to specify that the controller asks the user for > > > authorization. WDYT? > > > On Jan 18, 2:30 am, Ants Pants wrote: > > When I read the David Kahn's response, I thought it strange to have > > controller code in the model and was going to query him on it so I'm glad > > that others think the same. > > > > As for Nick's response, I will look into it_behaves_like (I remember > seeing > > that in the book with a pizza example) It sounds good to me. > > > > Thanks for the replies. > > > > -ants > > > > One thing you might consider is to separate your admin functionality > from your regular user functionality. This isn't for everyone, but it > might work out well for you. I used to do it the way you are currently > doing it, and it was okay until I ran into some situations in which a > regular user and an admin could edit a resource, but only the admin > could edit certain attributes. The logic in my controller started > putting on a bit of weight. My practice now is to separate appropriate > functionality into namespaced controllers. All features available for > users not logged in go in the default namespace, all features > requiring the user to be logged in (but not administrative) go in the / > user/ namespace, and all features that require administrative rights > go into the /admin/ namespace. Then, in each namespace, I create a > base controller that does the authorization/redirection and all other > controllers in the namespace inherit from it. Something like: > > https://gist.github.com/784363 > > Doing it this way does create seeming duplication in the views, but > partials can be used very easily to deal with that. This method also > more or less demands a menu structure that completely separates the > functionality of each role, but in the projects that I've been working > on, that has been a benefit. To have all of the role-based > functionality separated in controllers and menus has provided clear > lines that are easy to follow. In short, it has worked out really > well. But, as always, your own mileage may vary. > > Peace. > Phillip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > +1 for the many controllers for one model pattern, you can really simplify controllers with this approach. Having a separate view hierarchy for each of these controllers also makes for simpler views, with less logic. However you have be very disciplined with your view partials, or the number of files can get a bit confusing All best Andrew -- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From luislavena at gmail.com Fri Jan 21 18:45:05 2011 From: luislavena at gmail.com (Luis Lavena) Date: Fri, 21 Jan 2011 20:45:05 -0300 Subject: [rspec-users] major release required? In-Reply-To: References: Message-ID: On Tue, Jan 18, 2011 at 11:15 AM, David Chelimsky wrote: > > [...] > > I think the right thing to do is to rely on the autotest plugin, but I also think that this would require a 3.0 release, which feels a bit grand for this situation. My question to you is: do you think this warrants a major (3.0) release, or would it be an acceptable exception to the rule (assuming proper fanfare and documentation)? > IMHO this case is a exception to the rule that we can live with. -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From lists at ruby-forum.com Fri Jan 21 21:50:32 2011 From: lists at ruby-forum.com (wolf volpi) Date: Sat, 22 Jan 2011 03:50:32 +0100 Subject: [rspec-users] No command 'rspec' found In-Reply-To: References: Message-ID: <7e1edbc2f1a51582e52ea095c55e9e3f@ruby-forum.com> Thanks Richard. Adding the home .gem/ruby/1.8 path did not help. I have rspec version 2 installed. How do I make sure version 1 is not installed? Here is a copy&paste from my terminal: ~$ printenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/wolf/.gem/ruby/1.8 ~$ ls -a /home/wolf/.gem/ruby/1.8 . .. cache doc gems specifications ~$ gem list --local *** LOCAL GEMS *** rspec (2.0.0) ~$ rspec --help No command 'rspec' found, did you mean: Command 'spec' from package 'librspec-ruby1.8' (universe) Command 'tspec' from package 'tendra' (universe) rspec: command not found -- Posted via http://www.ruby-forum.com/. From dk at structuralartistry.com Fri Jan 21 23:25:28 2011 From: dk at structuralartistry.com (David Kahn) Date: Fri, 21 Jan 2011 22:25:28 -0600 Subject: [rspec-users] Best Practice for Controllers In-Reply-To: <6E186B7A-25F9-40FE-825E-DF9C08A1160D@gmail.com> References: <6E186B7A-25F9-40FE-825E-DF9C08A1160D@gmail.com> Message-ID: On Mon, Jan 17, 2011 at 1:43 PM, David Chelimsky wrote: > On Jan 17, 2011, at 10:16 AM, David Kahn wrote: > > On Mon, Jan 17, 2011 at 9:48 AM, Ants Pants wrote: > >> Hello all, >> >> From what I've seen, this type of question doesn't really seem to get an >> answer on this list as most of the replies relate to failures of RSpec. If >> this is the case, where is the best place to go to get advice about best >> practices etc? >> >> I have a question about best practice. In some of my controllers only an >> admin user can perform edit, update, show etc. So I have a before filter in >> those controllers; ApplicationController#authorise_is_admin >> >> The ApplicationController#authorise_is_admin throws an AccessDenied >> exception and that is caught in ApplicationController#access_denied >> >> My question is, in the spec for the calling controller, let's say >> ProductGroups, what should I spec? >> >> I have a context "user is admin" and that's easy to spec, but the context >> "user is not admin" is where I'm stuck as no actions are performed in that >> controller but I would just like to cover that failure somehow. >> >> Interesting question. I had the same dilemma and decided that it took too > much effort and test code to test this at the controller level. What I do > (and this may or may not work for you depending on your apps security > needs), is to have an authorize method in the User model. It returns success > or failure based on the controller and action passed. The model looks > something like this: > > def authorize(controller_name, action_name) > if self.role > current_role = self.role.name > else > # guest user is empty user > current_role = 'guest' > end > > > case controller_name > when 'activations' > if current_role != 'guest' > return set_autorize_failure_value("You are already logged in to the > system. If you are activating a new user please log out first and try > again.") > end > return authorize_success_message > > when 'feedback_supports' > if current_role == 'guest' || current_role == 'sysadmin' > return set_autorize_failure_value(LOGIN_NOTICE) > end > return authorize_success_message > ... > > end > > Then in the spec it is real easy: > > describe "user authorization - guest role" do > it "is authorized to access certain pages only" do > user = User.new > user.authorize('activations', 'create')[:success].should == true > user.authorize('home', 'index')[:success].should == false > > .... > > end > end > > This might not be everyone's cup of tea and I am sure I can refactor and > make this less verbose, but what I like is having the 'dna' of all my access > rights app wide in one place. > > > Definitely agree with the idea of keeping decisions in one place. I don't > really like the idea of 'controllers' living inside a model, but change > 'controller_name' to 'resource_collection_name' and that solves that > problem. > > I would still want to specify that the controller asks the user for > authorization. WDYT? > If I am following the thread right, I should clarify that I call 'authorize' from the application controller -- should have included this in my first response. It is from there that the User model is invoked: class ApplicationController < ActionController::Base private def authorize if current_user return_value = current_user.authorize(controller_name, action_name) else return_value = User.new.authorize(controller_name, action_name) end if !return_value[:success] flash[:notice] = return_value[:failure_message] if current_user redirect_to home_path else redirect_to login_path end end end end I would not venture to say what I have is the best but just what came up from refactoring in search of simplifying my code and tests. I also do not like the idea of anything dependent like a session or params or something else from a controller getting coupled to a model, but in this case it feels to me that the model is just a switchboard in decision-making, which for me I would consider business logic. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From antsmailinglist at gmail.com Sat Jan 22 03:54:22 2011 From: antsmailinglist at gmail.com (Ants Pants) Date: Sat, 22 Jan 2011 09:54:22 +0100 Subject: [rspec-users] Best Practice for Controllers In-Reply-To: <83c4f1ae-2d90-4ee1-9aa8-396529b37fc6@fo10g2000vbb.googlegroups.com> References: <6E186B7A-25F9-40FE-825E-DF9C08A1160D@gmail.com> <83c4f1ae-2d90-4ee1-9aa8-396529b37fc6@fo10g2000vbb.googlegroups.com> Message-ID: Yes, I like that response and I do do that to a limited fashion. Maybe I should think about using it more widely. -ants On 18 January 2011 13:28, Phillip Koebbe wrote: > > > > On 17 January 2011 20:43, David Chelimsky wrote: > > > > > On Jan 17, 2011, at 10:16 AM, David Kahn wrote: > > > > > On Mon, Jan 17, 2011 at 9:48 AM, Ants Pants >wrote: > > > > >> Hello all, > > > > >> From what I've seen, this type of question doesn't really seem to get > an > > >> answer on this list as most of the replies relate to failures of > RSpec. If > > >> this is the case, where is the best place to go to get advice about > best > > >> practices etc? > > > > >> I have a question about best practice. In some of my controllers only > an > > >> admin user can perform edit, update, show etc. So I have a before > filter in > > >> those controllers; ApplicationController#authorise_is_admin > > > > >> The ApplicationController#authorise_is_admin throws an AccessDenied > > >> exception and that is caught in ApplicationController#access_denied > > > > >> My question is, in the spec for the calling controller, let's say > > >> ProductGroups, what should I spec? > > > > >> I have a context "user is admin" and that's easy to spec, but the > context > > >> "user is not admin" is where I'm stuck as no actions are performed in > that > > >> controller but I would just like to cover that failure somehow. > > > > >> Interesting question. I had the same dilemma and decided that it took > too > > > much effort and test code to test this at the controller level. What I > do > > > (and this may or may not work for you depending on your apps security > > > needs), is to have an authorize method in the User model. It returns > success > > > or failure based on the controller and action passed. The model looks > > > something like this: > > > > > def authorize(controller_name, action_name) > > > if self.role > > > current_role = self.role.name > > > else > > > # guest user is empty user > > > current_role = 'guest' > > > end > > > > > case controller_name > > > when 'activations' > > > if current_role != 'guest' > > > return set_autorize_failure_value("You are already logged in to > the > > > system. If you are activating a new user please log out first and try > > > again.") > > > end > > > return authorize_success_message > > > > > when 'feedback_supports' > > > if current_role == 'guest' || current_role == 'sysadmin' > > > return set_autorize_failure_value(LOGIN_NOTICE) > > > end > > > return authorize_success_message > > > ... > > > > > end > > > > > Then in the spec it is real easy: > > > > > describe "user authorization - guest role" do > > > it "is authorized to access certain pages only" do > > > user = User.new > > > user.authorize('activations', 'create')[:success].should == true > > > user.authorize('home', 'index')[:success].should == false > > > > > .... > > > > > end > > > end > > > > > This might not be everyone's cup of tea and I am sure I can refactor > and > > > make this less verbose, but what I like is having the 'dna' of all my > access > > > rights app wide in one place. > > > > > Definitely agree with the idea of keeping decisions in one place. I > don't > > > really like the idea of 'controllers' living inside a model, but change > > > 'controller_name' to 'resource_collection_name' and that solves that > > > problem. > > > > > I would still want to specify that the controller asks the user for > > > authorization. WDYT? > > > On Jan 18, 2:30 am, Ants Pants wrote: > > When I read the David Kahn's response, I thought it strange to have > > controller code in the model and was going to query him on it so I'm glad > > that others think the same. > > > > As for Nick's response, I will look into it_behaves_like (I remember > seeing > > that in the book with a pizza example) It sounds good to me. > > > > Thanks for the replies. > > > > -ants > > > > One thing you might consider is to separate your admin functionality > from your regular user functionality. This isn't for everyone, but it > might work out well for you. I used to do it the way you are currently > doing it, and it was okay until I ran into some situations in which a > regular user and an admin could edit a resource, but only the admin > could edit certain attributes. The logic in my controller started > putting on a bit of weight. My practice now is to separate appropriate > functionality into namespaced controllers. All features available for > users not logged in go in the default namespace, all features > requiring the user to be logged in (but not administrative) go in the / > user/ namespace, and all features that require administrative rights > go into the /admin/ namespace. Then, in each namespace, I create a > base controller that does the authorization/redirection and all other > controllers in the namespace inherit from it. Something like: > > https://gist.github.com/784363 > > Doing it this way does create seeming duplication in the views, but > partials can be used very easily to deal with that. This method also > more or less demands a menu structure that completely separates the > functionality of each role, but in the projects that I've been working > on, that has been a benefit. To have all of the role-based > functionality separated in controllers and menus has provided clear > lines that are easy to follow. In short, it has worked out really > well. But, as always, your own mileage may vary. > > Peace. > Phillip > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat Jan 22 04:47:25 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 22 Jan 2011 03:47:25 -0600 Subject: [rspec-users] major release required? In-Reply-To: References: <959679BB-A576-45DB-BB31-7BC580393201@gmail.com> <9BC29C57-BFD7-4C26-8AB0-6BF38F68AE09@gmail.com> Message-ID: On Fri, Jan 21, 2011 at 5:13 PM, Andrew Premdas wrote: > On 21 January 2011 13:56, David Chelimsky wrote: >> >> On Jan 19, 2011, at 6:48 AM, Rick DeNatale wrote: >> >> > On Tue, Jan 18, 2011 at 1:31 PM, David Chelimsky >> > wrote: >> >> >> >> On Jan 18, 2011, at 11:08 AM, Rick DeNatale wrote: >> >> >> >>> On Tue, Jan 18, 2011 at 9:15 AM, David Chelimsky >> >>> wrote: >> >>>> Hi all, >> >>>> >> >>>> Since the release of rspec-2.0, I've been following Rubygems' >> >>>> rational versioning [1] as closely as possible. Patch releases (2.4.x) have >> >>>> only had bug fixes, and minor releases (2.x.0) have had new features, but no >> >>>> (intentionally) backward incompatible changes, which should require a major >> >>>> (3.0) release. >> >>>> >> >>>> The autotest extension in rspec-2.0 prefixes the command it generates >> >>>> with 'bundle exec' if it sees a 'Gemfile' in the project root directory. It >> >>>> turns out that this is not universally helpful, so there was a request to >> >>>> have an opt-out. >> >>>> >> >>>> It also turns out that autotest has a bundler plugin that prefixes >> >>>> the command with 'bundle exec'. To use an autotest plugin, you just require >> >>>> it in a .autotest file in the project root. In this case: >> >>>> >> >>>> ?require 'autotest/bundler' >> >>>> >> >>>> I think the right thing to do is to rely on the autotest plugin, but >> >>>> I also think that this would require a 3.0 release, which feels a bit grand >> >>>> for this situation. My question to you is: do you think this warrants a >> >>>> major (3.0) release, or would it be an acceptable exception to the rule >> >>>> (assuming proper fanfare and documentation)? >> >>> >> >>> Can't something be done here as a non-breaking change? ?I can see two >> >>> things. >> >>> >> >>> 1) add the requested option, I think this is optional >> >>> >> >>> 2) in lib/autotest/rspec2.rb >> >>> >> >>> ? def using_bundler? >> >>> ? ?File.exists?('./Gemfile') && !defined Autotest::Bundler ?# and >> >>> also check for the option if you decide to do #1 >> >>> ?end >> >> >> >> I actually did implement a --skip-bundler option (not yet released), >> >> but it has to be passed like this: >> >> >> >> autotest -- --skip-bundler >> >> >> >> Considering that this is a total hack, and that I'd be removing it at >> >> the next major release anyway, I really don't want to introduce a hack on >> >> top of a hack. I'd sooner do a 3.0 release now. >> > >> > I'm still trying to understand what you are proposing to change, and >> > what it breaks. >> > >> > I guess you are proposing that the ?rspec autotest extension would >> > never prefix the rspec command with 'bundle exec' and this would break >> > folks using autotest with rspec who haven't changed their .autotest >> > file. >> >> Correct. >> >> > And that you think that you should bump the whole rspec suite to >> > version 3 because of this? I guess this is because the autotest >> > 'extension' isn't really an extension, it's in rspec-core. >> >> Correct. And I'm trying to establish a consistent pattern in releases so >> people can trust that minor and patch releases won't introduce breaking >> changes. This one is a bit of an outlier, and I started this thread to see >> what ppl thought of treating it as such, but the more I think of it, the >> more I'm convinced that this should not be an exception. >> >> > What about those of us using other alternatives to autotest, e.g. >> > guard? ?I just looked at the guard code and changing rspec as a whole >> > to version 3 would break guard since it checks specifically for rspec >> > version 1 vs. 2 in order to determine whether to use 'spec' or 'rspec' >> > as the base command. >> >> That's unfortunate. Whether or not I do an rspec-3 release now, adherence >> to Rubygems' rational versioning policy will likely result in an rspec-3 >> release in much less time than it took us to get to rspec-2. When it comes >> out, rspec-3 will not represent a major rewrite or significant API or >> functional changes. It will simply be an indicator that there are >> backward-incompatible changes in that release and you should accept that >> upgrade consciously and carefully. >> >> > If you bump rspec to v3 because of this, it looks like guard users >> > will need to freeze on rspec 2, at least until the author of >> > guard-rspec catches up. ?I guess that's OK unless the latter takes too >> > long, and rspec continues to improve only on the version 3 branch. >> > That probably wouldn't happen, and if it does I could fork guard-rspec >> > myself I guess. >> >> Thanks for being willing to help out. We should probably hit guard-rspec >> up with this now, though, so when rspec-3 does come along guard users don't >> have to take a hit at that point. Do you want to drive that? >> >> > But if you do, I think you should also break out the autotest >> > extension into a separate gem which is NOT required by rspec-core, >> > much like Rails 3 broke out 'most-favored' things like Test::Unit and >> > put alternatives like, say RSpec, and Cucumber on more of an equal >> > footing. >> >> Definitely in the plan for rspec-3: >> https://github.com/rspec/rspec-core/issues/issue/285. >> >> Cheers, >> David >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > Whilst its very noble to try and follow the ruby gems document to the > letter, some consideration has to be given to the overall effect of rapidly > changing major version numbers on the project. RSpec has a very large user > base, a close tie in with Rails major versions, in particular the idea to > Rails 3 should use RSpec 2, and a history of changing major versions very > infrequently with major consequences to the vast majority of users. This I > think is a fair assessment of RSpec's context re version numbers. To move to > RSpec 3, for such a small change would be completely out of character for > the project. To end up in 4 months time with RSpec 9 would be very > detrimental to the projects reputation. > So I think the pragmatic approach is a minor release with a big caveat in > the history and a big announcement on the mailing list The goal here is to set a new standard that people can count on. Right now, many rspec users count on upgrades breaking things, which is not exactly the sort of reliability I'd like to convey. I want to eliminate any perception of a binding between Rails and RSpec releases. It's one thing to have a compatibility mapping (rspec-2 supports rails >= 3), but it's entirely another to assume that we need to wait for rails-4 to release rspec-3. As for the timing of major releases, I'm thinking more like a major release every 6 months to a year, not 7 more in 4 months time :) And, again, the idea is that major releases won't be quite so major. They simply indicate that there are breaking changes in the release, and you should upgrade to that release knowingly. I've found a solution that I think serves these goals well: rspec-2.5 will add the --skip-bundler option and deprecate the implicit addition of 'bundle exec'. It will still work as 2.4 does, but users will see a deprecation warning explaining to use the autotest/bundler plugin or the --skip-bundler option. When either of those options is applied, the deprecation warning goes away. When it comes time to release rspec-3, rspec-autotest will be extracted from rspec-core, the --skip-bundler will no longer do anything, and you'll see a message saying so. At that point, you either use the autotest/bundler plugin or not. Thoughts? From dchelimsky at gmail.com Sat Jan 22 04:49:07 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 22 Jan 2011 03:49:07 -0600 Subject: [rspec-users] major release required? In-Reply-To: References: Message-ID: On Fri, Jan 21, 2011 at 5:45 PM, Luis Lavena wrote: > On Tue, Jan 18, 2011 at 11:15 AM, David Chelimsky wrote: >> >> [...] >> >> I think the right thing to do is to rely on the autotest plugin, but I also think that this would require a 3.0 release, which feels a bit grand for this situation. My question to you is: do you think this warrants a major (3.0) release, or would it be an acceptable exception to the rule (assuming proper fanfare and documentation)? >> > > IMHO this case is a exception to the rule that we can live with. Luis, you're one of those early adopter types, aren't you :) I'd like to spend some time establishing the rule before making exceptions. Per other post this thread, I think I've got a workable solution in place for the rspec-2.5 release. Cheers, David From phillipkoebbe at gmail.com Sat Jan 22 07:06:49 2011 From: phillipkoebbe at gmail.com (Phillip Koebbe) Date: Sat, 22 Jan 2011 06:06:49 -0600 Subject: [rspec-users] Best Practice for Controllers In-Reply-To: References: <6E186B7A-25F9-40FE-825E-DF9C08A1160D@gmail.com> Message-ID: <4D3AC859.7090602@gmail.com> On 2011-01-21 10:25 PM, David Kahn wrote: > > > On Mon, Jan 17, 2011 at 1:43 PM, David Chelimsky > wrote: > > On Jan 17, 2011, at 10:16 AM, David Kahn wrote: > >> On Mon, Jan 17, 2011 at 9:48 AM, Ants Pants >> > wrote: >> >> Hello all, >> >> From what I've seen, this type of question doesn't really >> seem to get an answer on this list as most of the replies >> relate to failures of RSpec. If this is the case, where is >> the best place to go to get advice about best practices etc? >> >> I have a question about best practice. In some of my >> controllers only an admin user can perform edit, update, show >> etc. So I have a before filter in those controllers; >> ApplicationController#authorise_is_admin >> >> The ApplicationController#authorise_is_admin throws an >> AccessDenied exception and that is caught >> in ApplicationController#access_denied >> >> My question is, in the spec for the calling controller, let's >> say ProductGroups, what should I spec? >> >> I have a context "user is admin" and that's easy to spec, but >> the context "user is not admin" is where I'm stuck as no >> actions are performed in that controller but I would just >> like to cover that failure somehow. >> >> Interesting question. I had the same dilemma and decided that it >> took too much effort and test code to test this at the controller >> level. What I do (and this may or may not work for you depending >> on your apps security needs), is to have an authorize method in >> the User model. It returns success or failure based on the >> controller and action passed. The model looks something like this: >> >> def authorize(controller_name, action_name) >> if self.role >> current_role = self.role.name >> else >> # guest user is empty user >> current_role = 'guest' >> end >> >> >> case controller_name >> when 'activations' >> if current_role != 'guest' >> return set_autorize_failure_value("You are already logged >> in to the system. If you are activating a new user please log out >> first and try again.") >> end >> return authorize_success_message >> >> when 'feedback_supports' >> if current_role == 'guest' || current_role == 'sysadmin' >> return set_autorize_failure_value(LOGIN_NOTICE) >> end >> return authorize_success_message >> ... >> >> end >> >> Then in the spec it is real easy: >> >> describe "user authorization - guest role" do >> it "is authorized to access certain pages only" do >> user = User.new >> user.authorize('activations', 'create')[:success].should == >> true >> user.authorize('home', 'index')[:success].should == false >> >> .... >> >> end >> end >> >> This might not be everyone's cup of tea and I am sure I can >> refactor and make this less verbose, but what I like is having >> the 'dna' of all my access rights app wide in one place. > > Definitely agree with the idea of keeping decisions in one place. > I don't really like the idea of 'controllers' living inside a > model, but change 'controller_name' to 'resource_collection_name' > and that solves that problem. > > I would still want to specify that the controller asks the user > for authorization. WDYT? > > > If I am following the thread right, I should clarify that I call > 'authorize' from the application controller -- should have included > this in my first response. It is from there that the User model is > invoked: > > class ApplicationController < ActionController::Base > > private > > def authorize > if current_user > return_value = current_user.authorize(controller_name, > action_name) > else > return_value = User.new.authorize(controller_name, action_name) > end > > if !return_value[:success] > flash[:notice] = return_value[:failure_message] > if current_user > redirect_to home_path > else > redirect_to login_path > end > end > end > > end > > > I would not venture to say what I have is the best but just what came > up from refactoring in search of simplifying my code and tests. I also > do not like the idea of anything dependent like a session or params or > something else from a controller getting coupled to a model, but in > this case it feels to me that the model is just a switchboard in > decision-making, which for me I would consider business logic. > > Keeping the "cup of tea" idea in mind, I can understand how you could arrive at this point. I did something similar a couple of years ago. I was passing something into the model that could come only from a controller, which was fine and dandy until I needed to use the model method in some way that proved difficult to get that information. It may have been a rake task, I can't remember the exact details. But from that point, I started thinking about my models as separate from the particular application I was working on at the moment. When creating methods and passing in arguments, I started thinking about what would happen if I used this model outside of the Rails application. Would I still be able to pass that information in easily and would it make sense? The other thought that I had with this particular approach (passing controller name and action into the model) is that it seems the model specs would feel sort of fake. In order to unit test the authorize method, you have to test with real values. I may be overlooking something (just got up, so it's very possible), but that doesn't seem like it's testing behavior so much as how the method handles specific values. If you add new controllers and/or actions, you must then go add them to your unit test to make sure the authorize method responds correctly. That doesn't seem like the kind of test that I'd feel comfortable trusting. Now that I think about it, I actually had this same situation come up a couple of years ago. Before I started splitting role-based functionality into separate namespaced controllers, I was trying to control access to various actions via before_filters. Using the same concept of controller/action combination, I created a hash of those pairs and which roles could access them. The role names then turned into model methods that returned true/false. Something like: access_rules = { 'products' => { 'show' => [:clerk, :manager], 'new' => [:manager], 'edit' => [:manager] }, 'stores' => { 'show' => [:clerk, :manager], 'new' => [:manager], 'edit' => [:manager] } } roles = access_rules[controller_name][action_name] return true if roles.any? { |role| current_user.send("#{role}?") } return false Something like that anyway. I even went so far as to write a controller plugin so I could simplify it to allow_access(:clerk, :only => [:show]) allow_access(:manager, :only => [:show, :new, :edit]) verify_access This is obviously a contrived example, but it should suffice to get the point across. Bringing this back to RSpec, specs make more sense this way as you can check to make sure your role methods on the user model return true or false based on a database setting and you can easily mock/stub those methods in the controller specs to make sure that you don't get to actions that you shouldn't. By the way, I prefer English breakfast tea and Indian spiced chai. :) Peace. Phillip From rick.denatale at gmail.com Sat Jan 22 07:11:43 2011 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sat, 22 Jan 2011 07:11:43 -0500 Subject: [rspec-users] major release required? In-Reply-To: References: <959679BB-A576-45DB-BB31-7BC580393201@gmail.com> <9BC29C57-BFD7-4C26-8AB0-6BF38F68AE09@gmail.com> Message-ID: On Sat, Jan 22, 2011 at 4:47 AM, David Chelimsky wrote: > The goal here is to set a new standard that people can count on. Right > now, many rspec users count on upgrades breaking things, which is not > exactly the sort of reliability I'd like to convey. > > I want to eliminate any perception of a binding between Rails and > RSpec releases. It's one thing to have a compatibility mapping > (rspec-2 supports rails >= 3), but it's entirely another to assume > that we need to wait for rails-4 to release rspec-3. > > As for the timing of major releases, I'm thinking more like a major > release every 6 months to a year, not 7 more in 4 months time :) And, > again, the idea is that major releases won't be quite so major. They > simply indicate that there are breaking changes in the release, and > you should upgrade to that release knowingly. > > I've found a solution that I think serves these goals well: rspec-2.5 > will add the --skip-bundler option and deprecate the implicit addition > of 'bundle exec'. It will still work as 2.4 does, but users will see a > deprecation warning explaining to use the autotest/bundler plugin or > the --skip-bundler option. When either of those options is applied, > the deprecation warning goes away. > > When it comes time to release rspec-3, rspec-autotest will be > extracted from rspec-core, the --skip-bundler will no longer do > anything, and you'll see a message saying so. At that point, you > either use the autotest/bundler plugin or not. > > Thoughts? That sounds reasonably pragmatic to me. Of course I've only had two sips of coffee this morning. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From luislavena at gmail.com Sat Jan 22 08:50:08 2011 From: luislavena at gmail.com (Luis Lavena) Date: Sat, 22 Jan 2011 10:50:08 -0300 Subject: [rspec-users] No command 'rspec' found In-Reply-To: References: Message-ID: On Thu, Jan 20, 2011 at 6:51 PM, wolf volpi wrote: > I installed rspec on Linux Ubuntu 10.04, but no command 'rspec' is > found. ?Perhaps the PATH is wrong. ?What is the correct search path? > The following was copied from my terminal. ?Thank you for taking a look: > > ~$ sudo gem install rspec --version 2.0.0 > > ~$ gem list --local > > *** LOCAL GEMS *** > > rspec (2.0.0) So rspec is the only gem you obtain? What version of RubyGems do you have? Asking this because when I install rspec I get 3 more gems: https://rubygems.org/gems/rspec/versions/2.0.0 rspec-mocks = 2.0.0 rspec-expectations = 2.0.0 rspec-core = 2.0.0 Inside rspec-core is rspec command. Also, since you're using Ubuntu, you need to have /var/lib/gems/1.8/bin added to the PATH. Please check the above and let us know. -- Luis Lavena AREA 17 - Perfection in design is achieved not when there is nothing more to add, but rather when there is nothing more to take away. Antoine de Saint-Exup?ry From dchelimsky at gmail.com Sat Jan 22 11:07:11 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 22 Jan 2011 11:07:11 -0500 Subject: [rspec-users] Arrange Act Assert (AAA) style syntax for rspec2 In-Reply-To: <3100ed9b-36b0-4461-81d1-3cdade05cba2@a10g2000vby.googlegroups.com> References: <3100ed9b-36b0-4461-81d1-3cdade05cba2@a10g2000vby.googlegroups.com> Message-ID: <92516186-01F0-4125-9107-A8DF540BA8FF@gmail.com> On Jan 21, 2011, at 10:32 AM, JDeville wrote: > I'd like to be able to test w/ this methodology, and i'm having > trouble figuring out where to hook in to rspec to do it. Near as I > can tell, the flow is this: > > run all of the before filters in the order of highest to lowest > context > > <<-- I need to run something right here > > run tests > > run all of the after filters in the order of highest to lowest context > > Is there any way to create a before filter that is always run after > all of the others? This sounds complicated. In BDD, we use Given/When/Then to mean what you mean by AAA. You can do this all right in the example: it "does something" do # given # when # then end You can use before hooks to set up the givens if you want (though be careful, as this is widely abused leading to less readability), but the when and then should be right in the example. HTH, David From lists at ruby-forum.com Sat Jan 22 12:18:34 2011 From: lists at ruby-forum.com (wolf volpi) Date: Sat, 22 Jan 2011 18:18:34 +0100 Subject: [rspec-users] No command 'rspec' found In-Reply-To: References: Message-ID: <0f87c2d65f9ec58260b41c5e0a6d0faa@ruby-forum.com> Thanks Luis. I uninstaled rubygems1.8 and reinstalled rubygems1.8 and rspec. This time it worked. I installed rubygems1.8 from the Ubuntu Software Center. Then from the terminal: gem install rspec -v 2.0.0 WARNING: Installing to ~/.gem since /var/lib/gems/1.8 and /var/lib/gems/1.8/bin aren't both writable. WARNING: You don't have /home/wolf/.gem/ruby/1.8/bin in your PATH, gem executables will not run. ************************************************** Thank you for installing rspec-core-2.0.0 Please be sure to look at Upgrade.markdown to see what might have changed since the last release. ************************************************** Successfully installed diff-lcs-1.1.2 Successfully installed rspec-core-2.0.0 Successfully installed rspec-expectations-2.0.0 Successfully installed rspec-mocks-2.0.0 Successfully installed rspec-2.0.0 5 gems installed Installing ri documentation for diff-lcs-1.1.2... Installing ri documentation for rspec-core-2.0.0... Installing ri documentation for rspec-expectations-2.0.0... Installing ri documentation for rspec-mocks-2.0.0... Installing ri documentation for rspec-2.0.0... Installing RDoc documentation for diff-lcs-1.1.2... Installing RDoc documentation for rspec-core-2.0.0... Installing RDoc documentation for rspec-expectations-2.0.0... Installing RDoc documentation for rspec-mocks-2.0.0... Installing RDoc documentation for rspec-2.0.0... ~$ rspec --help No command 'rspec' found, did you mean: Command 'spec' from package 'librspec-ruby1.8' (universe) Command 'tspec' from package 'tendra' (universe) rspec: command not found ~$ printenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games ~$ export PATH=$PATH:/home/wolf/.gem/ruby/1.8/bin ~$ rspec --help Usage: rspec [options] [files or directories] -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Sat Jan 22 18:30:52 2011 From: lists at ruby-forum.com (Andrew Dangerfield) Date: Sun, 23 Jan 2011 00:30:52 +0100 Subject: [rspec-users] uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError) Message-ID: I am a new to ruby and rails and am trying to refactor some code with rspec and have run into a problem that has stumped me for a few days and I have searched google and ruby/rails forums to no avail so I really hope somebody can help me out with this problem which I think may be caused by a rails config problem. Anyway, I used 'rails new myapp' to make a new rails project and then I copied the files (just a few files each containing a class) I want to refactor into "myapp/app" and after running the command 'rspec collector_helper_spec.rb' I get the following error: ************************************************************************** C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/tag_helper.rb:10: uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError) from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/javascript_helper.rb:1 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/url_helper.rb:1 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/asset_tag_helper.rb:3 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' from ./helper.rb:3 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from C:/Users/bob/app/collector_helper_spec.rb:8 from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `map' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in `load_spec_files' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in `run' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in `run_in_process' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in `run' from C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in `autorun' from C:/Ruby187/bin/rspec:19 ************************************************************************** Can anyone explain to me why ERB cannot be found? From the information I found about ERB it is part of ActiveSupport and I ran the command "gem install activesupport" and afterwards I see activesupport installed when I issue the command "gem list". If anyone can point me in the right direction either by explaining what I am doing wrong or telling me about some documentation to read or something that would be great. -- Posted via http://www.ruby-forum.com/. From apremdas at gmail.com Sat Jan 22 19:50:15 2011 From: apremdas at gmail.com (Andrew Premdas) Date: Sun, 23 Jan 2011 00:50:15 +0000 Subject: [rspec-users] major release required? In-Reply-To: References: <959679BB-A576-45DB-BB31-7BC580393201@gmail.com> <9BC29C57-BFD7-4C26-8AB0-6BF38F68AE09@gmail.com> Message-ID: ]On 22 January 2011 09:47, David Chelimsky wrote: > On Fri, Jan 21, 2011 at 5:13 PM, Andrew Premdas > wrote: > > On 21 January 2011 13:56, David Chelimsky wrote: > >> > >> On Jan 19, 2011, at 6:48 AM, Rick DeNatale wrote: > >> > >> > On Tue, Jan 18, 2011 at 1:31 PM, David Chelimsky < > dchelimsky at gmail.com> > >> > wrote: > >> >> > >> >> On Jan 18, 2011, at 11:08 AM, Rick DeNatale wrote: > >> >> > >> >>> On Tue, Jan 18, 2011 at 9:15 AM, David Chelimsky > >> >>> wrote: > >> >>>> Hi all, > >> >>>> > >> >>>> Since the release of rspec-2.0, I've been following Rubygems' > >> >>>> rational versioning [1] as closely as possible. Patch releases > (2.4.x) have > >> >>>> only had bug fixes, and minor releases (2.x.0) have had new > features, but no > >> >>>> (intentionally) backward incompatible changes, which should require > a major > >> >>>> (3.0) release. > >> >>>> > >> >>>> The autotest extension in rspec-2.0 prefixes the command it > generates > >> >>>> with 'bundle exec' if it sees a 'Gemfile' in the project root > directory. It > >> >>>> turns out that this is not universally helpful, so there was a > request to > >> >>>> have an opt-out. > >> >>>> > >> >>>> It also turns out that autotest has a bundler plugin that prefixes > >> >>>> the command with 'bundle exec'. To use an autotest plugin, you just > require > >> >>>> it in a .autotest file in the project root. In this case: > >> >>>> > >> >>>> require 'autotest/bundler' > >> >>>> > >> >>>> I think the right thing to do is to rely on the autotest plugin, > but > >> >>>> I also think that this would require a 3.0 release, which feels a > bit grand > >> >>>> for this situation. My question to you is: do you think this > warrants a > >> >>>> major (3.0) release, or would it be an acceptable exception to the > rule > >> >>>> (assuming proper fanfare and documentation)? > >> >>> > >> >>> Can't something be done here as a non-breaking change? I can see > two > >> >>> things. > >> >>> > >> >>> 1) add the requested option, I think this is optional > >> >>> > >> >>> 2) in lib/autotest/rspec2.rb > >> >>> > >> >>> def using_bundler? > >> >>> File.exists?('./Gemfile') && !defined Autotest::Bundler # and > >> >>> also check for the option if you decide to do #1 > >> >>> end > >> >> > >> >> I actually did implement a --skip-bundler option (not yet released), > >> >> but it has to be passed like this: > >> >> > >> >> autotest -- --skip-bundler > >> >> > >> >> Considering that this is a total hack, and that I'd be removing it at > >> >> the next major release anyway, I really don't want to introduce a > hack on > >> >> top of a hack. I'd sooner do a 3.0 release now. > >> > > >> > I'm still trying to understand what you are proposing to change, and > >> > what it breaks. > >> > > >> > I guess you are proposing that the rspec autotest extension would > >> > never prefix the rspec command with 'bundle exec' and this would break > >> > folks using autotest with rspec who haven't changed their .autotest > >> > file. > >> > >> Correct. > >> > >> > And that you think that you should bump the whole rspec suite to > >> > version 3 because of this? I guess this is because the autotest > >> > 'extension' isn't really an extension, it's in rspec-core. > >> > >> Correct. And I'm trying to establish a consistent pattern in releases so > >> people can trust that minor and patch releases won't introduce breaking > >> changes. This one is a bit of an outlier, and I started this thread to > see > >> what ppl thought of treating it as such, but the more I think of it, the > >> more I'm convinced that this should not be an exception. > >> > >> > What about those of us using other alternatives to autotest, e.g. > >> > guard? I just looked at the guard code and changing rspec as a whole > >> > to version 3 would break guard since it checks specifically for rspec > >> > version 1 vs. 2 in order to determine whether to use 'spec' or 'rspec' > >> > as the base command. > >> > >> That's unfortunate. Whether or not I do an rspec-3 release now, > adherence > >> to Rubygems' rational versioning policy will likely result in an rspec-3 > >> release in much less time than it took us to get to rspec-2. When it > comes > >> out, rspec-3 will not represent a major rewrite or significant API or > >> functional changes. It will simply be an indicator that there are > >> backward-incompatible changes in that release and you should accept that > >> upgrade consciously and carefully. > >> > >> > If you bump rspec to v3 because of this, it looks like guard users > >> > will need to freeze on rspec 2, at least until the author of > >> > guard-rspec catches up. I guess that's OK unless the latter takes too > >> > long, and rspec continues to improve only on the version 3 branch. > >> > That probably wouldn't happen, and if it does I could fork guard-rspec > >> > myself I guess. > >> > >> Thanks for being willing to help out. We should probably hit guard-rspec > >> up with this now, though, so when rspec-3 does come along guard users > don't > >> have to take a hit at that point. Do you want to drive that? > >> > >> > But if you do, I think you should also break out the autotest > >> > extension into a separate gem which is NOT required by rspec-core, > >> > much like Rails 3 broke out 'most-favored' things like Test::Unit and > >> > put alternatives like, say RSpec, and Cucumber on more of an equal > >> > footing. > >> > >> Definitely in the plan for rspec-3: > >> https://github.com/rspec/rspec-core/issues/issue/285. > >> > >> Cheers, > >> David > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > Whilst its very noble to try and follow the ruby gems document to the > > letter, some consideration has to be given to the overall effect of > rapidly > > changing major version numbers on the project. RSpec has a very large > user > > base, a close tie in with Rails major versions, in particular the idea to > > Rails 3 should use RSpec 2, and a history of changing major versions very > > infrequently with major consequences to the vast majority of users. This > I > > think is a fair assessment of RSpec's context re version numbers. To move > to > > RSpec 3, for such a small change would be completely out of character for > > the project. To end up in 4 months time with RSpec 9 would be very > > detrimental to the projects reputation. > > So I think the pragmatic approach is a minor release with a big caveat in > > the history and a big announcement on the mailing list > > The goal here is to set a new standard that people can count on. Right > now, many rspec users count on upgrades breaking things, which is not > exactly the sort of reliability I'd like to convey. > > I want to eliminate any perception of a binding between Rails and > RSpec releases. It's one thing to have a compatibility mapping > (rspec-2 supports rails >= 3), but it's entirely another to assume > that we need to wait for rails-4 to release rspec-3. > Of course, and I wasn't suggesting that rspec3 should wait for rails4. > As for the timing of major releases, I'm thinking more like a major > release every 6 months to a year, not 7 more in 4 months time :) And, > again, the idea is that major releases won't be quite so major. They > simply indicate that there are breaking changes in the release, and > you should upgrade to that release knowingly. > > My concern is that people (especially project owners and people further away from the project) seeing RSpec moving quickly to 3, 4, 5 will judge the project unstable and think that each change will involve a similar amount of work as moving from rspec1 to 2, or even Rails 2.x to 3.x. This would be a good (in innaccurate) argument for choosing a more 'stable' test tool. A major release every 6 months to a year seems reasonable, but I'm not convinced you could keep to this if this particular change and changes like it caused a major release. I've found a solution that I think serves these goals well: rspec-2.5 > will add the --skip-bundler option and deprecate the implicit addition > of 'bundle exec'. It will still work as 2.4 does, but users will see a > deprecation warning explaining to use the autotest/bundler plugin or > the --skip-bundler option. When either of those options is applied, > the deprecation warning goes away. > The add an option and a deprecation warning approach seems an excellent compromise to prepare for a more permanent solution in 3.0. Perhaps there is a pattern here to be applied to similar changes, thus giving advanced users time to use the new functionality in anger, and get feedback over a period of time. All best Andrew > > When it comes time to release rspec-3, rspec-autotest will be > extracted from rspec-core, the --skip-bundler will no longer do > anything, and you'll see a message saying so. At that point, you > either use the autotest/bundler plugin or not. > > Thoughts? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffdeville at gmail.com Sat Jan 22 21:02:56 2011 From: jeffdeville at gmail.com (JDeville) Date: Sat, 22 Jan 2011 18:02:56 -0800 (PST) Subject: [rspec-users] Arrange Act Assert (AAA) style syntax for rspec2 In-Reply-To: <92516186-01F0-4125-9107-A8DF540BA8FF@gmail.com> References: <3100ed9b-36b0-4461-81d1-3cdade05cba2@a10g2000vby.googlegroups.com> <92516186-01F0-4125-9107-A8DF540BA8FF@gmail.com> Message-ID: <53fb9975-ca2b-487f-8f9f-f9b5558f91ec@q12g2000yqi.googlegroups.com> Thanks David, What I really need is an explicit way of calling 'when'. You helped me find the rspec-given gem, so I'll try that. I think that, and the spies support from the Bourne gem will give me what I've been hoping for. Thanks for everything David. On Jan 22, 11:07?am, David Chelimsky wrote: > On Jan 21, 2011, at 10:32 AM, JDeville wrote: > > > I'd like to be able to test w/ this methodology, and i'm having > > trouble figuring out where to hook in to rspec to do it. ?Near as I > > can tell, the flow is this: > > > run all of the before filters in the order of highest to lowest > > context > > > <<-- ?I need to run something right here > > > run tests > > > run all of the after filters in the order of highest to lowest context > > > Is there any way to create a before filter that is always run after > > all of the others? > > This sounds complicated. > > In BDD, we use Given/When/Then to mean what you mean by AAA. You can do this all right in the example: > > it "does something" do > ? # given > ? # when > ? # then > end > > You can use before hooks to set up the givens if you want (though be careful, as this is widely abused leading to less readability), but the when and then should be right in the example. > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Sat Jan 22 23:08:30 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 22 Jan 2011 22:08:30 -0600 Subject: [rspec-users] major release required? In-Reply-To: References: <959679BB-A576-45DB-BB31-7BC580393201@gmail.com> <9BC29C57-BFD7-4C26-8AB0-6BF38F68AE09@gmail.com> Message-ID: On Jan 22, 2011, at 6:50 PM, Andrew Premdas wrote: > ]On 22 January 2011 09:47, David Chelimsky wrote: > On Fri, Jan 21, 2011 at 5:13 PM, Andrew Premdas wrote: > > On 21 January 2011 13:56, David Chelimsky wrote: > >> > >> On Jan 19, 2011, at 6:48 AM, Rick DeNatale wrote: > >> > >> > On Tue, Jan 18, 2011 at 1:31 PM, David Chelimsky > >> > wrote: > >> >> > >> >> On Jan 18, 2011, at 11:08 AM, Rick DeNatale wrote: > >> >> > >> >>> On Tue, Jan 18, 2011 at 9:15 AM, David Chelimsky > >> >>> wrote: > >> >>>> Hi all, > >> >>>> > >> >>>> Since the release of rspec-2.0, I've been following Rubygems' > >> >>>> rational versioning [1] as closely as possible. Patch releases (2.4.x) have > >> >>>> only had bug fixes, and minor releases (2.x.0) have had new features, but no > >> >>>> (intentionally) backward incompatible changes, which should require a major > >> >>>> (3.0) release. > >> >>>> > >> >>>> The autotest extension in rspec-2.0 prefixes the command it generates > >> >>>> with 'bundle exec' if it sees a 'Gemfile' in the project root directory. It > >> >>>> turns out that this is not universally helpful, so there was a request to > >> >>>> have an opt-out. > >> >>>> > >> >>>> It also turns out that autotest has a bundler plugin that prefixes > >> >>>> the command with 'bundle exec'. To use an autotest plugin, you just require > >> >>>> it in a .autotest file in the project root. In this case: > >> >>>> > >> >>>> require 'autotest/bundler' > >> >>>> > >> >>>> I think the right thing to do is to rely on the autotest plugin, but > >> >>>> I also think that this would require a 3.0 release, which feels a bit grand > >> >>>> for this situation. My question to you is: do you think this warrants a > >> >>>> major (3.0) release, or would it be an acceptable exception to the rule > >> >>>> (assuming proper fanfare and documentation)? > >> >>> > >> >>> Can't something be done here as a non-breaking change? I can see two > >> >>> things. > >> >>> > >> >>> 1) add the requested option, I think this is optional > >> >>> > >> >>> 2) in lib/autotest/rspec2.rb > >> >>> > >> >>> def using_bundler? > >> >>> File.exists?('./Gemfile') && !defined Autotest::Bundler # and > >> >>> also check for the option if you decide to do #1 > >> >>> end > >> >> > >> >> I actually did implement a --skip-bundler option (not yet released), > >> >> but it has to be passed like this: > >> >> > >> >> autotest -- --skip-bundler > >> >> > >> >> Considering that this is a total hack, and that I'd be removing it at > >> >> the next major release anyway, I really don't want to introduce a hack on > >> >> top of a hack. I'd sooner do a 3.0 release now. > >> > > >> > I'm still trying to understand what you are proposing to change, and > >> > what it breaks. > >> > > >> > I guess you are proposing that the rspec autotest extension would > >> > never prefix the rspec command with 'bundle exec' and this would break > >> > folks using autotest with rspec who haven't changed their .autotest > >> > file. > >> > >> Correct. > >> > >> > And that you think that you should bump the whole rspec suite to > >> > version 3 because of this? I guess this is because the autotest > >> > 'extension' isn't really an extension, it's in rspec-core. > >> > >> Correct. And I'm trying to establish a consistent pattern in releases so > >> people can trust that minor and patch releases won't introduce breaking > >> changes. This one is a bit of an outlier, and I started this thread to see > >> what ppl thought of treating it as such, but the more I think of it, the > >> more I'm convinced that this should not be an exception. > >> > >> > What about those of us using other alternatives to autotest, e.g. > >> > guard? I just looked at the guard code and changing rspec as a whole > >> > to version 3 would break guard since it checks specifically for rspec > >> > version 1 vs. 2 in order to determine whether to use 'spec' or 'rspec' > >> > as the base command. > >> > >> That's unfortunate. Whether or not I do an rspec-3 release now, adherence > >> to Rubygems' rational versioning policy will likely result in an rspec-3 > >> release in much less time than it took us to get to rspec-2. When it comes > >> out, rspec-3 will not represent a major rewrite or significant API or > >> functional changes. It will simply be an indicator that there are > >> backward-incompatible changes in that release and you should accept that > >> upgrade consciously and carefully. > >> > >> > If you bump rspec to v3 because of this, it looks like guard users > >> > will need to freeze on rspec 2, at least until the author of > >> > guard-rspec catches up. I guess that's OK unless the latter takes too > >> > long, and rspec continues to improve only on the version 3 branch. > >> > That probably wouldn't happen, and if it does I could fork guard-rspec > >> > myself I guess. > >> > >> Thanks for being willing to help out. We should probably hit guard-rspec > >> up with this now, though, so when rspec-3 does come along guard users don't > >> have to take a hit at that point. Do you want to drive that? > >> > >> > But if you do, I think you should also break out the autotest > >> > extension into a separate gem which is NOT required by rspec-core, > >> > much like Rails 3 broke out 'most-favored' things like Test::Unit and > >> > put alternatives like, say RSpec, and Cucumber on more of an equal > >> > footing. > >> > >> Definitely in the plan for rspec-3: > >> https://github.com/rspec/rspec-core/issues/issue/285. > >> > >> Cheers, > >> David > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > Whilst its very noble to try and follow the ruby gems document to the > > letter, some consideration has to be given to the overall effect of rapidly > > changing major version numbers on the project. RSpec has a very large user > > base, a close tie in with Rails major versions, in particular the idea to > > Rails 3 should use RSpec 2, and a history of changing major versions very > > infrequently with major consequences to the vast majority of users. This I > > think is a fair assessment of RSpec's context re version numbers. To move to > > RSpec 3, for such a small change would be completely out of character for > > the project. To end up in 4 months time with RSpec 9 would be very > > detrimental to the projects reputation. > > So I think the pragmatic approach is a minor release with a big caveat in > > the history and a big announcement on the mailing list > > The goal here is to set a new standard that people can count on. Right > now, many rspec users count on upgrades breaking things, which is not > exactly the sort of reliability I'd like to convey. > > I want to eliminate any perception of a binding between Rails and > RSpec releases. It's one thing to have a compatibility mapping > (rspec-2 supports rails >= 3), but it's entirely another to assume > that we need to wait for rails-4 to release rspec-3. > > Of course, and I wasn't suggesting that rspec3 should wait for rails4. > > As for the timing of major releases, I'm thinking more like a major > release every 6 months to a year, not 7 more in 4 months time :) And, > again, the idea is that major releases won't be quite so major. They > simply indicate that there are breaking changes in the release, and > you should upgrade to that release knowingly. > > My concern is that people (especially project owners and people further away from the project) seeing RSpec moving quickly to 3, 4, 5 will judge the project unstable and think that each change will involve a similar amount of work as moving from rspec1 to 2, or even Rails 2.x to 3.x. This would be a good (in innaccurate) argument for choosing a more 'stable' test tool. If breaking changes only happen in major releases, and that turns some people away, then so be it. I'm hopeful that the ability to rely on minor releases not breaking things will outweigh that concern for most. I'll soon be posting a more detailed explanation of the release policy on http://relishapp.com/rspec, and blogging about it long before there is a 3.0 release. If people read that (or fail to read it) and still decide that this policy is a sign of instability, there's not much that I can do about that. > A major release every 6 months to a year seems reasonable, but I'm not convinced you could keep to this if this particular change and changes like it caused a major release. I'm not saying there would be a release every time a change like this came up. There will be a major release once enough of them pile up that it makes sense to clean house. > I've found a solution that I think serves these goals well: rspec-2.5 > will add the --skip-bundler option and deprecate the implicit addition > of 'bundle exec'. It will still work as 2.4 does, but users will see a > deprecation warning explaining to use the autotest/bundler plugin or > the --skip-bundler option. When either of those options is applied, > the deprecation warning goes away. > > The add an option and a deprecation warning approach seems an excellent compromise to prepare for a more permanent solution in 3.0. Perhaps there is a pattern here to be applied to similar changes, That's the idea. > thus giving advanced users time to use the new functionality in anger, and get feedback over a period of time. Early feedback would definitely be an added benefit. Cheers, David > > All best > > Andrew > > When it comes time to release rspec-3, rspec-autotest will be > extracted from rspec-core, the --skip-bundler will no longer do > anything, and you'll see a message saying so. At that point, you > either use the autotest/bundler plugin or not. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 23 08:17:04 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 23 Jan 2011 07:17:04 -0600 Subject: [rspec-users] uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError) In-Reply-To: References: Message-ID: <39E6F33A-9EC7-4D73-A556-C41A3EF114B3@gmail.com> On Jan 22, 2011, at 5:30 PM, Andrew Dangerfield wrote: > I am a new to ruby and rails and am trying to refactor some code with > rspec and have run into a problem that has stumped me for a few days and > I have searched google and ruby/rails forums to no avail so I really > hope somebody can help me out with this problem which I think may be > caused by a rails config problem. Anyway, I used 'rails new myapp' to > make a new rails project and then I copied the files (just a few files > each containing a class) I want to refactor into "myapp/app" and after > running the command 'rspec collector_helper_spec.rb' I get the following > error: > > ************************************************************************** > C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/tag_helper.rb:10: > uninitialized constant ActionView::Helpers::TagHelper::ERB (NameError) > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/javascript_helper.rb:1 > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/url_helper.rb:1 > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_view/helpers/asset_tag_helper.rb:3 > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in > `gem_original_require' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in > `require' > from ./helper.rb:3 > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `gem_original_require' > from > C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in > `require' > from C:/Users/bob/app/collector_helper_spec.rb:8 > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `map' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/configuration.rb:387:in > `load_spec_files' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/command_line.rb:18:in > `run' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:55:in > `run_in_process' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:46:in > `run' > from > C:/Ruby187/lib/ruby/gems/1.8/gems/rspec-core-2.4.0/lib/rspec/core/runner.rb:10:in > `autorun' > from C:/Ruby187/bin/rspec:19 > ************************************************************************** > > Can anyone explain to me why ERB cannot be found? From the information > I found about ERB it is part of ActiveSupport and I ran the command "gem > install activesupport" and afterwards I see activesupport installed when > I issue the command "gem list". If anyone can point me in the right > direction either by explaining what I am doing wrong or telling me about > some documentation to read or something that would be great. I see a couple of problems in the backtrace, and it's hard to know whether resolving them will fix this issue or not. But let's give it a shot: 1. Make sure you have this in your Gemfile: gem 'rspec-rails', :group => [:development, :test] 2. Install the bundle bundle install After you do this, 'gem list rspec' should include rspec, rspec-core, rspec-expectations, rspec-mocks, and rspec-rails. 3. Install rspec rails generate rspec:install 4. Move app/collector_helper_spec.rb to spec/helpers/collector_helper_spec.rb and make sure the following appears at the top: require "spec_helper" Now try running 'rake spec' and if you still run into the any problems, please post (preferably on http://gist.github.com/ or http://pastie.org/) the backtrace and code in spec/helpers/collector_helper_spec.rb, app/helpers/collector_helper.rb. HTH, David From wilkerlucio at gmail.com Mon Jan 24 09:26:40 2011 From: wilkerlucio at gmail.com (Wilker) Date: Mon, 24 Jan 2011 11:26:40 -0300 Subject: [rspec-users] Aidmock - safe mocking In-Reply-To: References: <88595570-CE2E-46AD-AA56-B3039739EA1F@me.com> Message-ID: Hi Guys, I added a significant release of Aidmock today. Now it supports an Automatic Interfacing feature. With this feature you can use Aidmock without defining any interface at all, when Aidmock try to check an interface, and it doesn't exists, Aidmock will automatic generate the interface (of class, and all of it ancestors). It's not much precise as manual one (I can't automatic detect return and argument types), but is an easy way to start, with minimum setup at all. It also can't detect ghost methods (methods implemented with method_missing). What you guys think about this new feature? --- Wilker L?cio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Wed, Jan 19, 2011 at 4:11 AM, Wilker wrote: > Thanks guys, > > When I said I'm not getting so much feedback, I was referring because more > time ago I talked about it in a lot of other lists too, but I know it still > a lot young, and need a lot of improvement too :) > > But you know, when we launch a new project we get a lot excited with it and > expects more feedback as possible :) > > Any suggestions, critics, any kind of feedback will be really welcome :) > --- > Wilker L?cio > http://about.me/wilkerlucio/bio > Kajabi Consultant > +55 81 82556600 > > > > On Wed, Jan 19, 2011 at 3:30 AM, Pat Maddox wrote: > >> On Jan 18, 2011, at 2:30 PM, Wilker wrote: >> >> > Yeah, unfortunately I'm not receiving too much feedback about it for >> now, so, I'm just using for myself and trying to make it better. I will try >> to spread more and more the idea, so make more people wanna try it, its a >> different concept and I mean people still a little afraid to try it. But I >> will keep going on it, I really believe in the idea :) >> >> I'll give it a good mess around. It looks great. >> >> And like David said, please don't be discouraged by the limited adoption >> after two days ;) >> >> Pat >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Mon Jan 24 15:36:44 2011 From: nick at deadorange.com (Nick) Date: Mon, 24 Jan 2011 12:36:44 -0800 (PST) Subject: [rspec-users] Feedback Requested (pretty please) In-Reply-To: Message-ID: <8833316.64.1295901404232.JavaMail.geo-discussion-forums@yqmb9> Also, try to keep have just one expectation (IE: call to #should) in each test. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Jan 24 16:19:56 2011 From: lists at ruby-forum.com (Fearless Fool) Date: Mon, 24 Jan 2011 22:19:56 +0100 Subject: [rspec-users] [newbie] CSS navigation in controller response? Message-ID: <91400f4dafc2aa093049415f725e7f02@ruby-forum.com> I'm hooked on RSpec after my first taste (thanks to http://railstutorial.org/book/ruby-on-rails-tutorial). And of course I have a newbish question. Assume a contrived doc structure like: Now lets say I want to write an RSpec controller test that will pass if the status is "moribund" or "Moribund" or "MORIBUND". I know I can write: it "should be moribund" do get :show response.should have_selector("td", :class => "status", :content => "moribund") end ... which captures the fact that the status string is inside a "td.status" element, but is case sensitive. Alternatively I could write: it "should be moribund" do get :show response.body.should =~ /moribund/i end ... which is case insensitive but doesn't discriminate where the string appears in the document. What's the right idiom to navigate to a specific place in a document (preferably using CSS navigation syntax) AND perform a case-insensitive test? TIA. - ff P.S.: I fully appreciate that you shouldn't normally hardwire the document structure into the test itself -- that's not what this question is about! :) P.P.S: I know that response is an ActionController::TestResponse object, but haven't been able to find docs or sources for that -- where should I look? -- Posted via http://www.ruby-forum.com/. From dolzenko at gmail.com Tue Jan 25 01:08:33 2011 From: dolzenko at gmail.com (Evgeniy Dolzhenko) Date: Tue, 25 Jan 2011 09:08:33 +0300 Subject: [rspec-users] [newbie] CSS navigation in controller response? In-Reply-To: <91400f4dafc2aa093049415f725e7f02@ruby-forum.com> References: <91400f4dafc2aa093049415f725e7f02@ruby-forum.com> Message-ID: <4D3E68E1.7050001@gmail.com> You can pass a block to `have_selector` to nest your assertions, like: response.should have_selector("td", :class => "status") do |td| td.to_s.should == /moribund/i # => td is [#, ...] here end On 1/25/2011 12:19 AM, Fearless Fool wrote: > I'm hooked on RSpec after my first taste (thanks to > http://railstutorial.org/book/ruby-on-rails-tutorial). And of course I > have a newbish question. > > Assume a contrived doc structure like: > > > > > > > > Now lets say I want to write an RSpec controller test that will pass if > the status is "moribund" or "Moribund" or "MORIBUND". > > I know I can write: > > it "should be moribund" do > get :show > response.should have_selector("td", :class => "status", :content => > "moribund") > end > > ... which captures the fact that the status string is inside a > "td.status" element, but is case sensitive. Alternatively I could > write: > > it "should be moribund" do > get :show > response.body.should =~ /moribund/i > end > > ... which is case insensitive but doesn't discriminate where the string > appears in the document. > > What's the right idiom to navigate to a specific place in a document > (preferably using CSS navigation syntax) AND perform a case-insensitive > test? > > TIA. > > - ff > > > P.S.: I fully appreciate that you shouldn't normally hardwire the > document structure into the test itself -- that's not what this question > is about! :) > > P.P.S: I know that response is an ActionController::TestResponse object, > but haven't been able to find docs or sources for that -- where should I > look? > From lists at ruby-forum.com Tue Jan 25 04:10:29 2011 From: lists at ruby-forum.com (Fearless Fool) Date: Tue, 25 Jan 2011 10:10:29 +0100 Subject: [rspec-users] [newbie] CSS navigation in controller response? In-Reply-To: <4D3E68E1.7050001@gmail.com> References: <91400f4dafc2aa093049415f725e7f02@ruby-forum.com> <4D3E68E1.7050001@gmail.com> Message-ID: <0bffc5bed192d07754597ba4230f52df@ruby-forum.com> Evgeniy Dolzhenko wrote in post #977322: > You can pass a block to `have_selector` to nest your assertions, like: > ... > td is [#, ...] here Most wonderfully cool. If it's Nokogiri, then I'm on familiar turf. Thanks very much. - ff -- Posted via http://www.ruby-forum.com/. From nick at deadorange.com Tue Jan 25 15:17:50 2011 From: nick at deadorange.com (Nick) Date: Tue, 25 Jan 2011 12:17:50 -0800 (PST) Subject: [rspec-users] [newbie] CSS navigation in controller response? In-Reply-To: <91400f4dafc2aa093049415f725e7f02@ruby-forum.com> Message-ID: <23898188.121.1295986670157.JavaMail.geo-discussion-forums@yqcj39> Would replacing :content => "moribund" with :content => /moribund/ work? -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Tue Jan 25 15:18:14 2011 From: nick at deadorange.com (Nick) Date: Tue, 25 Jan 2011 12:18:14 -0800 (PST) Subject: [rspec-users] [newbie] CSS navigation in controller response? In-Reply-To: <23898188.121.1295986670157.JavaMail.geo-discussion-forums@yqcj39> Message-ID: <3932625.1036.1295986694881.JavaMail.geo-discussion-forums@yqmb9> Whoops, let me fix that: Would replacing :content => "moribund" with :content => /moribund/i work? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dolzenko at gmail.com Wed Jan 26 02:21:51 2011 From: dolzenko at gmail.com (Evgeniy Dolzhenko) Date: Wed, 26 Jan 2011 10:21:51 +0300 Subject: [rspec-users] [newbie] CSS navigation in controller response? In-Reply-To: <3932625.1036.1295986694881.JavaMail.geo-discussion-forums@yqmb9> References: <3932625.1036.1295986694881.JavaMail.geo-discussion-forums@yqmb9> Message-ID: <4D3FCB8F.8030503@gmail.com> I wish it would, but no, it won't due to the nature of how Webrat have_selector matcher works (it uses XPath queries behind the scenes) On 1/25/2011 11:18 PM, Nick wrote: > Whoops, let me fix that: > > Would replacing > :content => "moribund" > with > :content => /moribund/i > work? > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From Rob.aldred at stardotstar.com Wed Jan 26 08:34:35 2011 From: Rob.aldred at stardotstar.com (Rob Aldred) Date: Wed, 26 Jan 2011 13:34:35 +0000 Subject: [rspec-users] Ability to stub a method differently the second time its called In-Reply-To: <53d2a6e9-4362-4121-82e4-e0453e7c2d50@w2g2000yqb.googlegroups.com> References: <35f1161a-a48b-4cfa-bffc-701e13625a12@fl7g2000vbb.googlegroups.com> <53d2a6e9-4362-4121-82e4-e0453e7c2d50@w2g2000yqb.googlegroups.com> Message-ID: <9EC25DA0-FB88-4E3B-8F1D-394C5592512A@stardotstar.com> I'm having a bit of trouble stubbing out a method on a model which has some quite specific behaviour. Basically I want to check the method returns something different after ive called update_attributes eg. @exam.draft? (returns true) @exam.update_attributes(params[:exam]) # sets draft to false @exam.draft? (returns false) To give this some context, if the exam is a draft and update_attributes sets draft to false then we want to redirect to the show view instead of edit because only exams that are draft can be edited. if @exam.draft? @exam.update_attributes param[:exam] end if @exam.draft? redirect_to :action => :edit else redirect_to :action => :show end I can obviously set consecutive values with and_return(true,false) but this feels a bit unreliable? maybe im just confusing myself -- Rob Aldred Software Developer rob at stardotstar.com twitter: stardotstar 47 Newton Street, Manchester, M1 1FT T: +44 (0) 161 236 9740 ___________________________________________________ This email and any files or ideas transmitted within it are sent in confidence and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager at info at stardotstar.com From tom at therye.org Wed Jan 26 09:12:41 2011 From: tom at therye.org (Tom Stuart) Date: Wed, 26 Jan 2011 14:12:41 +0000 Subject: [rspec-users] Ability to stub a method differently the second time its called In-Reply-To: <9EC25DA0-FB88-4E3B-8F1D-394C5592512A@stardotstar.com> References: <35f1161a-a48b-4cfa-bffc-701e13625a12@fl7g2000vbb.googlegroups.com> <53d2a6e9-4362-4121-82e4-e0453e7c2d50@w2g2000yqb.googlegroups.com> <9EC25DA0-FB88-4E3B-8F1D-394C5592512A@stardotstar.com> Message-ID: <2518D5C0-EE83-4581-855E-7290D484CA13@therye.org> On 26 Jan 2011, at 13:34, Rob Aldred wrote: > I'm having a bit of trouble stubbing out a method on a model which has some quite specific behaviour. > Basically I want to check the method returns something different after ive called update_attributes > > eg. > > @exam.draft? (returns true) > @exam.update_attributes(params[:exam]) # sets draft to false > @exam.draft? (returns false) > > To give this some context, if the exam is a draft and update_attributes sets draft to false > then we want to redirect to the show view instead of edit because only exams that are draft can be edited. > > if @exam.draft? > @exam.update_attributes param[:exam] > end > > if @exam.draft? > redirect_to :action => :edit > else > redirect_to :action => :show > end > > I can obviously set consecutive values with and_return(true,false) > but this feels a bit unreliable? maybe im just confusing myself > > -- > Rob Aldred > > Software Developer > rob at stardotstar.com > twitter: stardotstar > > 47 Newton Street, Manchester, M1 1FT > T: +44 (0) 161 236 9740 > ___________________________________________________ > > This email and any files or ideas transmitted within it are sent in > confidence and are intended solely for the use of the individual or > entity to whom they are addressed. If you have received this email > in error please notify the system manager at info at stardotstar.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Hi Rob, It sounds to me like you're trying to test two different behaviours in one 'it' block, something like: it "redirects based on whether the exam is a draft" do @exam.stub!(:draft).and_return(true, false) #make request, assert response redirected to edit #make request again, assert reponse redirected to edit end To describe your behaviour more clearly, you might want to consider splitting this test and using contexts, something along the lines of... describe "your action" do context "when exam is a draft" do @exam.stub!(:draft).and_return(true) it "redirects to edit" do end end context "when exam is final" do @exam.stub!(:draft).and_return(false) it "redirects to "show" do end end end Which gives you the benefit of making what you need to stub obvious based on the context. Hope that helps, Tom From pathsny at gmail.com Wed Jan 26 09:43:53 2011 From: pathsny at gmail.com (vishnu) Date: Wed, 26 Jan 2011 20:13:53 +0530 Subject: [rspec-users] changes in rspec 2.4 break ci_reporter Message-ID: Hi I use the ci_reporter gem for builds on my CI machine (hudson). Prior to rspec 2.4, environment options would override commandline options. So the gem used this to change the formatter and require its files. In 2.4, that order has been reversed. the thing is 2.4 supports multiple formatters, so there is another suggestion. RSpec::Core::ConfigurationOptions def parse_options @options = begin options_to_merge = [] if custom_options_file options_to_merge << custom_options else options_to_merge << global_options options_to_merge << local_options end options_to_merge << env_options options_to_merge << command_line_options options_to_merge.inject do |merged, options| merged.merge(options) end end end the last section, instead of merging hashes, could combine the values of all hashes with the keys "--require" or "--format". So you get the default formatter and the extra formatter that ci_reporter introduces. From zach.dennis at gmail.com Wed Jan 26 09:47:11 2011 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 26 Jan 2011 09:47:11 -0500 Subject: [rspec-users] class/type coercion in ruby blog post Message-ID: Not to spam, but I a colleague did a write up on coercion in Ruby, and I thought it was interesting and fresh, so I thought I'd share with the community: http://mutuallyhuman.com/blog/2011/01/25/class-coercion-in-ruby -- Zach Dennis http://www.continuousthinking.com (personal) http://www.mutuallyhuman.com (hire me) http://ideafoundry.info/behavior-driven-development (first rate BDD training) @zachdennis (twitter) From matt at mattwynne.net Wed Jan 26 10:26:54 2011 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 26 Jan 2011 15:26:54 +0000 Subject: [rspec-users] Comparing two XML documents Message-ID: I have a problem. I have a test that needs to assert that one XML document looks exactly like another XML document. I couldn't find a way to compare them as Nokogiri::XML::Documents, so I converted them both to strings with #to_xml and compared the strings. Trouble is, sometimes the attributes one of the nodes are rendered into the string in a different order to the other one, so you get an error of the form: Diff: @@ -5,7 +5,7 @@ - (RSpec::Expectations::ExpectationNotMetError) Most annoying. I've seen a couple of RSpec matchers in blog posts that walk and compare XML fragments but I'm surprised there isn't something more concrete that already exists. I feel like I'm missing a way to do it within an XML library, for example. Any clues out there? cheers, Matt matt at mattwynne.net 07974 430184 From dchelimsky at gmail.com Wed Jan 26 10:29:48 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 26 Jan 2011 09:29:48 -0600 Subject: [rspec-users] Ability to stub a method differently the second time its called In-Reply-To: <9EC25DA0-FB88-4E3B-8F1D-394C5592512A@stardotstar.com> References: <35f1161a-a48b-4cfa-bffc-701e13625a12@fl7g2000vbb.googlegroups.com> <53d2a6e9-4362-4121-82e4-e0453e7c2d50@w2g2000yqb.googlegroups.com> <9EC25DA0-FB88-4E3B-8F1D-394C5592512A@stardotstar.com> Message-ID: On Jan 26, 2011, at 7:34 AM, Rob Aldred wrote: > I'm having a bit of trouble stubbing out a method on a model which has some quite specific behaviour. > Basically I want to check the method returns something different after ive called update_attributes > > eg. > > @exam.draft? (returns true) > @exam.update_attributes(params[:exam]) # sets draft to false > @exam.draft? (returns false) You're testing the framework here. Why? > To give this some context, if the exam is a draft and update_attributes sets draft to false > then we want to redirect to the show view instead of edit because only exams that are draft can be edited. > > if @exam.draft? > @exam.update_attributes param[:exam] > end > > if @exam.draft? > redirect_to :action => :edit > else > redirect_to :action => :show > end > > I can obviously set consecutive values with and_return(true,false) > but this feels a bit unreliable? maybe im just confusing myself My first question is why the update_attributes needs to be conditional? Couldn't you just do: @exam.update_attributes param[:exam] if @exam.draft? redirect_to :action => :edit else redirect_to :action => :show end If it must be the way you have it, I wouldn't do this with stubs on the @exam itself. I'd do what you need to do to set the exam in a draft state (Factory(:exam, :draft => true)???), and then invoke the controller action with :draft => true in one example, and :draft => false in the other. That make sense? From haxie1 at me.com Wed Jan 26 14:19:45 2011 From: haxie1 at me.com (Kam Dahlin) Date: Wed, 26 Jan 2011 11:19:45 -0800 Subject: [rspec-users] Comparing two XML documents In-Reply-To: References: Message-ID: Aaron Patterson (author of Nokogiri) addressed this issue directly here: http://rubyforge.org/pipermail/nokogiri-talk/2009-April/000258.html I don't think document comparison was ever implemented in Nokogiri though. Cheers, kam On Jan 26, 2011, at 7:26 AM, Matt Wynne wrote: > I have a problem. I have a test that needs to assert that one XML document looks exactly like another XML document. > > I couldn't find a way to compare them as Nokogiri::XML::Documents, so I converted them both to strings with #to_xml and compared the strings. > > Trouble is, sometimes the attributes one of the nodes are rendered into the string in a different order to the other one, so you get an error of the form: > > Diff: > @@ -5,7 +5,7 @@ > > > > - > > > (RSpec::Expectations::ExpectationNotMetError) > > Most annoying. > > I've seen a couple of RSpec matchers in blog posts that walk and compare XML fragments but I'm surprised there isn't something more concrete that already exists. I feel like I'm missing a way to do it within an XML library, for example. > > Any clues out there? > > cheers, > Matt > > matt at mattwynne.net > 07974 430184 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jpshack at gmail.com Wed Jan 26 16:03:50 2011 From: jpshack at gmail.com (John-Mason P. Shackelford) Date: Wed, 26 Jan 2011 13:03:50 -0800 (PST) Subject: [rspec-users] --tty vs. --color Message-ID: <1e10e82b-f5ae-4489-ae90-729ef097c9ad@y19g2000prb.googlegroups.com> Greetings, What is the difference between rspec --tty and rspec --color. I just noticed that under JRuby output for --color is not colored but for -- tty it is. Seems like we only need one color option, why two? John-Mason P. Shackelford From dchelimsky at gmail.com Wed Jan 26 16:16:46 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 26 Jan 2011 15:16:46 -0600 Subject: [rspec-users] --tty vs. --color In-Reply-To: <1e10e82b-f5ae-4489-ae90-729ef097c9ad@y19g2000prb.googlegroups.com> References: <1e10e82b-f5ae-4489-ae90-729ef097c9ad@y19g2000prb.googlegroups.com> Message-ID: On Jan 26, 2011, at 3:03 PM, John-Mason P. Shackelford wrote: > Greetings, > > What is the difference between rspec --tty and rspec --color. I just > noticed that under JRuby output for --color is not colored but for -- > tty it is. Seems like we only need one color option, why two? The --tty option is there to tell RSpec that the output is being streamed to a terminal as opposed to a file, in which case we don't want to print the color codes even if --color is invoked. --tty by itself does not invoke colorization - there's got to be --color set somewhere: any of: ./.rspec ~/.rspec ENV["SPEC_OPTS"] RSpec.configure ... From dchelimsky at gmail.com Thu Jan 27 05:05:29 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Jan 2011 04:05:29 -0600 Subject: [rspec-users] changes in rspec 2.4 break ci_reporter In-Reply-To: References: Message-ID: <3337EDFE-4CF2-49F1-96A4-5D69E7120147@gmail.com> On Jan 26, 2011, at 8:43 AM, vishnu wrote: > Hi > I use the ci_reporter gem for builds on my CI machine (hudson). > Prior to rspec 2.4, environment options would override commandline > options. So the gem used this to change the formatter and require its > files. > > In 2.4, that order has been reversed. This has since been restored to its previous behavior, to be released in 2.5. See https://github.com/rspec/rspec-core/issues/276. > the thing is 2.4 supports multiple formatters, so there is another suggestion. > > RSpec::Core::ConfigurationOptions > def parse_options > @options = begin > options_to_merge = [] > if custom_options_file > options_to_merge << custom_options > else > options_to_merge << global_options > options_to_merge << local_options > end > options_to_merge << env_options > options_to_merge << command_line_options > > options_to_merge.inject do |merged, options| > merged.merge(options) > end > end > end > > the last section, instead of merging hashes, could combine the values > of all hashes with the keys "--require" or "--format". So you get the > default formatter and the extra formatter that ci_reporter introduces. I think I'd want a separate API for this - something like: # ~/.rspec --format-that-is-not-overridden html --out-that-is-not-overridden ~/rspec/this-project/report.html But maybe a bit less verbose :) Either that or maybe a marker option like this: # ~/.rspec --color --backtrace --no-override --require ~/path/to/file/to/always/require --format html --out ~/rspec/this-project/report.html Then require, format, and out options following the --no-override option would be additive. WDYT? Other ideas? From mguterl at gmail.com Thu Jan 27 08:48:13 2011 From: mguterl at gmail.com (Michael Guterl) Date: Thu, 27 Jan 2011 08:48:13 -0500 Subject: [rspec-users] feedback on matcher Message-ID: We have moved from Rails 2 to 3 and the changing Mailer syntax has caused us to rewrite some of our specs. In Rails 2: Implementation: Mailer.deliver_job_application(job.id, user.id) Spec: Mailer.should_receive(:deliver_job_application).with(@job.id, @user.id) --- In Rails 3: Implementation: Mailer.job_application(job.id, user.id).deliver Spec: message = double message.should_receive(:deliver) Mailer.should_receive(:job_application).with(@job.id, @user.id).and_return(message) --- I turned the latter example into a matcher for RSpec 2 and I'm open for feedback. Here's a gist incase the inline formatting sucks: https://gist.github.com/798513 RSpec::Matchers.define :deliver do |message| chain :with do |*args| @with = args end match do |mailer| mail = double mail.should_receive(:deliver) mailer.should_receive(message).with(*@with).and_return(mail) end end Mailer.should deliver(:job_application).with(@job.id, @user.id) --- Is this a sane approach? Would it have been better to adapt the Mailer interface to comply with the specs? Best, Michael Guterl From dchelimsky at gmail.com Thu Jan 27 10:30:57 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Jan 2011 09:30:57 -0600 Subject: [rspec-users] feedback on matcher In-Reply-To: References: Message-ID: On Jan 27, 2011, at 7:48 AM, Michael Guterl wrote: > We have moved from Rails 2 to 3 and the changing Mailer syntax has > caused us to rewrite some of our specs. > > In Rails 2: > > Implementation: > Mailer.deliver_job_application(job.id, user.id) > > Spec: > Mailer.should_receive(:deliver_job_application).with(@job.id, @user.id) > > --- > > In Rails 3: > > Implementation: > Mailer.job_application(job.id, user.id).deliver > > Spec: > message = double > message.should_receive(:deliver) > Mailer.should_receive(:job_application).with(@job.id, > @user.id).and_return(message) > > --- > > I turned the latter example into a matcher for RSpec 2 and I'm open > for feedback. > > Here's a gist incase the inline formatting sucks: https://gist.github.com/798513 > > RSpec::Matchers.define :deliver do |message| > chain :with do |*args| > @with = args > end > > match do |mailer| > mail = double > mail.should_receive(:deliver) > > mailer.should_receive(message).with(*@with).and_return(mail) > end > end > > Mailer.should deliver(:job_application).with(@job.id, @user.id) > > --- > > Is this a sane approach? I think it's sane for inside your own app, but not as part of a lib. First, it's bound to rspec-mocks, and including it in an rspec lib would require extra handling to either make it only available for rspec-mocks or make it support the other frameworks that rspec supports. Second, it hides a message expectation. Again, that's fine for your own app, in which you know what's going on, but would confuse some users if it were in a lib. Make sense? > Would it have been better to adapt the > Mailer interface to comply with the specs? That's a funny thing. There are a lot of things that I think would work differently in Rails API's if they were driven out with a TDD mindset. But the API's seem to be designed with rapid prototyping in mind more than long term maintainability. For example, I'd really like to be able to write a controller example like this: # not anything close to reality controller = ThingsController.new response = controller.action(:some => 'params') response.should be_redirect_to(:action => 'other') But we don't really have a public API for instantiating controllers, which is why we have the http verb methods, which conflate routing concerns with controller concerns. I'm not judging these choices as good or bad. Just observing one aspect of the resulting 'feel'. FWIW, David From mguterl at gmail.com Thu Jan 27 13:49:13 2011 From: mguterl at gmail.com (Michael Guterl) Date: Thu, 27 Jan 2011 13:49:13 -0500 Subject: [rspec-users] feedback on matcher In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 10:30 AM, David Chelimsky wrote: > > On Jan 27, 2011, at 7:48 AM, Michael Guterl wrote: > >> We have moved from Rails 2 to 3 and the changing Mailer syntax has >> caused us to rewrite some of our specs. >> >> In Rails 2: >> >> Implementation: >> ?Mailer.deliver_job_application(job.id, user.id) >> >> Spec: >> ?Mailer.should_receive(:deliver_job_application).with(@job.id, @user.id) >> >> --- >> >> In Rails 3: >> >> Implementation: >> ?Mailer.job_application(job.id, user.id).deliver >> >> Spec: >> ?message = double >> ?message.should_receive(:deliver) >> ?Mailer.should_receive(:job_application).with(@job.id, >> @user.id).and_return(message) >> >> --- >> >> I turned the latter example into a matcher for RSpec 2 and I'm open >> for feedback. >> >> Here's a gist incase the inline formatting sucks: https://gist.github.com/798513 >> >> RSpec::Matchers.define :deliver do |message| >> ?chain :with do |*args| >> ? ?@with = args >> ?end >> >> ?match do |mailer| >> ? ?mail = double >> ? ?mail.should_receive(:deliver) >> >> ? ?mailer.should_receive(message).with(*@with).and_return(mail) >> ?end >> end >> >> Mailer.should deliver(:job_application).with(@job.id, @user.id) >> >> --- >> >> Is this a sane approach? > > I think it's sane for inside your own app, but not as part of a lib. First, it's bound to rspec-mocks, and including it in an rspec lib would require extra handling to either make it only available for rspec-mocks or make it support the other frameworks that rspec supports. Second, it hides a message expectation. Again, that's fine for your own app, in which you know what's going on, but would confuse some users if it were in a lib. > > Make sense? > Definitely, although I'm sure I'm not the only one verifying Mailers in this way, it'd be nice to have a library. >> Would it have been better to adapt the >> Mailer interface to comply with the specs? > > That's a funny thing. There are a lot of things that I think would work differently in Rails API's if they were driven out with a TDD mindset. But the API's seem to be designed with rapid prototyping in mind more than long term maintainability. For example, I'd really like to be able to write a controller example like this: > > # not anything close to reality > controller = ThingsController.new > response = controller.action(:some => 'params') > response.should be_redirect_to(:action => 'other') > > But we don't really have a public API for instantiating controllers, which is why we have the http verb methods, which conflate routing concerns with controller concerns. > This is certainly an interesting point that you bring up. I had never really considering the "why" in why we write controller specs like we do. Thanks for your insight David. Best, Michael Guterl From mguterl at gmail.com Thu Jan 27 14:05:59 2011 From: mguterl at gmail.com (Michael Guterl) Date: Thu, 27 Jan 2011 14:05:59 -0500 Subject: [rspec-users] feedback on matcher In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 10:30 AM, David Chelimsky wrote: > > On Jan 27, 2011, at 7:48 AM, Michael Guterl wrote: > >> We have moved from Rails 2 to 3 and the changing Mailer syntax has >> caused us to rewrite some of our specs. >> >> In Rails 2: >> >> Implementation: >> ?Mailer.deliver_job_application(job.id, user.id) >> >> Spec: >> ?Mailer.should_receive(:deliver_job_application).with(@job.id, @user.id) >> >> --- >> >> In Rails 3: >> >> Implementation: >> ?Mailer.job_application(job.id, user.id).deliver >> >> Spec: >> ?message = double >> ?message.should_receive(:deliver) >> ?Mailer.should_receive(:job_application).with(@job.id, >> @user.id).and_return(message) >> >> --- >> >> I turned the latter example into a matcher for RSpec 2 and I'm open >> for feedback. >> >> Here's a gist incase the inline formatting sucks: https://gist.github.com/798513 >> >> RSpec::Matchers.define :deliver do |message| >> ?chain :with do |*args| >> ? ?@with = args >> ?end >> >> ?match do |mailer| >> ? ?mail = double >> ? ?mail.should_receive(:deliver) >> >> ? ?mailer.should_receive(message).with(*@with).and_return(mail) >> ?end >> end >> >> Mailer.should deliver(:job_application).with(@job.id, @user.id) >> >> --- >> >> Is this a sane approach? > > I think it's sane for inside your own app, but not as part of a lib. First, it's bound to rspec-mocks, and including it in an rspec lib would require extra handling to either make it only available for rspec-mocks or make it support the other frameworks that rspec supports. Second, it hides a message expectation. Again, that's fine for your own app, in which you know what's going on, but would confuse some users if it were in a lib. > > Make sense? > Once you confirmed my sanity, I started implementing this matching in the rest of the project. Everything was fine until I came to an example that negates the expectation with should_not. Mailer.should_not deliver(:job_application).with(@job.id, @user.id) Failure/Error: Mailer.should_not deliver(:job_application).with(@job.id, @user.id) expected Mailer not to deliver :candidate_abandon_message I can fix this by adding another matcher: RSpec::Matchers.define :not_deliver do |message| match do |mailer| mailer.should_not_receive(message).with(*@with) end end but this feels awfully hacky and unconventional. I know Capybara has to do something similar with has_content / has_no_content and I know my team (and myself) never seem to get this correct. Is there a better way to do this? Best, Michael Guterl From mguterl at gmail.com Thu Jan 27 14:07:35 2011 From: mguterl at gmail.com (Michael Guterl) Date: Thu, 27 Jan 2011 14:07:35 -0500 Subject: [rspec-users] feedback on matcher In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 2:05 PM, Michael Guterl wrote: > On Thu, Jan 27, 2011 at 10:30 AM, David Chelimsky wrote: >> >> On Jan 27, 2011, at 7:48 AM, Michael Guterl wrote: >> >>> We have moved from Rails 2 to 3 and the changing Mailer syntax has >>> caused us to rewrite some of our specs. >>> >>> In Rails 2: >>> >>> Implementation: >>> ?Mailer.deliver_job_application(job.id, user.id) >>> >>> Spec: >>> ?Mailer.should_receive(:deliver_job_application).with(@job.id, @user.id) >>> >>> --- >>> >>> In Rails 3: >>> >>> Implementation: >>> ?Mailer.job_application(job.id, user.id).deliver >>> >>> Spec: >>> ?message = double >>> ?message.should_receive(:deliver) >>> ?Mailer.should_receive(:job_application).with(@job.id, >>> @user.id).and_return(message) >>> >>> --- >>> >>> I turned the latter example into a matcher for RSpec 2 and I'm open >>> for feedback. >>> >>> Here's a gist incase the inline formatting sucks: https://gist.github.com/798513 >>> >>> RSpec::Matchers.define :deliver do |message| >>> ?chain :with do |*args| >>> ? ?@with = args >>> ?end >>> >>> ?match do |mailer| >>> ? ?mail = double >>> ? ?mail.should_receive(:deliver) >>> >>> ? ?mailer.should_receive(message).with(*@with).and_return(mail) >>> ?end >>> end >>> >>> Mailer.should deliver(:job_application).with(@job.id, @user.id) >>> >>> --- >>> >>> Is this a sane approach? >> >> I think it's sane for inside your own app, but not as part of a lib. First, it's bound to rspec-mocks, and including it in an rspec lib would require extra handling to either make it only available for rspec-mocks or make it support the other frameworks that rspec supports. Second, it hides a message expectation. Again, that's fine for your own app, in which you know what's going on, but would confuse some users if it were in a lib. >> >> Make sense? >> > > Once you confirmed my sanity, I started implementing this matching in > the rest of the project. ?Everything was fine until I came to an > example that negates the expectation with should_not. > > Mailer.should_not deliver(:job_application).with(@job.id, @user.id) > > Failure/Error: Mailer.should_not > deliver(:job_application).with(@job.id, @user.id) > ?expected Mailer not to deliver :candidate_abandon_message > Please ignore the fact that the failure message (candidate_abandon_message) is incorrect, I was adjusting my examples for consistency. Best, Michael Guterl From doug+rspecuser at netinlet.com Thu Jan 27 15:05:01 2011 From: doug+rspecuser at netinlet.com (Doug Bryant) Date: Thu, 27 Jan 2011 14:05:01 -0600 Subject: [rspec-users] Fixtures not loading when running full test suite In-Reply-To: References: Message-ID: I'm currently running into the same issue and can find very little about it on the interwebs - i.e. an individual test run with `script/spec` works fine but the same test without any code changes fails when run as part of the suite via `rake spec` This issue seemed to start out of the blue. Some background and details... Fixtures don't seem to be loading properly when run as part of the suite. When my Driver model tries to save, it runs a validation testing that the zip code entered is valid (i.e. exists in the ZipsTerritory rating table). I have the :zips_territories fixture declared in the tests with enough data in the fixture for the test to pass. The spec runs fine when executed with `script/spec` but fails when run as part of the test suite `rake spec`. The zips_territory fixture is declared properly and in before(:each) in the tests, a driver is created with FactoryGirl via a call like Factory.create(:driver). The callstack indicates the test is failing while FactoryGirl is trying to create the model. Also, for a given developer, the same set of tests fail due to this issue consistently, but the tests which fail differ across different developers. These tests had been running fine as a suite for almost two years. In trying to debug this, I stumbled across some interesting behavior. If in the before(:each) filter on the failing tests, I printed out a log message which ultimately executed "ZipsTerritory.count". After I did this, the tests would pass as part of a suite. Needing a quick fix and not having time to debug the issue further, I just did the following in the spec_helper.rb file... config.before(:each) do Rails.logger.warn "ZipsTerritory.count == #{ZipsTerritory.count}" end This worked fine for about a week before the issue popped back up again. I can't think of anything which changed in the codebase which would have triggered this problem. The app has been running rails 2.3.8 for several months. We had been using rspec 1.3.0 and rspec-rails 1.3.2 for several months. (sidenote: rspec 1.3.1 & rspec-rails 1.3.3 seem to have some sort of other bug which fails to properly call a method on a child class and somehow gets delegated to the parent class - not present in 1.3.0 & 1.3.2 rspec/rspec-rails). I've tried several version of FactoryGirl and all of those seem to trigger the issue too. My spec_helper.rb is: https://gist.github.com/0d3ea01ffe4a15f4b2b3 Does anything stand out? Has anybody else experienced this? Any ideas? Thanks, Doug On Fri, Aug 14, 2009 at 6:04 AM, Rob Aldred wrote: > Hi, I've been trying to work this out for a while, im convinced its some > local db configuration specific to my machine. > > When running `rake spec` 14 of my test fail all of them in the user_spec > generated by restful auth. > The error for all the failing tests is: > > ActiveRecord::RecordNotFound > Couldn't find User with ID=1 > > Iv put some debugger lines and at the start of some of the tests it would > appear that the users fixture is not being loaded when running the full > suite > If I run the specific test with the spec > binary `spec spec/modes/user_spec.rb` all the fixtures are loaded and pass as expected. > > Further more, the error is only apparent when using mysql for the test > db... > When I use sqlite for the test db the tests pass when running the whole > suite and the specific test... > > Weird... I'd like to know if anyone else has experienced this and if anyone > has any pointers > as to why the fixtures are not loaded when using mysql as the test db. > > Many thanks > Rob > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rob.westgeest at gmail.com Thu Jan 27 16:45:10 2011 From: rob.westgeest at gmail.com (Rob Westgeest) Date: Thu, 27 Jan 2011 13:45:10 -0800 (PST) Subject: [rspec-users] rspec-rails 2 adding current account helper to all view specs Message-ID: Hi, in rspec-1 view specs i had the ability to say: login_as(some_role_or_account) which made some helper methods like current_account that where used in views and controllers return something valuable. Implementation was based on the fact that the controller in rspec-1 was ApplicationController. My ApplicationController contained a method for setting the current_account. In Rspec2 this is broken as the controller in ViewExampleGroup is now ActionView::TestCase::TestController. Would anyone know of an elegant way to add functionality, like helper methods, to this controller instance in all ViewExampleGroups only. option 1, which i don't like because it depends on the fact that ViewExampleGroup uses ActionView::TestCase::TestController: class ActionView::TestCase::TestController attr_accessor :current_account helper_method :current_account end module RSpec::Rails::ViewExampleGroup def login_as account controller.current_account = account end end I would like to use some hook to add these methods only to the controller instance used in the view specs, regardless of what class it is. There must be an elegant way, is there? Cheers Rob From james at jamesalmond.com Thu Jan 27 17:34:59 2011 From: james at jamesalmond.com (James Almond) Date: Thu, 27 Jan 2011 22:34:59 +0000 Subject: [rspec-users] Relish documentation for RSpec Message-ID: I was looking at the Relish documentation for RSpec today and noticed there are a few missing bits. For example, the expectation raise_error can take a block which the raised error gets passed to. This is not documented in the Relish features. I'd love to contribute to the Relish documentation for RSpec, so: Is the Relish documentation the kind of thing pull requests are accepted for? If so, is that level of detail (i.e. the fact that matcher accepts a block) appropriate for the Relish docs? Should I be working on rspec-dev? I've looked at the instructions on there but I'm unsure how that fits in with forks and pull requests etc. Thanks! James -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Jan 27 17:41:39 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Jan 2011 16:41:39 -0600 Subject: [rspec-users] Relish documentation for RSpec In-Reply-To: References: Message-ID: <0A6E105D-30A6-4131-B2AA-46EA541D1F4A@gmail.com> On Jan 27, 2011, at 4:34 PM, James Almond wrote: > I was looking at the Relish documentation for RSpec today and noticed there are a few missing bits. For example, the expectation raise_error can take a block which the raised error gets passed to. This is not documented in the Relish features. I'd love to contribute to the Relish documentation for RSpec, so: > > Is the Relish documentation the kind of thing pull requests are accepted for? > Absolutely! The relish docs are, btw, a mix of Cucumber features and Markdown files. Source is in the features directories of each project. > If so, is that level of detail (i.e. the fact that matcher accepts a block) appropriate for the Relish docs? > Yes. This is *the* documentation site, and we need to improve it to where it serves as such. > Should I be working on rspec-dev? I've looked at the instructions on there but I'm unsure how that fits in with forks and pull requests etc. > Not for these. As mentioned above ^^ source for docs for each project lives in that project: https://github.com/rspec/rspec-core/tree/master/features https://github.com/rspec/rspec-expectations/tree/master/features https://github.com/rspec/rspec-mocks/tree/master/features https://github.com/rspec/rspec-rails/tree/master/features > Thanks! > Thank _you_! It's great to see someone offering to help. Hopefully you'll inspire some others to do so as well. Feel free to ask any questions about formatting, what should go where, etc, though probably that's best asked in github issues so we can keep those convos with the code (unless of course you don't know which project to use). Cheers, David > James > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Jan 27 17:56:28 2011 From: lists at ruby-forum.com (Brian Warner) Date: Thu, 27 Jan 2011 23:56:28 +0100 Subject: [rspec-users] Difference between :each and :all Message-ID: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> I'm having a hard time grasping the difference between :each and :all. If I have a bunch of stuff inside a "before :each" block. Everytime I try to run an example that block of code will be run before the example. Now if I had the same code inside a "before :all" block. Everytime an example is run, that block will still be run. Yielding the same results. At least in my mind. The RSpec book says something like "before :each" defines a state for each example. "before :all" defines a state for all the examples. But what's the difference? -- Posted via http://www.ruby-forum.com/. From johnf at distb.net Thu Jan 27 18:11:24 2011 From: johnf at distb.net (John Feminella) Date: Thu, 27 Jan 2011 18:11:24 -0500 Subject: [rspec-users] Difference between :each and :all In-Reply-To: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: That's not quite right. :each runs before _each_ spec, while :all runs once, before _any_ spec. -- John Feminella Principal Consultant, BitsBuilder LI: http://www.linkedin.com/in/fjsquared SO: http://stackoverflow.com/users/75170/ On Thu, Jan 27, 2011 at 17:56, Brian Warner wrote: > I'm having a hard time grasping the difference between :each and :all. > > If I have a bunch of stuff inside a "before :each" block. Everytime I > try to run an example that block of code will be run before the example. > > Now if I had the same code inside a "before :all" block. Everytime an > example is run, that block will still be run. Yielding the same results. > At least in my mind. > > The RSpec book says something like "before :each" defines a state for > each example. "before :all" defines a state for all the examples. But > what's the difference? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From johnf at distb.net Thu Jan 27 18:13:00 2011 From: johnf at distb.net (John Feminella) Date: Thu, 27 Jan 2011 18:13:00 -0500 Subject: [rspec-users] Difference between :each and :all In-Reply-To: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: Here's an illustrative example that should clear things up: require 'spec_helper' describe "behavior of before-each and before-all" do before(:all) { puts "-- running :all" } before(:each) { puts "-- running :each" } describe "addition" do it "should add two and two" do (2 + 2).should == 4 end it "should add three and three" do (3 + 3).should == 6 end it "should add four and four" do (4 + 4).should == 8 end end describe "multiplication" do it "should raise two to two" do (2 ** 2).should == 4 end it "should raise three to three" do (3 ** 3).should == 27 end it "should raise four to four" do (4 ** 4).should == 256 end end end And here's the result: behavior of before-each and before-all -- running :all addition -- running :each should add two and two -- running :each should add three and three -- running :each should add four and four multiplication -- running :each should raise two to two -- running :each should raise three to three -- running :each should raise four to four Finished in 0.0034 seconds 6 examples, 0 failures Notice how :each runs before _each_ spec, but :all runs once, before _any_spec. -- John Feminella Principal Consultant, BitsBuilder LI: http://www.linkedin.com/in/fjsquared SO: http://stackoverflow.com/users/75170/ On Thu, Jan 27, 2011 at 17:56, Brian Warner wrote: > I'm having a hard time grasping the difference between :each and :all. > > If I have a bunch of stuff inside a "before :each" block. Everytime I > try to run an example that block of code will be run before the example. > > Now if I had the same code inside a "before :all" block. Everytime an > example is run, that block will still be run. Yielding the same results. > At least in my mind. > > The RSpec book says something like "before :each" defines a state for > each example. "before :all" defines a state for all the examples. But > what's the difference? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Thu Jan 27 18:16:54 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Jan 2011 17:16:54 -0600 Subject: [rspec-users] Difference between :each and :all In-Reply-To: References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: On Jan 27, 2011, at 5:11 PM, John Feminella wrote: > That's not quite right. :each runs before _each_ spec, while :all runs > once, before _any_ spec. Perhaps :any is a better name? We could add it as an alternative for the same as :all. WDYT? > -- > John Feminella > Principal Consultant, BitsBuilder > LI: http://www.linkedin.com/in/fjsquared > SO: http://stackoverflow.com/users/75170/ > > > > On Thu, Jan 27, 2011 at 17:56, Brian Warner wrote: >> I'm having a hard time grasping the difference between :each and :all. >> >> If I have a bunch of stuff inside a "before :each" block. Everytime I >> try to run an example that block of code will be run before the example. >> >> Now if I had the same code inside a "before :all" block. Everytime an >> example is run, that block will still be run. Yielding the same results. >> At least in my mind. >> >> The RSpec book says something like "before :each" defines a state for >> each example. "before :all" defines a state for all the examples. But >> what's the difference? >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Thu Jan 27 18:28:46 2011 From: lists at ruby-forum.com (Brian Warner) Date: Fri, 28 Jan 2011 00:28:46 +0100 Subject: [rspec-users] Difference between :each and :all In-Reply-To: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: <6da286d5ce9e8c3662167ff8f8d3493c@ruby-forum.com> That does clear it. Thank you =] -- Posted via http://www.ruby-forum.com/. From mmazur at gmail.com Thu Jan 27 18:31:01 2011 From: mmazur at gmail.com (Mike Mazur) Date: Fri, 28 Jan 2011 07:31:01 +0800 Subject: [rspec-users] feedback on matcher In-Reply-To: References: Message-ID: Hi, On Thu, Jan 27, 2011 at 21:48, Michael Guterl wrote: > RSpec::Matchers.define :deliver do |message| > ?chain :with do |*args| > ? ?@with = args > ?end > > ?match do |mailer| > ? ?mail = double > ? ?mail.should_receive(:deliver) > > ? ?mailer.should_receive(message).with(*@with).and_return(mail) > ?end > end > > Mailer.should deliver(:job_application).with(@job.id, @user.id) On a recent Rails 3 project we implemented a matcher for sending email but without using any stubs. It looks something like this: RSpec::Matchers.define :send_mail do match do |block| ActionMailer::Base.deliveries = [] block.call ActionMailer::Base.deliveries.count.should == 1 mail = ActionMailer::Base.deliveries.last # now inspect the mail object as you see fit end end Then in our spec we have: expect { some_func }.to send_email We also have chains for recipients, subject, content, and so on. HTH, Mike From johnf at distb.net Thu Jan 27 21:08:52 2011 From: johnf at distb.net (John Feminella) Date: Thu, 27 Jan 2011 21:08:52 -0500 Subject: [rspec-users] Difference between :each and :all In-Reply-To: References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: > Perhaps :any is a better name? We could add it as an alternative for the same as :all. WDYT? I think that's an interesting idea, David. I whipped up a quick pull request, which you can see here: https://github.com/rspec/rspec-core/pull/293 ~ jf -- John Feminella Principal Consultant, BitsBuilder LI: http://www.linkedin.com/in/fjsquared SO: http://stackoverflow.com/users/75170/ On Thu, Jan 27, 2011 at 18:16, David Chelimsky wrote: > On Jan 27, 2011, at 5:11 PM, John Feminella wrote: > >> That's not quite right. :each runs before _each_ spec, while :all runs >> once, before _any_ spec. > > Perhaps :any is a better name? We could add it as an alternative for the same as :all. WDYT? > >> -- >> John Feminella >> Principal Consultant, BitsBuilder >> LI: http://www.linkedin.com/in/fjsquared >> SO: http://stackoverflow.com/users/75170/ >> >> >> >> On Thu, Jan 27, 2011 at 17:56, Brian Warner wrote: >>> I'm having a hard time grasping the difference between :each and :all. >>> >>> If I have a bunch of stuff inside a "before :each" block. Everytime I >>> try to run an example that block of code will be run before the example. >>> >>> Now if I had the same code inside a "before :all" block. Everytime an >>> example is run, that block will still be run. Yielding the same results. >>> At least in my mind. >>> >>> The RSpec book says something like "before :each" defines a state for >>> each example. "before :all" defines a state for all the examples. But >>> what's the difference? >>> >>> -- >>> Posted via http://www.ruby-forum.com/. >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From rick.denatale at gmail.com Thu Jan 27 21:53:30 2011 From: rick.denatale at gmail.com (Rick DeNatale) Date: Thu, 27 Jan 2011 21:53:30 -0500 Subject: [rspec-users] Difference between :each and :all In-Reply-To: References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: On Thu, Jan 27, 2011 at 6:16 PM, David Chelimsky wrote: > On Jan 27, 2011, at 5:11 PM, John Feminella wrote: > >> That's not quite right. :each runs before _each_ spec, while :all runs >> once, before _any_ spec. > > Perhaps :any is a better name? We could add it as an alternative for the same as :all. WDYT? > Speaking for myself, I never was confused between before(:each) and before(:all). The first always meant before each OF the examples, and the latter before all the examples. As a devil's advocate, while before(:any) might evoke the current meaning of before(:all) for some people, after(:any) to me evokes the curent meaning of after(:each) more than it does after(:all), i.e. after any OF the examples rather than after all the examples, because I'd never say after any the examples. But that might just be me. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From dchelimsky at gmail.com Thu Jan 27 21:58:12 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Jan 2011 20:58:12 -0600 Subject: [rspec-users] Difference between :each and :all In-Reply-To: References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: On Thu, Jan 27, 2011 at 8:53 PM, Rick DeNatale wrote: > On Thu, Jan 27, 2011 at 6:16 PM, David Chelimsky wrote: >> On Jan 27, 2011, at 5:11 PM, John Feminella wrote: >> >>> That's not quite right. :each runs before _each_ spec, while :all runs >>> once, before _any_ spec. >> >> Perhaps :any is a better name? We could add it as an alternative for the same as :all. WDYT? >> > > Speaking for myself, I never was confused between before(:each) and > before(:all). ?The first always meant before each OF the examples, and > the latter before all the examples. > > As a devil's advocate, while before(:any) might evoke the current > meaning of before(:all) for some people, after(:any) to me evokes the > curent meaning of after(:each) more than it does after(:all), i.e. > after any OF the examples rather than after all the examples, because > I'd never say after any the examples. > > But that might just be me. You're absolutely right that it would be confusing for after, and given that, I think we should probably not add it. From cezar at halmagean.ro Mon Jan 24 06:33:46 2011 From: cezar at halmagean.ro (Cezar Halmagean) Date: Mon, 24 Jan 2011 03:33:46 -0800 (PST) Subject: [rspec-users] specing nested models Message-ID: <17657691.5.1295868826881.JavaMail.geo-discussion-forums@yqoh2> So I am trying to spec a nested model / form like say Post has_many Comments and in order to build a nested form I need to build a new comment in @posts.comments like so: @post = Post.new @post.comments.build Now, my question is: How do you go about correctly testing this ? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Mon Jan 24 15:35:27 2011 From: nick at deadorange.com (Nick) Date: Mon, 24 Jan 2011 12:35:27 -0800 (PST) Subject: [rspec-users] specing nested models In-Reply-To: <17657691.5.1295868826881.JavaMail.geo-discussion-forums@yqoh2> Message-ID: <27692062.63.1295901327605.JavaMail.geo-discussion-forums@yqoh2> How about: it 'builds a comment in the post' do post = Post.new comments_assoc = mock comment = mock_model Comment post.stub(:comments).and_return comments_assoc comments_assoc.should_receive(:build).with(no_args).and_return comment # invoke something to trigger the action end -------------- next part -------------- An HTML attachment was scrubbed... URL: From josep.m.bach at gmail.com Wed Jan 26 05:06:51 2011 From: josep.m.bach at gmail.com (Josep M. Bach) Date: Wed, 26 Jan 2011 02:06:51 -0800 (PST) Subject: [rspec-users] Performance tests using Rspec In-Reply-To: Message-ID: <32838745.1455.1296036411492.JavaMail.geo-discussion-forums@yqae3> A while ago, I was looking at Minitest's benchmarking capabilities (contained in a single file here) and I thought it would be great to have an equivalent in RSpec. They have methods to assert type of performance (linear, exponential...) of a given block. Looking at minitest's file it might be relatively trivial to implement, but the question is: do you think that would naturally fit in rspec-matchers, or in a separate rspec-benchmark gem/plugin? Personally I think it's a good piece of functionality and deserves being baked in RSpec, but I'm not sure if many people would actually use it. Thoughts? -------------- next part -------------- An HTML attachment was scrubbed... URL: From cezar at halmagean.ro Wed Jan 26 10:34:14 2011 From: cezar at halmagean.ro (Cezar Halmagean) Date: Wed, 26 Jan 2011 07:34:14 -0800 (PST) Subject: [rspec-users] specing nested models In-Reply-To: <27692062.63.1295901327605.JavaMail.geo-discussion-forums@yqoh2> Message-ID: <27938928.1777.1296056054068.JavaMail.geo-discussion-forums@yqae3> That worked great, thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fregas at gmail.com Wed Jan 26 11:07:31 2011 From: fregas at gmail.com (Fregas) Date: Wed, 26 Jan 2011 08:07:31 -0800 (PST) Subject: [rspec-users] checking order of method calls on different mocks Message-ID: <388a715f-6073-429c-8287-09edc1ded93b@f30g2000yqa.googlegroups.com> I have a spec where I need to check that the order of 2 method calls to 2 different mocks is correct: mock_customer.should_receive(:save).ordered mock_customer.should_recieve(:id).and_return(1).ordered mock_order.should_receive(:customer_id=).with(1).ordered however this does not work. I can set order.customer_id at the beginning, before save and id are called and the spec passes. From nick at deadorange.com Wed Jan 26 23:34:06 2011 From: nick at deadorange.com (Nick) Date: Wed, 26 Jan 2011 20:34:06 -0800 (PST) Subject: [rspec-users] specing nested models In-Reply-To: <27938928.1777.1296056054068.JavaMail.geo-discussion-forums@yqae3> Message-ID: <32057728.93.1296102846795.JavaMail.geo-discussion-forums@yqmc35> On Wednesday, January 26, 2011 10:34:14 AM UTC-5, Cezar Halmagean wrote: > > That worked great, thank you. You're welcome, mate! -------------- next part -------------- An HTML attachment was scrubbed... URL: From jon at jonhoman.com Thu Jan 27 18:07:23 2011 From: jon at jonhoman.com (Jon Homan) Date: Thu, 27 Jan 2011 17:07:23 -0600 Subject: [rspec-users] Difference between :each and :all In-Reply-To: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: My understanding is that the before :each block runs before every example. While before :all blocks run once for the entire example group. Any side effects in the examples will be persist for objects if you use a before :all block. But if you were to use before :each, you guarantee the state before every example is run. Stupid code example. describe "stuff" before :all do puts "done one time" end before :each do puts "done once for every example" end describe "one thing stuff does" do end describe "second thing stuff does" do end end You'd see something like this in the output: done one time done once for every example done once for every example Again, this is just my understanding. Could be wrong. Jon Homan On Thu, Jan 27, 2011 at 4:56 PM, Brian Warner wrote: > I'm having a hard time grasping the difference between :each and :all. > > If I have a bunch of stuff inside a "before :each" block. Everytime I > try to run an example that block of code will be run before the example. > > Now if I had the same code inside a "before :all" block. Everytime an > example is run, that block will still be run. Yielding the same results. > At least in my mind. > > The RSpec book says something like "before :each" defines a state for > each example. "before :all" defines a state for all the examples. But > what's the difference? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Jan 27 22:02:09 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Jan 2011 21:02:09 -0600 Subject: [rspec-users] Performance tests using Rspec In-Reply-To: <32838745.1455.1296036411492.JavaMail.geo-discussion-forums@yqae3> References: <32838745.1455.1296036411492.JavaMail.geo-discussion-forums@yqae3> Message-ID: <81065CB5-43D0-43B6-9954-C30CD5BCC378@gmail.com> On Jan 26, 2011, at 4:06 AM, Josep M. Bach wrote: > A while ago, I was looking at Minitest's benchmarking capabilities (contained in a single file here) and I thought it would be great to have an equivalent in RSpec. They have methods to assert type of performance (linear, exponential...) of a given block. Looking at minitest's file it might be relatively trivial to implement, but the question is: do you think that would naturally fit in rspec-matchers, or in a separate rspec-benchmark gem/plugin? > Personally I think it's a good piece of functionality and deserves being baked in RSpec, but I'm not sure if many people would actually use it. Thoughts? I'd like to see it in an extension gem first. We can always merge it in if it becomes a standard component. If not, it's just more stuff to maintain that nobody uses :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnf at bitsbuilder.com Thu Jan 27 22:08:25 2011 From: johnf at bitsbuilder.com (John Feminella) Date: Thu, 27 Jan 2011 22:08:25 -0500 Subject: [rspec-users] Difference between :each and :all In-Reply-To: References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: Not to shoot my own patch in the foot, but my personal opinion is to have only one way to do it. I think whatever ambiguity there may be in before(:all) isn't adequately compensated by the additional confusion of having before(:any), which sounds like it would do something subtly different. -- John Feminella Principal Consultant, BitsBuilder LI: http://www.linkedin.com/in/johnxf SO: http://stackoverflow.com/users/75170/ On Thu, Jan 27, 2011 at 21:58, David Chelimsky wrote: > On Thu, Jan 27, 2011 at 8:53 PM, Rick DeNatale wrote: >> On Thu, Jan 27, 2011 at 6:16 PM, David Chelimsky wrote: >>> On Jan 27, 2011, at 5:11 PM, John Feminella wrote: >>> >>>> That's not quite right. :each runs before _each_ spec, while :all runs >>>> once, before _any_ spec. >>> >>> Perhaps :any is a better name? We could add it as an alternative for the same as :all. WDYT? >>> >> >> Speaking for myself, I never was confused between before(:each) and >> before(:all). ?The first always meant before each OF the examples, and >> the latter before all the examples. >> >> As a devil's advocate, while before(:any) might evoke the current >> meaning of before(:all) for some people, after(:any) to me evokes the >> curent meaning of after(:each) more than it does after(:all), i.e. >> after any OF the examples rather than after all the examples, because >> I'd never say after any the examples. >> >> But that might just be me. > > You're absolutely right that it would be confusing for after, and > given that, I think we should probably not add it. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From win at wincent.com Thu Jan 27 21:57:13 2011 From: win at wincent.com (Wincent Colaiuta) Date: Fri, 28 Jan 2011 03:57:13 +0100 Subject: [rspec-users] Difference between :each and :all In-Reply-To: References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: <80E2D8BE-B4B9-4756-B5C6-D538029F39BC@wincent.com> El 28/01/2011, a las 03:53, Rick DeNatale escribi?: > On Thu, Jan 27, 2011 at 6:16 PM, David Chelimsky wrote: >> On Jan 27, 2011, at 5:11 PM, John Feminella wrote: >> >>> That's not quite right. :each runs before _each_ spec, while :all runs >>> once, before _any_ spec. >> >> Perhaps :any is a better name? We could add it as an alternative for the same as :all. WDYT? >> > > Speaking for myself, I never was confused between before(:each) and > before(:all). Same. When you look at them side by side like that, it is pretty clear what "before each" and "before all" must refer to. Adding a third term to the mix would actually increase the chance of confusion, IMO. Cheers, Wincent From dchelimsky at gmail.com Thu Jan 27 22:20:32 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Jan 2011 21:20:32 -0600 Subject: [rspec-users] checking order of method calls on different mocks In-Reply-To: <388a715f-6073-429c-8287-09edc1ded93b@f30g2000yqa.googlegroups.com> References: <388a715f-6073-429c-8287-09edc1ded93b@f30g2000yqa.googlegroups.com> Message-ID: <856C2927-DE33-4BFF-A7E5-3258F6443234@gmail.com> On Jan 26, 2011, at 10:07 AM, Fregas wrote: > I have a spec where I need to check that the order of 2 method calls > to 2 different mocks is correct: > > mock_customer.should_receive(:save).ordered > mock_customer.should_recieve(:id).and_return(1).ordered Don't think it's related, but receive is misspelled here ^^. > mock_order.should_receive(:customer_id=).with(1).ordered > > however this does not work. I can set order.customer_id at the > beginning, before save and id are called and the spec passes. Ordering does not work across objects. Does this really need to happen in order? What's the real requirement you're trying to express (not how the code is doing it, but what's supposed to happen at a high level)? From dchelimsky at gmail.com Fri Jan 28 00:22:31 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 27 Jan 2011 23:22:31 -0600 Subject: [rspec-users] Fixtures not loading when running full test suite In-Reply-To: References: Message-ID: On Thu, Jan 27, 2011 at 2:05 PM, Doug Bryant wrote: > I'm currently running into the same issue and can find very little about it > on the interwebs - i.e. an individual test run with `script/spec` works fine > but the same test without any code changes fails when run as part of the > suite via `rake spec` > This issue seemed to start out of the blue. ?Some background and details... > Fixtures don't seem to be loading properly when run as part of the suite. > When my Driver model tries to save, it runs a validation testing that the > zip code entered is valid (i.e. exists in the ZipsTerritory rating table). > ?I have the :zips_territories fixture declared in the tests with enough data > in the fixture for the test to pass. ?The spec runs fine when executed with > `script/spec` but fails when run as part of the test suite `rake spec`. ?The > zips_territory fixture is declared properly and in before(:each) in the > tests, a driver is created with FactoryGirl via a call > like?Factory.create(:driver). ?The callstack indicates the test is failing > while FactoryGirl is trying to create the model. ?Also, for a given > developer, the same set of tests fail due to this issue consistently, but > the tests which fail differ across different developers. > These tests had been running fine as a suite for almost two years. > In trying to debug this, I stumbled across some interesting behavior. ?If in > the before(:each) filter on the failing tests, ?I printed out a log message > which ultimately executed "ZipsTerritory.count". ? After I did this, the > tests would pass as part of a suite. ?Needing a quick fix and not having > time to debug the issue further, I just did the following in the > spec_helper.rb file... >> >> ?? config.before(:each) do >> >> ?? ? Rails.logger.warn "ZipsTerritory.count == #{ZipsTerritory.count}" >> >> ?? end > > This worked fine for about a week before the issue popped back up again. > I can't think of anything which changed in the codebase which would have > triggered this problem. ?The app has been running rails 2.3.8 for several > months. ?We had been using rspec 1.3.0 and rspec-rails 1.3.2 for several > months. ?(sidenote: rspec 1.3.1 & rspec-rails 1.3.3 seem to have some sort > of other bug which fails to properly call a method on a child class and > somehow gets delegated to the parent class - not present in 1.3.0 & 1.3.2 > rspec/rspec-rails). Example please? > I've tried several version of FactoryGirl and all of > those seem to trigger the issue too. > My spec_helper.rb is:?https://gist.github.com/0d3ea01ffe4a15f4b2b3 > Does anything stand out? ?Has anybody else experienced this? ?Any ideas? > Thanks, Doug I made one comment on the gist, but I think it's unrelated. You say nothing changed that you _think_ would cause this, but something must have changes somewhere. What _did_ change? Any new gems or upgraded gems in the environment? > On Fri, Aug 14, 2009 at 6:04 AM, Rob Aldred > wrote: >> >> Hi, I've been trying to work this out for a while, im convinced its some >> local db configuration specific to my machine. >> When running `rake spec` 14 of my test fail all of them in the user_spec >> generated by restful auth. >> The error for all the failing tests is: >> ActiveRecord::RecordNotFound >> Couldn't find User with ID=1 >> Iv put some debugger lines and at the start of some of the tests it would >> appear that the users fixture is not being loaded when running the full >> suite >> If I run the specific test with the spec >> binary?`spec?spec/modes/user_spec.rb`?all?the?fixtures?are?loaded?and?pass?as?expected. >> Further more, the error is only apparent when using mysql for the test >> db... >> When I use sqlite for the test db the tests pass when running the whole >> suite and the specific test... >> Weird... I'd like to know if anyone else has experienced this and if >> anyone has any pointers >> as?to?why?the?fixtures?are?not?loaded?when?using?mysql?as?the?test?db. >> Many?thanks >> Rob >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Fri Jan 28 04:20:51 2011 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 28 Jan 2011 09:20:51 +0000 Subject: [rspec-users] rspec-rails 2 adding current account helper to all view specs In-Reply-To: References: Message-ID: <979805B1-49EA-4CF4-830F-6B411878348C@mattwynne.net> Hi Rob, On 27 Jan 2011, at 21:45, Rob Westgeest wrote: > Hi, > > in rspec-1 view specs i had the ability to say: > > login_as(some_role_or_account) > > which made some helper methods like > > current_account > > that where used in views and controllers return something valuable. > > Implementation was based on the fact that the controller in rspec-1 > was ApplicationController. My ApplicationController contained a method > for setting the current_account. > > In Rspec2 this is broken as the controller in ViewExampleGroup is now > ActionView::TestCase::TestController. > > Would anyone know of an elegant way to add functionality, like helper > methods, to this controller instance in all ViewExampleGroups only. > > option 1, which i don't like because it depends on the fact that > ViewExampleGroup uses ActionView::TestCase::TestController: > > class ActionView::TestCase::TestController > attr_accessor :current_account > helper_method :current_account > end > module RSpec::Rails::ViewExampleGroup > def login_as account > controller.current_account = account > end > end > > I would like to use some hook to add these methods only to the > controller instance used in the view specs, regardless of what class > it is. > > There must be an elegant way, is there? In your spec_helper, you can use the configuration block to tell RSpec to extend (i.e. mix a module in) to each ExampleGroup: RSpec.configure do |config| config.extend(MySpecialLoginMethods) end So you can define your test helper methods like #login_as in a module called MySpecialLoginMethods and then have it mixed in to each example group. You can also filter this, so it only does it to certain types of ExampleGroup. I can't remember exactly what the syntax is for filtering on view specs, but something like this: RSpec.configure do |config| config.extend(MySpecialLoginMethods, :view) end Does that help? cheers, Matt matt at mattwynne.net 07974 430184 From pathsny at gmail.com Fri Jan 28 05:24:12 2011 From: pathsny at gmail.com (vishnu) Date: Fri, 28 Jan 2011 15:54:12 +0530 Subject: [rspec-users] changes in rspec 2.4 break ci_reporter In-Reply-To: <3337EDFE-4CF2-49F1-96A4-5D69E7120147@gmail.com> References: <3337EDFE-4CF2-49F1-96A4-5D69E7120147@gmail.com> Message-ID: ah. Because people currently depend on the override behaviour? This seems to be a historical artifact though. I'd expect something that wants to override other configuration to have to specify that it does, not the other way around? so maybe SPEC_OPTS should have an --overide option to override behaviour specified through other configuration means? On Thu, Jan 27, 2011 at 3:35 PM, David Chelimsky wrote: > On Jan 26, 2011, at 8:43 AM, vishnu wrote: > >> Hi >> ? I ?use the ci_reporter gem for builds on my CI machine (hudson). >> Prior to rspec 2.4, environment options would override commandline >> options. So the gem used this to change the formatter and require its >> files. >> >> In 2.4, that order has been reversed. > > This has since been restored to its previous behavior, to be released in 2.5. See https://github.com/rspec/rspec-core/issues/276. > >> the thing is 2.4 supports multiple formatters, so there is another suggestion. >> >> RSpec::Core::ConfigurationOptions >> ? def parse_options >> ? ? ? ? ? ? ?@options = begin >> ? ? ? ? ? ? ? ? ? ? options_to_merge = [] >> ? ? ? ? ? ? ? ? ? ? if custom_options_file >> ? ? ? ? ? ? ? ? ? ? ? options_to_merge << custom_options >> ? ? ? ? ? ? ? ? ? ? else >> ? ? ? ? ? ? ? ? ? ? ? options_to_merge << global_options >> ? ? ? ? ? ? ? ? ? ? ? options_to_merge << local_options >> ? ? ? ? ? ? ? ? ? ? end >> ? ? ? ? ? ? ? ? ? ? options_to_merge << env_options >> ? ? ? ? ? ? ? ? ? ? options_to_merge << command_line_options >> >> ? ? ? ? ? ? ? ? ? ? options_to_merge.inject do |merged, options| >> ? ? ? ? ? ? ? ? ? ? ? merged.merge(options) >> ? ? ? ? ? ? ? ? ? ? end >> ? ? ? ? ? ? ? ? ? end >> ? ? ?end >> >> the last section, instead of merging hashes, could combine the values >> of all hashes with the keys "--require" or "--format". So you get the >> default formatter and the extra formatter that ci_reporter introduces. > > I think I'd want a separate API for this - something like: > > # ~/.rspec > --format-that-is-not-overridden html > --out-that-is-not-overridden ~/rspec/this-project/report.html > > But maybe a bit less verbose :) Either that or maybe a marker option like this: > > # ~/.rspec > --color > --backtrace > --no-override > --require ~/path/to/file/to/always/require > --format html > --out ~/rspec/this-project/report.html > > Then require, format, and out options following the --no-override option would be additive. > > WDYT? Other ideas? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From mmazur at gmail.com Fri Jan 28 08:05:50 2011 From: mmazur at gmail.com (Mike Mazur) Date: Fri, 28 Jan 2011 21:05:50 +0800 Subject: [rspec-users] specing nested models In-Reply-To: <17657691.5.1295868826881.JavaMail.geo-discussion-forums@yqoh2> References: <17657691.5.1295868826881.JavaMail.geo-discussion-forums@yqoh2> Message-ID: Hi, On Mon, Jan 24, 2011 at 19:33, Cezar Halmagean wrote: > So I am trying to spec a nested model / form like say Post has_many Comments > and in order to build a nested form I need to build a new comment in > @posts.comments like so: > @post = Post.new > @post.comments.build > Now, my question is: How do you go about correctly testing this ? I would do something as follows: it "creates a post with a comment" do expect { post :create, :args => { :some => "args" } }.to change(Post, :count).by(1) post = Post.last post.should have(1).comments end HTH, Mike From antsmailinglist at gmail.com Fri Jan 28 12:09:38 2011 From: antsmailinglist at gmail.com (Ants Pants) Date: Fri, 28 Jan 2011 18:09:38 +0100 Subject: [rspec-users] Feedback Requested (pretty please) In-Reply-To: <8833316.64.1295901404232.JavaMail.geo-discussion-forums@yqmb9> References: <8833316.64.1295901404232.JavaMail.geo-discussion-forums@yqmb9> Message-ID: Yes, I've come a long way since posting that. I'm embarrassed by that post but after reading the book and getting started, I just wanted some feedback. I'm a proffie now!! On 24 January 2011 21:36, Nick wrote: > Also, try to keep have just one expectation (IE: call to #should) in each > test. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Jan 28 17:34:00 2011 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 28 Jan 2011 22:34:00 +0000 Subject: [rspec-users] Fixtures not loading when running full test suite In-Reply-To: References: Message-ID: On 14 August 2009 12:04, Rob Aldred wrote: > Hi, I've been trying to work this out for a while, im convinced its some > local db configuration specific to my machine. > > When running `rake spec` 14 of my test fail all of them in the user_spec > generated by restful auth. > The error for all the failing tests is: > > ActiveRecord::RecordNotFound > Couldn't find User with ID=1 > > Iv put some debugger lines and at the start of some of the tests it would > appear that the users fixture is not being loaded when running the full > suite > If I run the specific test with the spec > binary `spec spec/modes/user_spec.rb` all the fixtures are loaded and pass as expected. > > Further more, the error is only apparent when using mysql for the test > db... > When I use sqlite for the test db the tests pass when running the whole > suite and the specific test... > > Weird... I'd like to know if anyone else has experienced this and if anyone > has any pointers > as to why the fixtures are not loaded when using mysql as the test db. > > Many thanks > Rob > > Could this be something to do with mysql not resetting its numbering between tests, so it is actually loading a user, but not with ID=1. I'm pretty sure I've seen that behaviour in the past. All best Andrew _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Fri Jan 28 22:42:09 2011 From: nick at deadorange.com (Nick) Date: Fri, 28 Jan 2011 19:42:09 -0800 (PST) Subject: [rspec-users] Feedback Requested (pretty please) In-Reply-To: Message-ID: <21220914.682.1296272529356.JavaMail.geo-discussion-forums@yqac31> On Friday, January 28, 2011 12:09:38 PM UTC-5, ants wrote: > > Yes, I've come a long way since posting that. I'm embarrassed by that post > but after reading the book and getting started, I just wanted some > feedback. Hah, don't be embarassed. Everyone starts out pretty rough with BDD. What's important is that you improve! -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Sun Jan 30 04:16:26 2011 From: lists at ruby-forum.com (Tom H.) Date: Sun, 30 Jan 2011 10:16:26 +0100 Subject: [rspec-users] Is there an easy way to inject each example text into test.log Message-ID: <93eba99ee3307777cb1a505465d08643@ruby-forum.com> This was asked back in 2008 but I'm wondering if there is an easier way with rspec2 and rails. Seems like it would make my test log much more meaningful. Surely somebody must have done it. Is there an easy way to inject each example text into test.log so I can isolate the log output per example? Thanks -- Posted via http://www.ruby-forum.com/. From jason.nah at gmail.com Sun Jan 30 04:48:57 2011 From: jason.nah at gmail.com (Jason Nah) Date: Sun, 30 Jan 2011 20:48:57 +1100 Subject: [rspec-users] Named routes problem... more rails than rspec Message-ID: Howdy, I have emailed before about the inconsistencies I'm spotting when using named routes/resource, but I think I've narrowed down the issue. It would seem this has nothing to do with rspec per se, but more with how routing works with rails. If you have an object instance, that isn't saved and you attempt to generate a path for that item, even though the item may have an ID, you get a "No route matches" exception. If the item is saved, then a valid route can be generated for that item. Two things seem odd: 1. The exception raised isn't very informative 2. Why is this a constraint? And can it be turned off for testing purposes? Is there a way around this? Or do I need to use rspec mock objects? Cheers, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: From dolzenko at gmail.com Sun Jan 30 05:33:26 2011 From: dolzenko at gmail.com (Evgeniy Dolzhenko) Date: Sun, 30 Jan 2011 13:33:26 +0300 Subject: [rspec-users] Is there an easy way to inject each example text into test.log In-Reply-To: <93eba99ee3307777cb1a505465d08643@ruby-forum.com> References: <93eba99ee3307777cb1a505465d08643@ruby-forum.com> Message-ID: <4D453E76.3080301@gmail.com> Do you need the full source code of an example in the log output, or just a description? On 1/30/2011 12:16 PM, Tom H. wrote: > This was asked back in 2008 but I'm wondering if there is an easier way > with rspec2 and rails. Seems like it would make my test log much more > meaningful. Surely somebody must have done it. > > Is there an easy way to inject each example text into test.log so I > can isolate the log output per example? > > Thanks > From lists at ruby-forum.com Sun Jan 30 06:00:27 2011 From: lists at ruby-forum.com (Tom H.) Date: Sun, 30 Jan 2011 12:00:27 +0100 Subject: [rspec-users] Is there an easy way to inject each example text into test.log In-Reply-To: <4D453E76.3080301@gmail.com> References: <93eba99ee3307777cb1a505465d08643@ruby-forum.com> <4D453E76.3080301@gmail.com> Message-ID: <0ace68d9060efc384f531e8aac3b8dee@ruby-forum.com> Evgeniy Dolzhenko wrote in post #978481: > Do you need the full source code of an example in the log output, or > just a description? Just the description would be good so I can match up the log entries to the spec -- Posted via http://www.ruby-forum.com/. From dolzenko at gmail.com Sun Jan 30 07:00:25 2011 From: dolzenko at gmail.com (Evgeniy Dolzhenko) Date: Sun, 30 Jan 2011 15:00:25 +0300 Subject: [rspec-users] Is there an easy way to inject each example text into test.log In-Reply-To: <0ace68d9060efc384f531e8aac3b8dee@ruby-forum.com> References: <93eba99ee3307777cb1a505465d08643@ruby-forum.com> <4D453E76.3080301@gmail.com> <0ace68d9060efc384f531e8aac3b8dee@ruby-forum.com> Message-ID: <4D4552D9.6000006@gmail.com> RSpec.configure do |c| c.before do |m| Rails.logger.debug "==> #{m.example.full_description}" end end Cheers On 1/30/2011 2:00 PM, Tom H. wrote: > Evgeniy Dolzhenko wrote in post #978481: >> Do you need the full source code of an example in the log output, or >> just a description? > Just the description would be good so I can match up the log entries to > the spec > From lists at ruby-forum.com Sun Jan 30 08:24:25 2011 From: lists at ruby-forum.com (Tom H.) Date: Sun, 30 Jan 2011 14:24:25 +0100 Subject: [rspec-users] Is there an easy way to inject each example text into test.log In-Reply-To: <93eba99ee3307777cb1a505465d08643@ruby-forum.com> References: <93eba99ee3307777cb1a505465d08643@ruby-forum.com> Message-ID: That worked a treat Thanks -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Sun Jan 30 09:09:21 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 30 Jan 2011 08:09:21 -0600 Subject: [rspec-users] Named routes problem... more rails than rspec In-Reply-To: References: Message-ID: <72070768-5F15-4FAB-B868-FAE083211FB3@gmail.com> On Jan 30, 2011, at 3:48 AM, Jason Nah wrote: > Howdy, > > I have emailed before about the inconsistencies I'm spotting when using named routes/resource, but I think I've narrowed down the issue. It would seem this has nothing to do with rspec per se, but more with how routing works with rails. > > If you have an object instance, that isn't saved and you attempt to generate a path for that item, even though the item may have an ID, you get a "No route matches" exception. > > If the item is saved, then a valid route can be generated for that item. > > Two things seem odd: > The exception raised isn't very informative > Why is this a constraint? And can it be turned off for testing purposes? If that's how the framework works and it's an internal thing like this, turning it off for testing purposes would just lead to confusion. > Is there a way around this? Or do I need to use rspec mock objects? You can either use mock_model or mock_stub (which each act like saved objects unless you tell them otherwise), or use real objects saved to the db. HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Jan 30 09:16:08 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 30 Jan 2011 08:16:08 -0600 Subject: [rspec-users] Is there an easy way to inject each example text into test.log In-Reply-To: <4D4552D9.6000006@gmail.com> References: <93eba99ee3307777cb1a505465d08643@ruby-forum.com> <4D453E76.3080301@gmail.com> <0ace68d9060efc384f531e8aac3b8dee@ruby-forum.com> <4D4552D9.6000006@gmail.com> Message-ID: On Jan 30, 2011, at 6:00 AM, Evgeniy Dolzhenko wrote: > On 1/30/2011 2:00 PM, Tom H. wrote: >> Evgeniy Dolzhenko wrote in post #978481: >>> Do you need the full source code of an example in the log output, or >>> just a description? >> Just the description would be good so I can match up the log entries to >> the spec >> > RSpec.configure do |c| > > c.before do |m| > Rails.logger.debug "==> #{m.example.full_description}" > end > > end That won't work if you use one liners (`it { should do_something }`) because the full_description isn't generated until after the example runs. You _could_ do it in an after hook instead. I'd also include the location information so you can get right to the example if you need to: RSpec.configure do |c| c.after do |m| Rails.logger.debug "=== ^^ #{m.example.full_description} ^^ ===" Rails.logger.debug "=== ^^ #{m.example.location} ^^ ===" end end From rick.denatale at gmail.com Sun Jan 30 10:34:55 2011 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 30 Jan 2011 10:34:55 -0500 Subject: [rspec-users] Named routes problem... more rails than rspec In-Reply-To: <72070768-5F15-4FAB-B868-FAE083211FB3@gmail.com> References: <72070768-5F15-4FAB-B868-FAE083211FB3@gmail.com> Message-ID: On Sun, Jan 30, 2011 at 9:09 AM, David Chelimsky wrote: > You can either use mock_model or mock_stub David, Did you mean to say stub_model rather than mock_stub? -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From rick.denatale at gmail.com Sun Jan 30 11:39:22 2011 From: rick.denatale at gmail.com (Rick DeNatale) Date: Sun, 30 Jan 2011 11:39:22 -0500 Subject: [rspec-users] Is there an easy way to inject each example text into test.log In-Reply-To: References: <93eba99ee3307777cb1a505465d08643@ruby-forum.com> <4D453E76.3080301@gmail.com> <0ace68d9060efc384f531e8aac3b8dee@ruby-forum.com> <4D4552D9.6000006@gmail.com> Message-ID: On Sun, Jan 30, 2011 at 9:16 AM, David Chelimsky wrote: > On Jan 30, 2011, at 6:00 AM, Evgeniy Dolzhenko wrote: > >> On 1/30/2011 2:00 PM, Tom H. wrote: >>> Evgeniy Dolzhenko wrote in post #978481: >>>> Do you need the full source code of an example in the log output, or >>>> just a description? >>> Just the description would be good so I can match up the log entries to >>> the spec >>> >> RSpec.configure do |c| >> >> ?c.before do |m| >> ? ?Rails.logger.debug "==> #{m.example.full_description}" >> ?end >> >> end > > That won't work if you use one liners (`it { should do_something }`) because the full_description isn't generated until after the example runs. > > You _could_ do it in an after hook instead. I'd also include the location information so you can get right to the example if you need to: > > RSpec.configure do |c| > ?c.after do |m| > ? Rails.logger.debug "=== ^^ #{m.example.full_description} ^^ ===" > ? Rails.logger.debug "=== ^^ #{m.example.location} ^^ ===" > ?end > end I'm thinking this might be an interesting use case for a custom formatter. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From dchelimsky at gmail.com Sun Jan 30 12:33:55 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 30 Jan 2011 11:33:55 -0600 Subject: [rspec-users] Named routes problem... more rails than rspec In-Reply-To: References: <72070768-5F15-4FAB-B868-FAE083211FB3@gmail.com> Message-ID: <34FA4279-F8A3-4F63-9636-153EBABD4D7A@gmail.com> On Jan 30, 2011, at 9:34 AM, Rick DeNatale wrote: > On Sun, Jan 30, 2011 at 9:09 AM, David Chelimsky wrote: >> You can either use mock_model or mock_stub > > > David, > > Did you mean to say stub_model rather than mock_stub? Yes :) From khellls at gmail.com Fri Jan 28 16:12:01 2011 From: khellls at gmail.com (khelll) Date: Fri, 28 Jan 2011 13:12:01 -0800 (PST) Subject: [rspec-users] undefined method `stub!' for Message-ID: <9fedcdd5-8343-4a7e-9654-ef0d9b252793@x4g2000yql.googlegroups.com> Hey, Using RSpec 2.4.0 with Rails 3.0.3 I'm doing this: rake spec:models and things works well. Now, when doing rspec spec/models/spot_spec.rb that has Spot.stub! :test1 I get: undefined method `stub!' for Spot:Class Am I missing something here? From jason.nah at gmail.com Sun Jan 30 18:53:02 2011 From: jason.nah at gmail.com (Jason Nah) Date: Mon, 31 Jan 2011 10:53:02 +1100 Subject: [rspec-users] Named routes problem... more rails than rspec In-Reply-To: <34FA4279-F8A3-4F63-9636-153EBABD4D7A@gmail.com> References: <72070768-5F15-4FAB-B868-FAE083211FB3@gmail.com> <34FA4279-F8A3-4F63-9636-153EBABD4D7A@gmail.com> Message-ID: Thanks for that... although the exception still bugs me... and digging through the router code in rails is mighty obtuse. I'm switching over to rspec mocks to get me over this... (was using mocha). One problem I ran into, I'm testing a mailer (+ view), and I'm trying to generate the email ONCE for the entire spec, and then run various it { should have_body_text(x) } If I generate the email once using before(:all), I don't have access to any mock methods (which is understandable). Is there a way to get this going? Or am I going to have to do the whole thing in one big "it" block? Cheers, Jason On 31 January 2011 04:33, David Chelimsky wrote: > On Jan 30, 2011, at 9:34 AM, Rick DeNatale wrote: > > > On Sun, Jan 30, 2011 at 9:09 AM, David Chelimsky > wrote: > >> You can either use mock_model or mock_stub > > > > > > David, > > > > Did you mean to say stub_model rather than mock_stub? > > Yes :) > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon Jan 31 00:54:07 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 30 Jan 2011 23:54:07 -0600 Subject: [rspec-users] Named routes problem... more rails than rspec In-Reply-To: References: <72070768-5F15-4FAB-B868-FAE083211FB3@gmail.com> <34FA4279-F8A3-4F63-9636-153EBABD4D7A@gmail.com> Message-ID: On Jan 30, 2011, at 5:53 PM, Jason Nah wrote: > On 31 January 2011 04:33, David Chelimsky wrote: > On Jan 30, 2011, at 9:34 AM, Rick DeNatale wrote: > > > On Sun, Jan 30, 2011 at 9:09 AM, David Chelimsky wrote: > >> You can either use mock_model or mock_stub > > > > > > David, > > > > Did you mean to say stub_model rather than mock_stub? > > Yes :) > Thanks for that... although the exception still bugs me... and digging through the router code in rails is mighty obtuse. > > I'm switching over to rspec mocks to get me over this... (was using mocha). > > > One problem I ran into, I'm testing a mailer (+ view), and I'm trying to generate the email ONCE for the entire spec, and then run various it { should have_body_text(x) } > > If I generate the email once using before(:all), I don't have access to any mock methods (which is understandable). Is there a way to get this going? Yes - you've got it in front of you, but you don't seem to want to do it :) Use mocks in before(:each). > Or am I going to have to do the whole thing in one big "it" block? That's an alternative too, but I'd recommend what I wrote above. FWIW, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From patmaddox at me.com Mon Jan 31 03:26:51 2011 From: patmaddox at me.com (Pat Maddox) Date: Mon, 31 Jan 2011 00:26:51 -0800 Subject: [rspec-users] Comparing two XML documents In-Reply-To: References: Message-ID: I load my XML docs into a hash using Hash#from_xml and then compare the hashes. On Jan 26, 2011, at 7:26 AM, Matt Wynne wrote: > I have a problem. I have a test that needs to assert that one XML document looks exactly like another XML document. > > I couldn't find a way to compare them as Nokogiri::XML::Documents, so I converted them both to strings with #to_xml and compared the strings. > > Trouble is, sometimes the attributes one of the nodes are rendered into the string in a different order to the other one, so you get an error of the form: > > Diff: > @@ -5,7 +5,7 @@ > > > > - > > > (RSpec::Expectations::ExpectationNotMetError) > > Most annoying. > > I've seen a couple of RSpec matchers in blog posts that walk and compare XML fragments but I'm surprised there isn't something more concrete that already exists. I feel like I'm missing a way to do it within an XML library, for example. > > Any clues out there? > > cheers, > Matt > > matt at mattwynne.net > 07974 430184 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From patmaddox at me.com Mon Jan 31 03:34:28 2011 From: patmaddox at me.com (Pat Maddox) Date: Mon, 31 Jan 2011 00:34:28 -0800 Subject: [rspec-users] Difference between :each and :all In-Reply-To: References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> Message-ID: <035B9168-5FD3-4C9B-96F8-2694CD2E180C@me.com> On Jan 27, 2011, at 6:53 PM, Rick DeNatale wrote: > On Thu, Jan 27, 2011 at 6:16 PM, David Chelimsky wrote: >> On Jan 27, 2011, at 5:11 PM, John Feminella wrote: >> >>> That's not quite right. :each runs before _each_ spec, while :all runs >>> once, before _any_ spec. >> >> Perhaps :any is a better name? We could add it as an alternative for the same as :all. WDYT? >> > > Speaking for myself, I never was confused between before(:each) and > before(:all). The first always meant before each OF the examples, and > the latter before all the examples. > > As a devil's advocate, while before(:any) might evoke the current > meaning of before(:all) for some people, after(:any) to me evokes the > curent meaning of after(:each) more than it does after(:all), i.e. > after any OF the examples rather than after all the examples, because > I'd never say after any the examples. > > But that might just be me. > > -- > Rick DeNatale > > Blog: http://talklikeaduck.denhaven2.com/ > Github: http://github.com/rubyredrick > Twitter: @RickDeNatale > WWR: http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn: http://www.linkedin.com/in/rickdenatale > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users I feel like a third option will cause more confusion, especially if it's just an alias of an existing option! Pat From dolzenko at gmail.com Mon Jan 31 04:38:04 2011 From: dolzenko at gmail.com (Evgeniy Dolzhenko) Date: Mon, 31 Jan 2011 12:38:04 +0300 Subject: [rspec-users] Difference between :each and :all In-Reply-To: <035B9168-5FD3-4C9B-96F8-2694CD2E180C@me.com> References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> <035B9168-5FD3-4C9B-96F8-2694CD2E180C@me.com> Message-ID: <4D4682FC.9080106@gmail.com> Btw. there is also before(:suite), and working from there wouldn't it make sense to have 1. before(:suite) 2. before(:group) 3. before(:example) which would reflect the hierarchy of RSpec run (i.e. suite > group > example). Anyway likely it's too late to introduce something like this, just my 2 cents, because I'm from these folks which were always confused about :each/:all and what is the default, etc. when I just started speccing. From dolzenko at gmail.com Mon Jan 31 05:38:07 2011 From: dolzenko at gmail.com (Evgeniy Dolzhenko) Date: Mon, 31 Jan 2011 13:38:07 +0300 Subject: [rspec-users] Are there test:recent, test:uncommitted task alternative for RSpec Message-ID: <4D46910F.3050202@gmail.com> By default Rails provides these task to test_unit tests: > rake -T rake test:recent # Run tests for recenttest:prepare / Test recent changes rake test:uncommitted # Run tests for uncommittedtest:prepare / Test changes since last checkin (only Subversion and Git) I wonder if somebody has readymade spec:recent and spec:uncommitted to share. Sincerely, Evgeniy From Rob.aldred at stardotstar.com Mon Jan 31 07:26:41 2011 From: Rob.aldred at stardotstar.com (Rob Aldred) Date: Mon, 31 Jan 2011 12:26:41 +0000 Subject: [rspec-users] Command with -l and shared examples Message-ID: I cannot use the -l option on a spec that has shared examples definition. If I try to run with -l value set to a test block that is outside the shared examples group all it does it runs the tests in the shared examples block The command line docs have a note saying that the -l option will not work with dynamic tests. It does not mention shared examples but I assume internally they are setup dynamically? Is there anyway around this at all? -- Rob Aldred Software Developer rob at stardotstar.com twitter: stardotstar 47 Newton Street, Manchester, M1 1FT T: +44 (0) 161 236 9740 ___________________________________________________ This email and any files or ideas transmitted within it are sent in confidence and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager at info at stardotstar.com From Rob.aldred at stardotstar.com Mon Jan 31 07:39:58 2011 From: Rob.aldred at stardotstar.com (Rob Aldred) Date: Mon, 31 Jan 2011 12:39:58 +0000 Subject: [rspec-users] Ability to stub a method differently the second time its called In-Reply-To: References: <35f1161a-a48b-4cfa-bffc-701e13625a12@fl7g2000vbb.googlegroups.com> <53d2a6e9-4362-4121-82e4-e0453e7c2d50@w2g2000yqb.googlegroups.com> <9EC25DA0-FB88-4E3B-8F1D-394C5592512A@stardotstar.com> Message-ID: <13578E03-D34F-4274-972F-D8DD5BCAC623@stardotstar.com> On 26 Jan 2011, at 15:29, David Chelimsky wrote: > On Jan 26, 2011, at 7:34 AM, Rob Aldred wrote: > >> I'm having a bit of trouble stubbing out a method on a model which has some quite specific behaviour. >> Basically I want to check the method returns something different after ive called update_attributes >> >> eg. >> >> @exam.draft? (returns true) >> @exam.update_attributes(params[:exam]) # sets draft to false >> @exam.draft? (returns false) > > You're testing the framework here. Why? > >> To give this some context, if the exam is a draft and update_attributes sets draft to false >> then we want to redirect to the show view instead of edit because only exams that are draft can be edited. >> >> if @exam.draft? >> @exam.update_attributes param[:exam] >> end >> >> if @exam.draft? >> redirect_to :action => :edit >> else >> redirect_to :action => :show >> end >> >> I can obviously set consecutive values with and_return(true,false) >> but this feels a bit unreliable? maybe im just confusing myself > > My first question is why the update_attributes needs to be conditional? Couldn't you just do: > > @exam.update_attributes param[:exam] > > if @exam.draft? > redirect_to :action => :edit > else > redirect_to :action => :show > end Published (not draft) exams are not allowed to be edited We are using couchDB the couchrest_model gem does not implement ActiveModel::Dirty so there is no way to check for changing values eg... draft_was or draft_changed? so implementing a validator in the model is a pain without making another call to the db to check the current draft status before_save The reason for the double conditional because if the user passes the draft param set to false (To make the exam published) we need to allow them to save the instance. We then use the 2nd conditional to decide where to send them based on the final state of the exam instance whether draft was changed or not. > > If it must be the way you have it, I wouldn't do this with stubs on the @exam itself. I'd do what you need to do to set the exam in a draft state (Factory(:exam, :draft => true)???), and then invoke the controller action with :draft => true in one example, and :draft => false in the other. > > That make sense? > > Yes, this would work and your right I guess I was testing the framework. This seems like a workable solution. Thanks for your time. Rob From srogers1 at gmail.com Mon Jan 31 09:29:37 2011 From: srogers1 at gmail.com (Steven Rogers) Date: Mon, 31 Jan 2011 08:29:37 -0600 Subject: [rspec-users] Difference between :each and :all In-Reply-To: <4D4682FC.9080106@gmail.com> References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> <035B9168-5FD3-4C9B-96F8-2694CD2E180C@me.com> <4D4682FC.9080106@gmail.com> Message-ID: <2905DB4E-64A4-4CB3-A34B-17636754755C@gmail.com> On Jan 31, 2011, at 3:38 AM, Evgeniy Dolzhenko wrote: > Btw. there is also before(:suite), and working from there wouldn't it make sense to have > > 1. before(:suite) > 2. before(:group) > 3. before(:example) > > which would reflect the hierarchy of RSpec run (i.e. suite > group > example). That or :once and :always SR From dchelimsky at gmail.com Mon Jan 31 09:31:20 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 31 Jan 2011 08:31:20 -0600 Subject: [rspec-users] feedback on feature request Message-ID: Hey all, There is a feature request for rspec-core that I'd like to see some opinions about. The idea is to be able to reference subjects and methods defined with let() in parent groups from within the subject() and let() methods in a child group. Two approaches are to use super or a block argument: describe "outer" do subject { "outer thing" } describe "inner with super" do subject { super.gsub("outer","inner") } end describe "inner with block arg" do subject { |outer_outer| outer_subject.gsub("outer","inner") } end end The same would apply to let: describe "outer" do let(:thing) { "outer thing" } describe "inner with super" do let(:thing) { super.gsub("outer","inner") } end describe "inner with block arg" do let(:thing) { |outer_thing| outer_thing.gsub("outer","inner") } end end Please comment in the github issue: https://github.com/rspec/rspec-core/issues/294 rather than in this thread. Cheers, David From dchelimsky at gmail.com Mon Jan 31 11:15:58 2011 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 31 Jan 2011 10:15:58 -0600 Subject: [rspec-users] Difference between :each and :all In-Reply-To: <4D4682FC.9080106@gmail.com> References: <288eb1883a023d0b7cc2533368ddca96@ruby-forum.com> <035B9168-5FD3-4C9B-96F8-2694CD2E180C@me.com> <4D4682FC.9080106@gmail.com> Message-ID: <689A441C-DF97-4A8D-A3C9-9476377809DA@gmail.com> On Jan 31, 2011, at 3:38 AM, Evgeniy Dolzhenko wrote: > Btw. there is also before(:suite), and working from there wouldn't it make sense to have > > 1. before(:suite) > 2. before(:group) > 3. before(:example) > > which would reflect the hierarchy of RSpec run (i.e. suite > group > example). I really, really like this. It maps well to the afters as well, and therefore does not add to confusion the way :any would. > Anyway likely it's too late to introduce something like this, just my 2 cents, because I'm from > these folks which were always confused about :each/:all and what is the default, etc. when > I just started speccing. I don't think it's too late for this. I'm not convinced to do it yet, but I think this is a solid, clear direction. More opinions on this? From matt at mattwynne.net Mon Jan 31 17:16:33 2011 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 31 Jan 2011 22:16:33 +0000 Subject: [rspec-users] Comparing two XML documents In-Reply-To: References: Message-ID: <62B007FF-815F-48AB-B716-9CAFE10E2029@mattwynne.net> On 31 Jan 2011, at 08:26, Pat Maddox wrote: > I load my XML docs into a hash using Hash#from_xml and then compare the hashes. Bullseye! Thanks Pat. > On Jan 26, 2011, at 7:26 AM, Matt Wynne wrote: > >> I have a problem. I have a test that needs to assert that one XML document looks exactly like another XML document. >> >> I couldn't find a way to compare them as Nokogiri::XML::Documents, so I converted them both to strings with #to_xml and compared the strings. >> >> Trouble is, sometimes the attributes one of the nodes are rendered into the string in a different order to the other one, so you get an error of the form: >> >> Diff: >> @@ -5,7 +5,7 @@ >> >> >> >> - >> >> >> (RSpec::Expectations::ExpectationNotMetError) >> >> Most annoying. >> >> I've seen a couple of RSpec matchers in blog posts that walk and compare XML fragments but I'm surprised there isn't something more concrete that already exists. I feel like I'm missing a way to do it within an XML library, for example. >> >> Any clues out there? >> >> cheers, >> Matt >> >> matt at mattwynne.net >> 07974 430184 >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users cheers, Matt matt at mattwynne.net 07974 430184