Re: [rspec-users] no should raise_exception
On Dec 28, 2:33 pm, David Chelimsky wrote: > So we're going to leave it as raise_error for now. If you'd like to push on > this (which you're welcome to), please add a ticket to lighthouse so it's > easy to find the discussions around it. If we can get general consensus that > this would be a good move in spite of the negatives I just outlined, I'm > happy to do it. Hey all - Roger submitted https://rspec.lighthouseapp.com/projects/5645/tickets/933 on this, so if anybody else has more thoughts on it, please add them to the ticket. Cheers, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Rails 3, Rspec 2, Autotest
On May 9, 8:43 am, Scott Woods wrote: > I get a slightly different error when following the gist. Here is my > error, in case the extra data point helps: > > $ autotest > loading autotest/rails_rspec_rspec2 > Error loading Autotest style autotest/rails_rspec_rspec2 (no such file > to load -- autotest/rails_rspec_rspec2). Aborting. > > Note the extra "rspec" in the path that it's trying to load. That's because autotest looks in the gem paths and the load path for any files named autotest/discover.rb. It's finding the one in the rspec-1.3.0 gem, which adds 'rspec', and the one in your app, which is probably adding 'rspec2'. Try adding a file to your app named autotest/rails_rspec_rspec2.rb and require 'autotest/rails_rspec2' in that file. Let us know if that works. > > Here is some more info about my environment: > > wo...@beidleheimer ~/src/git/example $ gem list rspec > > *** LOCAL GEMS *** > > rspec (2.0.0.beta.8, 1.3.0, 1.2.9, 1.2.8, 1.2.6, 1.2.2, 1.2.0, 1.1.9, > 1.1.3, 1.1.0) > rspec-core (2.0.0.beta.8) > rspec-expectations (2.0.0.beta.8) > rspec-mocks (2.0.0.beta.8) > rspec-rails (1.3.2, 1.2.9, 1.2.7.1, 1.2.6, 1.2.2, 1.2.0, 1.1.9) > wo...@beidleheimer ~/src/git/example $ gem list rails > > *** LOCAL GEMS *** > > rails (3.0.0.beta3, 2.3.5, 2.3.4, 2.3.3, 2.3.2, 2.2.2, 2.1.2, 2.1.1, > 2.1.0, 2.0.4, 2.0.2, 2.0.1, 1.2.3) > wo...@beidleheimer ~/src/git/example $ ruby --version > ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10] > > On Apr 17, 10:42 am, Tim Riendeau wrote: > > > > > I am having similar issue getting this working. I am running rails3.beta3 > > with ruby 1.8.7. I followedhttp://gist.github.com/365816andI get the > > following: > > > loading autotest/rails_rspec2 > > Autotest style autotest/rails_rspec2 doesn't seem to exist. Aborting. > > > I uninstalled and reinstalled the ZenTest & autotest gems with no luck. The > > same thing occurs in other rails3 apps. > > > Any help would be much appreciated > > > --Tim > > > On Apr 15, 2010, at 11:40 AM, Mark Pittillo wrote: > > > > Trying to set up a Rails 3 project with RSpec and Autotest. I followed > > > these steps exactly: > > > >http://gist.github.com/365816 > > > > But when I start up autotest, I get: > > > > $ autotest > > > loading autotest/rails > > > style: Rails > > > > instead of: > > > > $ autotest > > > loading autotest/rails_rspec2 > > > style: RailsRspec2 > > > > And autotest doesn't seem to do anything. Any idea what's happening? > > > I'm using Ruby 1.9.2-head in rvm. Relevant gems: > > > > autotest (4.2.9) > > > autotest-rails (4.1.0) > > > rspec (2.0.0.beta.6) > > > rspec-core (2.0.0.beta.6) > > > rspec-expectations (2.0.0.beta.6) > > > rspec-mocks (2.0.0.beta.6) > > > rspec-rails (2.0.0.beta.6) > > > ZenTest (4.3.1) > > > > Thanks a lot for any help. > > > Mark > > > -- > > > Posted viahttp://www.ruby-forum.com/. > > > ___ > > > rspec-users mailing list > > > rspec-us...@rubyforge.org > > >http://rubyforge.org/mailman/listinfo/rspec-users > > > smime.p7s > > 5KViewDownload > > > ___ > > rspec-users mailing list > > rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > ___ > rspec-users mailing list > rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > > -- > You received this message because you are subscribed to the Google Groups > "rspec" group. > To post to this group, send email to rs...@googlegroups.com. > To unsubscribe from this group, send email to > rspec+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/rspec?hl=en. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] How do I stub a view in rspec-2
On Jun 8, 12:15 pm, David Chelimsky wrote: > On Jun 8, 2010, at 10:26 AM, Trey Bean wrote: > > > > > > > Hi, > > > I'm in the process of upgrading an app to Rails 3/Rspec 2. I see that > > stubbing a view helper method has changed in Rspec 2. It looks like > > instead of doing template.stub!, we're now supposed to do view.stub!, > > but I can't seem to get this to work on beta 10. I get an "undefined > > local variable or method `view' for > > #" > > error. > > > I see that in this commit (http://github.com/rspec/rspec-rails/commit/ > > 0e860f580618045a34c17069b308c093e2e830cb) David removed the view > > method, but I can't figure out what it was replaced with. Something > > in ActionView::TestCase::Behavior? > > > I'm on rails 3.0.0.beta3. > > > Any idea what I'm missing? > > Please report this tohttp://github.com/rspec/rspec-rails/issues Nevermind - I've already got it entered and fix on the way: http://github.com/rspec/rspec-rails/issues/issue/73 ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] [Rails] Can't get controller test working with RSpec 2 and edge Rails 3
On Jun 25, 9:21 pm, David Chelimsky wrote: > On Jun 25, 2010, at 5:02 PM, Patrick Gannon wrote: > > > > > > > Not sure if this is a Rails 3 issue or an RSpec 2 issue, but I can't seem > > to get a standard controller test working - it seems that the 'get' method > > can't be found. > > > I have a controller test that looks like this (named > > "discrepancies_controller_spec.rb" in spec/controllers directory): > > > require 'spec_helper' > > > describe DiscrepanciesController do > > before :each do > > Discrepancy.delete_all > > end > > > it "resolves a discrepancy" do > > discrepancy = Discrepancy.create(:my_number=>"12345", :status=>"Open") > > > get :resolve, :id => discrepancy.id > > > retrieved_discrepancy = Discrepancy.find_by_my_number("12345") > > retrieved_discrepancy.status.should == "Resolved" > > end > > end > > > (Yes, I'm aware of the security implications of modifying data with an > > HTTP/GET - that's a separate issue...) > > When I run it with rake, I get the following error: > > > 1) DiscrepanciesController resolves a discrepancy > > Failure/Error: Unable to find C to read failed line > > undefined method `get' for > > # > > # ./spec/controllers/discrepancies_controller_spec.rb:38 (ignore the > > line number, commented out code was removed from the sample) > > # > > C:/Users/Patrick_Gannon/.bundle/ruby/1.8/bundler/gems/rails-16a5e918a06649f > > fac24fd5873b875daf66212ad-master/activesupport/lib/active_support/dependenc > > ies.rb:212:in `inject' > > # C:/Ruby187/bin/rake:19:in `load' > > # C:/Ruby187/bin/rake:19 > > I'm surprised this is the first time this has come up with rspec-2, but here > we are :) > > This is a path-separator bug that I'll resolve in the next release. For now, > you can do this in your controller specs: > > describe DiscrepanciesController do > include RSpec::Rails::ControllerExampleGroup > > That should work fine. > > If you want to do a more global workaround, add this to your spec_helper > config: > > RSpec.configure do |c| > c.include RSpec::Rails::ControllerExampleGroup, :example_group => { > :file_path => /\bspec[\\\/]controllers[\\\/]/ } > end > > HTH, > David FYI: http://github.com/rspec/rspec-rails/issues/99 > > > > > > > I can manage to test the controller action by instantiating the controller > > myself and calling the controller action directly, and it works, but its > > ugly because I have to mock out things like 'respond_to' and 'params'. > > > Other pertinent information: I am running Windows 7 32-bit, Ruby 1.8.7 > > (2010-01-10 patchlevel 249) [i386-wingw32], edge Rails 3 and > > MongoDB/MongoMapper. Here is my list of installed gems (via 'bundle gem' - > > all my installed gems were installed by Bundler) > > > * abstract (1.0.0) > > * actionmailer (3.0.0.beta4) > > * actionpack (3.0.0.beta4) > > * activemodel (3.0.0.beta4) > > * activerecord (3.0.0.beta4) > > * activeresource (3.0.0.beta4) > > * activesupport (3.0.0.beta4) > > * arel (0.4.0) > > * bcrypt-ruby (2.1.2) > > * bson (1.0.3) > > * bson_ext (1.0.1) > > * builder (2.1.2) > > * bundler (0.9.26) > > * capistrano (2.5.19) > > * capybara (0.3.8 a94f99) > > * cucumber (0.8.3) > > * cucumber-rails (0.3.2 master-b75110) > > * culerity (0.2.10) > > * database_cleaner (0.5.2 7ea99d) > > * devise (1.1.rc1 88ab2f) > > * diff-lcs (1.1.2) > > * erubis (2.6.5) > > * factory_girl (1.3.0) > > * factory_girl_rails (1.0) > > * faker (0.3.1) > > * ffi (0.6.3) > > * gherkin (2.0.2) > > * highline (1.5.2) > > * i18n (0.4.1) > > * jnunemaker-validatable (1.8.4) > > * joint (0.3.2 11a094) > > * json_pure (1.4.3) > > * mail (2.2.5) > > * mime-types (1.16) > > * mongo (1.0.3) > > * mongo_mapper (0.8.2) > > * net-scp (1.0.2) > > * net-sftp (2.0.4) > > * net-ssh (2.0.23) > > * net-ssh-gateway (1.0.1) > > * nokogiri (1.4.2.1) > > * plucky (0.3.2) > > * polyglot (0.3.1) > > * rack (1.1.0) > > * rack-mount (0.6.6) > > * rack-test (0.5.4) > > * rails (3.0.0.beta4 6682cc) > > * railties (3.0.0.beta4) > > * rake (0.8.7) > > * rspec (2.0.0.beta.13) > > * rspec-core (2.0.0.beta.13) > > * rspec-expectations (2.0.0.beta.13) > > * rspec-mocks (2.0.0.beta.13) > > * rspec-rails (2.0.0.beta.13) > > * selenium-webdriver (0.0.24) > > * term-ansicolor (1.0.5) > > * thor (0.13.6) > > * treetop (1.4.8) > > * trollop (1.16.2) > > * tzinfo (0.3.22) > > * wand (0.2.1) > > * warden (0.10.7) > > * webrat (0.7.1) > > > I also added a puts statement in the test to show what methods are > > available in the test fixture, and "get" is not in the list. Here is what > > is in the list: > > > "__memoized", "__should_for_example_group__", > > "__should_not_for_example_group__", "_fixture_class_names", > > "_fixture_path", "_fixture_table_names", "_pre_loaded_fixtures", > > "_setup_mocks", "_teardown_mocks", "_use_instantiated_fixtures", > > "
Re: [rspec-users] rspec2 help output has brackets?
On Jul 19, 9:20 am, Wincent Colaiuta wrote: > El 19/07/2010, a las 15:52, David Chelimsky escribió: > > > > > > > On Jul 19, 2010, at 8:17 AM, rogerdpack wrote: > > >> Hi all. > > >> Saw this: > > >> Usage: rspec [options] [files or directories] > >> -b, --backtrace Enable full backtrace > >> -c, --[no-]color, --[no-]colour Enable color in the output > >> -d, --debug Enable debugging > >> -e, --example PATTERN Run examples whose full > >> descriptions match this pattern > >> (PATTERN is compiled into a Ruby > >> regular expression) > >> -f, --format FORMATTER Choose a formatter > >> [p]rogress (default - dots) > >> [d]ocumentation (group and > >> example names) > >> [h]tml > >> [t]extmate > >> custom formatter class name > > >> tried this: > >> $ rspec -fp (for the [p] in [p]rogress) > > >> got this: > > >> Exception `ArgumentError' at c:/dev/ruby/downloads/jruby/lib/ruby/gems/ > >> 1.8/gems/rspec-core-2.0.0.beta.17/lib/rspec/core/configuration.rb:191 > >> - Formatter 'p' unknown - maybe you meant 'documentation' or > >> 'progress'?. > >> c:/dev/ruby/downloads/jruby/lib/ruby/gems/1.8/gems/rspec- > >> core-2.0.0.beta.17/lib/rspec/core/configuration.rb:191:in > >> `formatter=': Formatter 'p' unknown - maybe you meant 'documentation' > >> or 'progress'?. (ArgumentError) > > >> is this expected? > > > Nope. Bug. rspec-core bugs go here:http://github.com/rspec/rspec-core/issues > > In the meantime, "rspec -f p" (with a space) works fine. Fixed: http://github.com/rspec/rspec-core/issues/closed#issue/84 > > Wincent > > ___ > rspec-users mailing list > rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Fwd: Issue with AR::Base descendants with certain argument
On Oct 28, 7:40 am, Alexey Ilyichev wrote: > I have made 2 examples for this and I can't figure out how to make both > pass. Take a look please: > > require 'spec_helper' > > describe "Mock" do > class A > def self.method_missing(name, *args, &block) > '*a_method_missing*' > end > > def self.present_method(arg) > '*present_method*' > end > end > > class B < A > def self.method_missing(name, *args, &block) > '*b_method_missing*' > end > end > > it 'should call derived class method_missing when args differ from what is > stubbed' do > B.stub!(:missing_method).with(1).and_return '*stub*' > B.missing_method(2).should == '*b_method_missing*' > end > > it 'should call present_method when it is defined in parent class and args > differ from what is stubbed' do > B.stub!(:present_method).with(1).and_return '*stub*' > B.present_method(2).should == '*present_method*' > end > end > > -- Forwarded message -- > From: Alexey Ilyichev > Date: Thu, Oct 28, 2010 at 12:44 PM > Subject: Issue with AR::Base descendants with certain argument > To: rspec-us...@rubyforge.org > > Hi! > > I am trying to upgrade rspec-rails to 1.3.3, and one of my specs fails. > > In before :each I stub finder method like this: > Payment.stub!(:find_by_id).with(@payment.id.to_s).and_return @payment > Payment class is derived from AR::Base > > And then in one of the examples I call Payment.find_by_id((@payment.id + > 1).to_s), and I am expecting it to return null, as it used to with 1.2.9 > version, however it leads to an exception in active_record/base.rb. > Analyzing the stack trace I figured that in line 115 of mock/proxy.rb method > find_by_id is called for ActiveRecord::Base, which is not correct. > > I'm not familiar with rspec internals, so I don't have an idea on where in > code the actual problem is. So any help would be greatly appreciated. The expected behaviour is that when you stub or mock a method on a real object (we call this partial stubbing/mocking), the framework takes over that method for the duration of the example. So the expectation that when the wrong args are received the call is delegated to the original object is incorrect, and making this change would introduce potential problems for other users who count on this behaviour. There is a request to add an explicit way to call to the original in rspec-mocks-2's issue tracker: http://github.com/rspec/rspec-mocks/issues#issue/23. HTH, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] using shared_context in a global way
On Sunday, April 1, 2012 9:34:00 PM UTC-5, Bradley wrote: > > I have some let and before declarations that I want to define for all of > my tests. I can't seem to figure out how to do this in a clean way (ie by > including a module in my Rspec config). I don't want to have to > include_context for each test, I just want to run some before(:all) hooks > and provide access to some default variables that example groups could > override with their own let declarations. > > I must be missing something because I can't find anywhere in the docs how > I might achieve this. Any help is greatly appreciated. > > Brad > Hey Brad, You can set up global `before` hooks using `RSpec.configure` [1] [2]: RSpec.configure {|c| c.before(:all) { do_stuff }} `let` is not supported in `RSpec.configure`, but you _can_ set up a global `let` by including it in a SharedContext module [3] and including that module using `config.before`: module MyLetDeclarations extend RSpec::Core::SharedContext let(:foo) { Foo.new } end RSpec.configure { |c| c.include MyLetDeclarations } If you're going to use that, you may as well put all your global stuff in the same module: module GlobalStuff extend RSpec::Core::SharedContext before(:all) { do_stuff } let(:foo) { Foo.new } end RSpec.configure { |c| c.include MyLetDeclarations } HTH, David [1] http://rubydoc.info/gems/rspec-core/RSpec#configure-class_method [2] http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration [3] http://rubydoc.info/gems/rspec-core/RSpec/Core/SharedContext ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users