From jbrainsberger at gmail.com Sun Nov 1 22:49:54 2009 From: jbrainsberger at gmail.com (J. B. Rainsberger) Date: Sun, 1 Nov 2009 22:49:54 -0500 Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: References: Message-ID: On Wed, Oct 28, 2009 at 20:46, nruth wrote: > I'm going to put the cat amongst the pigeons here in the hope of some > clarity falling out of the sky on me. > My question is this: In a world with Cucumber what is the value of > view specs? http://blog.thecodewhisperer.com/post/207813060/two-kinds-of-views Not a Rails-specific nor RSpec-specific answer, but I think it relates to the question. -- J. B. (Joe) Rainsberger :: http://www.jbrains.ca :: http://blog.thecodewhisperer.com Diaspar Software Services :: http://www.diasparsoftware.com Author, JUnit Recipes 2005 Gordon Pask Award for contribution to Agile practice :: Agile 2010: Learn. Practice. Explore. From lists at ruby-forum.com Mon Nov 2 00:49:06 2009 From: lists at ruby-forum.com (Brian Takita) Date: Mon, 2 Nov 2009 06:49:06 +0100 Subject: [rspec-users] Can't run specs after upgrading gems... get 0 tests, 0 assertions... In-Reply-To: <57c63afe0910060731j6428fa59rc47bea73aa25d581@mail.gmail.com> References: <128f4f21-00e0-4627-ab9a-71049b10cb80@l13g2000yqb.googlegroups.com> <57c63afe0909292049p2aea80c5kfd0818bcff872ef8@mail.gmail.com> <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> <57c63afe0910040654s79984c6fy572fc5b31395ea8d@mail.gmail.com> <1a0e0bbe98277e5014f0fd8b4ac91134@ruby-forum.com> <1fb4df0910041635ma09b27dqcb7d520c09cab0b3@mail.gmail.com> <57c63afe0910060731j6428fa59rc47bea73aa25d581@mail.gmail.com> Message-ID: <8f490534918d7d93dba363bdf24dbf9b@ruby-forum.com> Actually, I think this is more of a bug with test/unit. If you are going to override inherited, be a good citizen and call super. :-) Same with method_missing or any other "core" method you override. Anyways, I do have a fix. It's to monkey-patch test/unit. How do I also submit the patch to test/unit? David Chelimsky wrote: > On Sun, Oct 4, 2009 at 6:35 PM, Stephen Eley wrote: >> >> Test::Unit gem into RSpec? ?And then require the bundled Test::Unit >> directly on its path instead of the gem and Ruby loadpaths? >> >> Sure, for stock Ruby 1.8 users this would be redundant, but they >> wouldn't really lose anything. ?And everyone on 1.9 or running the >> Test::Unit gem for other purposes gains reliability and a much easier >> path to getting RSpec running the first time. ?It's not an ideal >> solution but it'd be quick to set up. ?Is there a reason why this >> wouldn't work or shouldn't be done? > > I'll give this some thought, though I'd much rather just solve the > problem. For the 1.2.9 release I added a message. When you run specs > w/ test/unit interop (which is implicit in rspec-rails) it senses > whether t/u 1.2.3 is loaded - if not it raises an error explaining > your options. > > In terms of solving the problem, there are a few paths: > > 1. Figure out why ruby 1.9 + rubygems + activesupport is allowing two > different versions of the same gem to be loaded. > > 2. Get rspec to play nice w/ test-unit-2.0.3 > > 3. Get rspec to play nice w/ minitest. > > 4. Some combination of 1, 2, and 3. > > This probably won't get resolved (by me) until we release rspec-2, > work on which has begun but it's waiting for me to get the book off to > print before it gets the full love and attention it needs. If anybody > out there wants to help w/ any of the above, please fork the repo, get > it to work, and if it works well I'll be glad to merge it back in. > > Cheers, > David -- Posted via http://www.ruby-forum.com/. From ben at benmabey.com Mon Nov 2 01:17:16 2009 From: ben at benmabey.com (Ben Mabey) Date: Sun, 01 Nov 2009 23:17:16 -0700 Subject: [rspec-users] testing Rake tasks with FakeFS In-Reply-To: <4AEC847D.2010201@tngtech.com> References: <4AEC847D.2010201@tngtech.com> Message-ID: <4AEE796C.9040300@benmabey.com> Jake Benilov wrote: > Hello Ben, > Hi Jake, I hope you don't mind but I am copying this response to the rspec-users list in case any one else is able to shed more light on it. > I have a bit of a newbie question regarding fakefs; I want to test Rake > tasks using fakefs and rspec: > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > require 'fakefs/safe' > require 'rake' > require 'spec' > > task :create_file do > touch "/abc" > end > > describe "my rake script" do > before do > FakeFS.activate! > end > > it "should create a file abc" do > Rake::Task[:create_file].invoke > File.should exist("/abc") > end > > after do > FakeFS::FileSystem.clear > FakeFS.deactivate! > end > end > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > When I run this, a real file /abc is being created on the filesystem. I > am guessing that this has to do with the fact that the touch method > isn't FileUtils.touch, but rather that FileUtils is being included into > Rake and thus touch is not being mocked out. > > Is my analysis correct? In any case, is there a way that you can think > of to write such a spec? > I've never tested a Rake task with FakeFS before so I looked into a bit. In short, I think your analysis is correct. However, it is a bit confusing because Rake does in fact use FileUtils::touch. I discovered that when you fully qualify FileUtils::touch in the rake task then it works fine. I stepped into rake's call to 'touch' and it seems to be doing some other logic specific to rake. My hunch is that rake somehow retains a handle onto the original FileUtils const even though it is replaced by the fake ones with FakeFS. I'm not familiar with Rake's code base so I can't say that for sure or how to really fix it. However, you can fully qualify the call if you want to but that will be going around some rake logic and may have some undesired effects (I can't think of what though). I'm sure someone more familiar with Rake's code could offer a better solution. Here is a gist of my explorations in case anyone else wants to play around with it: http://gist.github.com/223989 HTH, Ben From lists at ruby-forum.com Mon Nov 2 03:35:13 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Mon, 2 Nov 2009 09:35:13 +0100 Subject: [rspec-users] Problem with before filters Message-ID: <25be40a82f097663b3bfc65d1f2d2295@ruby-forum.com> Following is the scenario. describe BbPostsController, "POST Create" do context "Admin" do fixtures :users, :bb_posts, :user_channels, :channels, :channel_features it "should save post" do login_as(:amit) # Added to pass before filters in controller controller.stub!(:validate_channel).and_return(true) controller.stub!(:is_feature_active).and_return(Blog) controller.stub!(:load_categories).and_return(1) @post = mock_model( BbPost, :body => "test_description", :title => "test123", :abstract => "test_abstract", :channel_feature_id => "v1", :published => "1", :bb_post_category_id => "1" ) BbPost.stub!(:new).and_return @post @post.should_receive( :save ) post :create, {:bb_post => {:title => 'test123'}} response.should redirect_to( blog_bb_posts_url(:channel => @channel.brand_name) ) end Following is the controller code: class BbPostsController < ApplicationController before_filter :login_required before_filter :validate_channel before_filter :manager_access_required before_filter :is_feature_active before_filter :load_categories, :only => [ :new, :edit, :create, :update ] # BEFORE FILTER : Feature must active def is_feature_active @feature = @channel.channel_features.by_name( BLOG ).active.first unless @feature flash[ :notice ] = 'Blog feature was not active.' redirect_to requests_features_path end end # BEFORE FILTER : Load blog categories def load_categories # manager blog will not have admin specific categories @categories = ( params[ :channel ].camelize == ADMIN_CHANNEL ) ? BbPostCategory.visible : BbPostCategory.visible.without_admin end def create params[ :bb_post ][ :brand_list ] = ADMIN_CHANNEL if params[ :bb_post ][ :brand_list ].blank? p params @bb_post = @feature.posts.new( params[ :bb_post ] ) @bb_post.user = current_user # CREATE Channel Blog post respond_to do |format| if @bb_post.save flash[ :notice ] = 'Blog post was successfully created.' format.html { redirect_to( blog_bb_posts_url ) } format.xml { render :xml => @bb_post, :status => :created, :location => @bb_post } else load_featured_posts if @bb_post.editorial? format.html { render :action => "new" } format.xml { render :xml => @bb_post.errors, :status => :unprocessable_entity } end end end Now if i run my specs,i get an error which says NoMethodError in 'BbPostsController POST Crete dmin should sve post' You hve nil object when you didn't expect it! The error occurred while evluting nil.posts Error comes at "@bb_post = @feature.posts.new( params[ :bb_post ] )" Just above that line i tried to print params and i get following values: # {"ction"=>"crete", "controller"=>"bb_posts", "bb_post"=>{"brnd_list"=>"BrndPotio n", "title"=>"test123"}} Can somebody help me with this Also by using controller.stub!(:validate_channel).and_return(true) can somebody tell me actually,what exactly happens here.How does it handle before filters. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Mon Nov 2 09:19:11 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 Nov 2009 09:19:11 -0500 Subject: [rspec-users] Problem with before filters In-Reply-To: <25be40a82f097663b3bfc65d1f2d2295@ruby-forum.com> References: <25be40a82f097663b3bfc65d1f2d2295@ruby-forum.com> Message-ID: <93C202EE-0D76-4A8E-94CE-1073E80E2719@gmail.com> On Nov 2, 2009, at 3:35 AM, Amit Kulkarni wrote: > Following is the scenario. > > describe BbPostsController, "POST Create" do > context "Admin" do > fixtures :users, :bb_posts, :user_channels, :channels, > :channel_features > it "should save post" do > login_as(:amit) > # Added to pass before filters in controller > controller.stub!(:validate_channel).and_return(true) > controller.stub!(:is_feature_active).and_return(Blog) > controller.stub!(:load_categories).and_return(1) > @post = mock_model( BbPost, :body => "test_description", :title > => "test123", :abstract => "test_abstract", :channel_feature_id => > "v1", > :published => "1", :bb_post_category_id => "1" ) > BbPost.stub!(:new).and_return @post > @post.should_receive( :save ) > post :create, {:bb_post => {:title => 'test123'}} > response.should redirect_to( blog_bb_posts_url(:channel => > @channel.brand_name) ) > end > > Following is the controller code: > class BbPostsController < ApplicationController > before_filter :login_required > before_filter :validate_channel > before_filter :manager_access_required > before_filter :is_feature_active > before_filter :load_categories, :only => [ :new, :edit, :create, > :update ] > > # BEFORE FILTER : Feature must active > def is_feature_active > @feature = @channel.channel_features.by_name( BLOG ).active.first > unless @feature > flash[ :notice ] = 'Blog feature was not active.' > redirect_to requests_features_path > end > end > > # BEFORE FILTER : Load blog categories > def load_categories > # manager blog will not have admin specific categories > @categories = ( params[ :channel ].camelize == ADMIN_CHANNEL ) ? > BbPostCategory.visible : BbPostCategory.visible.without_admin > end > > def create > params[ :bb_post ][ :brand_list ] = ADMIN_CHANNEL if params[ > :bb_post ][ :brand_list ].blank? > p params > @bb_post = @feature.posts.new( params[ :bb_post ] ) > @bb_post.user = current_user > # CREATE Channel Blog post > respond_to do |format| > if @bb_post.save > flash[ :notice ] = 'Blog post was successfully created.' > format.html { redirect_to( blog_bb_posts_url ) } > format.xml { render :xml => @bb_post, :status => :created, > :location => @bb_post } > else > load_featured_posts if @bb_post.editorial? > format.html { render :action => "new" } > format.xml { render :xml => @bb_post.errors, :status => > :unprocessable_entity } > end > end > end > > Now if i run my specs,i get an error which says > > NoMethodError in 'BbPostsController POST Crete dmin should sve post' > You hve nil object when you didn't expect it! > The error occurred while evluting nil.posts > Error comes at "@bb_post = @feature.posts.new( params[ :bb_post ] )" This tells you that @feature is nil. This is because filter that declares @feature and assigns it a value is being stubbed. Although very common, using filters to set instance variables makes it difficult to test in isolation. I recommend pushing the model concerns to the model, and use filters for application flow control concerns (like authentication/ authorization) in the controller. In this case, that would mean eliminating the validate_channel, is_feature_active, and load_categories filters and simply passing the params to the model. I'm not sure of the models and relationships, but I'm imagining something like: def create @bb_post = BbPost.new( params[ :bb_post ].merge(:user => current_user) ) respond_to do |format| if @bb_post.save ... All of the logic in the filters and before the assignment of @bb_post can be managed in the BbPost model, where it is far easier to spec in my experience. If you don't want to follow that recommendation, you'll have to either set up all the state you need in the database for each example, or do more invasive setup like this: controller.instance_eval { @feature = mock('feature') } > Just above that line i tried to print params and i get following > values: > # > {"ction"=>"crete", "controller"=>"bb_posts", > "bb_post"=>{"brnd_list"=>"BrndPotio > n", "title"=>"test123"}} > > Can somebody help me with this > Also by using controller.stub!(:validate_channel).and_return(true) can > somebody tell me actually,what exactly happens here.How does it handle > before filters. Filters are just methods that get called implicitly by the controller. RSpec's mocking framework doesn't handle them in any special way (nor does any test double frameowrk that I'm aware of). Stubs return values. They do not set state on the object in question, which is why if you stub is_feature_active, for example, that needs to be coupled with code that sets the value of @feature on the controller (per above). HTH, David From matt at mattwynne.net Mon Nov 2 10:55:16 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 2 Nov 2009 15:55:16 +0000 Subject: [rspec-users] Problem with before filters In-Reply-To: <93C202EE-0D76-4A8E-94CE-1073E80E2719@gmail.com> References: <25be40a82f097663b3bfc65d1f2d2295@ruby-forum.com> <93C202EE-0D76-4A8E-94CE-1073E80E2719@gmail.com> Message-ID: <86AC58CB-06D4-49B8-8666-252D8B236521@mattwynne.net> On 2 Nov 2009, at 14:19, David Chelimsky wrote: > On Nov 2, 2009, at 3:35 AM, Amit Kulkarni wrote: > >> Following is the scenario. >> >> describe BbPostsController, "POST Create" do >> context "Admin" do >> fixtures :users, :bb_posts, :user_channels, :channels, >> :channel_features >> it "should save post" do >> login_as(:amit) >> # Added to pass before filters in controller >> controller.stub!(:validate_channel).and_return(true) >> controller.stub!(:is_feature_active).and_return(Blog) >> controller.stub!(:load_categories).and_return(1) >> @post = mock_model( BbPost, :body => "test_description", :title >> => "test123", :abstract => "test_abstract", :channel_feature_id => >> "v1", >> :published => "1", :bb_post_category_id => "1" ) >> BbPost.stub!(:new).and_return @post >> @post.should_receive( :save ) >> post :create, {:bb_post => {:title => 'test123'}} >> response.should redirect_to( blog_bb_posts_url(:channel => >> @channel.brand_name) ) >> end >> >> Following is the controller code: >> class BbPostsController < ApplicationController >> before_filter :login_required >> before_filter :validate_channel >> before_filter :manager_access_required >> before_filter :is_feature_active >> before_filter :load_categories, :only => [ :new, :edit, :create, >> :update ] >> >> # BEFORE FILTER : Feature must active >> def is_feature_active >> @feature = @channel.channel_features.by_name( BLOG ).active.first >> unless @feature >> flash[ :notice ] = 'Blog feature was not active.' >> redirect_to requests_features_path >> end >> end >> >> # BEFORE FILTER : Load blog categories >> def load_categories >> # manager blog will not have admin specific categories >> @categories = ( params[ :channel ].camelize == ADMIN_CHANNEL ) ? >> BbPostCategory.visible : BbPostCategory.visible.without_admin >> end >> >> def create >> params[ :bb_post ][ :brand_list ] = ADMIN_CHANNEL if params[ >> :bb_post ][ :brand_list ].blank? >> p params >> @bb_post = @feature.posts.new( params[ :bb_post ] ) >> @bb_post.user = current_user >> # CREATE Channel Blog post >> respond_to do |format| >> if @bb_post.save >> flash[ :notice ] = 'Blog post was successfully created.' >> format.html { redirect_to( blog_bb_posts_url ) } >> format.xml { render :xml => @bb_post, :status => :created, >> :location => @bb_post } >> else >> load_featured_posts if @bb_post.editorial? >> format.html { render :action => "new" } >> format.xml { render :xml => @bb_post.errors, :status => >> :unprocessable_entity } >> end >> end >> end >> >> Now if i run my specs,i get an error which says >> >> NoMethodError in 'BbPostsController POST Crete dmin should sve post' >> You hve nil object when you didn't expect it! >> The error occurred while evluting nil.posts >> Error comes at "@bb_post = @feature.posts.new( params[ :bb_post ] )" > > This tells you that @feature is nil. This is because filter that > declares @feature and assigns it a value is being stubbed. Although > very common, using filters to set instance variables makes it > difficult to test in isolation. > > I recommend pushing the model concerns to the model, and use filters > for application flow control concerns (like authentication/ > authorization) in the controller. In this case, that would mean > eliminating the validate_channel, is_feature_active, and > load_categories filters and simply passing the params to the model. > I'm not sure of the models and relationships, but I'm imagining > something like: > > def create > @bb_post = BbPost.new( params[ :bb_post ].merge(:user => > current_user) ) > respond_to do |format| > if @bb_post.save > ... > > All of the logic in the filters and before the assignment of > @bb_post can be managed in the BbPost model, where it is far easier > to spec in my experience. > > If you don't want to follow that recommendation, you'll have to > either set up all the state you need in the database for each > example, or do more invasive setup like this: > > controller.instance_eval { @feature = mock('feature') } I'd just back this up to say that one of the major benefits of test- driven-development is the guidance you get with your design. Mocking, particularly, gives you really clear feedback on whether you have a loosely-coupled OO design or not. If you're finding your specs are hard to write, and your mocks are unwieldy and complex, it's always a good idea to take a step back and think about whether your design needs some work. > >> Just above that line i tried to print params and i get following >> values: >> # >> {"ction"=>"crete", "controller"=>"bb_posts", >> "bb_post"=>{"brnd_list"=>"BrndPotio >> n", "title"=>"test123"}} >> >> Can somebody help me with this >> Also by using controller.stub!(:validate_channel).and_return(true) >> can >> somebody tell me actually,what exactly happens here.How does it >> handle >> before filters. > > Filters are just methods that get called implicitly by the > controller. RSpec's mocking framework doesn't handle them in any > special way (nor does any test double frameowrk that I'm aware of). > Stubs return values. They do not set state on the object in > question, which is why if you stub is_feature_active, for example, > that needs to be coupled with code that sets the value of @feature > on the controller (per above). > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users cheers, Matt http://mattwynne.net +447974 430184 From wbsmith83 at gmail.com Mon Nov 2 15:07:19 2009 From: wbsmith83 at gmail.com (BrianTheCoder) Date: Mon, 2 Nov 2009 12:07:19 -0800 (PST) Subject: [rspec-users] undefined method get In-Reply-To: References: <43ae96a2-05c9-4a14-af7f-8b6ec5d39c90@15g2000yqy.googlegroups.com> Message-ID: <6f516545-ce1e-412c-b53f-4aa4dfeb5010@g23g2000yqh.googlegroups.com> Thanks. I ended up just instantiating the rails integration session and operating off of that. Not the prettiest, but it does what I want it to. Also apparently the ActionController::Response breaks some methods that work on Rack::Response, go rails! *sarcasm* On Oct 31, 8:43?am, David Chelimsky wrote: > On Oct 29, 2009, at 6:04 PM, BrianTheCoder wrote: > > > So here's the deal. Was using rack-test in rspec, cause I like passing > > paths instead of an action name, but it doesn't have access to the > > session, flash, cookies, etc. So I tried to switch to normal rspec and > > here's what I get (gist is working for me, so just pasting here) > > > # error > > > 1) > > NoMethodError in 'PagesController should get the home page' > > undefined method `get' for > > # > > ./spec/functional/public/pages_controller_spec.rb:5: > > For rspec to know that you're writing a controller spec and provide ? > the services you're looking for (like the get() method), you need one ? > of two conditions: > > 1. the file lives in the ./spec/controllers/ directory or any of its ? > subdirectories > > 2. explicit declaration: > > describe PagesController, :type => :controller do > ? ?... > end > > HTH, > David > > > > > > > > > # spec > > > require File.join(File.dirname(__FILE__),'..','..','spec_helper') > > > describe PagesController do > > ?it "should get the home page" do > > ? ?get 'home' > > ? ?response.should be_redirect > > ?end > > end > > > # controller > > > class PagesController < ApplicationController > > ?def home > > ? ?render :layout => false > > ?end > > end > > > # spec_helper.rb > > > require 'rubygems' > > require 'spork' > > > Spork.prefork do > > ?# Loading more in this block will cause your tests to run faster. > > However, > > ?# if you change any configuration or code from libraries loaded > > here, you'll > > ?# need to restart spork for it take effect. > > ?ENV["RAILS_ENV"] ||= 'test' > > ?require File.dirname(__FILE__) + "/../config/environment" > > ?require 'spec/autorun' > > ?require 'spec/rails' > > ?require 'faker' > > ?require 'nokogiri' > > > ?Spec::Runner.configure do |config| > > ? ?config.before(:all) do > > ? ? ?DataMapper.auto_migrate! > > ? ? ?ActionMailer::Base.delivery_method = :test > > ? ? ?ActionMailer::Base.perform_deliveries = true > > ? ? ?ActionMailer::Base.deliveries = [] > > > ? ?end > > > ? ?config.before do > > ? ? ?@time_now = Time.now > > ? ? ?Time.stub!(:now).and_return(@time_now) > > > ? ? ?def emails; ActionMailer::Base.deliveries end > > > ? ? ?emails.clear > > > ? ? ?repository do |r| > > ? ? ? ?transaction = DataMapper::Transaction.new(r) > > ? ? ? ?transaction.begin > > ? ? ? ?r.adapter.push_transaction(transaction) > > ? ? ?end > > ? ?end > > > ? ?config.after do > > ? ? ?repository do |r| > > ? ? ? ?adapter = r.adapter > > ? ? ? ?while adapter.current_transaction > > ? ? ? ? ?adapter.current_transaction.rollback > > ? ? ? ? ?adapter.pop_transaction > > ? ? ? ?end > > ? ? ?end > > ? ?end > > ?end > > > end > > > Spork.each_run do > > ?# This code will be run each time you run your specs. > > ?Dir[File.dirname(__FILE__) + '/helpers/*.rb'].each{|helper| require > > helper} > > ?require File.dirname(__FILE__) / 'fixtures' > > end > > _______________________________________________ > > 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 wbsmith83 at gmail.com Mon Nov 2 15:10:23 2009 From: wbsmith83 at gmail.com (BrianTheCoder) Date: Mon, 2 Nov 2009 12:10:23 -0800 (PST) Subject: [rspec-users] spec runner Message-ID: <049ec418-f812-4fe2-9e63-83e99c4b7a0a@f16g2000yqm.googlegroups.com> How do I just invoke the spec runner through code? I have a watchr file that I want to run the specs when files change, but I am shelling out right now, so i though i'd speed it up by keeping it ruby. I tried digging through the spec file, but lost while digging through the files From vishu at thinklinkr.com Mon Nov 2 15:22:20 2009 From: vishu at thinklinkr.com (Vishu Ramanathan) Date: Mon, 2 Nov 2009 14:22:20 -0600 Subject: [rspec-users] spec runner In-Reply-To: <049ec418-f812-4fe2-9e63-83e99c4b7a0a@f16g2000yqm.googlegroups.com> References: <049ec418-f812-4fe2-9e63-83e99c4b7a0a@f16g2000yqm.googlegroups.com> Message-ID: Brian, Have you tried autospec. It does almost exactly this. When used with spork it's incredibly fast. -- Vishu Ramanathan co-founder thinklink llc 312.436.1627 new homepage! ---> thinklinkllc.com mocklinkr.com makes web mockups come to life thinklinkr.com is the web-based collaborative outliner On Mon, Nov 2, 2009 at 2:10 PM, BrianTheCoder wrote: > How do I just invoke the spec runner through code? I have a watchr > file that I want to run the specs when files change, but I am shelling > out right now, so i though i'd speed it up by keeping it ruby. I > tried digging through the spec file, but lost while digging through > the files > _______________________________________________ > 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 Nov 2 17:40:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 Nov 2009 17:40:47 -0500 Subject: [rspec-users] spec runner In-Reply-To: <049ec418-f812-4fe2-9e63-83e99c4b7a0a@f16g2000yqm.googlegroups.com> References: <049ec418-f812-4fe2-9e63-83e99c4b7a0a@f16g2000yqm.googlegroups.com> Message-ID: <253CF033-DE2F-44D6-A227-014788B9B1D4@gmail.com> On Nov 2, 2009, at 3:10 PM, BrianTheCoder wrote: > How do I just invoke the spec runner through code? I have a watchr > file that I want to run the specs when files change, but I am shelling > out right now, so i though i'd speed it up by keeping it ruby. I > tried digging through the spec file, but lost while digging through > the files Spec::Runner::CommandLine.run(Spec::Runner::OptionParser.parse(argv, err, out)) * argv should be the args you would otherwise pass in on the command line * err is normally STDERR, but can be whatever you want for an error stream * out is normally STDOUT, but can be whatever you want for an output stream HTH, David From dchelimsky at gmail.com Mon Nov 2 18:11:23 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 2 Nov 2009 18:11:23 -0500 Subject: [rspec-users] Can't run specs after upgrading gems... get 0 tests, 0 assertions... In-Reply-To: <8f490534918d7d93dba363bdf24dbf9b@ruby-forum.com> References: <128f4f21-00e0-4627-ab9a-71049b10cb80@l13g2000yqb.googlegroups.com> <57c63afe0909292049p2aea80c5kfd0818bcff872ef8@mail.gmail.com> <9ca4aee5d025ac497ed7c172ed7eda4f@ruby-forum.com> <57c63afe0910040654s79984c6fy572fc5b31395ea8d@mail.gmail.com> <1a0e0bbe98277e5014f0fd8b4ac91134@ruby-forum.com> <1fb4df0910041635ma09b27dqcb7d520c09cab0b3@mail.gmail.com> <57c63afe0910060731j6428fa59rc47bea73aa25d581@mail.gmail.com> <8f490534918d7d93dba363bdf24dbf9b@ruby-forum.com> Message-ID: <539489FA-959C-47D5-9061-22092661F59A@gmail.com> On Nov 2, 2009, at 12:49 AM, Brian Takita wrote: > Actually, I think this is more of a bug with test/unit. > > If you are going to override inherited, be a good citizen and call > super. :-) > Same with method_missing or any other "core" method you override. > > Anyways, I do have a fix. It's to monkey-patch test/unit. How do I > also > submit the patch to test/unit? I see a tracker at http://rubyforge.org/projects/test-unit/ - give that a try? And thanks for doing the research. If you don't get a prompt response from the test/unit team, maybe we should include the monkey patch in RSpec for the time being. WDYT? > David Chelimsky wrote: >> On Sun, Oct 4, 2009 at 6:35 PM, Stephen Eley >> wrote: >>> >>> Test::Unit gem into RSpec? ?And then require the bundled >>> Test::Unit >>> directly on its path instead of the gem and Ruby loadpaths? >>> >>> Sure, for stock Ruby 1.8 users this would be redundant, but they >>> wouldn't really lose anything. ?And everyone on 1.9 or running the >>> Test::Unit gem for other purposes gains reliability and a much >>> easier >>> path to getting RSpec running the first time. ?It's not an ideal >>> solution but it'd be quick to set up. ?Is there a reason why this >>> wouldn't work or shouldn't be done? >> >> I'll give this some thought, though I'd much rather just solve the >> problem. For the 1.2.9 release I added a message. When you run specs >> w/ test/unit interop (which is implicit in rspec-rails) it senses >> whether t/u 1.2.3 is loaded - if not it raises an error explaining >> your options. >> >> In terms of solving the problem, there are a few paths: >> >> 1. Figure out why ruby 1.9 + rubygems + activesupport is allowing two >> different versions of the same gem to be loaded. >> >> 2. Get rspec to play nice w/ test-unit-2.0.3 >> >> 3. Get rspec to play nice w/ minitest. >> >> 4. Some combination of 1, 2, and 3. >> >> This probably won't get resolved (by me) until we release rspec-2, >> work on which has begun but it's waiting for me to get the book off >> to >> print before it gets the full love and attention it needs. If anybody >> out there wants to help w/ any of the above, please fork the repo, >> get >> it to work, and if it works well I'll be glad to merge it back in. >> >> Cheers, >> David > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Cheers, David From lists at ruby-forum.com Tue Nov 3 08:01:24 2009 From: lists at ruby-forum.com (Ray K.) Date: Tue, 3 Nov 2009 14:01:24 +0100 Subject: [rspec-users] cucumber table diff haml problem Message-ID: <6bc8446f7fcb656c13cd1d98fa45645b@ruby-forum.com> Inspired by the latest railscast I tried to do some table diffing: But my problem is that the haml generated table does not produce the same html as the erb generated one. And table diffing seems to depend on a rather specific html table format my table diff step: [code] Then /^I should see the (.+) table$/ do |table_id, expected_table| html_table = table_at("##{table_id}").to_a html_table.map! { |r| r.map! { |c| c.gsub(/<.+?>/, '') } } expected_table.diff!(html_table) end [/code] erb code and output: [code] <% for client in @clients %> <% end %>
<%= client.name %> <%= client.number %>
## erb output [/code] And the difference with HAML is this: [code] %table#clients - for client in @clients %tr %td = client.name %td = client.number ##HAML output [/code] Any ideas how I can get table diff working without leaving HAML for ERB? Thx Tick I hope this is readable, not sure if editing or bb is allowed here. -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Tue Nov 3 08:05:34 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 3 Nov 2009 14:05:34 +0100 Subject: [rspec-users] cucumber table diff haml problem In-Reply-To: <6bc8446f7fcb656c13cd1d98fa45645b@ruby-forum.com> References: <6bc8446f7fcb656c13cd1d98fa45645b@ruby-forum.com> Message-ID: <8d961d900911030505i7599c665jb295bdc6074814a@mail.gmail.com> Cucumber has its own mailing list now. Can you please post there? http://groups.google.com/group/cukes Aslak On Tue, Nov 3, 2009 at 2:01 PM, Ray K. wrote: > Inspired by the latest railscast I tried to do some table diffing: > > But my problem is that the haml generated table does not produce the > same html as the erb generated one. And table diffing seems to depend on > a rather specific html table format > > my table diff step: > [code] > Then /^I should see the (.+) table$/ do |table_id, expected_table| > ?html_table = table_at("##{table_id}").to_a > ?html_table.map! { |r| r.map! { |c| c.gsub(/<.+?>/, '') } } > ?expected_table.diff!(html_table) > end > [/code] > > > erb code and output: > [code] >
Client123 123
Client222/td> 222
Client123 123
> <% for client in @clients %> > ? > ? ? > ? ? > ? > <% end %> >
<%= client.name %><%= client.number %>
> > > ## erb output > > > ? > ? > > > ? > > [/code] > > > And the difference with HAML is this: > > [code] > %table#clients > ?- for client in @clients > ? ?%tr > ? ? ?%td > ? ? ? ?= client.name > ? ? ?%td > ? ? ? ?= client.number > > ##HAML output > > ? > > ? > > [/code] > > > Any ideas how I can get table diff working without leaving HAML for ERB? > > Thx > Tick > > I hope this is readable, not sure if editing or bb is allowed here. > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From lists at ruby-forum.com Tue Nov 3 08:12:46 2009 From: lists at ruby-forum.com (Ray K.) Date: Tue, 3 Nov 2009 14:12:46 +0100 Subject: [rspec-users] cucumber table diff haml problem In-Reply-To: <8d961d900911030505i7599c665jb295bdc6074814a@mail.gmail.com> References: <6bc8446f7fcb656c13cd1d98fa45645b@ruby-forum.com> <8d961d900911030505i7599c665jb295bdc6074814a@mail.gmail.com> Message-ID: <9034880baf9adbaaea67ecf15446883d@ruby-forum.com> will do -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Nov 3 15:27:24 2009 From: lists at ruby-forum.com (Steve Scruggs) Date: Tue, 3 Nov 2009 21:27:24 +0100 Subject: [rspec-users] ThreadError on click_button In-Reply-To: References: Message-ID: <1c2be7c94918e70a1de988c9637e94af@ruby-forum.com> Steve Scruggs wrote: > I get the following error > > ThreadError in 'Managing InvoicePayments viewing index lists all > InvoicePayments' > stopping only thread > note: use sleep to stop forever > (eval):2:in `click_button' > > when running rake spec using rspec and rspec-rails 1.2.9 and webrat > 0.5.3. I have tried webrat 0.6.rc1 with the same results. > > Here is the spec being executed: > require 'spec_helper' > > describe "Managing InvoicePayments" do > > describe "viewing index" do > it "lists all InvoicePayments" do > visit 'sessions/new' > fill_in "loginid", :with => "janepublic" > fill_in "password", :with => "janepub123" > click_button "Log in" > end > end > end > > > Any idea what could be causing this? Found the issue, had to monkey-patch actionpack/lib/action_controller/integration.rb with the following: app = Rack::Lint.new(@application) status, headers, body = app.call(env) + body.close if body.respond_to?(:close) + @request_count += 1 @html_document = nil -- Posted via http://www.ruby-forum.com/. From tom at experthuman.com Wed Nov 4 10:23:16 2009 From: tom at experthuman.com (Tom Stuart) Date: Wed, 4 Nov 2009 15:23:16 +0000 Subject: [rspec-users] be_none and be_any don't seem to work properly In-Reply-To: <64C52603-0F84-4CBD-954A-9FD3A9B1B929@gmail.com> References: <24a19427-e0b0-4131-8398-b81debd07720@r36g2000vbn.googlegroups.com> <64C52603-0F84-4CBD-954A-9FD3A9B1B929@gmail.com> Message-ID: <1B23EBE8-5929-4A19-9976-6DDF48C7DCD1@experthuman.com> On 21 Oct 2009, at 16:45, David Chelimsky wrote: > On Oct 19, 2009, at 2:12 PM, iain wrote: >> I use be_all(&:some_predicate) to test if all the elements in the >> collection are valid, which works, but when I try to test the >> inverse, it fails. > I'm not certain, but I _think_ that the problem is the way you're > setting up the factories. I don't think be_all(&:some_predicate) actually works at all, except in the accidental sense that Enumerable#all indiscriminately returns true as long as all of the entries in the collection are truthy. At the moment it looks like dynamic predicate matchers like be_all completely ignore their block argument (&:some_predicate doesn't get rolled into *args) so you just get the default blockless behaviour of the underlying predicate. I've reported and patched this on Lighthouse: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/905 Cheers, -Tom From apremdas at gmail.com Wed Nov 4 10:56:02 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Wed, 4 Nov 2009 15:56:02 +0000 Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: References: Message-ID: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> 2009/10/29 nruth > Hi Guys > > I'm going to put the cat amongst the pigeons here in the hope of some > clarity falling out of the sky on me. > My question is this: In a world with Cucumber what is the value of > view specs? > > In the community (railscamp, for example) there are a fair number of > people using Cucumber and skipping view specs, but still speccing > controllers, models, tricky view helpers and so on. > > Why? Because they don't find them helpful. Indeed they are seen as a > waste of time (money) not only duplicating Cucumber coverage, but also > introducing a high-maintenance example group which designers (who > don't run tests) will frequently break. > > These people aren't stupid. They're producing working apps. I don't > claim that their work cycle is perfect: this is about utility and > efficiency, or about being lazy or avoiding boredom, if you prefer. > > I've been working in a mixed environment, with an existing project > which uses rspec and cucumber (sans view specs) and my own green field > app for a different client. > I've been following the BDD approach prescribed by the RSpec book (or > so I think). This works, and has produced a lot of LOC. > > I've not worried, as it has given me plenty of practice with the > various arms of rspec, webrat, and other tools. > Now that I'm more comfortable with them things are starting to get > tiresome, especially duplication, and I'm worried I'm creating a > monolith. Too many specs => TLDR ? > > What should I try using view specs for? Why are they better than > cucumber for this? > > "Driving views through examples helps us think about what the view > needs in order for it to do its job. It encourages us to write the > code we wish we had to fulfil those needs." > > I'm not sure how this is any different to what I do in the outer > circle with Cucumber. If I write an explicit scenario like > http://gist.github.com/221004 then I already know what the view needs > to let me do. > > If I write something more broad-brush (which you will do, if quickly > sketching out features during a design meeting) like "When I add a > page link" I have to then define that step so it goes red (or, heaven > forbid, green). But to write that step definition I have to know how I > can interact with the page. This example actually comes from a broad- > brush step being expanded in the scenario itself rather than hiding it > away in a step definition, but that's a different subject. > > I'm specifying the page's behaviour in the scenario, or in the step > definition. Why duplicate this process with a view spec? > > I keep coming back to the introduction of chapter 23 in the RSpec book > but don't seem to be getting anywhere from it. > > For the time being I'm going to keep writing view specs, but try to > make them lighter and cut some of the dead wood by describing unusual > or interesting behaviour rather than all behaviour. > > I'd love to hear your thoughts. > > Regards > > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Currently I don't do view specs, but I'm beginning to see a use for them. This is all to do with a recent change change in my thinking about features. In addition to all the other things features do, I am now seeing them as a map to what the "business" wants from the application. This map works best if it is clear and simple (a bit like the London tube map). Putting lots of view details in the features (and I should see a wibble field etc. ...) pollutes this map with clutter that is not relevant to the "business" context. So view specs seem like a really good place to spec all this detail. Another benefit of this is that the view specs might end up as another map that is useful to designers and front end developers. I've been thinking about features, specs and even code as maps recently. It provides a really good explanation of why names and description are so important. Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfeley at gmail.com Wed Nov 4 11:29:44 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 4 Nov 2009 11:29:44 -0500 Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> References: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> Message-ID: <1fb4df0911040829m759a8e9j63ab8c0d474836cd@mail.gmail.com> On Wed, Nov 4, 2009 at 10:56 AM, Andrew Premdas wrote: > > Putting lots of > view details in the features (and I should see a wibble field etc. ...) > pollutes this map with clutter that is not relevant to the "business" > context. So view specs seem like a really good place to spec all this > detail. I think this is a really good point. However, I'd suggest that this could still be done in Cucumber. If you have a step like "Then I should see my wozbat's details" you could put your detail map in the step definition: Then /^I should see my wozbat's details$/ do Then "I should see my wozbat's wibble" Then "I should see my wozbat's wobble" Then "I should see my wozbat's wombat" end And so forth. Generalize or specialize as needed. I don't think this is conceptually better than doing it in a view spec. View specs probably are philosophically superior in most cases. The advantage is that in Cucumber this takes essentially no extra setup and is fairly concise to read, whereas mocking your model instances in a view spec is a pain and the specs themselves tend to be much more verbose. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From apremdas at gmail.com Wed Nov 4 15:24:12 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Wed, 4 Nov 2009 20:24:12 +0000 Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: <1fb4df0911040829m759a8e9j63ab8c0d474836cd@mail.gmail.com> References: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> <1fb4df0911040829m759a8e9j63ab8c0d474836cd@mail.gmail.com> Message-ID: <88fd8ddc0911041224t26532daeweffa200766b25c34@mail.gmail.com> 2009/11/4 Stephen Eley > On Wed, Nov 4, 2009 at 10:56 AM, Andrew Premdas > wrote: > > > > Putting lots of > > view details in the features (and I should see a wibble field etc. ...) > > pollutes this map with clutter that is not relevant to the "business" > > context. So view specs seem like a really good place to spec all this > > detail. > > I think this is a really good point. However, I'd suggest that this > could still be done in Cucumber. If you have a step like "Then I > should see my wozbat's details" you could put your detail map in the > step definition: > > Then /^I should see my wozbat's details$/ do > Then "I should see my wozbat's wibble" > Then "I should see my wozbat's wobble" > Then "I should see my wozbat's wombat" > end > > And so forth. Generalize or specialize as needed. > > I don't think this is conceptually better than doing it in a view > spec. View specs probably are philosophically superior in most cases. > The advantage is that in Cucumber this takes essentially no extra > setup and is fairly concise to read, whereas mocking your model > instances in a view spec is a pain and the specs themselves tend to be > much more verbose. > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Yes you can use step definitions to do this, but I would avoid nesting the steps and actually make the direct calls e.g. response.should_have (#wozbat) Personally I now think nested steps are evil - but thats another story :) If the items are fields in forms I'd just assume their presence and fill them in in a step e.g. when /^I fill in foo form correctly$/ do fill_in foo.wibble, :with => "wibbling" However before I can do this I'm thinking that a view spec that says the form has a wibble field would be useful, concise and expressive. The feature drives what you do with the view, and the view spec specifies whats in the view. This matches the loop within loop workflow in the rspec book. Having said all this I haven't actually done this in practice yet, going to try it on my next view. By the way its nice to find a fellow soul who appreciates the wonderfully expressive power of the word 'wibble'! All best Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From rogerpack2005 at gmail.com Wed Nov 4 15:34:05 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Wed, 4 Nov 2009 12:34:05 -0800 (PST) Subject: [rspec-users] unable to build gem Message-ID: <1b9170ed-b5e1-4b4c-8fd3-5e16c66d9e29@j9g2000prh.googlegroups.com> Is the following expected? C:\dev\ruby\downloads\rspec>rake gem (in C:/dev/ruby/downloads/rspec) in rdoc 2.4.3 rake aborted! Don't know how to build task 'lib/spec/matchers/extensions/ instance_exec.rb' (See full trace by running task with --trace) Thanks. -r From sfeley at gmail.com Wed Nov 4 15:36:39 2009 From: sfeley at gmail.com (Stephen Eley) Date: Wed, 4 Nov 2009 15:36:39 -0500 Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: <88fd8ddc0911041224t26532daeweffa200766b25c34@mail.gmail.com> References: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> <1fb4df0911040829m759a8e9j63ab8c0d474836cd@mail.gmail.com> <88fd8ddc0911041224t26532daeweffa200766b25c34@mail.gmail.com> Message-ID: <1fb4df0911041236k2038c08epa39a84f47978ccc1@mail.gmail.com> On Wed, Nov 4, 2009 at 3:24 PM, Andrew Premdas wrote: > > Personally I now think nested steps are evil - but thats another story :) It sounds like an entertaining one. I'd love to hear why sometime. (Though whether the right place for it would be here or the Cucumber list, I couldn't say.) > Having said all this I haven't actually done this in practice yet, going to > try it on my next view. Please share what you find out. Particularly if you discover a way to do them that doesn't make them feel like more work. >8-> > By the way its nice to find a fellow soul who appreciates the wonderfully > expressive power of the word 'wibble'! Of course! They wobble, but they don't fall down. >8-> -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From rogerpack2005 at gmail.com Wed Nov 4 15:37:24 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Wed, 4 Nov 2009 12:37:24 -0800 (PST) Subject: [rspec-users] odd error Message-ID: with 1.8.6 + rspec 1.2.9 (sorry couldn't try trunk, see previous post) I get: C:\dev\ruby\old\arguments>spec spec\arguments_spec.rb ..................F.... 0.000000 0.000000 0.000000 ( 0.000000) .F 0.000000 0.000000 0.000000 ( 0.000000) 0.015000 0.000000 0.015000 ( 0.015625) . 1) 'Arguments should raise ArgumentError if passing recoginized keywords' FAILED expected: "`four, five` are not recognized argument keywords", got: "`five, four` are not recognized argument keywords" (using ==) ./spec\arguments_spec.rb:140: (succeeds with 1.9.x) Thanks. -r From rogerpack2005 at gmail.com Wed Nov 4 16:28:26 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Wed, 4 Nov 2009 13:28:26 -0800 (PST) Subject: [rspec-users] question Message-ID: <9a3b7640-7dda-49ee-b477-1242cbf8d991@12g2000pri.googlegroups.com> Perhaps it would be useful to do some parsing of the messages... it "should raise an Exception if record is invalid" do end # expects that block to raise Thoughts? -r From rogerpack2005 at gmail.com Wed Nov 4 16:51:34 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Wed, 4 Nov 2009 13:51:34 -0800 (PST) Subject: [rspec-users] better documentation? Message-ID: I'm interested in helping the documentation for rspec, ex: http://rspec.info/ described similarly to how this person feels (that there's not too much "getting started" docu). http://creativedeletion.com/2007/05/27/the-new-rspec-format-testingspecing-in-ruby/ Is there anywhere to fork or what not for the website? Thanks. -r From dchelimsky at gmail.com Wed Nov 4 17:13:07 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Nov 2009 17:13:07 -0500 Subject: [rspec-users] better documentation? In-Reply-To: References: Message-ID: On Nov 4, 2009, at 4:51 PM, rogerdpack wrote: > I'm interested in helping the documentation for rspec, ex: > > http://rspec.info/ > > described similarly to how this person feels (that there's not too > much "getting started" docu). > > http://creativedeletion.com/2007/05/27/the-new-rspec-format-testingspecing-in-ruby/ > > Is there anywhere to fork or what not for the website? Hey Roger, I really like what Aslak and the Cucumber community have done by making cukes.info more high level and building up more extensive documentation on the github wiki, so I'd rather put energy into beefing up the github wiki than improve rspec.info. What do you think? Cheers, David > Thanks. > -r From dchelimsky at gmail.com Wed Nov 4 17:15:05 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Nov 2009 17:15:05 -0500 Subject: [rspec-users] unable to build gem In-Reply-To: <1b9170ed-b5e1-4b4c-8fd3-5e16c66d9e29@j9g2000prh.googlegroups.com> References: <1b9170ed-b5e1-4b4c-8fd3-5e16c66d9e29@j9g2000prh.googlegroups.com> Message-ID: <57c63afe0911041415y31bd62daje645c49a448fe828@mail.gmail.com> On Wed, Nov 4, 2009 at 3:34 PM, rogerdpack wrote: > Is the following expected? > Absolutely not. I moved some things around and failed to update the manifest. This is fixed in git HEAD now, so please update and try again. Cheers, David > > > C:\dev\ruby\downloads\rspec>rake gem > (in C:/dev/ruby/downloads/rspec) > in rdoc 2.4.3 > rake aborted! > Don't know how to build task 'lib/spec/matchers/extensions/ > instance_exec.rb' > > (See full trace by running task with --trace) > > Thanks. > -r > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Nov 4 17:18:09 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Nov 2009 17:18:09 -0500 Subject: [rspec-users] odd error In-Reply-To: References: Message-ID: <57c63afe0911041418o4ea50668w21c2e5d6f68ff402@mail.gmail.com> On Wed, Nov 4, 2009 at 3:37 PM, rogerdpack wrote: > with 1.8.6 + rspec 1.2.9 (sorry couldn't try trunk, see previous post) > > I get: > > > C:\dev\ruby\old\arguments>spec spec\arguments_spec.rb > ..................F.... 0.000000 0.000000 0.000000 ( 0.000000) > .F 0.000000 0.000000 0.000000 ( 0.000000) > 0.015000 0.000000 0.015000 ( 0.015625) > . > > 1) > 'Arguments should raise ArgumentError if passing recoginized keywords' > FAILED > expected: "`four, five` are not recognized argument keywords", > got: "`five, four` are not recognized argument keywords" (using > ==) > ./spec\arguments_spec.rb:140: > Please be sure to post the relevant code when you are asking for help on this list. I'll take a guess at what is going on, but it's hard to know if I'm barking up the right tree without seeing the code. If I understand the problem correctly, it's that the spec is expecting hash keys to be in a specific order. In Ruby 1.8, the order of hash keys are not guaranteed to be in any specific order, whereas in 1.9, AFAIK, they are. HTH, David > > (succeeds with 1.9.x) > > Thanks. > -r > _______________________________________________ > 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 conradwt at gmail.com Tue Nov 3 07:25:52 2009 From: conradwt at gmail.com (Conrad Taylor) Date: Tue, 3 Nov 2009 04:25:52 -0800 (PST) Subject: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9 Message-ID: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. I'm getting the following error message when I run the specs: /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ option_parser_spec.rb:21:in `block (2 levels) in ': wrong number of arguments (0 for 1) (ArgumentError) After analyzing the error message, it appears that "use_fakefs" method on lines 21 and 522 of the option_parser_spec.rb should take an argument. -Conrad From dima at koulikoff.ru Wed Nov 4 06:10:13 2009 From: dima at koulikoff.ru (Dmitri Koulikoff) Date: Wed, 4 Nov 2009 14:10:13 +0300 Subject: [rspec-users] Some tiny but usefill fix Message-ID: <200911041410.14721.dima@koulikoff.ru> Dear David! I use rpec for the several years and almost in every prject I apply the following patch. Today I thought that maybe you will accept it so that others may have it's benefit. diff --git a/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb b/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb index 4f8b9b7..895dcbd 100644 --- a/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb +++ b/vendor/plugins/rspec/lib/spec/runner/formatter/base_text_formatter.rb @@ -52,7 +52,7 @@ module Spec def dump_summary(duration, example_count, failure_count, pending_count) return if dry_run? @output.puts - @output.puts "Finished in #{duration} seconds" + @output.puts "Finished in #{duration} seconds at #{Time.now.strftime('%Y.%m.%d %H:%M:%S')}" @output.puts summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}" Thank you in advance. -- With best regards, Dmitri Koulikoff mailto:dima at koulikoff.ru phone: +7-495-5052185 From joseph.delcioppio at gmail.com Sun Nov 1 23:48:13 2009 From: joseph.delcioppio at gmail.com (Joseph.DelCioppio) Date: Sun, 1 Nov 2009 20:48:13 -0800 (PST) Subject: [rspec-users] [RSpec] Testing "validates_uniquesness of" Message-ID: Guys, Getting used to doing BDD, and in my current project I'm trying to spec out my model, and in particular the fact that my model must validate that one of its fields are unique; in this case, the customer's email address. Simple enough model, a customer, who only has two fields. :email_address and :state. I have a model spec that does the following: it "ensureness that the customer's email is unique" do customer.new :email_address => "Joe at Test.com" customer2.new :email_address => "Joe @Test.com" customer2.should_not be_valid end Once I run my spec, it fails, as their is no validator in the model yet. However, once I add the validator it still fails. class Customer < ActiveRecord::Base validates_precense_of :email_address, :message => "needs to be valid." end The thing is, the validator actually works if I fire up the server and try to do it myself. Anybody know why that spec doesn't do what I expect it to? I have a feeling its something to do with the variables I'm creating, but could anybody give me an example that would show me how to do this? Thanks, Joe From dchelimsky at gmail.com Wed Nov 4 17:28:21 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Nov 2009 17:28:21 -0500 Subject: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9 In-Reply-To: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> References: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> Message-ID: <57c63afe0911041428s4dae12caj171d5bf56982df11@mail.gmail.com> On Tue, Nov 3, 2009 at 7:25 AM, Conrad Taylor wrote: > Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. Hi Conrad, If this was a problem in the gem, it is now fixed: $ rvm 1.9.1 $ which ruby /Users/david/.rvm/ruby-1.9.1-p243/bin/ruby $ rake spec ... 1522 examples, 0 failures, 2 pending Cheers, David > I'm > getting the following error message when I run the specs: > > /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ > option_parser_spec.rb:21:in `block (2 levels) in ': > wrong number of arguments (0 for 1) (ArgumentError) > > After analyzing the error message, it appears that "use_fakefs" method > on lines 21 and 522 of the > > option_parser_spec.rb > > should take an argument. > > -Conrad > > _______________________________________________ > 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 lbocseg at yahoo.com.br Wed Nov 4 17:40:55 2009 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Wed, 04 Nov 2009 22:40:55 +0000 Subject: [rspec-users] [RSpec] Testing "validates_uniquesness of" In-Reply-To: References: Message-ID: <4AF202F7.8000607@yahoo.com.br> Em 02-11-2009 04:48, Joseph.DelCioppio escreveu: > Guys, > > Getting used to doing BDD, and in my current project I'm trying to > spec out my model, and in particular the fact that my model must > validate that one of its fields are unique; in this case, the > customer's email address. > > Simple enough model, a customer, who only has two > fields. :email_address and :state. > > I have a model spec that does the following: > > it "ensureness that the customer's email is unique" do > > customer.new :email_address => "Joe at Test.com" It is simple. You should have used this instead: customer.*create* :email_address => "Joe at Test.com" When you call new, it doesn't instanciate in database and there is why the second try suceeds... Hope that helps, Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From dchelimsky at gmail.com Wed Nov 4 20:30:38 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 4 Nov 2009 20:30:38 -0500 Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: <1fb4df0911041236k2038c08epa39a84f47978ccc1@mail.gmail.com> References: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> <1fb4df0911040829m759a8e9j63ab8c0d474836cd@mail.gmail.com> <88fd8ddc0911041224t26532daeweffa200766b25c34@mail.gmail.com> <1fb4df0911041236k2038c08epa39a84f47978ccc1@mail.gmail.com> Message-ID: <57c63afe0911041730u6ce13bf3x1b29d1287e0e4c96@mail.gmail.com> On Wed, Nov 4, 2009 at 3:36 PM, Stephen Eley wrote: > On Wed, Nov 4, 2009 at 3:24 PM, Andrew Premdas wrote: > > > > Personally I now think nested steps are evil - but thats another story :) > > It sounds like an entertaining one. I'd love to hear why sometime. > (Though whether the right place for it would be here or the Cucumber > list, I couldn't say.) > I'll pipe in since it's here on this list at the moment: I won't go as far as to say that nested steps are evil, but I don't really like to use them myself because they do conflate two levels of abstraction. I'd sooner have two steps delegate to a helper than one step delegate to another. FWIW, David > > Having said all this I haven't actually done this in practice yet, going > to > > try it on my next view. > > Please share what you find out. Particularly if you discover a way to > do them that doesn't make them feel like more work. >8-> > > > > By the way its nice to find a fellow soul who appreciates the wonderfully > > expressive power of the word 'wibble'! > > Of course! They wobble, but they don't fall down. >8-> > > > -- > Have Fun, > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org > _______________________________________________ > 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 zach.dennis at gmail.com Wed Nov 4 21:58:40 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 4 Nov 2009 21:58:40 -0500 Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: References: Message-ID: <85d99afe0911041858w54857870n4375aae93e9ec683@mail.gmail.com> I have had this thread starred since I first saw it... finally a few minutes to participate in our community! It's been too long! > My question is this: In a world with Cucumber what is the value of > view specs? I've used view specs as a learning tool to help folks (including myself) "get" the whole separation of concerns concept between views and how they get their data. In my own personal journey writing examples against views helped me transition to a better developer. A lot of pain I saw developing real code early on but I couldn't understand why suddenly came into focus when the same pain was experienced writing those view examples. This was long before Cucumber, and I must admit, I love Cucumber. For most things view related I find it my first tool of choice since I like to ensure things are there as a result of the app doing something (or the user doing something to it)! Personally I've noticed quite a bit of overlap between how I'd structure my view specs and how I structure some Cucumber steps. I tend to write both semantically and I try to focus on particular sections of the page rather than just on content. So if there should be a leaderboard widget with the top 3 scorers listed I don't have steps like: Then I see "Bob" And I see "Mary" And I see "Fred" To me those are pretty worthless steps. What if you're logged in as "Bobby"? Okay, I know that might seem like a far cry, but this has actually happened (at least to me). Where information that seemed unique at the time ended up not being so unique has the app involved into a smorgus board of social networking mashups. And nothing is worse than a false positive. Instead though I'd write: Then I see the top 3 scorers in the leaderboard are: | 1 | Bob | | 2 | Mary | | 3 | Fred | And in my step definition I'd have something similar to: within ".leaderboard" do response.should have_selector(".position", :content => 1) response.should have_selector(".name", :content => "Bob") end This is actually the same exact code I would put in my view specs. The only difference is the setup. Rather than using Cucumber's Given/When steps to set the page up, in a view spec I'd do something similar to: before(:each) do @bob, @mary, @fred = people("Bob", "Mary", "Fred") assigns[:top_scorers] = [@bob, @mary, @fred] end At the end of the day I find myself following the same practices that I did with view specs, I just utilize Cucumber a lot more to make them run. Now there are things I like to write view specs for that I don't think are very well-suited for cucumber scenarios. * site-wide navigation headers and footers * views which display polymorphic data (like system event logs) For me these things are less pertinent to a single feature. And I enjoy the confidence of knowing navigation headers and footers are rendering the proper links. I've also gone and added super small view specs that look like this: describe "projects/show.html.erb" should_render_navigation_partial end I have a higher level of confidence that each the application-wide systematically applied navigation is showing up on all of the pages its supposed to. Scenarios suck for this kind of thing IMO. Just like scenarios suck for ensuring resources are protected by logins or permissions. I personally get a lot more confidence (and a lot less boilerplate redundancy in some scenarios) with ensuring that an action won't run when the person doesn't have a said permission. It's just to easy to declare in a controller spec and feel super confident: describe ProjectsController do # generic login should_require_login :get # privilege specific should_require_privilege :get, :privilege => [:foo, :bar, :baz] end When there are many permutations of a thing to provide examples for I find lower level specs are better for broader confidence (because you control the low level inputs) than a high level tool like Cucumber's scenarios. Although I did watch a screen cast recently on some Obtiva guys driving ruby class creation with scenarios. View specs and cucumber scenarios have another thing in common though. They can both be brittle if you're not writing semantic markup and instead focusing on the literal structure of the page (ie: "div ul > li p + a"). Writing non-semantic markup in Cucumber will succumb to same evil has writing non-semantic markup in view specs -- unnecessary maintenance time. > In the community (railscamp, for example) there are a fair number of > people using Cucumber and skipping view specs, but still speccing > controllers, models, tricky view helpers and so on. Cucumber definitely overlaps with view specs and in many cases Cucumber is a better choice for many reasons. But I still find times where I write or would like to (if I'm not on a project with rspec and view specs) a view spec. In the past few year what I write a view spec has gone down considerably. > Why? Because they don't find them helpful. Indeed they are seen as a > waste of time (money) not only duplicating Cucumber coverage, but also > introducing a high-maintenance example group which designers (who > don't run tests) will frequently break. Some of this goes to the makeup of the team as David pointed out, but in general if you are wasting money writing doing anything unnecessary than stop doing it. If the makeup of your team consists of designers who aren't able/willing to run specs and/or know how to fix them then that is something to be considered. Also, if you're duplicating considerable amounts of outcome verification between Cucumber and the view specs, then stop. If you get the coverage with your scenario then let those drive the implementation. In some cases you may find the language of the scenarios is more high level and leaves out some details that should show up on a page which you want to get some coverage against. If it doesn't make sense to keep adding things to scenarios view specs are a viable option. In addition to the language of the scenario this may also depend on who owns the scenarios. It's much easier to use scenarios to cover a lot detail when developers own them. At the end of the day I would recommend utilizing view specs until you get a good hang of them, maybe even on a personal project. That way if you come across a situation where it might be applicable then you'll have the knowledge to know to use that tool. If you find Cucumber meets your needs then you'll be able to make that decision, empowered with knowledge, and you'll be able to contribute to your team with more thoughtful ideas on how to organize scenarios, step definitions, views, and specs in a way that maximizes communication, productivity, confidence, and regression. -- 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 dchelimsky at gmail.com Thu Nov 5 00:21:48 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 5 Nov 2009 00:21:48 -0500 Subject: [rspec-users] question In-Reply-To: <9a3b7640-7dda-49ee-b477-1242cbf8d991@12g2000pri.googlegroups.com> References: <9a3b7640-7dda-49ee-b477-1242cbf8d991@12g2000pri.googlegroups.com> Message-ID: <57c63afe0911042121r20987986me66d83574384189d@mail.gmail.com> On Wed, Nov 4, 2009 at 4:28 PM, rogerdpack wrote: > Perhaps it would be useful to do some parsing of the messages... > > it "should raise an Exception if record is invalid" do > > end > > # expects that block to raise > Thoughts? > Cool idea at first blush, but riddled with problems, not the least of which is that there are likely thousands of examples that would suddenly start failing because they start with "should raise an Exception .." and they don't raise an exception :) Seems like an interesting idea to explore in a new framework, but probably not in RSpec. Cheers, David > -r > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Nov 5 04:49:11 2009 From: lists at ruby-forum.com (comopasta Gr) Date: Thu, 5 Nov 2009 10:49:11 +0100 Subject: [rspec-users] [Cucumber] How Do You Use Cucumber? In-Reply-To: <06BC16CC-2028-4F2B-A2C4-AF0C6A9061A6@gmail.com> References: <06BC16CC-2028-4F2B-A2C4-AF0C6A9061A6@gmail.com> Message-ID: Hi, So late reply after your post. I just started with cucumber and actually the list of questions you collected and answers to them (or points of views) would be quite nice. Even though different cases will require different approaches. But well if your idea ever materializes it will be interesting to check in my opinion. Of course participation is the key in a survey... Cheers. -- Posted via http://www.ruby-forum.com/. From elza.morelli at tagview.com.br Thu Nov 5 17:10:16 2009 From: elza.morelli at tagview.com.br (Elza Di Sirio) Date: Thu, 5 Nov 2009 20:10:16 -0200 Subject: [rspec-users] Stub named_scope with params Message-ID: I need some help to stub this method of my controller @users = User.accessible_by(current_user).paginate( :conditions => conditions.to_sql, :include => :user_channels, :order => build_sort_conditions(:name, true), :page => get_param(:page, :integer), :per_page => 10 ) end My rspec is describe 'GET /index' do ############################################################## should_require_login :get, :index ############################################################## describe "authenticated user" do ############################################################## before do login_as_user check_session_expiration @user = mock_model(User) @users = [@user] User.stub_chain(:accessible_by, :paginate).and_return(@users) end ############################################################## it 'should load the users' do User.should_receive(:paginate).with( :conditions => ['active = ?', true], :order => :name, :page => nil, :per_page => 10 ).and_return(@users) do_get assigns[:users].should == @users end end end ############################################################## The error I get is Spec::Mocks::MockExpectationError in 'UsersController GET /index authenticated user should load the users' expected :paginate with ({:per_page=>10, :conditions=>["active = ?", true], :order=>:name, :page=>nil}) once, but received it 0 times ./spec/controllers/users_controller_spec.rb:269: ************************************************* How should I stub a named_scope with params(accessible_by(current_user)), following a stub to paginate.with(...). I can not change my controller Thank you EM -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Thu Nov 5 17:30:47 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 5 Nov 2009 17:30:47 -0500 Subject: [rspec-users] Stub named_scope with params In-Reply-To: References: Message-ID: <85d99afe0911051430p5529ea73tb234cccca2d6cfe3@mail.gmail.com> On Thu, Nov 5, 2009 at 5:10 PM, Elza Di Sirio wrote: > I need some help to stub this method of my controller > ?@users = > ? ? ? ? User.accessible_by(current_user).paginate( > ? ? ? ? ? :conditions => conditions.to_sql, > ? ? ? ? ? :include? ? => :user_channels, > ? ? ? ? ? :order? ? ? => build_sort_conditions(:name, true), > ? ? ? ? ? :page ? ? ? => get_param(:page, :integer), > ? ? ? ? ? :per_page ? => 10 > ? ? ? ? ) > ? end > My rspec is > ??describe 'GET /index' do > ? ? ############################################################## > ? ? should_require_login :get, :index > ? ? ############################################################## > ? ? describe "authenticated user" do > ? ? ? ############################################################## > ? ? ? before do > ? ? ? ? login_as_user > ? ? ? ? check_session_expiration > ? ? ? ? @user = mock_model(User) > ? ? ? ? @users = [@user] > ? ? ? ? User.stub_chain(:accessible_by, :paginate).and_return(@users) > > > > ? ? ? end > > > > ?? ? ?############################################################## > ? ? ? it 'should load the users' do > ? ? ? ? User.should_receive(:paginate).with( > ? ? ? ? ? :conditions => ['active = ?', true], > ? ? ? ? ? :order => :name, > ? ? ? ? ? :page => nil, > ? ? ? ? ? :per_page => 10 > ? ? ? ? ).and_return(@users) > ? ? ? ? do_get > > > > ? ? ? ? assigns[:users].should == @users > ? ? ? end > ?? ?end > ??end > ############################################################## > The error I get is > Spec::Mocks::MockExpectationError in 'UsersController GET /index > authenticated user should load the users' > password_salt: string, persistence_token: string, role: string, active: > boolean, password_last_changed_at: datetime, created_at: datetime, > updated_at: datetime) > (class)> expected :paginate with ({:per_page=>10, :conditions=>["active = > ?", true], :order=>:name, :page=>nil}) once, but received it 0 times > ./spec/controllers/users_controller_spec.rb:269: > ************************************************* > How should I stub a named_scope with params(accessible_by(current_user)), > following a stub to paginate.with(...). In your example User does not receive the #paginate call, the return value of #accessible_by does. It looks like you're having both of those methods return @users in your spec by default. Try updating your spec to say... @users.should_receive(:paginate)... instead of User.should_receive(:paginate)... > I can not change my controller In case you can change your controller... this controller action seems pretty vanilla. I would probably add some good model-level specs around #accessible_by, and then have a few cucumber scenarios ensure whatever it was that pulled up this page was working (I like scenarios for pagination as well). To make things easier I would assign the default PER_PAGE to a configuration setting or a constant so it can be easily changed in a scenario. This can reduce scenario running time and necessary setup whilst still ensuring behaviour. Just an idea with the very little I know from what you pasted, -- 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 sqapro at gmail.com Thu Nov 5 17:55:54 2009 From: sqapro at gmail.com (Chuck van der Linden) Date: Thu, 5 Nov 2009 14:55:54 -0800 (PST) Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: <57c63afe0911041730u6ce13bf3x1b29d1287e0e4c96@mail.gmail.com> References: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> <1fb4df0911040829m759a8e9j63ab8c0d474836cd@mail.gmail.com> <88fd8ddc0911041224t26532daeweffa200766b25c34@mail.gmail.com> <1fb4df0911041236k2038c08epa39a84f47978ccc1@mail.gmail.com> <57c63afe0911041730u6ce13bf3x1b29d1287e0e4c96@mail.gmail.com> Message-ID: <43022205-a160-4008-9a82-f9d65877942b@i12g2000prg.googlegroups.com> On Nov 4, 5:30 pm, David Chelimsky wrote: > On Wed, Nov 4, 2009 at 3:36 PM, Stephen Eley wrote: > > On Wed, Nov 4, 2009 at 3:24 PM, Andrew Premdas wrote: > > > > Personally I now think nested steps are evil - but thats another story :) > > > It sounds like an entertaining one. I'd love to hear why sometime. > > (Though whether the right place for it would be here or the Cucumber > > list, I couldn't say.) > > I'll pipe in since it's here on this list at the moment: > > I won't go as far as to say that nested steps are evil, but I don't really > like to use them myself because they do conflate two levels of abstraction. > I'd sooner have two steps delegate to a helper than one step delegate to > another. > > FWIW, > David > I'll chime in also as to why I really dislike burying details like that in the steps file. Nobody but dev plays around with the lower layers and the step files in particular. Potentially everyone in the business may have a hand in the 'feature' definition, or maybe need to see or modify it at a later time. Also a Dev or tester reviewing things to see 'how should it work' gets everything high level in one place (the feature file) instead of having to chase down into multple levels of step files ( an exercise reminding one of why we hate spaghetti code) to find the details that matter up at the UI or potentially integration test level. Remember Rspec/Cucumber are all about implementing BDD.. Part of BDD is that more than just the folks in Dev will be looking at what's done at the 'feature' level. If you bury the details of something inside the step file, then nobody outside of dev can play along, and that defeats a large part of the purpose of BDD. If it is important to the business that a particular field be on that page, then you ought to have it expressed in the feature and not buried in the steps. Consider something like 'Scenario: User reviews their profile details' Given I am logged in as: When I click the link: view profile Then I should see my profile details. How much more value to the business (and clarity to those implementing the feature) is created if we were to instead have something more like: .... Then I will be on the page: User Profile and I will see identified as containing and I will see identified as containing etc The <> items could either of course be spelled out, or they could be parameters in a scenario outline's examples section. --Chuck From skizzybiz at gmail.com Thu Nov 5 17:23:56 2009 From: skizzybiz at gmail.com (Joel Young) Date: Thu, 5 Nov 2009 14:23:56 -0800 (PST) Subject: [rspec-users] [Rails] render_to_string in a controller fails under RSpec Message-ID: <99d3b33a-1931-4b7f-84da-92e64f629893@f18g2000prf.googlegroups.com> I'm using render_to_string in a controller to send some JSON data with an HTML fragment. Unfortunately, it seems that rspec-rails breaks that by intercepting render and simply recording that a render was called. Using rspec-rails and rspec versions 1.2.9, I've tracked it down to lib/spec/rails/example/controller_example_group.rb:181 -- since it's calling record_render, it returns a Fixnum, so instead of an HTML fragment, I get "1". I've confirmed that if I add a call to "super" on the next line, it does what I want. Obviously that would be bad for other reasons, though. Is there a workaround for this? Is there a better way to get an HTML fragment included in the JSON? Using an RJS template won't work, since it wraps my JSON object in an exception handling block. For reference, here's the controller action that calls render_to_string: def changed unless params[:since] render :status => :bad_request return end respond_to do |format| format.js do @changed = Event.changed_since(params[:since]).collect do | event| { :id => dom_id(event), :sidebar_html => render_to_string(:partial => "history_item", :object => event) } end render :json => @changed end end end And here is the relevant part of the controller spec: it "should return the sidebar HTML for the event" do get :changed, :since => @time json = JSON.parse(response.body) json.should have(1).event response.body = json.first["sidebar_html"] response.should include_text("TestApp r1234") end From conradwt at gmail.com Thu Nov 5 06:59:05 2009 From: conradwt at gmail.com (Conrad Taylor) Date: Thu, 5 Nov 2009 03:59:05 -0800 (PST) Subject: [rspec-users] [WEBSITE] runners.html page out of date Message-ID: Hi, the following page needs to be updated to use spork instead of spec_server: http://rspec.info/rails/runners.html From dchelimsky at gmail.com Thu Nov 5 21:15:59 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 5 Nov 2009 21:15:59 -0500 Subject: [rspec-users] [Rails] render_to_string in a controller fails under RSpec In-Reply-To: <99d3b33a-1931-4b7f-84da-92e64f629893@f18g2000prf.googlegroups.com> References: <99d3b33a-1931-4b7f-84da-92e64f629893@f18g2000prf.googlegroups.com> Message-ID: <57c63afe0911051815g57bb33b5v9ba2cd3a5cdded9f@mail.gmail.com> On Thu, Nov 5, 2009 at 5:23 PM, Joel Young wrote: > I'm using render_to_string in a controller to send some JSON data with > an HTML fragment. Unfortunately, it seems that rspec-rails breaks that > by intercepting render and simply recording that a render was called. > Using rspec-rails and rspec versions 1.2.9, I've tracked it down to > lib/spec/rails/example/controller_example_group.rb:181 -- since it's > calling record_render, it returns a Fixnum, so instead of an HTML > fragment, I get "1". I've confirmed that if I add a call to "super" on > the next line, it does what I want. Obviously that would be bad for > other reasons, though. > > Is there a workaround for this? Is there a better way to get an HTML > fragment included in the JSON? Using an RJS template won't work, since > it wraps my JSON object in an exception handling block. > > For reference, here's the controller action that calls > render_to_string: > > def changed > unless params[:since] > render :status => :bad_request > return > end > respond_to do |format| > format.js do > @changed = Event.changed_since(params[:since]).collect do | > event| > { > :id => dom_id(event), > :sidebar_html => render_to_string(:partial => > "history_item", :object => event) > } > end > render :json => @changed > end > end > end > > And here is the relevant part of the controller spec: > > it "should return the sidebar HTML for the event" do > get :changed, :since => @time > json = JSON.parse(response.body) > json.should have(1).event > response.body = json.first["sidebar_html"] > response.should include_text("TestApp r1234") > end > http://rspec.info/rails/writing/controllers.html For any case in which you want the controller to render views, you can say integrate_views. HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom at experthuman.com Fri Nov 6 02:37:20 2009 From: tom at experthuman.com (Tom Stuart) Date: Fri, 6 Nov 2009 07:37:20 +0000 Subject: [rspec-users] [WEBSITE] runners.html page out of date In-Reply-To: References: Message-ID: On 5 Nov 2009, at 11:59, Conrad Taylor wrote: > Hi, the following page needs to be updated to use spork instead of > spec_server: Incidentally, I strongly second David's suggestion that rspec.info be turned into, for want of a better word, "brochureware" like cukes.info, with all of the actual instructions and documentation moved to the wiki, not least because it'd reduce the incidence of staleness problems like this. Cheers, -Tom From lee.hambley at gmail.com Fri Nov 6 03:16:52 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Fri, 6 Nov 2009 09:16:52 +0100 Subject: [rspec-users] [WEBSITE] runners.html page out of date In-Reply-To: References: Message-ID: +1 -- Lee Hambley Twitter: @leehambley | @capistranorb Blog: http://lee.hambley.name/ Working with Rails: http://is.gd/1s5W1 2009/11/6 Tom Stuart > On 5 Nov 2009, at 11:59, Conrad Taylor wrote: > >> Hi, the following page needs to be updated to use spork instead of >> spec_server: >> > > Incidentally, I strongly second David's suggestion that rspec.info be > turned into, for want of a better word, "brochureware" like cukes.info, > with all of the actual instructions and documentation moved to the wiki, not > least because it'd reduce the incidence of staleness problems like this. > > Cheers, > -Tom > > _______________________________________________ > 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 Nov 6 07:49:10 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 6 Nov 2009 07:49:10 -0500 Subject: [rspec-users] describe "RSpec's documentation" do Message-ID: Hi all, describe "RSpec's documentation" do it "should be helpful" it "should be maintainable" end I've been wanting to improve RSpec's documentation situation for a long time, but my writing energies have been consumed by rspec itself and The RSpec Book for a longer time, and will continue to do so for the foreseeable future. So I'm going to need some help. The problem to solve is that we have (at least) four sources of documentation, each of which moves at its own pace and has evolved in its meaning/place: 1. The RSpec code examples that ship with RSpec 2. The Cucumber features that ship with RSpec 3. The github wiki: http://wiki.github.com/dchelimsky/rspec 4. http://rspec.info The model that Aslak and the Cucumber community has used has worked very well because it's a community effort, but there is still some duplication between what's on the wiki [1] and the Cucumber features/ scenarios that ship with Cucumber [2]. In the long run, what I'd like is the following: * Cucumber features that ship with RSpec become the authoritative end- user documentation. This is something that anybody can contribute to with patches, as it's all in files that ship with RSpec. I'd also like to use such an effort to push the envelope on Cucumber features as executable documentation. I think that with a little bit of work we could use the features to generate a website with meaningful organization/navigation. Is anybody already doing that? * RSpec code examples become a solid source of additional detailed documentation for those who want to either extend RSpec or debug problems. * http://rspec.info becomes a one pager like http://cukes.info * The github wiki becomes a community driven resource center with links to tutorials, blogs, matcher libraries, etc, etc I welcome suggestions, but I really need volunteers volunteers! I'm not going to be able to spend much personal time on this, so if there are any among you who are willing to coordinate with me and drive the effort, I'd love to hear from you. Cheers, David [1] http://wiki.github.com/aslakhellesoy/cucumber [2] http://github.com/aslakhellesoy/cucumber/tree/master/features/ From martin.emde at gmail.com Sat Nov 7 01:43:42 2009 From: martin.emde at gmail.com (Martin Emde) Date: Fri, 6 Nov 2009 22:43:42 -0800 Subject: [rspec-users] should_yield (is it needed?) Message-ID: <145359ad0911062243m66eff304oe3e3a007dd445cf0@mail.gmail.com> I have the code working for this but I wanted an opinion on making a patch. I sometimes have the need to expect that a method will yield a block it's given. Usually this means something like this: yielded = false subject.method { yielded = true } yielded.should == true which is a bit tedious and ugly. My solution might be just as ugly, but I wanted to get feedback because it saves that tedious code. subject.method(&should_yield) I wrote a few methods, that when called, return an object with #to_proc that expects that the proc is called (or not called). I have the following forms available fairly simply: subject.method(&should_not_yield) subject.method(&should_yield_with(object)) # Expects 3 yields, one with each argument [1,2,3].each(&should_yield_each(1,2,3)) I think this is a little cleaner and the code is very simple. I wanted to get an opinion on whether this is worth making into a patch. Martin Emde Tw: @martinemde -------------- next part -------------- An HTML attachment was scrubbed... URL: From lbocseg at yahoo.com.br Sat Nov 7 08:15:48 2009 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Sat, 07 Nov 2009 11:15:48 -0200 Subject: [rspec-users] describe "RSpec's documentation" do In-Reply-To: References: Message-ID: <4AF57304.3010409@yahoo.com.br> David Chelimsky escreveu: > Hi all, > > describe "RSpec's documentation" do > it "should be helpful" > it "should be maintainable" > end > > I've been wanting to improve RSpec's documentation situation for a > long time, but my writing energies have been consumed by rspec itself > and The RSpec Book for a longer time, and will continue to do so for > the foreseeable future. So I'm going to need some help. > > The problem to solve is that we have (at least) four sources of > documentation, each of which moves at its own pace and has evolved in > its meaning/place: > > 1. The RSpec code examples that ship with RSpec > 2. The Cucumber features that ship with RSpec > 3. The github wiki: http://wiki.github.com/dchelimsky/rspec > 4. http://rspec.info > > The model that Aslak and the Cucumber community has used has worked > very well because it's a community effort, but there is still some > duplication between what's on the wiki [1] and the Cucumber > features/scenarios that ship with Cucumber [2]. > > In the long run, what I'd like is the following: > > * Cucumber features that ship with RSpec become the authoritative > end-user documentation. This is something that anybody can contribute > to with patches, as it's all in files that ship with RSpec. I'd also > like to use such an effort to push the envelope on Cucumber features > as executable documentation. I think that with a little bit of work we > could use the features to generate a website with meaningful > organization/navigation. Is anybody already doing that? > * RSpec code examples become a solid source of additional detailed > documentation for those who want to either extend RSpec or debug > problems. > * http://rspec.info becomes a one pager like http://cukes.info > * The github wiki becomes a community driven resource center with > links to tutorials, blogs, matcher libraries, etc, etc > > I welcome suggestions, but I really need volunteers volunteers! I'm > not going to be able to spend much personal time on this, so if there > are any among you who are willing to coordinate with me and drive the > effort, I'd love to hear from you. > Hi David, it is awesome that you are concerned about improving Rspec documentation. Although I have no time currently to coordinate/drive the effort, and I'm not even skilled enough yet, I would be happy to contribute to documentation when I get some time, slowly... I really liked the docrails project and it was really simple to contribute to Rails documentation using their model. Maybe it could be another way of improving Rspec's documentation. Although I like the idea of using some kind of wiki, I simple don't like the Github's wiki... I think they are a bit polluted... It would be good if the Rspec site's content were hosted on Github, and there was a fork with open access for who wants to contribute, as it happens on railsdoc, and then, from time to time, someone could take a look at the changes and merge with main repository. There are some mispelled words on Rspec site that could easily be corrected that way... And I think we should mantain Rspec site, improving its documentation instead of a one pager that links to Github's wiki... Something like Rails Guides would also be awesome (like the tutorials you've proposed). What do you think? Best Regards, Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From jko170 at gmail.com Fri Nov 6 20:44:56 2009 From: jko170 at gmail.com (jko170) Date: Fri, 6 Nov 2009 17:44:56 -0800 (PST) Subject: [rspec-users] rake spec runs my spec:remote specs! Message-ID: <81301c17-3248-4821-8e5b-745a114628c2@t11g2000prh.googlegroups.com> In my spec folder, I have a "remote" directory, which contains my specs for live data transferring with an outside api. When I run rake spec, it runs the remote specs and I don't want it to. Keep in mind there is NO lib/tasks/remote.task file. I ONLY want these remote specs to run when I execute rake spec:remote How can I achieve this? From ryan.briones at brionesandco.com Fri Nov 6 17:27:40 2009 From: ryan.briones at brionesandco.com (Ryan Briones) Date: Fri, 6 Nov 2009 17:27:40 -0500 Subject: [rspec-users] [rspec-devel] describe "RSpec's documentation" do In-Reply-To: References: Message-ID: <2566dc840911061427o53dc6294o5228045bf7cf8c5d@mail.gmail.com> This sounds pretty cool. Are there any ideas or examples of how features would get turned into end user documentation? My first thought is something RDoc like would go in the free-form user story area... I'd certainly like to help as time permitted. I'd definitely like to be more informed of rspec internals. On Fri, Nov 6, 2009 at 7:49 AM, David Chelimsky wrote: > Hi all, > > describe "RSpec's documentation" do > it "should be helpful" > it "should be maintainable" > end > > I've been wanting to improve RSpec's documentation situation for a long > time, but my writing energies have been consumed by rspec itself and The > RSpec Book for a longer time, and will continue to do so for the foreseeable > future. So I'm going to need some help. > > The problem to solve is that we have (at least) four sources of > documentation, each of which moves at its own pace and has evolved in its > meaning/place: > > 1. The RSpec code examples that ship with RSpec > 2. The Cucumber features that ship with RSpec > 3. The github wiki: http://wiki.github.com/dchelimsky/rspec > 4. http://rspec.info > > The model that Aslak and the Cucumber community has used has worked very > well because it's a community effort, but there is still some duplication > between what's on the wiki [1] and the Cucumber features/scenarios that ship > with Cucumber [2]. > > In the long run, what I'd like is the following: > > * Cucumber features that ship with RSpec become the authoritative end-user > documentation. This is something that anybody can contribute to with > patches, as it's all in files that ship with RSpec. I'd also like to use > such an effort to push the envelope on Cucumber features as executable > documentation. I think that with a little bit of work we could use the > features to generate a website with meaningful organization/navigation. Is > anybody already doing that? > * RSpec code examples become a solid source of additional detailed > documentation for those who want to either extend RSpec or debug problems. > * http://rspec.info becomes a one pager like http://cukes.info > * The github wiki becomes a community driven resource center with links to > tutorials, blogs, matcher libraries, etc, etc > > I welcome suggestions, but I really need volunteers volunteers! I'm not > going to be able to spend much personal time on this, so if there are any > among you who are willing to coordinate with me and drive the effort, I'd > love to hear from you. > > Cheers, > David > > [1] http://wiki.github.com/aslakhellesoy/cucumber > [2] http://github.com/aslakhellesoy/cucumber/tree/master/features/ > > > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > -- Ryan Carmelo Briones -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlos at eddorre.com Sat Nov 7 18:18:32 2009 From: carlos at eddorre.com (Carlos Rodriguez) Date: Sat, 7 Nov 2009 15:18:32 -0800 Subject: [rspec-users] "lambda Should Change" Behavior Failing When Checking Time Message-ID: <67b9f24a0911071518t61f665cdla6c376e838b27c7a@mail.gmail.com> Hello, I'm having a problem with RSpec when using the "lambda should change behavior". This is happening in a Rails 2.3.4 app and I'm running the following in my test environment: 'cucumber', :version => '0.4.2' 'faker', :version => '0.3.1' 'notahat-machinist', :lib => 'machinist', :version => '1.0.3' "remarkable_rails", :lib => false 'rspec', :lib => false, :version => '1.2.9' 'rspec-rails', :lib => false, :version => '1.2.9' 'jtrupiano-timecop', :lib => 'timecop', :version => '0.3.0' 'webrat', :lib => false, :version => '0.5.1' 'fakeweb', :lib => false, :version => '1.2.6' In my application, I have a Post model that is using Rubyist's AASM gem. The aasm column is defined as 'state'. The other column of note is 'published_at'; this is defined as a datetime. These are the settings for the state machine: aasm_column :state aasm_initial_state :draft aasm_state :draft aasm_state :published, :enter => :set_published aasm_event :publish do transitions :to => :published, :from => :draft end set_published is a method that is defined as: def set_published self.update_attributes(:published_at => Time.now) end For those that are unfamiliar with Rubyist's AASM, defining an aasm_event gives you an bang instance method with the same name of the aasm_event. For example, I have :publish defined as an aasm_event and because of this I can call the publish! method on an instance of a Post. This will change the state from 'draft' to 'published'. It will also call the set_published method as defined by the :enter statement. This is my first spec attempt. I've removed all of the post attributes for brevity. describe "AASM States" do before(:each) do @post = Post.create([snip...post attributes here]) end it "should set the publish date to now when transitioning to published" do lambda { @post.publish! }.should change(@post, :published_at).from(nil).to(Time.now) end end This fails with a message like the following: published_at should have been changed to Sat Nov 07 15:02:00 -0800 2009, but is now Sat Nov 07 15:02:00 -0800 2009 *blink* *blink* They appear to be the same. Just in case the time was being altered by milliseconds that I couldn't see, I tried using jtrupiano's Timecop gem to freeze time and check against the frozen time. it "should set the publish date to now when transitioning to published" do time = Time.now Timecop.freeze(time) lambda { @post.publish! }.should change(@post, :published_at).from(nil).to(time) Timecop.return end This still gives me the same failure message. For those unfamiliar with Timecop, here is how it works (in the console): >> require 'Timecop' => [] >> time = Timecop.freeze(Time.now) => Sat Nov 07 15:07:32 -0800 2009 >> sleep(10) => 10 >> time == Time.now => true >> Timecop.return => Sat Nov 07 15:08:09 -0800 2009 >> time == Time.now => false In development, I know that the published_at time is truly transitioning from nil to an actual time, I just don't know why it's failing in the spec and even stranger when RSpec tells me that they are the (supposedly) the same. >From the development console: >> p = Post.new([snip...post attributes here]) >> p.save => true >> p.published_at => nil >> p.publish! => true >> p.published_at => Sat Nov 07 15:10:22 -0800 2009 Is there something that I'm missing? Thank you in advance for your help, Carlos From apremdas at gmail.com Sat Nov 7 19:55:59 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Sun, 8 Nov 2009 00:55:59 +0000 Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: <43022205-a160-4008-9a82-f9d65877942b@i12g2000prg.googlegroups.com> References: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> <1fb4df0911040829m759a8e9j63ab8c0d474836cd@mail.gmail.com> <88fd8ddc0911041224t26532daeweffa200766b25c34@mail.gmail.com> <1fb4df0911041236k2038c08epa39a84f47978ccc1@mail.gmail.com> <57c63afe0911041730u6ce13bf3x1b29d1287e0e4c96@mail.gmail.com> <43022205-a160-4008-9a82-f9d65877942b@i12g2000prg.googlegroups.com> Message-ID: <88fd8ddc0911071655t5924c7c5m30d1bfb045f61b36@mail.gmail.com> 2009/11/5 Chuck van der Linden > On Nov 4, 5:30 pm, David Chelimsky wrote: > > On Wed, Nov 4, 2009 at 3:36 PM, Stephen Eley wrote: > > > On Wed, Nov 4, 2009 at 3:24 PM, Andrew Premdas > wrote: > > > > > > Personally I now think nested steps are evil - but thats another > story :) > > > > > It sounds like an entertaining one. I'd love to hear why sometime. > > > (Though whether the right place for it would be here or the Cucumber > > > list, I couldn't say.) > > > > I'll pipe in since it's here on this list at the moment: > > > > I won't go as far as to say that nested steps are evil, but I don't > really > > like to use them myself because they do conflate two levels of > abstraction. > > I'd sooner have two steps delegate to a helper than one step delegate to > > another. > > > > FWIW, > > David > > > > I'll chime in also as to why I really dislike burying details like > that in the steps file. Nobody but dev plays around with the lower > layers and the step files in particular. Potentially everyone in the > business may have a hand in the 'feature' definition, or maybe need to > see or modify it at a later time. Also a Dev or tester reviewing > things to see 'how should it work' gets everything high level in one > place (the feature file) instead of having to chase down into multple > levels of step files ( an exercise reminding one of why we hate > spaghetti code) to find the details that matter up at the UI or > potentially integration test level. > > Remember Rspec/Cucumber are all about implementing BDD.. Part of BDD > is that more than just the folks in Dev will be looking at what's done > at the 'feature' level. If you bury the details of something inside > the step file, then nobody outside of dev can play along, and that > defeats a large part of the purpose of BDD. > > If it is important to the business that a particular field be on that > page, then you ought to have it expressed in the feature and not > buried in the steps. Consider something like > > 'Scenario: User reviews their profile details' > Given I am logged in as: > When I click the link: view profile > Then I should see my profile details. > > How much more value to the business (and clarity to those implementing > the feature) is created if we were to instead have something more > like: > > .... > Then I will be on the page: User Profile > and I will see identified as containing > > and I will see identified as containing > > etc > > The <> items could either of course be spelled out, or they could be > parameters in a scenario outline's examples section. > > --Chuck > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Couldn't agree less :-) , although alot of that depends on the business. There are many problems with the sort of scenarios you prefer 1) They are very fragile - change a label and it breaks. A business will review the application not the feature. When I change the label who fixes the feature, and why should I have to run 30 minutes of features to change one label! 2) You have to get detail correct before you know the context. As a business person how do I know what details should be in the user profile. 3) It places the responsibility for trivial and obvious decisions with the business people. And makes them make these decisions before they are ready. Its much easier to decide what should be on the profile page when you can see it and navigate to it. And as a business it is cheaper and far more effective to trust your development team rather than micro-manage them to the nth degree. 4) With an application of any size the amount of detail these type of scenarios generates soon removes and chance of the business actually reading or reviewing the features. Any chance of getting an overview of what the application does, or even readable reports of what works and what doesn't is lost. Dev's and testers are perfectly capable of looking at step definitions and working with them. Business people (at least the ones I know and have experienced) are much better at telling you want they want by providing feedback from the application itself than by doing any sort of up front work. One of the elegant parts of BDD is that by writing simple succinct features business can get you quickly into a feedback loop. It is much easier to create Feature As a user I want to have a profile So I can stop you spamming me Scenario When I view my profile I should be able to stop you spamming me and start iterating around that, than to create some big feature that specifies different labels for mailings and whether to use radio button or checkboxes. It is also much easier for the business to come back to a 5 line profile feature, and review this by looking at the application, than to review a 200 line profile feature. This is an Agile process we're supposed to be working with after all. All best Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat Nov 7 21:16:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Nov 2009 21:16:47 -0500 Subject: [rspec-users] "lambda Should Change" Behavior Failing When Checking Time In-Reply-To: <67b9f24a0911071518t61f665cdla6c376e838b27c7a@mail.gmail.com> References: <67b9f24a0911071518t61f665cdla6c376e838b27c7a@mail.gmail.com> Message-ID: <57c63afe0911071816p5182477fua7e80741f5aff806@mail.gmail.com> On Sat, Nov 7, 2009 at 6:18 PM, Carlos Rodriguez wrote: > Hello, > > I'm having a problem with RSpec when using the "lambda should change > behavior". > > This is happening in a Rails 2.3.4 app and I'm running the following > in my test environment: > > 'cucumber', :version => '0.4.2' > 'faker', :version => '0.3.1' > 'notahat-machinist', :lib => 'machinist', :version => '1.0.3' > "remarkable_rails", :lib => false > 'rspec', :lib => false, :version => '1.2.9' > 'rspec-rails', :lib => false, :version => '1.2.9' > 'jtrupiano-timecop', :lib => 'timecop', :version => '0.3.0' > 'webrat', :lib => false, :version => '0.5.1' > 'fakeweb', :lib => false, :version => '1.2.6' > > In my application, I have a Post model that is using Rubyist's AASM > gem. The aasm column is defined as 'state'. The other column of note > is 'published_at'; this is defined as a datetime. > > These are the settings for the state machine: > > aasm_column :state > aasm_initial_state :draft > aasm_state :draft > aasm_state :published, :enter => :set_published > aasm_event :publish do > transitions :to => :published, :from => :draft > end > > set_published is a method that is defined as: > > def set_published > self.update_attributes(:published_at => Time.now) > end > > For those that are unfamiliar with Rubyist's AASM, defining an > aasm_event gives you an bang instance method with the same name of the > aasm_event. For example, I have :publish defined as an aasm_event and > because of this I can call the publish! method on an instance of a > Post. This will change the state from 'draft' to 'published'. It will > also call the set_published method as defined by the :enter statement. > > This is my first spec attempt. I've removed all of the post attributes > for brevity. > > describe "AASM States" do > before(:each) do > @post = Post.create([snip...post attributes here]) > end > > it "should set the publish date to now when transitioning to published" do > lambda { @post.publish! }.should change(@post, > :published_at).from(nil).to(Time.now) > end > end > > This fails with a message like the following: > > published_at should have been changed to Sat Nov 07 15:02:00 -0800 > 2009, but is now Sat Nov 07 15:02:00 -0800 2009 > > *blink* *blink* > > They appear to be the same. > > Just in case the time was being altered by milliseconds that I > couldn't see, I tried using jtrupiano's Timecop gem to freeze time and > check against the frozen time. > > it "should set the publish date to now when transitioning to published" > do > time = Time.now > Timecop.freeze(time) > lambda { @post.publish! }.should change(@post, > :published_at).from(nil).to(time) > Timecop.return > end > > This still gives me the same failure message. For those unfamiliar > with Timecop, here is how it works (in the console): > > >> require 'Timecop' > => [] > >> time = Timecop.freeze(Time.now) > => Sat Nov 07 15:07:32 -0800 2009 > >> sleep(10) > => 10 > >> time == Time.now > => true > >> Timecop.return > => Sat Nov 07 15:08:09 -0800 2009 > >> time == Time.now > => false > > In development, I know that the published_at time is truly > transitioning from nil to an actual time, I just don't know why it's > failing in the spec and even stranger when RSpec tells me that they > are the (supposedly) the same. > > >From the development console: > > >> p = Post.new([snip...post attributes here]) > >> p.save > => true > >> p.published_at > => nil > >> p.publish! > => true > >> p.published_at > => Sat Nov 07 15:10:22 -0800 2009 > > Is there something that I'm missing? > > Thank you in advance for your help, > Hi Carlos, I would definitely assume that the times are off by milliseconds here and that the to_s method simply produces the same result on two different times. Not sure why it's still failing even when using Timecop, though. Perhaps somebody else has some ideas about that. HTH, David > > Carlos > _______________________________________________ > 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 Nov 7 21:25:33 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Nov 2009 21:25:33 -0500 Subject: [rspec-users] rake spec runs my spec:remote specs! In-Reply-To: <81301c17-3248-4821-8e5b-745a114628c2@t11g2000prh.googlegroups.com> References: <81301c17-3248-4821-8e5b-745a114628c2@t11g2000prh.googlegroups.com> Message-ID: <57c63afe0911071825s7a93ee78y803fdc147416b051@mail.gmail.com> On Fri, Nov 6, 2009 at 8:44 PM, jko170 wrote: > In my spec folder, I have a "remote" directory, which contains my > specs for live data transferring with an outside api. When I run rake > spec, it runs the remote specs and I don't want it to. Keep in mind > there is NO lib/tasks/remote.task file. I ONLY want these remote specs > to run when I execute rake spec:remote > The spec task is for running all specs under the ./spec directory. As things stand now, you'd have to either rewrite that task (found in lib/tasks/rspec.rake), find a way to override it (perhaps lib/task/rspec-overrides.rake would get loaded after rspec.rake, I'm not sure), or move those specs to a different directory. HTH, David > > How can I achieve this? > _______________________________________________ > 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 Nov 7 21:31:06 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 7 Nov 2009 21:31:06 -0500 Subject: [rspec-users] [rspec-devel] describe "RSpec's documentation" do In-Reply-To: <2566dc840911061427o53dc6294o5228045bf7cf8c5d@mail.gmail.com> References: <2566dc840911061427o53dc6294o5228045bf7cf8c5d@mail.gmail.com> Message-ID: <57c63afe0911071831v1b24d575n4b7371fbd8ed1f31@mail.gmail.com> On Fri, Nov 6, 2009 at 5:27 PM, Ryan Briones wrote: > This sounds pretty cool. Are there any ideas or examples of how features > would get turned into end user documentation? My first thought is something > RDoc like would go in the free-form user story area... I'd certainly like to > help as time permitted. I'd definitely like to be more informed of rspec > internals. > Yes, we should definitely beef up the narratives in each feature. Then we need to generate the output as HTML and, the tricky part, generate some wrapper HTML to make a site out of the different pages. As for internals, my goal for the Cucumber features is to provide an executable set of documentation for end users to understand how to use RSpec. Not so much to expose internals, which I think is better addressed in the RSpec code examples themselves. Make sense? > > On Fri, Nov 6, 2009 at 7:49 AM, David Chelimsky wrote: > >> Hi all, >> >> describe "RSpec's documentation" do >> it "should be helpful" >> it "should be maintainable" >> end >> >> I've been wanting to improve RSpec's documentation situation for a long >> time, but my writing energies have been consumed by rspec itself and The >> RSpec Book for a longer time, and will continue to do so for the foreseeable >> future. So I'm going to need some help. >> >> The problem to solve is that we have (at least) four sources of >> documentation, each of which moves at its own pace and has evolved in its >> meaning/place: >> >> 1. The RSpec code examples that ship with RSpec >> 2. The Cucumber features that ship with RSpec >> 3. The github wiki: http://wiki.github.com/dchelimsky/rspec >> 4. http://rspec.info >> >> The model that Aslak and the Cucumber community has used has worked very >> well because it's a community effort, but there is still some duplication >> between what's on the wiki [1] and the Cucumber features/scenarios that ship >> with Cucumber [2]. >> >> In the long run, what I'd like is the following: >> >> * Cucumber features that ship with RSpec become the authoritative end-user >> documentation. This is something that anybody can contribute to with >> patches, as it's all in files that ship with RSpec. I'd also like to use >> such an effort to push the envelope on Cucumber features as executable >> documentation. I think that with a little bit of work we could use the >> features to generate a website with meaningful organization/navigation. Is >> anybody already doing that? >> * RSpec code examples become a solid source of additional detailed >> documentation for those who want to either extend RSpec or debug problems. >> * http://rspec.info becomes a one pager like http://cukes.info >> * The github wiki becomes a community driven resource center with links to >> tutorials, blogs, matcher libraries, etc, etc >> >> I welcome suggestions, but I really need volunteers volunteers! I'm not >> going to be able to spend much personal time on this, so if there are any >> among you who are willing to coordinate with me and drive the effort, I'd >> love to hear from you. >> >> Cheers, >> David >> >> [1] http://wiki.github.com/aslakhellesoy/cucumber >> [2] http://github.com/aslakhellesoy/cucumber/tree/master/features/ >> >> >> _______________________________________________ >> rspec-devel mailing list >> rspec-devel at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-devel >> > > > > -- > Ryan Carmelo Briones > > _______________________________________________ > rspec-devel mailing list > rspec-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sfeley at gmail.com Sat Nov 7 23:39:34 2009 From: sfeley at gmail.com (Stephen Eley) Date: Sat, 7 Nov 2009 23:39:34 -0500 Subject: [rspec-users] [rspec-devel] describe "RSpec's documentation" do In-Reply-To: <57c63afe0911071831v1b24d575n4b7371fbd8ed1f31@mail.gmail.com> References: <2566dc840911061427o53dc6294o5228045bf7cf8c5d@mail.gmail.com> <57c63afe0911071831v1b24d575n4b7371fbd8ed1f31@mail.gmail.com> Message-ID: <1fb4df0911072039y788acfabv144358ac02bf1cec@mail.gmail.com> On Sat, Nov 7, 2009 at 9:31 PM, David Chelimsky wrote: > > As for internals, my goal for the Cucumber features is to provide an > executable set of documentation for end users to understand how to use > RSpec. Not so much to expose internals, which I think is better addressed in > the RSpec code examples themselves. Make sense? I'm sorry David; it might be because I haven't seen examples, but conceptually I don't think this quite gels. Some issues I have with the idea: 1.) It's trying to achieve too many goals at once. Application verification and documentation are not the same problem. If you try to do both with the exact same files, I believe both will suffer. 2.) It creates an unnecessary knowledge dependency. People who are brand new to RSpec cannot be expected to have proficiency with Cucumber just to read the docs. I understand that they don't *have* to execute the features, but if you don't know Cucumber at all, trying to wrap your head around the feature syntax will distract from the part that's important (understanding RSpec). 3.) The knowledge transfer would be inefficient, unclear, and incomplete. Too many concepts cannot be effectively communicated in a "Given/When/Then" structure. How do you explain the history and philosophy of BDD in that syntax? How do you explain the role of "red, green, refactor" patterns within iterative RSpec development? --Presuming you've figured out how to phrase that knowledge in a Cucumber feature, how do you *execute* it? And at that point what have you gained? Cucumber is great for many things. I don't believe it would be a great documentation tool at a "primer" level. If anyone can show that it can not only be done, but be done *well* in a way that will make inherent sense to newbies and speed up their learning of RSpec, I'd stand corrected and support this wholeheartedly. Otherwise, I'd suggest separating concerns, and not try to integrate and educate at the same time. ---Having said that, I'm interested in contributing to the (prose, not Cucumber) documentation effort. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From lbocseg at yahoo.com.br Sun Nov 8 05:39:31 2009 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Sun, 08 Nov 2009 08:39:31 -0200 Subject: [rspec-users] "lambda Should Change" Behavior Failing When Checking Time In-Reply-To: <57c63afe0911071816p5182477fua7e80741f5aff806@mail.gmail.com> References: <67b9f24a0911071518t61f665cdla6c376e838b27c7a@mail.gmail.com> <57c63afe0911071816p5182477fua7e80741f5aff806@mail.gmail.com> Message-ID: <4AF69FE3.2030304@yahoo.com.br> David Chelimsky escreveu: > On Sat, Nov 7, 2009 at 6:18 PM, Carlos Rodriguez > wrote: > > Hello, > > I'm having a problem with RSpec when using the "lambda should > change behavior". > > This is happening in a Rails 2.3.4 app and I'm running the following > in my test environment: > > 'cucumber', :version => '0.4.2' > 'faker', :version => '0.3.1' > 'notahat-machinist', :lib => 'machinist', :version => '1.0.3' > "remarkable_rails", :lib => false > 'rspec', :lib => false, :version => '1.2.9' > 'rspec-rails', :lib => false, :version => '1.2.9' > 'jtrupiano-timecop', :lib => 'timecop', :version => '0.3.0' > 'webrat', :lib => false, :version => '0.5.1' > 'fakeweb', :lib => false, :version => '1.2.6' > > In my application, I have a Post model that is using Rubyist's AASM > gem. The aasm column is defined as 'state'. The other column of note > is 'published_at'; this is defined as a datetime. > > These are the settings for the state machine: > > aasm_column :state > aasm_initial_state :draft > aasm_state :draft > aasm_state :published, :enter => :set_published > aasm_event :publish do > transitions :to => :published, :from => :draft > end > > set_published is a method that is defined as: > > def set_published > self.update_attributes(:published_at => Time.now) > end > > For those that are unfamiliar with Rubyist's AASM, defining an > aasm_event gives you an bang instance method with the same name of the > aasm_event. For example, I have :publish defined as an aasm_event and > because of this I can call the publish! method on an instance of a > Post. This will change the state from 'draft' to 'published'. It will > also call the set_published method as defined by the :enter statement. > > This is my first spec attempt. I've removed all of the post attributes > for brevity. > > describe "AASM States" do > before(:each) do > @post = Post.create([snip...post attributes here]) > end > > it "should set the publish date to now when transitioning to > published" do > lambda { @post.publish! }.should change(@post, > :published_at).from(nil).to(Time.now) > end > end > > This fails with a message like the following: > > published_at should have been changed to Sat Nov 07 15:02:00 -0800 > 2009, but is now Sat Nov 07 15:02:00 -0800 2009 > > *blink* *blink* > > They appear to be the same. > > Just in case the time was being altered by milliseconds that I > couldn't see, I tried using jtrupiano's Timecop gem to freeze time and > check against the frozen time. > > it "should set the publish date to now when transitioning to > published" do > time = Time.now > Timecop.freeze(time) > lambda { @post.publish! }.should change(@post, > :published_at).from(nil).to(time) > Timecop.return > end > > This still gives me the same failure message. For those unfamiliar > with Timecop, here is how it works (in the console): > > >> require 'Timecop' > => [] > >> time = Timecop.freeze(Time.now) > => Sat Nov 07 15:07:32 -0800 2009 > >> sleep(10) > => 10 > >> time == Time.now > => true > >> Timecop.return > => Sat Nov 07 15:08:09 -0800 2009 > >> time == Time.now > => false > > In development, I know that the published_at time is truly > transitioning from nil to an actual time, I just don't know why it's > failing in the spec and even stranger when RSpec tells me that they > are the (supposedly) the same. > > >From the development console: > > >> p = Post.new([snip...post attributes here]) > >> p.save > => true > >> p.published_at > => nil > >> p.publish! > => true > >> p.published_at > => Sat Nov 07 15:10:22 -0800 2009 > > Is there something that I'm missing? > > Thank you in advance for your help, > > > Hi Carlos, > > I would definitely assume that the times are off by milliseconds here > and that the to_s method simply produces the same result on two > different times. > > Not sure why it's still failing even when using Timecop, though. > Perhaps somebody else has some ideas about that. I believe Timecop doesn't help in this case. ActiveRecord will probably fill the time using SQL now() instead of Time.now. Anyway, I wouldn't bother to test if the time was changed to now. I think it suffices to test that time was changed from nil. If you really want to test that it changed to now, I would write something like: @post.published_at.should be_nil @post.publish! (Time.now - @post.published_at).should have_at_most(1).second Or you could write a new matcher if you need to check this often... But I think this is an already tested ActiveRecord behavior and that you should test only your code and rely on ActiveRecord to fill the corrected timestamp. Good luck, Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From lbocseg at yahoo.com.br Sun Nov 8 05:55:08 2009 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Sun, 08 Nov 2009 08:55:08 -0200 Subject: [rspec-users] [rspec-devel] describe "RSpec's documentation" do In-Reply-To: <57c63afe0911071831v1b24d575n4b7371fbd8ed1f31@mail.gmail.com> References: <2566dc840911061427o53dc6294o5228045bf7cf8c5d@mail.gmail.com> <57c63afe0911071831v1b24d575n4b7371fbd8ed1f31@mail.gmail.com> Message-ID: <4AF6A38C.50101@yahoo.com.br> David Chelimsky escreveu: > ... > > As for internals, my goal for the Cucumber features is to provide an > executable set of documentation for end users to understand how to use > RSpec. Not so much to expose internals, which I think is better > addressed in the RSpec code examples themselves. Make sense? Actually, I don't like very much the idea of hiding the internals. I've spent too much time trying to figure out what happens in the internals so that I could integrate Rspec with Webrat and I still don't understand a lot of things. For instance, why can I use 'visit' when I am testing an expected behavior, but cannot use 'redirected_to' while both belongs to Webrat::Session? I think it helps a lot understanding what is happening on the internals. Some topics that could be approached on documentation: - What happens on a describe/context/it/specify call? - What is the load order when running tests? (talking more deeply about spec_helper.rb) - How are database transactions dealt with in Rspec and the differences between before(:all) and before(:each) with respect to databases. - What is the class (how is it created?) that we are writing code on? How are the expectations/matchers injected on classes and which classes? I really think that knowing the internals would help a lot and save us many many time. The syntax of Rspec should be simple so that reading the specs should be natural, but it doesn't mean that we should abstract from what is happening in the internals... Well, that is my opinion. Regards, Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From dchelimsky at gmail.com Sun Nov 8 07:32:50 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Nov 2009 07:32:50 -0500 Subject: [rspec-users] [rspec-devel] describe "RSpec's documentation" do In-Reply-To: <1fb4df0911072039y788acfabv144358ac02bf1cec@mail.gmail.com> References: <2566dc840911061427o53dc6294o5228045bf7cf8c5d@mail.gmail.com> <57c63afe0911071831v1b24d575n4b7371fbd8ed1f31@mail.gmail.com> <1fb4df0911072039y788acfabv144358ac02bf1cec@mail.gmail.com> Message-ID: <57c63afe0911080432p2ea842f9udb433851d7614191@mail.gmail.com> On Sat, Nov 7, 2009 at 11:39 PM, Stephen Eley wrote: > On Sat, Nov 7, 2009 at 9:31 PM, David Chelimsky > wrote: > > > > As for internals, my goal for the Cucumber features is to provide an > > executable set of documentation for end users to understand how to use > > RSpec. Not so much to expose internals, which I think is better addressed > in > > the RSpec code examples themselves. Make sense? > > I'm sorry David; it might be because I haven't seen examples, but > conceptually I don't think this quite gels. Some issues I have with > the idea: > > 1.) It's trying to achieve too many goals at once. Application > verification and documentation are not the same problem. If you try > to do both with the exact same files, I believe both will suffer. > Executable documentation is what I'm after. If Cucumber is not giving that to us now, then I'd like to use this opportunity to push in that direction. The whole point is to bind the documentation to the code so that as the code evolves, the documentation is less likely to stray from it. > > 2.) It creates an unnecessary knowledge dependency. People who are > brand new to RSpec cannot be expected to have proficiency with > Cucumber just to read the docs. I understand that they don't *have* > to execute the features, but if you don't know Cucumber at all, trying > to wrap your head around the feature syntax will distract from the > part that's important (understanding RSpec). > Have you looked at http://github.com/dchelimsky/rspec/blob/master/features/before_and_after_blocks/before_and_after_blocks.feature, for example? I don't think Given/When/Then are going to confuse anybody in this case. > > 3.) The knowledge transfer would be inefficient, unclear, and > incomplete. Too many concepts cannot be effectively communicated in a > "Given/When/Then" structure. How do you explain the history and > philosophy of BDD in that syntax? How do you explain the role of > "red, green, refactor" patterns within iterative RSpec development? > --Presuming you've figured out how to phrase that knowledge in a > Cucumber feature, how do you *execute* it? And at that point what > have you gained? > That's what the narrative area is for, in part. And where that is inappropriate, we should have a way to build a website that integrates cucumber pages with plain HTML pages. Something like webby with a plugin for running the .feature files and storing the output as HTML pages. The examples of what the code looks like should be executable. > Cucumber is great for many things. I don't believe it would be a > great documentation tool at a "primer" level. If anyone can show that > it can not only be done, but be done *well* in a way that will make > inherent sense to newbies and speed up their learning of RSpec, I'd > stand corrected and support this wholeheartedly. Otherwise, I'd > suggest separating concerns, and not try to integrate and educate at > the same time. > > ---Having said that, I'm interested in contributing to the (prose, not > Cucumber) documentation effort. > Great. My goal is to have an integrated result, but that doesn't mean that people can't contribute to prose separately from scenarios. -- > Have Fun, > I usually do :) Cheers, David > Steve Eley (sfeley at gmail.com) > ESCAPE POD - The Science Fiction Podcast Magazine > http://www.escapepod.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From conradwt at gmail.com Sun Nov 8 02:35:53 2009 From: conradwt at gmail.com (Conrad Taylor) Date: Sat, 7 Nov 2009 23:35:53 -0800 (PST) Subject: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9 In-Reply-To: <57c63afe0911041428s4dae12caj171d5bf56982df11@mail.gmail.com> References: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> <57c63afe0911041428s4dae12caj171d5bf56982df11@mail.gmail.com> Message-ID: <906e5e28-5243-432f-99a7-5033f359bbe0@h14g2000pri.googlegroups.com> David, I'm still seeing the issue. Thus, here's a transcript of my activity: http://pastie.org/688639 -Conrad On Nov 4, 2:28?pm, David Chelimsky wrote: > On Tue, Nov 3, 2009 at 7:25 AM, Conrad Taylor wrote: > > Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. > > Hi Conrad, > > If this was a problem in the gem, it is now fixed: > > $ rvm 1.9.1 > $ which ruby > /Users/david/.rvm/ruby-1.9.1-p243/bin/ruby > $ rake spec > ... > 1522 examples, 0 failures, 2 pending > > Cheers, > David > > > > > I'm > > getting the following error message when I run the specs: > > > /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ > > option_parser_spec.rb:21:in `block (2 levels) in ': > > wrong number of arguments (0 for 1) (ArgumentError) > > > After analyzing the error message, it appears that "use_fakefs" method > > on lines 21 and 522 of the > > > option_parser_spec.rb > > > should take an argument. > > > -Conrad > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://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 Sun Nov 8 07:39:02 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Nov 2009 07:39:02 -0500 Subject: [rspec-users] [rspec-devel] describe "RSpec's documentation" do In-Reply-To: <4AF6A38C.50101@yahoo.com.br> References: <2566dc840911061427o53dc6294o5228045bf7cf8c5d@mail.gmail.com> <57c63afe0911071831v1b24d575n4b7371fbd8ed1f31@mail.gmail.com> <4AF6A38C.50101@yahoo.com.br> Message-ID: <57c63afe0911080439n6037dbe9r2929e3159fad8410@mail.gmail.com> On Sun, Nov 8, 2009 at 5:55 AM, Rodrigo Rosenfeld Rosas < lbocseg at yahoo.com.br> wrote: > David Chelimsky escreveu: > >> >> As for internals, my goal for the Cucumber features is to provide an >> executable set of documentation for end users to understand how to use >> RSpec. Not so much to expose internals, which I think is better addressed in >> the RSpec code examples themselves. Make sense? >> > > Actually, I don't like very much the idea of hiding the internals. I'm not saying hide them. I'm saying document them in a different way. > I've spent too much time trying to figure out what happens in the internals > so that I could integrate Rspec with Webrat and I still don't understand a > lot of things. > > For instance, why can I use 'visit' when I am testing an expected behavior, > but cannot use 'redirected_to' while both belongs to Webrat::Session? > > I think it helps a lot understanding what is happening on the internals. > Some topics that could be approached on documentation: > > - What happens on a describe/context/it/specify call? > - What is the load order when running tests? (talking more deeply about > spec_helper.rb) > - How are database transactions dealt with in Rspec and the differences > between before(:all) and before(:each) with respect to databases. > - What is the class (how is it created?) that we are writing code on? How > are the expectations/matchers injected on classes and which classes? > > I really think that knowing the internals would help a lot and save us many > many time. > > The syntax of Rspec should be simple so that reading the specs should be > natural, but it doesn't mean that we should abstract from what is happening > in the internals... > Separate, not abstract. > Well, that is my opinion. Thanks for sharing it. I think we can work towards this goal as well, but I'd like to push this one further back as plan to make significant changes to internals in the next major version of rspec. We'll roll that out gradually (with alpha, beta, and candidate releases), but any time spent on a big document-the-internals effort before then would be a waste. Cheers, David > Regards, > > Rodrigo. > > __________________________________________________ > Fa?a liga??es para outros computadores com o novo Yahoo! Messenger > http://br.beta.messenger.yahoo.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 ashley.moran at patchspace.co.uk Sun Nov 8 09:28:19 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sun, 8 Nov 2009 14:28:19 +0000 Subject: [rspec-users] "lambda Should Change" Behavior Failing When Checking Time In-Reply-To: <4AF69FE3.2030304@yahoo.com.br> References: <67b9f24a0911071518t61f665cdla6c376e838b27c7a@mail.gmail.com> <57c63afe0911071816p5182477fua7e80741f5aff806@mail.gmail.com> <4AF69FE3.2030304@yahoo.com.br> Message-ID: <4DBE05A1-0146-46F0-819A-AE5FBFAD629C@patchspace.co.uk> On Nov 08, 2009, at 10:39 am, Rodrigo Rosenfeld Rosas wrote: > @post.published_at.should be_nil > @post.publish! > (Time.now - @post.published_at).should have_at_most(1).second FWIW, this is what I do too, although I normally use "should <" or "be_close", but the idea is the same. You only need to worry about more accuracy than that if it's time-critical. Also, I've found meddling with Time breaks RSpec's timing - don't know if that's still the case. For times when I really care about timing, I've made a Clock class, and have everything use that, instead of Time directly. Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran From dchelimsky at gmail.com Sun Nov 8 10:30:04 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 8 Nov 2009 10:30:04 -0500 Subject: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9 In-Reply-To: <906e5e28-5243-432f-99a7-5033f359bbe0@h14g2000pri.googlegroups.com> References: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> <57c63afe0911041428s4dae12caj171d5bf56982df11@mail.gmail.com> <906e5e28-5243-432f-99a7-5033f359bbe0@h14g2000pri.googlegroups.com> Message-ID: <57c63afe0911080730j19983a93v869c61f221b814ed@mail.gmail.com> On Sun, Nov 8, 2009 at 2:35 AM, Conrad Taylor wrote: > David, I'm still seeing the issue. Thus, here's a transcript of my > activity: > > http://pastie.org/688639 $ gem which fakefs (checking gem bmabey-fakefs-0.1.1.1 for fakefs) /Users/david/.rvm/gems/ruby/1.9.1/gems/bmabey-fakefs-0.1.1.1/lib/fakefs.rb What version of fakefs are you using? > > > -Conrad > > On Nov 4, 2:28 pm, David Chelimsky wrote: > > On Tue, Nov 3, 2009 at 7:25 AM, Conrad Taylor > wrote: > > > Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. > > > > Hi Conrad, > > > > If this was a problem in the gem, it is now fixed: > > > > $ rvm 1.9.1 > > $ which ruby > > /Users/david/.rvm/ruby-1.9.1-p243/bin/ruby > > $ rake spec > > ... > > 1522 examples, 0 failures, 2 pending > > > > Cheers, > > David > > > > > > > > > I'm > > > getting the following error message when I run the specs: > > > > > /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ > > > option_parser_spec.rb:21:in `block (2 levels) in ': > > > wrong number of arguments (0 for 1) (ArgumentError) > > > > > After analyzing the error message, it appears that "use_fakefs" method > > > on lines 21 and 522 of the > > > > > option_parser_spec.rb > > > > > should take an argument. > > > > > -Conrad > > > > > _______________________________________________ > > > rspec-users mailing list > > > rspec-us... at rubyforge.org > > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlos at eddorre.com Sun Nov 8 13:10:28 2009 From: carlos at eddorre.com (Carlos Rodriguez) Date: Sun, 8 Nov 2009 10:10:28 -0800 Subject: [rspec-users] "lambda Should Change" Behavior Failing When Checking Time Message-ID: <67b9f24a0911081010l6766d9d6n82ed68d951143ea8@mail.gmail.com> Thanks to everyone that responded to my question. Here is what I ended up doing to make the spec pass: time_now = Time.now Time.stub!(:now).and_return(time_now) lambda { @post.publish! }.should change(@post, :published_at).from(nil).to(time_now) Carlos From lbocseg at yahoo.com.br Sun Nov 8 20:40:55 2009 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Sun, 08 Nov 2009 23:40:55 -0200 Subject: [rspec-users] "lambda Should Change" Behavior Failing When Checking Time In-Reply-To: <67b9f24a0911081010l6766d9d6n82ed68d951143ea8@mail.gmail.com> References: <67b9f24a0911081010l6766d9d6n82ed68d951143ea8@mail.gmail.com> Message-ID: <4AF77327.1090402@yahoo.com.br> Carlos Rodriguez escreveu: > Thanks to everyone that responded to my question. > > Here is what I ended up doing to make the spec pass: > > time_now = Time.now > Time.stub!(:now).and_return(time_now) > lambda { @post.publish! }.should change(@post, > :published_at).from(nil).to(time_now) > I have thought on this approach after I realized that ActiveRecord would not probably populate this field using SQL since it doesn't know per itself about published_at attribute and I realized that you probably used something like "published_at = Time.now" on an after_save or before_save hook. I would suggest you this approach but then, in the middle of the message I realized it wouldn't be a good idea to mock the Time class, since it wouldn't test what you want, I thought... Unless you really care if the implementation uses Time.now to fill the published_at field (instead of a SQL now(), or some trigger...), the other alternative would be less dependent on implementation... And looking at the complete solution, I really don't think it is clearer or more compact to read :) But I guess you were intrigued on how to do that :) It happens to me sometimes... Today, I've spent the morning reading Rspec and Webrat internals just to figure out that the error I was getting was really a silly mistake (I was using assert_not_contain before requesting a URL). Sometimes, things just bother us because we actually want to know how something works... I was really intrigued about what describe/context/it did from behind the scenes. And even more intrigued in trying to understand how webrat integration works. Every time I had a problem, I blessed the fact that I didn't understand the internals, but, although knowing the internals better helps to solve all sort of confusion, the problem usually is something simpler :) But, at least, it is good when we solve all the mystery, right? :) Good night, Rodrigo. __________________________________________________ Fa?a liga??es para outros computadores com o novo Yahoo! Messenger http://br.beta.messenger.yahoo.com/ From lists at ruby-forum.com Mon Nov 9 06:13:46 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Mon, 9 Nov 2009 12:13:46 +0100 Subject: [rspec-users] Display Rspec output in an html file Message-ID: Hello, I had written some model scenarios. Now i want to generate that output in an html file. i am executing the models using rake i.e. rake spec:models from spec directory. But the html file is not getting generated. Following is the error trace: ** Invoke spec:models (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:abort_if_pending_migrations ** Execute db:test:prepare ** Invoke db:test:load (first_time) ** Invoke db:test:purge (first_time) ** Invoke environment ** Execute db:test:purge ** Execute db:test:load ** Invoke db:schema:load (first_time) ** Invoke environment ** Execute db:schema:load ** Execute spec:models ./spec/models/forum_spec.rb:43: warning: don't put space before argument parentheses ./spec/models/forum_spec.rb:50: warning: don't put space before argument parentheses #Desc

", idiom_id: nil, permalink: "forum2"> # rake aborted! Command /usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib" "/usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/bin/spec" "spec/models/forum_spec.rb" "spec/models/attachment_spec.rb" "spec/models/channel_detail_spec.rb" "spec/models/whatwewant_spec.rb" "spec/models/channel_spec.rb" "spec/models/question_spec.rb" "spec/models/rating_spec.rb" "spec/models/topic_spec.rb" "spec/models/channel_feature_spec.rb" "spec/models/idea_spec.rb" "spec/models/user_channel_spec.rb" "spec/models/promotion_spec.rb" "spec/models/product_spec.rb" "spec/models/poll_spec.rb" "spec/models/bb_post_spec.rb" "spec/models/channel_category_spec.rb" "spec/models/survey_spec.rb" --format html:result.html failed /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/rake/spectask.rb:174:in `define' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1112:in `verbose' /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/rake/spectask.rb:150:in `define' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain' /usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/local/bin/rake:19:in `load' /usr/local/bin/rake:19 I had tried various options: 1:Under lib/tasks/rspec file i had added a line "t.spec_opts = ['--format' , 'html:result.html' ]" under the [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub| desc "Run the code examples in spec/#{sub}" Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] t.spec_opts = ['--format' , 'html:result.html' ] end end but when i run the rake command above error is generated. 2:I also tried updating spec.opts file by adding --format html:spec/a.html. After adding this code i ran the spec using rake spec:models RAILS_ENV=test but what i think that if we add something in spec.opts then running command for models is different. Please suggest how to display output in html using rake command rake spec:models -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Mon Nov 9 06:15:22 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Mon, 9 Nov 2009 12:15:22 +0100 Subject: [rspec-users] Display Rspec output in an html file In-Reply-To: References: Message-ID: My spec.opts file contains --colour --format html:spec/a.html --loadby mtime --reverse -- Posted via http://www.ruby-forum.com/. From voodoorai2000 at gmail.com Mon Nov 9 07:05:32 2009 From: voodoorai2000 at gmail.com (Raimond Garcia) Date: Mon, 9 Nov 2009 04:05:32 -0800 (PST) Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: <88fd8ddc0911071655t5924c7c5m30d1bfb045f61b36@mail.gmail.com> References: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> <1fb4df0911040829m759a8e9j63ab8c0d474836cd@mail.gmail.com> <88fd8ddc0911041224t26532daeweffa200766b25c34@mail.gmail.com> <1fb4df0911041236k2038c08epa39a84f47978ccc1@mail.gmail.com> <57c63afe0911041730u6ce13bf3x1b29d1287e0e4c96@mail.gmail.com> <43022205-a160-4008-9a82-f9d65877942b@i12g2000prg.googlegroups.com> <88fd8ddc0911071655t5924c7c5m30d1bfb045f61b36@mail.gmail.com> Message-ID: <5087b52a-aa26-4930-8b67-ee10537bf914@b15g2000yqd.googlegroups.com> IMHO steps can test everything that view specs can test, but in a much faster and will less effort. You don't have to build a huge feature to test a complex view, you can just split it into different scenarios. In the profile example of a social site, you could have a scenario for friend, one for personal info, one for messages in your wall etc, etc. All nice and clear for developers, designers and business man. Regarding the detail of features, I think if that if someone in the business does not get involved enough to look at the features and agree on them, them before starting with the implementation then we don't have a commitment. If the president of the company is too busy, someone else should be in charge of agreeing on the stories. We are not talking about implementation details, we are talking about the behavior of the application. That said, I think there is a missing interface in features, where one should be able to reduce detail or show it. Just like nesting steps but not in step files, instead they should be in the feature file. For example: When I fill in the form correctly Every nested step should be visible in the feature file, or hidden depending on what the person reading the feature is most interested in seeing. Footers and other layout checks, I simply test them in the main page, I think that covers the requirement that they will be seen in all pages. Zack, you example: Then I see the top 3 scorers in the leaderboard are: | 1 | Bob | | 2 | Mary | | 3 | Fred | Is a very good one. See the beauty of steps, is that you don't have to write a single line of ruby to test this. You can just reuse steps. For that we would have to re-write this step to be more reusable, something like this: Scenario: Top Scores Given the following users: | name | score | On Nov 8, 1:55?am, Andrew Premdas wrote: > 2009/11/5 Chuck van der Linden > > > > > > > On Nov 4, 5:30 pm, David Chelimsky wrote: > > > On Wed, Nov 4, 2009 at 3:36 PM, Stephen Eley wrote: > > > > On Wed, Nov 4, 2009 at 3:24 PM, Andrew Premdas > > wrote: > > > > > > Personally I now think nested steps are evil - but thats another > > story :) > > > > > It sounds like an entertaining one. ?I'd love to hear why sometime. > > > > (Though whether the right place for it would be here or the Cucumber > > > > list, I couldn't say.) > > > > I'll pipe in since it's here on this list at the moment: > > > > I won't go as far as to say that nested steps are evil, but I don't > > really > > > like to use them myself because they do conflate two levels of > > abstraction. > > > I'd sooner have two steps delegate to a helper than one step delegate to > > > another. > > > > FWIW, > > > David > > > I'll chime in also as to why I really dislike burying details like > > that in the steps file. ?Nobody but dev plays around with the lower > > layers and the step files in particular. ?Potentially everyone in the > > business may have a hand in the 'feature' definition, or maybe need to > > see or modify it at a later time. ?Also a Dev or tester reviewing > > things to see 'how should it work' gets everything high level in one > > place (the feature file) instead of having to chase down into multple > > levels of step files ( an exercise reminding one of why we hate > > spaghetti code) to find the details that matter up at the UI or > > potentially integration test level. > > > Remember Rspec/Cucumber are all about implementing BDD.. ?Part of BDD > > is that more than just the folks in Dev will be looking at what's done > > at the 'feature' level. ? If you bury the details of something inside > > the step file, then nobody outside of dev can play along, and that > > defeats a large part of the purpose of BDD. > > > If it is important to the business that a particular field be on that > > page, then you ought to have it expressed in the feature and not > > buried in the steps. ? Consider something like > > > 'Scenario: User reviews their profile details' > > Given I am logged in as: > > When I click the link: view profile > > Then I should see my profile details. > > > How much more value to the business (and clarity to those implementing > > the feature) is created if we were to instead have something more > > like: > > > .... > > Then I will be on the page: User Profile > > and I will see identified as containing > > > > and I will see identified as containing > > > > ?etc > > > The <> items could either of course be spelled out, or they could be > > parameters in a scenario outline's examples section. > > > --Chuck > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > Couldn't agree less :-) , although alot of that depends on the business. > There are many problems with the sort of scenarios you prefer > > 1) They are very fragile - change a label and it breaks. A business will > review the application not the feature. When I change the label who fixes > the feature, and why should I have to run 30 minutes of features to change > one label! > > 2) You have to get detail correct before you know the context. As a business > person how do I know what details should be in the user profile. > > 3) It places the responsibility for trivial and obvious decisions with the > business people. And makes them make these decisions before they are ready. > Its much easier to decide what should be on the profile page when you can > see it and navigate to it. And as a business it is cheaper and far more > effective to trust your development team rather than micro-manage them to > the nth degree. > > 4) With an application of any size the amount of detail these type of > scenarios generates soon removes and chance of the business actually reading > or reviewing the features. Any chance of getting an overview of what the > application does, or even readable reports of what works and what doesn't is > lost. > > Dev's and testers are perfectly capable of looking at step definitions and > working with them. Business people (at least the ones I know and have > experienced) are much better at telling you want they want by providing > feedback from the application itself than by doing any sort of up front > work. One of the elegant parts of BDD is that by writing simple succinct > features business can get you quickly into a feedback loop. It is much > easier to create > > Feature > As a user > I want to have a profile > So I can stop you spamming me > > Scenario > When I view my profile > I should be able to stop you spamming me > > and start iterating around that, than to create some big feature that > specifies different labels for mailings and whether to use radio button or > checkboxes. It is also much easier for the business to come back to a 5 line > profile feature, and review this by looking at the application, than to > review a 200 line profile feature. This is an Agile process we're supposed > to be working with after all. > > All best > > Andrew > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Mon Nov 9 16:03:28 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 9 Nov 2009 21:03:28 +0000 Subject: [rspec-users] [BDD] View specs and cucumber -- duplication of effort? In-Reply-To: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> References: <88fd8ddc0911040756p3aabd256meab24b137e2d7822@mail.gmail.com> Message-ID: <3850499D-C9BC-4403-BFDF-E82F2355DD1A@mattwynne.net> On 4 Nov 2009, at 15:56, Andrew Premdas wrote: > 2009/10/29 nruth > Hi Guys > > I'm going to put the cat amongst the pigeons here in the hope of some > clarity falling out of the sky on me. > My question is this: In a world with Cucumber what is the value of > view specs? > > In the community (railscamp, for example) there are a fair number of > people using Cucumber and skipping view specs, but still speccing > controllers, models, tricky view helpers and so on. > > Why? Because they don't find them helpful. Indeed they are seen as a > waste of time (money) not only duplicating Cucumber coverage, but also > introducing a high-maintenance example group which designers (who > don't run tests) will frequently break. > > These people aren't stupid. They're producing working apps. I don't > claim that their work cycle is perfect: this is about utility and > efficiency, or about being lazy or avoiding boredom, if you prefer. > > I've been working in a mixed environment, with an existing project > which uses rspec and cucumber (sans view specs) and my own green field > app for a different client. > I've been following the BDD approach prescribed by the RSpec book (or > so I think). This works, and has produced a lot of LOC. > > I've not worried, as it has given me plenty of practice with the > various arms of rspec, webrat, and other tools. > Now that I'm more comfortable with them things are starting to get > tiresome, especially duplication, and I'm worried I'm creating a > monolith. Too many specs => TLDR ? > > What should I try using view specs for? Why are they better than > cucumber for this? > > "Driving views through examples helps us think about what the view > needs in order for it to do its job. It encourages us to write the > code we wish we had to fulfil those needs." > > I'm not sure how this is any different to what I do in the outer > circle with Cucumber. If I write an explicit scenario like > http://gist.github.com/221004 then I already know what the view needs > to let me do. > > If I write something more broad-brush (which you will do, if quickly > sketching out features during a design meeting) like "When I add a > page link" I have to then define that step so it goes red (or, heaven > forbid, green). But to write that step definition I have to know how I > can interact with the page. This example actually comes from a broad- > brush step being expanded in the scenario itself rather than hiding it > away in a step definition, but that's a different subject. > > I'm specifying the page's behaviour in the scenario, or in the step > definition. Why duplicate this process with a view spec? > > I keep coming back to the introduction of chapter 23 in the RSpec book > but don't seem to be getting anywhere from it. > > For the time being I'm going to keep writing view specs, but try to > make them lighter and cut some of the dead wood by describing unusual > or interesting behaviour rather than all behaviour. > > I'd love to hear your thoughts. > > Regards > > Nick > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > Currently I don't do view specs, but I'm beginning to see a use for > them. This is all to do with a recent change change in my thinking > about features. In addition to all the other things features do, I > am now seeing them as a map to what the "business" wants from the > application. This map works best if it is clear and simple (a bit > like the London tube map). Putting lots of view details in the > features (and I should see a wibble field etc. ...) pollutes this > map with clutter that is not relevant to the "business" context. So > view specs seem like a really good place to spec all this detail. > > Another benefit of this is that the view specs might end up as > another map that is useful to designers and front end developers. > > I've been thinking about features, specs and even code as maps > recently. It provides a really good explanation of why names and > description are so important. > > Andrew I've been pretty vocal on here about my dislike for view specs, but here's another strength they do have: they force you to think about the of the *interface* between the view and the rest of the app. When you're building a page that's rich in content[1] it becomes important to have a bright line drawn between the presentation code and the rest. A lot of the view specs we wrote in the early days at Songkick, frankly, sucked in this regard - they didn't listen to the tests and just mocked away like crazy across really broad interfaces, walking model associations and allsorts. These are the brittle tests I took pleasure in deleting each time we replaced them with a broad-brush cuke. What we missed of course was the design guidance we could have had all along if only we'd listened to the tests... [1]http://www.songkick.com/artists/395944-radiohead cheers, Matt http://mattwynne.net +447974 430184 From matt at mattwynne.net Mon Nov 9 16:46:30 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 9 Nov 2009 21:46:30 +0000 Subject: [rspec-users] Display Rspec output in an html file In-Reply-To: References: Message-ID: On 9 Nov 2009, at 11:13, Amit Kulkarni wrote: > Hello, > I had written some model scenarios. > Now i want to generate that output in an html file. > i am executing the models using rake i.e. rake spec:models from spec > directory. > But the html file is not getting generated. > > Following is the error trace: > ** Invoke spec:models (first_time) > ** Invoke db:test:prepare (first_time) > ** Invoke db:abort_if_pending_migrations (first_time) > ** Invoke environment (first_time) > ** Execute environment > ** Execute db:abort_if_pending_migrations > ** Execute db:test:prepare > ** Invoke db:test:load (first_time) > ** Invoke db:test:purge (first_time) > ** Invoke environment > ** Execute db:test:purge > ** Execute db:test:load > ** Invoke db:schema:load (first_time) > ** Invoke environment > ** Execute db:schema:load > ** Execute spec:models > ./spec/models/forum_spec.rb:43: warning: don't put space before > argument > parentheses > ./spec/models/forum_spec.rb:50: warning: don't put space before > argument > parentheses > # posts_count: 0, position: nil, description_html: "

Desc

", > idiom_id: nil, permalink: "forum2"> > # created_at: nil, updated_at: nil> > rake aborted! > Command /usr/local/bin/ruby > -I"/usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib" > "/usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/bin/spec" > "spec/models/forum_spec.rb" "spec/models/attachment_spec.rb" > "spec/models/channel_detail_spec.rb" "spec/models/whatwewant_spec.rb" > "spec/models/channel_spec.rb" "spec/models/question_spec.rb" > "spec/models/rating_spec.rb" "spec/models/topic_spec.rb" > "spec/models/channel_feature_spec.rb" "spec/models/idea_spec.rb" > "spec/models/user_channel_spec.rb" "spec/models/promotion_spec.rb" > "spec/models/product_spec.rb" "spec/models/poll_spec.rb" > "spec/models/bb_post_spec.rb" "spec/models/channel_category_spec.rb" > "spec/models/survey_spec.rb" --format html:result.html failed > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/rake/ > spectask.rb:174:in > `define' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1112:in > `verbose' > /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/rake/ > spectask.rb:150:in > `define' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in > `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in > `execute' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in > `invoke_with_call_chain' > /usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in > `invoke_with_call_chain' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in > `invoke' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in > `invoke_task' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in > `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in > `each' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in > `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in > `top_level' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in > `standard_exception_handling' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run' > /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 > /usr/local/bin/rake:19:in `load' > /usr/local/bin/rake:19 > > I had tried various options: > 1:Under lib/tasks/rspec file i had added a line > "t.spec_opts = ['--format' , 'html:result.html' ]" under the > > [:models, :controllers, :views, :helpers, :lib, :integration].each do > |sub| > desc "Run the code examples in spec/#{sub}" > Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] > t.spec_opts = ['--format' , 'html:result.html' ] > end > end > but when i run the rake command above error is generated. > > 2:I also tried updating spec.opts file by adding --format > html:spec/a.html. > After adding this code i ran the spec using rake spec:models > RAILS_ENV=test but what i think that if we add something in spec.opts > then running command for models is different. > > Please suggest how to display output in html using rake command rake > spec:models > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Do you get an error message? I don't see one here. cheers, Matt http://mattwynne.net +447974 430184 From matt at mattwynne.net Mon Nov 9 17:03:18 2009 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 9 Nov 2009 22:03:18 +0000 Subject: [rspec-users] describe "RSpec's documentation" do In-Reply-To: References: Message-ID: <98A6AC6B-BECC-4564-AF04-C49429AC7C75@mattwynne.net> On 6 Nov 2009, at 12:49, David Chelimsky wrote: > In the long run, what I'd like is the following: > > * Cucumber features that ship with RSpec become the authoritative > end-user documentation. This is something that anybody can > contribute to with patches, as it's all in files that ship with > RSpec. I'd also like to use such an effort to push the envelope on > Cucumber features as executable documentation. I think that with a > little bit of work we could use the features to generate a website > with meaningful organization/navigation. Is anybody already doing > that? +1 I had a little epiphany working on the wire protocol feature for cucumber[3]. We were trying to design the protocol via email and lighthouse ticket discussion, started using a wiki to document the desired protocol when I realised - why don't we just use the features!? I would like to see more people pushing Cucumber in this direction, and I think it would be interesting to consider adding mark- up to comments to allow us to build RDoc-style websites from a features folder. > * RSpec code examples become a solid source of additional detailed > documentation for those who want to either extend RSpec or debug > problems. > * http://rspec.info becomes a one pager like http://cukes.info > * The github wiki becomes a community driven resource center with > links to tutorials, blogs, matcher libraries, etc, etc > > I welcome suggestions, but I really need volunteers volunteers! I'm > not going to be able to spend much personal time on this, so if > there are any among you who are willing to coordinate with me and > drive the effort, I'd love to hear from you. > > Cheers, > David > > [1] http://wiki.github.com/aslakhellesoy/cucumber > [2] http://github.com/aslakhellesoy/cucumber/tree/master/features/ [3]http://github.com/aslakhellesoy/cucumber/blob/master/features/wire_protocol.feature I'm well behind this effort and would like to offer my help on the Cucumber end to make it possible to use the features to generate the user documentation - I think this would make a terrific use case for us to support. cheers, Matt http://mattwynne.net +447974 430184 From lists at ruby-forum.com Tue Nov 10 01:46:30 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Tue, 10 Nov 2009 07:46:30 +0100 Subject: [rspec-users] Display Rspec output in an html file In-Reply-To: References: Message-ID: <6bb97fe564ebbb30e16ad7e753473ca0@ruby-forum.com> Yes i get an error message as rake aborted. spec/models/survey_spec.rb" --format html:result.html failed -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Tue Nov 10 01:59:11 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 10 Nov 2009 06:59:11 +0000 Subject: [rspec-users] Display Rspec output in an html file In-Reply-To: <6bb97fe564ebbb30e16ad7e753473ca0@ruby-forum.com> References: <6bb97fe564ebbb30e16ad7e753473ca0@ruby-forum.com> Message-ID: <6E9E130A-B144-4AAC-9EEF-CA69E189D553@mattwynne.net> On 10 Nov 2009, at 06:46, Amit Kulkarni wrote: > > Yes i get an error message as rake aborted. > spec/models/survey_spec.rb" --format html:result.html failed Have you looked in the survey_spec.rb file to see if there's a problem then? Does the 'error message' give you a line number to look at? cheers, Matt http://mattwynne.net +447974 430184 From lists at ruby-forum.com Tue Nov 10 07:24:44 2009 From: lists at ruby-forum.com (Alexander Seidl) Date: Tue, 10 Nov 2009 13:24:44 +0100 Subject: [rspec-users] This test should pass, but it does not :-/ Why? Message-ID: <250491b5d2786aed32e00d0ecf27a2ba@ruby-forum.com> http://gist.github.com/230814 -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Nov 10 07:30:18 2009 From: lists at ruby-forum.com (Alexander Seidl) Date: Tue, 10 Nov 2009 13:30:18 +0100 Subject: [rspec-users] This test should pass, but it does not :-/ Why? In-Reply-To: <250491b5d2786aed32e00d0ecf27a2ba@ruby-forum.com> References: <250491b5d2786aed32e00d0ecf27a2ba@ruby-forum.com> Message-ID: <7f58a2338ea4657d340261321edde211@ruby-forum.com> Alexander Seidl wrote: > http://gist.github.com/230814 I should give some keywords here: I set an expectation in the test that a redirect_to should take place if a certain condition is made: @login_user.categories.size <= 0. But the test fails and says: "expected redirect to {:action=>"index"}, got no redirect" -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Nov 10 07:34:12 2009 From: lists at ruby-forum.com (Alexander Seidl) Date: Tue, 10 Nov 2009 13:34:12 +0100 Subject: [rspec-users] This test should pass, but it does not :-/ Why? In-Reply-To: <7f58a2338ea4657d340261321edde211@ruby-forum.com> References: <250491b5d2786aed32e00d0ecf27a2ba@ruby-forum.com> <7f58a2338ea4657d340261321edde211@ruby-forum.com> Message-ID: <3965484b392a26d4a5f3f85dadd17e3f@ruby-forum.com> Alexander Seidl wrote: > Alexander Seidl wrote: >> http://gist.github.com/230814 > > I should give some keywords here: > I set an expectation in the test that a redirect_to should take place if > a certain condition is made: @login_user.categories.size <= 0. > But the test fails and says: "expected redirect to {:action=>"index"}, > got no redirect" argh, i know whats missing: get :assign *g* -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Nov 10 07:37:44 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Tue, 10 Nov 2009 13:37:44 +0100 Subject: [rspec-users] Display Rspec output in an html file In-Reply-To: <6E9E130A-B144-4AAC-9EEF-CA69E189D553@mattwynne.net> References: <6bb97fe564ebbb30e16ad7e753473ca0@ruby-forum.com> <6E9E130A-B144-4AAC-9EEF-CA69E189D553@mattwynne.net> Message-ID: I checked the whole code but there is no error as such. What i have done is i added a line i.e. t.spec_opts = ['--format' , 'html:result.html' ] under /lib/tasks/rspec.rake i.e. [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub| desc "Run the code examples in spec/#{sub}" Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] t.spec_opts = ['--format' , 'html:result.html' ] end end After adding i am running the rake tasks as rake spec:models RAILS_ENV=test But it is giving me error as posted above. Also is there is any other way to print output in an html file bu using above rake command? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Nov 10 07:44:27 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Tue, 10 Nov 2009 13:44:27 +0100 Subject: [rspec-users] undefined method `route_for Message-ID: Hi all, I am writing scenarios for testing my routes but it is giving me error as undefined method `route_for and also for params_from. Did i miss something which i need to add in my controller My code is as follows: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HomeController, "routes" do describe "route generation" do it "should map { :controller => 'home', :action => 'index' } to /home" do route_for(:controller => 'home', :action => 'index').should == '/home' end it "should map { :controller => 'home' } RESTfully" do params_from( :get, '/home' ).should == { :controller => 'home', :action => 'index' } end end end -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Nov 10 09:08:35 2009 From: lists at ruby-forum.com (Saverio Miroddi) Date: Tue, 10 Nov 2009 15:08:35 +0100 Subject: [rspec-users] Stub activerecord find given instance? Message-ID: Is there a clean/simple way of stubbing the activerecord find() for a single instance? As usual pattern, I see something like myModel = MyModel.new(...) MyModel.stub( :find ).and_return( myModel ) which can give problems in case we want to find other instances. ??? Saverio -- Posted via http://www.ruby-forum.com/. From tom at experthuman.com Tue Nov 10 09:19:14 2009 From: tom at experthuman.com (Tom Stuart) Date: Tue, 10 Nov 2009 14:19:14 +0000 Subject: [rspec-users] Stub activerecord find given instance? In-Reply-To: References: Message-ID: <4A3616AC-32C2-478C-B20D-DF65FE1C031E@experthuman.com> On 10 Nov 2009, at 14:08, Saverio Miroddi wrote: > Is there a clean/simple way of stubbing the activerecord find() for a > single instance? MyModel.stub(:find).with(42).and_return(myModel) From dchelimsky at gmail.com Tue Nov 10 09:59:25 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Nov 2009 06:59:25 -0800 Subject: [rspec-users] undefined method `route_for In-Reply-To: References: Message-ID: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> On Tue, Nov 10, 2009 at 4:44 AM, Amit Kulkarni wrote: > Hi all, > I am writing scenarios for testing my routes but it is giving me error > as undefined method `route_for and also for params_from. > Did i miss something which i need to add in my controller > > My code is as follows: > > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe HomeController, "routes" do > describe "route generation" do > it "should map { :controller => 'home', :action => 'index' } to > /home" do > route_for(:controller => 'home', :action => 'index').should == > '/home' > end > > it "should map { :controller => 'home' } RESTfully" do > params_from( :get, '/home' ).should == { :controller => 'home', > :action => 'index' } > end > end > end > route_to, route_for and params_from are all available in controller specs, which are identified by: 1. spec/controllers in their path (i.e. spec/controllers/foo_controller_spec 2. describe "route generation", :type => :controller do If neither of those cases is true, then you won't have access to the right helpers and matchers. HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Nov 10 11:17:23 2009 From: lists at ruby-forum.com (Ray K.) Date: Tue, 10 Nov 2009 17:17:23 +0100 Subject: [rspec-users] Model spec for file upload with paperclip and fastercsv Message-ID: <8539b726144cb1cec3a5ebec205c4c20@ruby-forum.com> I just started my ImportsController and was this was really the way to go: ////////import.rb///////////////// class Import < ActiveRecord::Base has_attached_file :csv validates_attachment_presence :csv after_save :process_csv private def process_csv FasterCSV.foreach( csv.path) do |row| #TODO end end end /////////import_spec.rb///////////////// require 'spec_helper' describe Import do it "should should succeed creating a valid Import from the factory" do import = Factory.build(:import) import.csv.stub!(:url).and_return("#{RAILS_ROOT}/spec/csv/3_products.csv") import.save end describe "handling CSV files" do describe "to import products" do before(:each) do @import = Factory.build(:import) @import.csv.stub!(:url).and_return("#{RAILS_ROOT}/spec/csv/3_products.csv") end def do_save @import.save end it "should process the csv file after save" do @import.should_receive(:process_csv) do_save end it "should load the csv file" do FasterCSV.should_receive(:foreach) do_save end end end end -- Posted via http://www.ruby-forum.com/. From david.spurr at gmail.com Tue Nov 10 17:29:14 2009 From: david.spurr at gmail.com (DEfusion) Date: Tue, 10 Nov 2009 14:29:14 -0800 (PST) Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking Message-ID: <7546c31f-2610-45c8-bb23-9e665e4bb526@s31g2000yqs.googlegroups.com> Using RSpec 1.2.9 and Rails 2.3.4. RSpec is not matching some of my routes during controller testing when I have subdomain checking (courtesy of subdomain-fu) on namespaces. These routes appear in the rake routes output, and work fine via HTTP requests . The really annoying thing is it's working fine for routes that aren't at the root of the namespace. E.g. say I have map.namespace :foo, :path_prefix => '', :conditions => { :subdomain => 'foo' } do |foo| foo.bars, :controller => 'bars', :only => [:show] do |bar| bar.resources some_things .... end foo.resources :monkeys end My specs for bars/some_things all resolve the routes fine (e.g. doing get :index etc.) Any spec that tries to hit monkeys/ give me a no route matches even though these routes exist, e.g. doing get :index would result in: No route matches {:controller=>"foo/monkeys", :action=>"index"} I've tried setting both @request.host and request.host to foo.test.host but that doesn't make a blind bit of difference. Maybe RSpec is doing something different with the request, as if I monkey patch the routing with the following I never get the dumps when using RSpec even though both these are called pretty early on in route recognition. module Foo module RouteSetExtensions def self.included(base) base.alias_method_chain :extract_request_environment, :debug base.alias_method_chain :recognize_path, :debug end def recognize_path_with_debug(path, environment={}) puts path puts environment.to_yaml recognize_path_without_debug(path, environment) end def extract_request_environment_with_debug(request) env = extract_request_environment_without_debug(request) puts env.to_yaml env end end end ActionController::Routing::RouteSet.send :include, Foo::RouteSetExtensions So as you can probably tell, I'm out of ideas so I wondered if anyone had any thoughts. From david.spurr at gmail.com Tue Nov 10 17:25:21 2009 From: david.spurr at gmail.com (DEfusion) Date: Tue, 10 Nov 2009 14:25:21 -0800 (PST) Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking Message-ID: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> I'm getting really cheesed off with RSpec not matching some of my routes when controller testing when I have subdomain checking (courtesy of subdomain-fu) on namespaces. These routes appear in the rake routes output, and work fine via HTTP requests . The really annoying thing is it's working fine for routes that aren't at the root of the namespace. E.g. say I have map.namespace :foo, :path_prefix => '', :conditions => { :subdomain => 'foo' } do |foo| foo.bars, :controller => 'bars', :only => [:show] do |bar| bar.resources some_things .... end foo.resources :monkeys end My specs for bars/some_things all resolve the routes fine (e.g. doing get :index etc.) Any spec that tries to hit monkeys/ give me a no route matches even though these routes exist No route matches {:controller=>"foo/monkeys", :action=>"update"} I've tried setting both @request.host and request.host to foo.test.host but that doesn't make a blind bit of difference. Maybe RSpec is doing something different with the request, as if I monkey patch the routing with the following I never get the dumps when using RSpec even though both these are called pretty early on in route recognition. module Foo module RouteSetExtensions def self.included(base) base.alias_method_chain :extract_request_environment, :debug base.alias_method_chain :recognize_path, :debug end def recognize_path_with_debug(path, environment={}) puts path puts environment.to_yaml recognize_path_without_debug(path, environment) end def extract_request_environment_with_debug(request) env = extract_request_environment_without_debug(request) puts env.to_yaml env end end end ActionController::Routing::RouteSet.send :include, Foo::RouteSetExtensions So as you can probably tell, I'm out of ideas so I wondered if anyone had any thoughts. From dchelimsky at gmail.com Tue Nov 10 17:48:27 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Nov 2009 14:48:27 -0800 Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking In-Reply-To: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> References: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> Message-ID: <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> On Tue, Nov 10, 2009 at 2:25 PM, DEfusion wrote: > I'm getting really cheesed off with RSpec not matching some of my > routes when controller testing when I have subdomain checking > (courtesy of subdomain-fu) on namespaces. These routes appear in the > rake routes output, and work fine via HTTP requests . > > The really annoying thing is it's working fine for routes that aren't > at the root of the namespace. > > E.g. say I have > > map.namespace :foo, :path_prefix => '', :conditions => { :subdomain => > 'foo' } do |foo| > > foo.bars, :controller => 'bars', :only => [:show] do |bar| > bar.resources some_things .... > end > > foo.resources :monkeys > end > > My specs for bars/some_things all resolve the routes fine (e.g. doing > get :index etc.) > > Any spec that tries to hit monkeys/ give me a no route matches even > though these routes exist > > No route matches {:controller=>"foo/monkeys", :action=>"update"} > > I've tried setting both @request.host and request.host to > foo.test.host but that doesn't make a blind bit of difference. > > Maybe RSpec is doing something different with the request, as if I > monkey patch the routing with the following I never get the dumps when > using RSpec even though both these are called pretty early on in route > recognition. > > module Foo > > module RouteSetExtensions > def self.included(base) > base.alias_method_chain :extract_request_environment, :debug > base.alias_method_chain :recognize_path, :debug > end > > def recognize_path_with_debug(path, environment={}) > puts path > puts environment.to_yaml > recognize_path_without_debug(path, environment) > end > > def extract_request_environment_with_debug(request) > env = extract_request_environment_without_debug(request) > puts env.to_yaml > env > end > end > > end > > ActionController::Routing::RouteSet.send :include, > Foo::RouteSetExtensions > > So as you can probably tell, I'm out of ideas so I wondered if anyone > had any thoughts. Please post the failing spec and the exact failure message. Thx, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.spurr at gmail.com Tue Nov 10 18:25:02 2009 From: david.spurr at gmail.com (DEfusion) Date: Tue, 10 Nov 2009 15:25:02 -0800 (PST) Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking In-Reply-To: <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> References: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> Message-ID: Now that is weird. I tried to make an isolated example for you and that worked fine. So I put un-commented my spec bit by bit and it works fine. I'm sure I've had this problem before. If I do re-create it I'll post more details here. =D On Nov 10, 10:48?pm, David Chelimsky wrote: > On Tue, Nov 10, 2009 at 2:25 PM, DEfusion wrote: > > I'm getting really cheesed off with RSpec not matching some of my > > routes when controller testing when I have subdomain checking > > (courtesy of subdomain-fu) on namespaces. These routes appear in the > > rake routes output, and work fine via HTTP requests . > > > The really annoying thing is it's working fine for routes that aren't > > at the root of the namespace. > > > E.g. ?say I have > > > map.namespace :foo, :path_prefix => '', :conditions => { :subdomain => > > 'foo' } do |foo| > > > ? ?foo.bars, :controller => 'bars', :only => [:show] do |bar| > > ? ? ? ?bar.resources some_things .... > > ? ?end > > > ? ?foo.resources :monkeys > > end > > > My specs for bars/some_things all resolve the routes fine (e.g. doing > > get :index etc.) > > > Any spec that tries to hit monkeys/ give me a no route matches even > > though these routes exist > > > ? ?No route matches {:controller=>"foo/monkeys", :action=>"update"} > > > I've tried setting both @request.host and request.host to > > foo.test.host but that doesn't make a blind bit of difference. > > > Maybe RSpec is doing something different with the request, as if I > > monkey patch the routing with the following I never get the dumps when > > using RSpec even though both these are called pretty early on in route > > recognition. > > > module Foo > > > ?module RouteSetExtensions > > ? ?def self.included(base) > > ? ? ?base.alias_method_chain :extract_request_environment, :debug > > ? ? ?base.alias_method_chain :recognize_path, :debug > > ? ?end > > > ? ?def recognize_path_with_debug(path, environment={}) > > ? ? ?puts path > > ? ? ?puts environment.to_yaml > > ? ? ?recognize_path_without_debug(path, environment) > > ? ?end > > > ? ?def extract_request_environment_with_debug(request) > > ? ? ?env = extract_request_environment_without_debug(request) > > ? ? ?puts env.to_yaml > > ? ? ?env > > ? ?end > > ?end > > > end > > > ActionController::Routing::RouteSet.send :include, > > Foo::RouteSetExtensions > > > So as you can probably tell, I'm out of ideas so I wondered if anyone > > had any thoughts. > > Please post the failing spec and the exact failure message. > > Thx, > David > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From david.spurr at gmail.com Tue Nov 10 18:59:51 2009 From: david.spurr at gmail.com (DEfusion) Date: Tue, 10 Nov 2009 15:59:51 -0800 (PST) Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking In-Reply-To: References: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> Message-ID: Okay I've managed to re-create my original problem by trying to use params_from to verify the routing (which was another area I was experiencing problems with before). Note each one of the routes I'm defining here all return fine in the browser, they hit the appropriate controller and run the show action, however as you can see by the comments 2 of the specs fail to find the routes defined. http://gist.github.com/231408 -D On Nov 10, 11:25?pm, DEfusion wrote: > Now that is weird. I tried to make an isolated example for you and > that worked fine. So I put un-commented my spec bit by bit and it > works fine. > > I'm sure I've had this problem before. If I do re-create it I'll post > more details here. > > =D > > On Nov 10, 10:48?pm, David Chelimsky wrote: > > > On Tue, Nov 10, 2009 at 2:25 PM, DEfusion wrote: > > > I'm getting really cheesed off with RSpec not matching some of my > > > routes when controller testing when I have subdomain checking > > > (courtesy of subdomain-fu) on namespaces. These routes appear in the > > > rake routes output, and work fine via HTTP requests . > > > > The really annoying thing is it's working fine for routes that aren't > > > at the root of the namespace. > > > > E.g. ?say I have > > > > map.namespace :foo, :path_prefix => '', :conditions => { :subdomain => > > > 'foo' } do |foo| > > > > ? ?foo.bars, :controller => 'bars', :only => [:show] do |bar| > > > ? ? ? ?bar.resources some_things .... > > > ? ?end > > > > ? ?foo.resources :monkeys > > > end > > > > My specs for bars/some_things all resolve the routes fine (e.g. doing > > > get :index etc.) > > > > Any spec that tries to hit monkeys/ give me a no route matches even > > > though these routes exist > > > > ? ?No route matches {:controller=>"foo/monkeys", :action=>"update"} > > > > I've tried setting both @request.host and request.host to > > > foo.test.host but that doesn't make a blind bit of difference. > > > > Maybe RSpec is doing something different with the request, as if I > > > monkey patch the routing with the following I never get the dumps when > > > using RSpec even though both these are called pretty early on in route > > > recognition. > > > > module Foo > > > > ?module RouteSetExtensions > > > ? ?def self.included(base) > > > ? ? ?base.alias_method_chain :extract_request_environment, :debug > > > ? ? ?base.alias_method_chain :recognize_path, :debug > > > ? ?end > > > > ? ?def recognize_path_with_debug(path, environment={}) > > > ? ? ?puts path > > > ? ? ?puts environment.to_yaml > > > ? ? ?recognize_path_without_debug(path, environment) > > > ? ?end > > > > ? ?def extract_request_environment_with_debug(request) > > > ? ? ?env = extract_request_environment_without_debug(request) > > > ? ? ?puts env.to_yaml > > > ? ? ?env > > > ? ?end > > > ?end > > > > end > > > > ActionController::Routing::RouteSet.send :include, > > > Foo::RouteSetExtensions > > > > So as you can probably tell, I'm out of ideas so I wondered if anyone > > > had any thoughts. > > > Please post the failing spec and the exact failure message. > > > Thx, > > David > > > _______________________________________________ > > 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 david.spurr at gmail.com Tue Nov 10 19:10:49 2009 From: david.spurr at gmail.com (DEfusion) Date: Tue, 10 Nov 2009 16:10:49 -0800 (PST) Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking In-Reply-To: References: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> Message-ID: <038eeaaa-b06e-448b-b469-6325d33a4fec@l13g2000yqb.googlegroups.com> Removing the :sub domain conditions from the namespace does fix the issue, and moving the sub domain conditions to the individual route definitions causes them all to fail. On Nov 10, 11:59?pm, DEfusion wrote: > Okay I've managed to re-create my original problem by trying to use > params_from to verify the routing (which was another area I was > experiencing problems with before). > > Note each one of the routes I'm defining here all return fine in the > browser, they hit the appropriate controller and run the show action, > however as you can see by the comments 2 of the specs fail to find the > routes defined. > > http://gist.github.com/231408 > > -D > > On Nov 10, 11:25?pm, DEfusion wrote: > > > Now that is weird. I tried to make an isolated example for you and > > that worked fine. So I put un-commented my spec bit by bit and it > > works fine. > > > I'm sure I've had this problem before. If I do re-create it I'll post > > more details here. > > > =D > > > On Nov 10, 10:48?pm, David Chelimsky wrote: > > > > On Tue, Nov 10, 2009 at 2:25 PM, DEfusion wrote: > > > > I'm getting really cheesed off with RSpec not matching some of my > > > > routes when controller testing when I have subdomain checking > > > > (courtesy of subdomain-fu) on namespaces. These routes appear in the > > > > rake routes output, and work fine via HTTP requests . > > > > > The really annoying thing is it's working fine for routes that aren't > > > > at the root of the namespace. > > > > > E.g. ?say I have > > > > > map.namespace :foo, :path_prefix => '', :conditions => { :subdomain => > > > > 'foo' } do |foo| > > > > > ? ?foo.bars, :controller => 'bars', :only => [:show] do |bar| > > > > ? ? ? ?bar.resources some_things .... > > > > ? ?end > > > > > ? ?foo.resources :monkeys > > > > end > > > > > My specs for bars/some_things all resolve the routes fine (e.g. doing > > > > get :index etc.) > > > > > Any spec that tries to hit monkeys/ give me a no route matches even > > > > though these routes exist > > > > > ? ?No route matches {:controller=>"foo/monkeys", :action=>"update"} > > > > > I've tried setting both @request.host and request.host to > > > > foo.test.host but that doesn't make a blind bit of difference. > > > > > Maybe RSpec is doing something different with the request, as if I > > > > monkey patch the routing with the following I never get the dumps when > > > > using RSpec even though both these are called pretty early on in route > > > > recognition. > > > > > module Foo > > > > > ?module RouteSetExtensions > > > > ? ?def self.included(base) > > > > ? ? ?base.alias_method_chain :extract_request_environment, :debug > > > > ? ? ?base.alias_method_chain :recognize_path, :debug > > > > ? ?end > > > > > ? ?def recognize_path_with_debug(path, environment={}) > > > > ? ? ?puts path > > > > ? ? ?puts environment.to_yaml > > > > ? ? ?recognize_path_without_debug(path, environment) > > > > ? ?end > > > > > ? ?def extract_request_environment_with_debug(request) > > > > ? ? ?env = extract_request_environment_without_debug(request) > > > > ? ? ?puts env.to_yaml > > > > ? ? ?env > > > > ? ?end > > > > ?end > > > > > end > > > > > ActionController::Routing::RouteSet.send :include, > > > > Foo::RouteSetExtensions > > > > > So as you can probably tell, I'm out of ideas so I wondered if anyone > > > > had any thoughts. > > > > Please post the failing spec and the exact failure message. > > > > Thx, > > > David > > > > _______________________________________________ > > > 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 > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Nov 10 19:54:35 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 10 Nov 2009 16:54:35 -0800 Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking In-Reply-To: <038eeaaa-b06e-448b-b469-6325d33a4fec@l13g2000yqb.googlegroups.com> References: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> <038eeaaa-b06e-448b-b469-6325d33a4fec@l13g2000yqb.googlegroups.com> Message-ID: <57c63afe0911101654i522db6cbq41e69b54c29e6cfe@mail.gmail.com> On Tue, Nov 10, 2009 at 4:10 PM, DEfusion wrote: > Removing the :sub domain conditions from the namespace does fix the > issue, and moving the sub domain conditions to the individual route > definitions causes them all to fail. > > On Nov 10, 11:59 pm, DEfusion wrote: > > Okay I've managed to re-create my original problem by trying to use > > params_from to verify the routing (which was another area I was > > experiencing problems with before). > > > > Note each one of the routes I'm defining here all return fine in the > > browser, they hit the appropriate controller and run the show action, > > however as you can see by the comments 2 of the specs fail to find the > > routes defined. > > > > http://gist.github.com/231408 > Can you try using route_to instead of params_from().should ==? See http://github.com/dchelimsky/rspec-rails/blob/master/Upgrade.rdoc Let me know if that works better. David > > > > > -D > > > > On Nov 10, 11:25 pm, DEfusion wrote: > > > > > Now that is weird. I tried to make an isolated example for you and > > > that worked fine. So I put un-commented my spec bit by bit and it > > > works fine. > > > > > I'm sure I've had this problem before. If I do re-create it I'll post > > > more details here. > > > > > =D > > > > > On Nov 10, 10:48 pm, David Chelimsky wrote: > > > > > > On Tue, Nov 10, 2009 at 2:25 PM, DEfusion > wrote: > > > > > I'm getting really cheesed off with RSpec not matching some of my > > > > > routes when controller testing when I have subdomain checking > > > > > (courtesy of subdomain-fu) on namespaces. These routes appear in > the > > > > > rake routes output, and work fine via HTTP requests . > > > > > > > The really annoying thing is it's working fine for routes that > aren't > > > > > at the root of the namespace. > > > > > > > E.g. say I have > > > > > > > map.namespace :foo, :path_prefix => '', :conditions => { :subdomain > => > > > > > 'foo' } do |foo| > > > > > > > foo.bars, :controller => 'bars', :only => [:show] do |bar| > > > > > bar.resources some_things .... > > > > > end > > > > > > > foo.resources :monkeys > > > > > end > > > > > > > My specs for bars/some_things all resolve the routes fine (e.g. > doing > > > > > get :index etc.) > > > > > > > Any spec that tries to hit monkeys/ give me a no route matches even > > > > > though these routes exist > > > > > > > No route matches {:controller=>"foo/monkeys", :action=>"update"} > > > > > > > I've tried setting both @request.host and request.host to > > > > > foo.test.host but that doesn't make a blind bit of difference. > > > > > > > Maybe RSpec is doing something different with the request, as if I > > > > > monkey patch the routing with the following I never get the dumps > when > > > > > using RSpec even though both these are called pretty early on in > route > > > > > recognition. > > > > > > > module Foo > > > > > > > module RouteSetExtensions > > > > > def self.included(base) > > > > > base.alias_method_chain :extract_request_environment, :debug > > > > > base.alias_method_chain :recognize_path, :debug > > > > > end > > > > > > > def recognize_path_with_debug(path, environment={}) > > > > > puts path > > > > > puts environment.to_yaml > > > > > recognize_path_without_debug(path, environment) > > > > > end > > > > > > > def extract_request_environment_with_debug(request) > > > > > env = extract_request_environment_without_debug(request) > > > > > puts env.to_yaml > > > > > env > > > > > end > > > > > end > > > > > > > end > > > > > > > ActionController::Routing::RouteSet.send :include, > > > > > Foo::RouteSetExtensions > > > > > > > So as you can probably tell, I'm out of ideas so I wondered if > anyone > > > > > had any thoughts. > > > > > > Please post the failing spec and the exact failure message. > > > > > > Thx, > > > > David > > > > > > _______________________________________________ > > > > 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 > > > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Nov 11 04:42:47 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Wed, 11 Nov 2009 10:42:47 +0100 Subject: [rspec-users] undefined method `route_for In-Reply-To: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> Message-ID: Thanks David for the information but still i am getting the same error. What i have done is: I have home controller. now i am writing route scenarios in home_controller_spec.rb which is under spec/controllers directory I tried your code which looks like as describe "route generation", :type => :HomeController do it "should map { :controller => 'home', :action => 'index' } to /home" do route_for(:controller => 'home', :action => 'index').should == '/home' end it "should map { :controller => 'home' } RESTfully" do params_from( :get, '/home' ).should == { :controller => 'home', :action => 'index' } end end But it is not working,i know i am missing something. Also can you explain the first point? Can you tell me up what i need to add to get it running atleast :-) -- Posted via http://www.ruby-forum.com/. From david.spurr at gmail.com Wed Nov 11 06:12:58 2009 From: david.spurr at gmail.com (DEfusion) Date: Wed, 11 Nov 2009 03:12:58 -0800 (PST) Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking In-Reply-To: <57c63afe0911101654i522db6cbq41e69b54c29e6cfe@mail.gmail.com> References: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> <038eeaaa-b06e-448b-b469-6325d33a4fec@l13g2000yqb.googlegroups.com> <57c63afe0911101654i522db6cbq41e69b54c29e6cfe@mail.gmail.com> Message-ID: <48c7cd94-e130-4e0f-95fe-f4346a137e98@m16g2000yqc.googlegroups.com> Hi David, Yeah I had used the new style in the past and got the same issue, I just accidentally reverted to the old style. Anyway changing to the new style using route_to as suggested doesn't resolve the issue, the same 2 routes give the same error, but the telling thing is the failure message shows that the subdomain wasn't passed, or at least received by the routing: ActionController::RoutingError in 'Foo::MonkeysController should route' No route matches "/monkeys/1" with {:port=>80, :method=>:get, :host_with_port=>"test.host", :subdomain=>nil, :domain=>"test.host", :host=>"test.host"} If you're expecting this failure, we suggest { :get => "/monkeys/ 1" }.should_not be_routable Even if I specifically set @request.host = 'foo.some.com' before the test it still errors saying host_with_port=>'test.host' -D On Nov 11, 12:54?am, David Chelimsky wrote: > On Tue, Nov 10, 2009 at 4:10 PM, DEfusion wrote: > > Removing the :sub domain conditions from the namespace does fix the > > issue, and moving the sub domain conditions to the individual route > > definitions causes them all to fail. > > > On Nov 10, 11:59 pm, DEfusion wrote: > > > Okay I've managed to re-create my original problem by trying to use > > > params_from to verify the routing (which was another area I was > > > experiencing problems with before). > > > > Note each one of the routes I'm defining here all return fine in the > > > browser, they hit the appropriate controller and run the show action, > > > however as you can see by the comments 2 of the specs fail to find the > > > routes defined. > > > >http://gist.github.com/231408 > > Can you try using route_to instead of params_from().should ==? > > Seehttp://github.com/dchelimsky/rspec-rails/blob/master/Upgrade.rdoc > > Let me know if that works better. > > David > > > > > > -D > > > > On Nov 10, 11:25 pm, DEfusion wrote: > > > > > Now that is weird. I tried to make an isolated example for you and > > > > that worked fine. So I put un-commented my spec bit by bit and it > > > > works fine. > > > > > I'm sure I've had this problem before. If I do re-create it I'll post > > > > more details here. > > > > > =D > > > > > On Nov 10, 10:48 pm, David Chelimsky wrote: > > > > > > On Tue, Nov 10, 2009 at 2:25 PM, DEfusion > > wrote: > > > > > > I'm getting really cheesed off with RSpec not matching some of my > > > > > > routes when controller testing when I have subdomain checking > > > > > > (courtesy of subdomain-fu) on namespaces. These routes appear in > > the > > > > > > rake routes output, and work fine via HTTP requests . > > > > > > > The really annoying thing is it's working fine for routes that > > aren't > > > > > > at the root of the namespace. > > > > > > > E.g. ?say I have > > > > > > > map.namespace :foo, :path_prefix => '', :conditions => { :subdomain > > => > > > > > > 'foo' } do |foo| > > > > > > > ? ?foo.bars, :controller => 'bars', :only => [:show] do |bar| > > > > > > ? ? ? ?bar.resources some_things .... > > > > > > ? ?end > > > > > > > ? ?foo.resources :monkeys > > > > > > end > > > > > > > My specs for bars/some_things all resolve the routes fine (e.g. > > doing > > > > > > get :index etc.) > > > > > > > Any spec that tries to hit monkeys/ give me a no route matches even > > > > > > though these routes exist > > > > > > > ? ?No route matches {:controller=>"foo/monkeys", :action=>"update"} > > > > > > > I've tried setting both @request.host and request.host to > > > > > > foo.test.host but that doesn't make a blind bit of difference. > > > > > > > Maybe RSpec is doing something different with the request, as if I > > > > > > monkey patch the routing with the following I never get the dumps > > when > > > > > > using RSpec even though both these are called pretty early on in > > route > > > > > > recognition. > > > > > > > module Foo > > > > > > > ?module RouteSetExtensions > > > > > > ? ?def self.included(base) > > > > > > ? ? ?base.alias_method_chain :extract_request_environment, :debug > > > > > > ? ? ?base.alias_method_chain :recognize_path, :debug > > > > > > ? ?end > > > > > > > ? ?def recognize_path_with_debug(path, environment={}) > > > > > > ? ? ?puts path > > > > > > ? ? ?puts environment.to_yaml > > > > > > ? ? ?recognize_path_without_debug(path, environment) > > > > > > ? ?end > > > > > > > ? ?def extract_request_environment_with_debug(request) > > > > > > ? ? ?env = extract_request_environment_without_debug(request) > > > > > > ? ? ?puts env.to_yaml > > > > > > ? ? ?env > > > > > > ? ?end > > > > > > ?end > > > > > > > end > > > > > > > ActionController::Routing::RouteSet.send :include, > > > > > > Foo::RouteSetExtensions > > > > > > > So as you can probably tell, I'm out of ideas so I wondered if > > anyone > > > > > > had any thoughts. > > > > > > Please post the failing spec and the exact failure message. > > > > > > Thx, > > > > > David > > > > > > _______________________________________________ > > > > > 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 > > > > _______________________________________________ > > > 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 > > > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Wed Nov 11 07:46:52 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Nov 2009 04:46:52 -0800 Subject: [rspec-users] undefined method `route_for In-Reply-To: References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> Message-ID: <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> On Wed, Nov 11, 2009 at 1:42 AM, Amit Kulkarni wrote: > Thanks David for the information but still i am getting the same error. > What i have done is: > I have home controller. > now i am writing route scenarios in home_controller_spec.rb which is > under spec/controllers directory > > I tried your code which looks like as > > describe "route generation", :type => :HomeController do > it "should map { :controller => 'home', :action => 'index' } to > /home" do > route_for(:controller => 'home', :action => 'index').should == > '/home' > end > > it "should map { :controller => 'home' } RESTfully" do > params_from( :get, '/home' ).should == { :controller => 'home', > :action => 'index' } > end > end > > But it is not working,i know i am missing something. > > Also can you explain the first point? > Can you tell me up what i need to add to get it running atleast :-) > If the spec is in spec/controllers/home_controller_spec.rb, you don't need the :type argument, so just get rid of that and you should be fine. If this still doesn't work, please post the command you are using as well. For future reference, if you put a controller or routing spec in another directory, then you do need the :type argument, but :type means the type of spec, not the type of controller: describe "route generation", :type => :controller do HTH, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Nov 11 07:54:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Nov 2009 04:54:47 -0800 Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking In-Reply-To: <48c7cd94-e130-4e0f-95fe-f4346a137e98@m16g2000yqc.googlegroups.com> References: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> <038eeaaa-b06e-448b-b469-6325d33a4fec@l13g2000yqb.googlegroups.com> <57c63afe0911101654i522db6cbq41e69b54c29e6cfe@mail.gmail.com> <48c7cd94-e130-4e0f-95fe-f4346a137e98@m16g2000yqc.googlegroups.com> Message-ID: <57c63afe0911110454n19e1f657i88793805b30056b2@mail.gmail.com> On Wed, Nov 11, 2009 at 3:12 AM, DEfusion wrote: > Hi David, > > Yeah I had used the new style in the past and got the same issue, I > just accidentally reverted to the old style. > > Anyway changing to the new style using route_to as suggested doesn't > resolve the issue, the same 2 routes give the same error, but the > telling thing is the failure message shows that the subdomain wasn't > passed, or at least received by the routing: > > ActionController::RoutingError in 'Foo::MonkeysController should > route' > No route matches "/monkeys/1" with > {:port=>80, :method=>:get, :host_with_port=>"test.host", :subdomain=>nil, > :domain=>"test.host", :host=>"test.host"} > If you're expecting this failure, we suggest { :get => "/monkeys/ > 1" }.should_not be_routable > > Even if I specifically set @request.host = 'foo.some.com' before the > test it still errors saying host_with_port=>'test.host' > OK. I haven't used subdomain-fu before, but I'm guessing that it's either getting loaded or invoked after rspec, or the two are monkey patching the same things and creating a conflict. Would you do me a favor and slap together a small demo app with the specific version of rspec and subdomain-fu that you are using bundled (vendor/gems preferable), zip it up and submit it in a ticket to http://rspec.lighthouseapp.com? Thx, David > > -D > > On Nov 11, 12:54 am, David Chelimsky wrote: > > On Tue, Nov 10, 2009 at 4:10 PM, DEfusion wrote: > > > Removing the :sub domain conditions from the namespace does fix the > > > issue, and moving the sub domain conditions to the individual route > > > definitions causes them all to fail. > > > > > On Nov 10, 11:59 pm, DEfusion wrote: > > > > Okay I've managed to re-create my original problem by trying to use > > > > params_from to verify the routing (which was another area I was > > > > experiencing problems with before). > > > > > > Note each one of the routes I'm defining here all return fine in the > > > > browser, they hit the appropriate controller and run the show action, > > > > however as you can see by the comments 2 of the specs fail to find > the > > > > routes defined. > > > > > >http://gist.github.com/231408 > > > > Can you try using route_to instead of params_from().should ==? > > > > Seehttp://github.com/dchelimsky/rspec-rails/blob/master/Upgrade.rdoc > > > > Let me know if that works better. > > > > David > > > > > > > > > > -D > > > > > > On Nov 10, 11:25 pm, DEfusion wrote: > > > > > > > Now that is weird. I tried to make an isolated example for you and > > > > > that worked fine. So I put un-commented my spec bit by bit and it > > > > > works fine. > > > > > > > I'm sure I've had this problem before. If I do re-create it I'll > post > > > > > more details here. > > > > > > > =D > > > > > > > On Nov 10, 10:48 pm, David Chelimsky wrote: > > > > > > > > On Tue, Nov 10, 2009 at 2:25 PM, DEfusion > > > > wrote: > > > > > > > I'm getting really cheesed off with RSpec not matching some of > my > > > > > > > routes when controller testing when I have subdomain checking > > > > > > > (courtesy of subdomain-fu) on namespaces. These routes appear > in > > > the > > > > > > > rake routes output, and work fine via HTTP requests . > > > > > > > > > The really annoying thing is it's working fine for routes that > > > aren't > > > > > > > at the root of the namespace. > > > > > > > > > E.g. say I have > > > > > > > > > map.namespace :foo, :path_prefix => '', :conditions => { > :subdomain > > > => > > > > > > > 'foo' } do |foo| > > > > > > > > > foo.bars, :controller => 'bars', :only => [:show] do |bar| > > > > > > > bar.resources some_things .... > > > > > > > end > > > > > > > > > foo.resources :monkeys > > > > > > > end > > > > > > > > > My specs for bars/some_things all resolve the routes fine (e.g. > > > doing > > > > > > > get :index etc.) > > > > > > > > > Any spec that tries to hit monkeys/ give me a no route matches > even > > > > > > > though these routes exist > > > > > > > > > No route matches {:controller=>"foo/monkeys", > :action=>"update"} > > > > > > > > > I've tried setting both @request.host and request.host to > > > > > > > foo.test.host but that doesn't make a blind bit of difference. > > > > > > > > > Maybe RSpec is doing something different with the request, as > if I > > > > > > > monkey patch the routing with the following I never get the > dumps > > > when > > > > > > > using RSpec even though both these are called pretty early on > in > > > route > > > > > > > recognition. > > > > > > > > > module Foo > > > > > > > > > module RouteSetExtensions > > > > > > > def self.included(base) > > > > > > > base.alias_method_chain :extract_request_environment, > :debug > > > > > > > base.alias_method_chain :recognize_path, :debug > > > > > > > end > > > > > > > > > def recognize_path_with_debug(path, environment={}) > > > > > > > puts path > > > > > > > puts environment.to_yaml > > > > > > > recognize_path_without_debug(path, environment) > > > > > > > end > > > > > > > > > def extract_request_environment_with_debug(request) > > > > > > > env = extract_request_environment_without_debug(request) > > > > > > > puts env.to_yaml > > > > > > > env > > > > > > > end > > > > > > > end > > > > > > > > > end > > > > > > > > > ActionController::Routing::RouteSet.send :include, > > > > > > > Foo::RouteSetExtensions > > > > > > > > > So as you can probably tell, I'm out of ideas so I wondered if > > > anyone > > > > > > > had any thoughts. > > > > > > > > Please post the failing spec and the exact failure message. > > > > > > > > Thx, > > > > > > David > > > > > > > > _______________________________________________ > > > > > > 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 > > > > > > _______________________________________________ > > > > 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 > > > > > > > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Nov 11 07:55:15 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Nov 2009 04:55:15 -0800 Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking In-Reply-To: <57c63afe0911110454n19e1f657i88793805b30056b2@mail.gmail.com> References: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> <038eeaaa-b06e-448b-b469-6325d33a4fec@l13g2000yqb.googlegroups.com> <57c63afe0911101654i522db6cbq41e69b54c29e6cfe@mail.gmail.com> <48c7cd94-e130-4e0f-95fe-f4346a137e98@m16g2000yqc.googlegroups.com> <57c63afe0911110454n19e1f657i88793805b30056b2@mail.gmail.com> Message-ID: <57c63afe0911110455s26ceb8f5ga5072f8b1280e390@mail.gmail.com> On Wed, Nov 11, 2009 at 4:54 AM, David Chelimsky wrote: > On Wed, Nov 11, 2009 at 3:12 AM, DEfusion wrote: > >> Hi David, >> >> Yeah I had used the new style in the past and got the same issue, I >> just accidentally reverted to the old style. >> >> Anyway changing to the new style using route_to as suggested doesn't >> resolve the issue, the same 2 routes give the same error, but the >> telling thing is the failure message shows that the subdomain wasn't >> passed, or at least received by the routing: >> >> ActionController::RoutingError in 'Foo::MonkeysController should >> route' >> No route matches "/monkeys/1" with >> {:port=>80, :method=>:get, :host_with_port=>"test.host", :subdomain=>nil, >> :domain=>"test.host", :host=>"test.host"} >> If you're expecting this failure, we suggest { :get => "/monkeys/ >> 1" }.should_not be_routable >> >> Even if I specifically set @request.host = 'foo.some.com' before the >> test it still errors saying host_with_port=>'test.host' >> > > OK. I haven't used subdomain-fu before, but I'm guessing that it's either > getting loaded or invoked after rspec, or the two are monkey patching the > same things and creating a conflict. > > Would you do me a favor and slap together a small demo app with the > specific version of rspec and subdomain-fu that you are using bundled > (vendor/gems preferable), zip it up and submit it in a ticket to > http://rspec.lighthouseapp.com? > Of course, the app should demonstrate the failure :) Forgot that little tidbit. > > Thx, > David > > >> >> -D >> >> On Nov 11, 12:54 am, David Chelimsky wrote: >> > On Tue, Nov 10, 2009 at 4:10 PM, DEfusion >> wrote: >> > > Removing the :sub domain conditions from the namespace does fix the >> > > issue, and moving the sub domain conditions to the individual route >> > > definitions causes them all to fail. >> > >> > > On Nov 10, 11:59 pm, DEfusion wrote: >> > > > Okay I've managed to re-create my original problem by trying to use >> > > > params_from to verify the routing (which was another area I was >> > > > experiencing problems with before). >> > >> > > > Note each one of the routes I'm defining here all return fine in the >> > > > browser, they hit the appropriate controller and run the show >> action, >> > > > however as you can see by the comments 2 of the specs fail to find >> the >> > > > routes defined. >> > >> > > >http://gist.github.com/231408 >> > >> > Can you try using route_to instead of params_from().should ==? >> > >> > Seehttp://github.com/dchelimsky/rspec-rails/blob/master/Upgrade.rdoc >> > >> > Let me know if that works better. >> > >> > David >> > >> > >> > >> > > > -D >> > >> > > > On Nov 10, 11:25 pm, DEfusion wrote: >> > >> > > > > Now that is weird. I tried to make an isolated example for you and >> > > > > that worked fine. So I put un-commented my spec bit by bit and it >> > > > > works fine. >> > >> > > > > I'm sure I've had this problem before. If I do re-create it I'll >> post >> > > > > more details here. >> > >> > > > > =D >> > >> > > > > On Nov 10, 10:48 pm, David Chelimsky >> wrote: >> > >> > > > > > On Tue, Nov 10, 2009 at 2:25 PM, DEfusion < >> david.sp... at gmail.com> >> > > wrote: >> > > > > > > I'm getting really cheesed off with RSpec not matching some of >> my >> > > > > > > routes when controller testing when I have subdomain checking >> > > > > > > (courtesy of subdomain-fu) on namespaces. These routes appear >> in >> > > the >> > > > > > > rake routes output, and work fine via HTTP requests . >> > >> > > > > > > The really annoying thing is it's working fine for routes that >> > > aren't >> > > > > > > at the root of the namespace. >> > >> > > > > > > E.g. say I have >> > >> > > > > > > map.namespace :foo, :path_prefix => '', :conditions => { >> :subdomain >> > > => >> > > > > > > 'foo' } do |foo| >> > >> > > > > > > foo.bars, :controller => 'bars', :only => [:show] do |bar| >> > > > > > > bar.resources some_things .... >> > > > > > > end >> > >> > > > > > > foo.resources :monkeys >> > > > > > > end >> > >> > > > > > > My specs for bars/some_things all resolve the routes fine >> (e.g. >> > > doing >> > > > > > > get :index etc.) >> > >> > > > > > > Any spec that tries to hit monkeys/ give me a no route matches >> even >> > > > > > > though these routes exist >> > >> > > > > > > No route matches {:controller=>"foo/monkeys", >> :action=>"update"} >> > >> > > > > > > I've tried setting both @request.host and request.host to >> > > > > > > foo.test.host but that doesn't make a blind bit of difference. >> > >> > > > > > > Maybe RSpec is doing something different with the request, as >> if I >> > > > > > > monkey patch the routing with the following I never get the >> dumps >> > > when >> > > > > > > using RSpec even though both these are called pretty early on >> in >> > > route >> > > > > > > recognition. >> > >> > > > > > > module Foo >> > >> > > > > > > module RouteSetExtensions >> > > > > > > def self.included(base) >> > > > > > > base.alias_method_chain :extract_request_environment, >> :debug >> > > > > > > base.alias_method_chain :recognize_path, :debug >> > > > > > > end >> > >> > > > > > > def recognize_path_with_debug(path, environment={}) >> > > > > > > puts path >> > > > > > > puts environment.to_yaml >> > > > > > > recognize_path_without_debug(path, environment) >> > > > > > > end >> > >> > > > > > > def extract_request_environment_with_debug(request) >> > > > > > > env = extract_request_environment_without_debug(request) >> > > > > > > puts env.to_yaml >> > > > > > > env >> > > > > > > end >> > > > > > > end >> > >> > > > > > > end >> > >> > > > > > > ActionController::Routing::RouteSet.send :include, >> > > > > > > Foo::RouteSetExtensions >> > >> > > > > > > So as you can probably tell, I'm out of ideas so I wondered if >> > > anyone >> > > > > > > had any thoughts. >> > >> > > > > > Please post the failing spec and the exact failure message. >> > >> > > > > > Thx, >> > > > > > David >> > >> > > > > > _______________________________________________ >> > > > > > 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 >> > >> > > > _______________________________________________ >> > > > 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 >> > >> > >> > >> > _______________________________________________ >> > 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 >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Nov 11 08:48:40 2009 From: lists at ruby-forum.com (Ray K.) Date: Wed, 11 Nov 2009 14:48:40 +0100 Subject: [rspec-users] Model spec for file upload with paperclip and fastercsv In-Reply-To: <8539b726144cb1cec3a5ebec205c4c20@ruby-forum.com> References: <8539b726144cb1cec3a5ebec205c4c20@ruby-forum.com> Message-ID: Now I have another weird error. My Products doesn't save in the specs, but it does in cucumber tests and human tests. I'd be glad if someone could look into this. http://pastie.org/693611 Ray -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Nov 11 08:58:51 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Wed, 11 Nov 2009 14:58:51 +0100 Subject: [rspec-users] undefined method `route_for In-Reply-To: <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> Message-ID: Hi David still no success. require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HomeController, "routes" do describe "route generation" do it "should map { :controller => 'home', :action => 'index' } to /home" do route_for(:controller => 'home', :action => 'index').should == '/home' end it "should map { :controller => 'home' } RESTfully" do params_from( :get, '/home' ).should == { :controller => 'home', :action => 'index' } end end end I am using "spec home_controller_spec.rb" by going under spec/controllers/ directory. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Nov 11 08:59:41 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Wed, 11 Nov 2009 14:59:41 +0100 Subject: [rspec-users] Display Rspec output in an html file In-Reply-To: References: <6bb97fe564ebbb30e16ad7e753473ca0@ruby-forum.com> <6E9E130A-B144-4AAC-9EEF-CA69E189D553@mattwynne.net> Message-ID: <744c997fb5fe43cbb5987ef33930c18b@ruby-forum.com> Any suggestions on the above topic -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Nov 11 10:43:06 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 11 Nov 2009 07:43:06 -0800 Subject: [rspec-users] undefined method `route_for In-Reply-To: References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> Message-ID: <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> On Nov 11, 2009, at 5:58 AM, Amit Kulkarni wrote: > Hi David still no success. > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > describe HomeController, "routes" do > describe "route generation" do > it "should map { :controller => 'home', :action => 'index' } to / > home" > do > route_for(:controller => 'home', :action => 'index').should == > '/home' > end > > it "should map { :controller => 'home' } RESTfully" do > params_from( :get, '/home' ).should == { :controller => 'home', > :action => 'index' } > end > end > end > > I am using "spec home_controller_spec.rb" by going under > spec/controllers/ directory. Don't do that :) Go to the project root directory and say "spec spec/controllers/ home_controller_spec.rb" > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Wed Nov 11 10:56:10 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 11 Nov 2009 10:56:10 -0500 Subject: [rspec-users] Model spec for file upload with paperclip and fastercsv In-Reply-To: References: <8539b726144cb1cec3a5ebec205c4c20@ruby-forum.com> Message-ID: <85d99afe0911110756t4770b3c7n11aff3d87f2a73b5@mail.gmail.com> In the example that is failing, "should build 3 new Products" you have: it "should build 3 new Products" do # I have to tag this pending, this results in a weird error I don't have time for yet # full stack testing with cucumber succeeds, human testing does too # pending Product.should_receive(:new) do_save Product.count.should == 3 end You are setting up an expectation with "should_receive(:new)", and you're not supplying anything to be returned so it is defaulting to nil. This is why you get the NoMethodError calling nil.save... because your local variable product is nil for the duration of this example. I don't think you want to be using mocking down in the model spec like you are doing. For example, does it really matter that #foreach was called? Or that Product#new was called? Or that product#save was called? These can all be inferred if you have a CSV file, save the import ,and then suddenly you have products. No need to worry about them directly IMO. Using mocks in this example happen to make this spec brittle, and it doesn't add any value. For example, say you changed from using fastercsv to some other csv library that had a different API, but it properly parsed the CSV files. All of the behaviour of importing products the CSV file still worked, but suddenly your examples fail because #foreach isn't be used. When focusing on the Import model focus on the behaviour you want out of it. Based on the pastie you made it seems like you want it to import products from a CSV after save. So, you can write an example for ensuring the right number of products were created. You might also want to write an example to ensure the write fields from the CSV ended in the right attributes on a product. Picking one or two products should be enough to gain confidence. I've done a quick edit of your original spec to show what I was thinking when I quickly read your spec: http://pastie.org/693775 Hopefully this helps! On Wed, Nov 11, 2009 at 8:48 AM, Ray K. wrote: > Now I have another weird error. My Products doesn't save in the specs, > but it does in cucumber tests and human tests. > I'd be glad if someone could look into this. > > http://pastie.org/693611 > > Ray > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- 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 lists at ruby-forum.com Wed Nov 11 11:07:53 2009 From: lists at ruby-forum.com (Ray K.) Date: Wed, 11 Nov 2009 17:07:53 +0100 Subject: [rspec-users] Model spec for file upload with paperclip and fastercsv In-Reply-To: <85d99afe0911110756t4770b3c7n11aff3d87f2a73b5@mail.gmail.com> References: <8539b726144cb1cec3a5ebec205c4c20@ruby-forum.com> <85d99afe0911110756t4770b3c7n11aff3d87f2a73b5@mail.gmail.com> Message-ID: <4075972247a4e7e5723c3c9a00a17591@ruby-forum.com> Thanks for your input, I will try that later. The reason why I posted here is, that it felt all wrong to spec my model like this while writing it. It just wasn't behavior driven, but implementation driven. Ray -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Nov 11 11:36:07 2009 From: lists at ruby-forum.com (Ray K.) Date: Wed, 11 Nov 2009 17:36:07 +0100 Subject: [rspec-users] Model spec for file upload with paperclip and fastercsv In-Reply-To: <4075972247a4e7e5723c3c9a00a17591@ruby-forum.com> References: <8539b726144cb1cec3a5ebec205c4c20@ruby-forum.com> <85d99afe0911110756t4770b3c7n11aff3d87f2a73b5@mail.gmail.com> <4075972247a4e7e5723c3c9a00a17591@ruby-forum.com> Message-ID: Here's a conclusion I'm drawing for myself. With little prior experience, there's only so much I could take with me from one read through the rspec book. Maybe it's time to read it again. -- Posted via http://www.ruby-forum.com/. From jeremy at infinitecube.com Wed Nov 11 16:56:54 2009 From: jeremy at infinitecube.com (JGailor) Date: Wed, 11 Nov 2009 13:56:54 -0800 (PST) Subject: [rspec-users] Returning a StringIO object from a stub Message-ID: <327c8334-b74c-4466-bfb4-df87543d2eec@g22g2000prf.googlegroups.com> I'm trying to stub File.new so I can return a StringIO object from it to set some expectation and make sure the subject under test is behaving correctly, but calling readline() on the StringIO object in the subject always returns nil. What's strange is that calling read() returns the entire set of data in the StringIO object. Additionally, calling readline() on the StringIO object from inside the test works fine as well. data = <<-DATA ... DATA faux_file = StringIO.new(data) File.stub!(:new).and_return(faux_file) faux_file.should_receive(:readline).exactly(x).times Subject.new("").parse I'm using rspec 1.2.9 (this is not testing a rails app). Can anyone give me any advice on why this might be? Thanks, Jeremy From paul.t.hinze at gmail.com Wed Nov 11 22:43:10 2009 From: paul.t.hinze at gmail.com (Paul Hinze) Date: Wed, 11 Nov 2009 21:43:10 -0600 Subject: [rspec-users] Returning a StringIO object from a stub In-Reply-To: <327c8334-b74c-4466-bfb4-df87543d2eec@g22g2000prf.googlegroups.com> References: <327c8334-b74c-4466-bfb4-df87543d2eec@g22g2000prf.googlegroups.com> Message-ID: <20091112034310.GC5736@vpr1000.dynamic.uiowa.edu> JGailor on 2009-11-11 at 16:11: > I'm trying to stub File.new so I can return a StringIO object from it > to set some expectation and make sure the subject under test is > behaving correctly, but calling readline() on the StringIO object in > the subject always returns nil. > > data = <<-DATA > ... > DATA > > faux_file = StringIO.new(data) > File.stub!(:new).and_return(faux_file) > faux_file.should_receive(:readline).exactly(x).times > Subject.new("").parse As soon as you call `should_receive(:readline)`, you are not only setting an expectation for that method to be received but also stubbing out the method. Here's a bit more in-depth discussion of that: http://axonflux.com/rspecs-shouldreceive-doesnt-ac That link also discusses why that might be a good idea -- it keeps specs simple. So you've got two options, (1) If you've got your heart set on counting the number of calls to readline you can do something like the following: faux_file.should_receive(:readline).exactly(x).times.and_return(*data.readlines) Which, as you can see, is basically a funky re-implementation of StringIO#readline, but it should do the trick. (2) I would encourage you to consider this: rather than asserting that every line is _read_, simply verify that the result of your Subject#parse method includes data that would _prove_ that each line has been read. That way you're testing behavior rather than implementation. Cheers, Paul From lists at ruby-forum.com Thu Nov 12 02:19:46 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Thu, 12 Nov 2009 08:19:46 +0100 Subject: [rspec-users] undefined method `route_for In-Reply-To: <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> Message-ID: David Chelimsky wrote: > On Nov 11, 2009, at 5:58 AM, Amit Kulkarni wrote: > >> >> it "should map { :controller => 'home' } RESTfully" do >> params_from( :get, '/home' ).should == { :controller => 'home', >> :action => 'index' } >> end >> end >> end >> >> I am using "spec home_controller_spec.rb" by going under >> spec/controllers/ directory. > > Don't do that :) > > Go to the project root directory and say "spec spec/controllers/ > home_controller_spec.rb" Hi David, I tried to run from the above command. It gets executed but i am not able to see any results as in 2 examples 2 passed something like that as it comes normally. -- Posted via http://www.ruby-forum.com/. From jeremy at infinitecube.com Thu Nov 12 13:02:41 2009 From: jeremy at infinitecube.com (JGailor) Date: Thu, 12 Nov 2009 10:02:41 -0800 (PST) Subject: [rspec-users] Returning a StringIO object from a stub In-Reply-To: <20091112034310.GC5736@vpr1000.dynamic.uiowa.edu> References: <327c8334-b74c-4466-bfb4-df87543d2eec@g22g2000prf.googlegroups.com> <20091112034310.GC5736@vpr1000.dynamic.uiowa.edu> Message-ID: Thanks Paul, As soon as I read the first part of your message I had one of those face-palm moments. Thanks for your help. In the case of this expectation, I'm not sure which path I'll take as this particular test is looking for it to read a certain number of lines of input before finding the target line. From rogerpack2005 at gmail.com Thu Nov 12 19:31:18 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Thu, 12 Nov 2009 16:31:18 -0800 (PST) Subject: [rspec-users] odd error In-Reply-To: <57c63afe0911041418o4ea50668w21c2e5d6f68ff402@mail.gmail.com> References: <57c63afe0911041418o4ea50668w21c2e5d6f68ff402@mail.gmail.com> Message-ID: <87636c14-e114-4585-b92a-a01df10b477b@37g2000yqm.googlegroups.com> > > expected: "`four, five` are not recognized argument keywords", > > ? ? got: "`five, four` are not recognized argument keywords" (using > > ==) > > ./spec\arguments_spec.rb:140: > > Please be sure to post the relevant code when you are asking for help on > this list. I'll take a guess at what is going on, but it's hard to know if > I'm barking up the right tree without seeing the code. Oops my apologies. For some reason my eyes got crossed and I thought the strings were identical. My bad. -r From rogerpack2005 at gmail.com Thu Nov 12 19:34:24 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Thu, 12 Nov 2009 16:34:24 -0800 (PST) Subject: [rspec-users] ruby file.spec? Message-ID: perhaps this has been discussed before and you can point me to the right thread, but is it possible to run specs from the command line using just ruby? ruby arguments_spec.rb and it "just run" (like test/unit seems to)? I can't think of a great reason why this would be useful, other than not having to remember which command is which to run files--you only have to type "ruby" (and IDE's that aren't spec aware would be easier to run with). Thanks! -r From rogerpack2005 at gmail.com Thu Nov 12 19:14:37 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Thu, 12 Nov 2009 16:14:37 -0800 (PST) Subject: [rspec-users] better documentation? In-Reply-To: References: Message-ID: <29f24fee-5837-411c-8460-e523093453a5@g23g2000yqh.googlegroups.com> > I really like what Aslak and the Cucumber community have done by ? > making cukes.info more high level and building up more extensive ? > documentation on the github wiki, so I'd rather put energy into ? > beefing up the github wiki than improve rspec.info. What do you think? Using a wiki sounds like a great idea. -r From zach.dennis at gmail.com Thu Nov 12 20:36:53 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 12 Nov 2009 20:36:53 -0500 Subject: [rspec-users] ruby file.spec? In-Reply-To: References: Message-ID: <85d99afe0911121736m10ec040epd72ccc03ec6970c8@mail.gmail.com> On Thu, Nov 12, 2009 at 7:34 PM, rogerdpack wrote: > perhaps this has been discussed before and you can point me to the > right thread, but is it possible to run specs from the command line > using just ruby? > ruby arguments_spec.rb > > and it "just run" (like test/unit seems to)? > > I can't think of a great reason why this would be useful, other than > not having to remember which command is which to run files--you only > have to type "ruby" (and IDE's that aren't spec aware would be easier > to run with). You want to use "spec" to run files directly. If you have your heart set on running files from "ruby" then you'll need to load "spec/autorun" to actually execute the specs. Note using the following will not work on ruby 1.8.x (see thread http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/334942 ) but it should work on 1.9.x. ruby -rubygems -rspec -rspec/autorun file_spec.rb -- 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 sfeley at gmail.com Thu Nov 12 22:12:41 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 12 Nov 2009 22:12:41 -0500 Subject: [rspec-users] better documentation? In-Reply-To: <29f24fee-5837-411c-8460-e523093453a5@g23g2000yqh.googlegroups.com> References: <29f24fee-5837-411c-8460-e523093453a5@g23g2000yqh.googlegroups.com> Message-ID: <1fb4df0911121912u3a964b0dj606fa5ed3671a55e@mail.gmail.com> On Thu, Nov 12, 2009 at 7:14 PM, rogerdpack wrote: > >> I really like what Aslak and the Cucumber community have done by >> making cukes.info more high level and building up more extensive >> documentation on the github wiki, so I'd rather put energy into >> beefing up the github wiki than improve rspec.info. What do you think? > > Using a wiki sounds like a great idea. Agreed, but the wiki implementation on Github is too simplistic and lacks the organizing and search features to make it usable. I think the Cucumber project is evidence of this. There are wikis much better suited for the purpose, like Dokuwiki or TikiWiki. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Thu Nov 12 22:28:48 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 12 Nov 2009 22:28:48 -0500 Subject: [rspec-users] ruby file.spec? In-Reply-To: <85d99afe0911121736m10ec040epd72ccc03ec6970c8@mail.gmail.com> References: <85d99afe0911121736m10ec040epd72ccc03ec6970c8@mail.gmail.com> Message-ID: <1fb4df0911121928t1b80f84fk921ccfd81f02839a@mail.gmail.com> On Thu, Nov 12, 2009 at 8:36 PM, Zach Dennis wrote: > > You want to use "spec" to run files directly. If you have your heart > set on running files from "ruby" then you'll need to load > "spec/autorun" to actually execute the specs. After giving the original querent a hard time, it surprises me to have to tell you that you're wrong. At least if you're running any spec file written with the typical Railsish convention of requiring 'spec_helper.rb' at the top. If for some reason you have spec files that *don't* require the framework one way or another, you'd be correct, but...why wouldn't you? Otherwise, it works fine. (How do I know? I went into one of my projects, then into a spec directory, and typed 'ruby user_spec.rb' and watched it work. At first I didn't think that trying things before posting to a mailing list about them was an extraordinary act, but now I'm wondering if I ought to get a medal for courage.) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From sfeley at gmail.com Thu Nov 12 22:16:36 2009 From: sfeley at gmail.com (Stephen Eley) Date: Thu, 12 Nov 2009 22:16:36 -0500 Subject: [rspec-users] ruby file.spec? In-Reply-To: References: Message-ID: <1fb4df0911121916j2ee0bf70h39bc39ffbcfa00bf@mail.gmail.com> On Thu, Nov 12, 2009 at 7:34 PM, rogerdpack wrote: > perhaps this has been discussed before and you can point me to the > right thread, but is it possible to run specs from the command line > using just ruby? > ruby arguments_spec.rb > > and it "just run" (like test/unit seems to)? What happens when you try it? (You *do* have the power to experiment, you know. You don't need permission.) -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From dchelimsky at gmail.com Thu Nov 12 22:57:24 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Nov 2009 19:57:24 -0800 Subject: [rspec-users] undefined method `route_for In-Reply-To: References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> Message-ID: <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> On Wed, Nov 11, 2009 at 11:19 PM, Amit Kulkarni wrote: > David Chelimsky wrote: > > On Nov 11, 2009, at 5:58 AM, Amit Kulkarni wrote: > > > >> > >> it "should map { :controller => 'home' } RESTfully" do > >> params_from( :get, '/home' ).should == { :controller => 'home', > >> :action => 'index' } > >> end > >> end > >> end > >> > >> I am using "spec home_controller_spec.rb" by going under > >> spec/controllers/ directory. > > > > Don't do that :) > > > > Go to the project root directory and say "spec spec/controllers/ > > home_controller_spec.rb" > > Hi David, > I tried to run from the above command. > It gets executed but i am not able to see any results as in 2 examples 2 > passed something like that as it comes normally. > Then how do you know it gets executed? -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Thu Nov 12 23:15:03 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 12 Nov 2009 23:15:03 -0500 Subject: [rspec-users] ruby file.spec? In-Reply-To: <1fb4df0911121928t1b80f84fk921ccfd81f02839a@mail.gmail.com> References: <85d99afe0911121736m10ec040epd72ccc03ec6970c8@mail.gmail.com> <1fb4df0911121928t1b80f84fk921ccfd81f02839a@mail.gmail.com> Message-ID: <85d99afe0911122015v4ccc7925l4548980de27ce971@mail.gmail.com> On Thu, Nov 12, 2009 at 10:28 PM, Stephen Eley wrote: > On Thu, Nov 12, 2009 at 8:36 PM, Zach Dennis wrote: >> >> You want to use "spec" to run files directly. If you have your heart >> set on running files from "ruby" then you'll need to load >> "spec/autorun" to actually execute the specs. > > After giving the original querent a hard time, it surprises me to have > to tell you that you're wrong. ?At least if you're running any spec > file written with the typical Railsish convention of requiring > 'spec_helper.rb' at the top. ?If for some reason you have spec files > that *don't* require the framework one way or another, you'd be > correct, but...why wouldn't you? ?Otherwise, it works fine. And in that case spec_helper.rb still needs to load spec/autorun for this to work. > > (How do I know? ?I went into one of my projects, then into a spec > directory, and typed 'ruby user_spec.rb' and watched it work. ?At > first I didn't think that trying things before posting to a mailing > list about them was an extraordinary act, but now I'm wondering if I > ought to get a medal for courage.) > > > -- > Have Fun, > ? Steve Eley (sfeley at gmail.com) > ? ESCAPE POD - The Science Fiction Podcast Magazine > ? http://www.escapepod.org > -- 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 lists at ruby-forum.com Fri Nov 13 02:32:24 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Fri, 13 Nov 2009 08:32:24 +0100 Subject: [rspec-users] undefined method `route_for In-Reply-To: <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> Message-ID: <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> David Chelimsky wrote: > On Wed, Nov 11, 2009 at 11:19 PM, Amit Kulkarni > wrote: > >> >> >> It gets executed but i am not able to see any results as in 2 examples 2 >> passed something like that as it comes normally. >> > > Then how do you know it gets executed? I dont know,When i run the command no result is displayed. Also error is not displayed. But why is this happening?Also how can i run this to test my routes? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Nov 13 02:56:53 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 12 Nov 2009 23:56:53 -0800 Subject: [rspec-users] undefined method `route_for In-Reply-To: <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> Message-ID: <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> On Thu, Nov 12, 2009 at 11:32 PM, Amit Kulkarni wrote: > David Chelimsky wrote: > > On Wed, Nov 11, 2009 at 11:19 PM, Amit Kulkarni > > wrote: > > > >> >> > >> It gets executed but i am not able to see any results as in 2 examples 2 > >> passed something like that as it comes normally. > >> > > > > Then how do you know it gets executed? > > I dont know,When i run the command no result is displayed. > Also error is not displayed. > That likely means nothing is actually happening. Please post your spec_helper.rb. Also, what versions of rspec, rspec-rails, and rails are you using? > But why is this happening?Also how can i run this to test my routes? -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Fri Nov 13 05:28:47 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Fri, 13 Nov 2009 11:28:47 +0100 Subject: [rspec-users] undefined method `route_for In-Reply-To: <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> Message-ID: MY spec helper contains following code: # This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] ||= 'test' require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) require 'spec' require 'webrat' require 'spec/autorun' require 'spec/rails' require File.join( Rails.root, 'spec', 'macros' ) # Uncomment the next line to use webrat's matchers #require 'webrat/integrations/rspec-rails' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} Spec::Runner.configure do |config| config.include(ModelExampleGroupHelper, :type => :model) config.include(ControllerExampleGroupHelper, :type => :controller) # If you're not using ActiveRecord you should remove these # lines, delete config/database.yml and disable :active_record # in your config/boot.rb config.use_transactional_fixtures = true config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/spec/fixtures/' config.include Webrat::Matchers, :type => :views # == Fixtures # # You can declare fixtures for each example_group like this: # describe "...." do # fixtures :table_a, :table_b # # Alternatively, if you prefer to declare them only once, you can # do so right here. Just uncomment the next line and replace the fixture # names with your fixtures. # # config.global_fixtures = :table_a, :table_b # # If you declare global fixtures, be aware that they will be declared # for all of your examples, even those that don't use them. # # You can also declare which fixtures to use (for example fixtures for test/fixtures): # # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' # # == Mock Framework # # RSpec uses it's own mocking framework by default. 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 # # == Notes # # For more information take a look at Spec::Runner::Configuration and Spec::Runner end def login controller.stub!( :logged_in? ).and_return( true ) controller.stub!( :login_required ).and_return( true ) @current_user = mock_model( User, :id => 1, :time_zone => 'Rome', :idiom => 'it', :login => 'quentin', :email => 'foo at bar.com', :can_join? => true ) controller.stub!( :current_user ).and_return( @current_user ) end def login_as( name ) controller.stub!( :logged_in? ).and_return( true ) controller.stub!( :login_required ).and_return( true ) @current_user = users(name) controller.stub!( :current_user ).and_return( @current_user ) end def valid_channel_attributes { :brand_name => 'RspecChannel' } end def valid_user_attributes { :login => 'testtest', :password => '555555', :password_confirmation => '555555', :email => 'test at test.com', :idiom => 'it', :privacy => '1', } end def create_channel(args=nil) args ||= valid_channel_attributes Channel.create args end def create_user(args = nil) args ||= valid_user_attributes User.create args end #~ %w!User Contest Video Print Radio Banner Conceptl!.each do |model| #~ model.constantize.any_instance.stubs(:save_attached_files).returns(true) #~ end rspec = 1.2.9 rspec-rails - 1.2.9 rails = 2.1.2 -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Nov 13 09:39:51 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 13 Nov 2009 06:39:51 -0800 Subject: [rspec-users] undefined method `route_for In-Reply-To: References: <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> Message-ID: <57c63afe0911130639w1168fdbav5aebcb019f563eb@mail.gmail.com> On Fri, Nov 13, 2009 at 2:28 AM, Amit Kulkarni wrote: > MY spec helper contains following code: > # This file is copied to ~/spec when you run 'ruby script/generate > rspec' > # from the project root directory. > ENV["RAILS_ENV"] ||= 'test' > require > > File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) > require 'spec' > require 'webrat' > require 'spec/autorun' > require 'spec/rails' > > require File.join( Rails.root, 'spec', 'macros' ) > # Uncomment the next line to use webrat's matchers > #require 'webrat/integrations/rspec-rails' > > # Requires supporting files with custom matchers and macros, etc, > # in ./support/ and its subdirectories. > > Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each > {|f| require f} > > Spec::Runner.configure do |config| > config.include(ModelExampleGroupHelper, :type => :model) > config.include(ControllerExampleGroupHelper, :type => :controller) > # If you're not using ActiveRecord you should remove these > # lines, delete config/database.yml and disable :active_record > # in your config/boot.rb > config.use_transactional_fixtures = true > config.use_instantiated_fixtures = false > config.fixture_path = RAILS_ROOT + '/spec/fixtures/' > > config.include Webrat::Matchers, :type => :views > # == Fixtures > # > # You can declare fixtures for each example_group like this: > # describe "...." do > # fixtures :table_a, :table_b > # > # Alternatively, if you prefer to declare them only once, you can > # do so right here. Just uncomment the next line and replace the > fixture > # names with your fixtures. > # > # config.global_fixtures = :table_a, :table_b > # > # If you declare global fixtures, be aware that they will be declared > # for all of your examples, even those that don't use them. > # > # You can also declare which fixtures to use (for example fixtures for > test/fixtures): > # > # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' > # > # == Mock Framework > # > # RSpec uses it's own mocking framework by default. 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 > # > # == Notes > # > # For more information take a look at Spec::Runner::Configuration and > Spec::Runner > end > > def login > controller.stub!( :logged_in? ).and_return( true ) > controller.stub!( :login_required ).and_return( true ) > @current_user = mock_model( User, :id => 1, :time_zone => 'Rome', > :idiom => 'it', :login => 'quentin', :email => 'foo at bar.com', :can_join? > => true ) > controller.stub!( :current_user ).and_return( @current_user ) > end > > def login_as( name ) > controller.stub!( :logged_in? ).and_return( true ) > controller.stub!( :login_required ).and_return( true ) > @current_user = users(name) > controller.stub!( :current_user ).and_return( @current_user ) > end > > def valid_channel_attributes > { > :brand_name => 'RspecChannel' > } > end > > def valid_user_attributes > { > :login => 'testtest', :password => '555555', :password_confirmation > => '555555', :email => 'test at test.com', :idiom => 'it', :privacy => '1', > } > end > > def create_channel(args=nil) > args ||= valid_channel_attributes > Channel.create args > end > > def create_user(args = nil) > args ||= valid_user_attributes > User.create args > end > > > #~ %w!User Contest Video Print Radio Banner Conceptl!.each do |model| > #~ > model.constantize.any_instance.stubs(:save_attached_files).returns(true) > #~ end > > rspec = 1.2.9 > rspec-rails - 1.2.9 > rails = 2.1.2 > There's your problem. The last version of rspec that supports rails 2.1.x is 1.1.12. See http://github.com/dchelimsky/rspec-rails/blob/master/History.rdoc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From rogerpack2005 at gmail.com Fri Nov 13 13:26:07 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Fri, 13 Nov 2009 10:26:07 -0800 (PST) Subject: [rspec-users] ruby file.spec? In-Reply-To: <1fb4df0911121916j2ee0bf70h39bc39ffbcfa00bf@mail.gmail.com> References: <1fb4df0911121916j2ee0bf70h39bc39ffbcfa00bf@mail.gmail.com> Message-ID: <701aff93-c64a-484e-b023-969535b86bf1@l2g2000yqd.googlegroups.com> > What happens when you try it? > > (You *do* have the power to experiment, you know. ?You don't need permission.) C:\dev\ruby\old\arguments\spec>ruby arguments_spec.rb arguments_spec.rb:5: undefined method `describe' for main:Object (NoMethodError) or adding a require 'spec' in there C:\dev\ruby\old\arguments\spec>ruby arguments_spec.rb C:\dev\ruby\old\arguments\spec> # (it output nothing) adding require 'spec/autorun' worked like a champ, however. It's not clear from the github wiki where I would submit such a tidbit of information. Also is there a link to rdoc's somewhere? Thanks! -r From akleak at gmail.com Fri Nov 13 13:04:52 2009 From: akleak at gmail.com (Arco) Date: Fri, 13 Nov 2009 10:04:52 -0800 (PST) Subject: [rspec-users] Using Mock / Datamapper / Associations Message-ID: I'm using datamapper and have two associated classes: - Org - has n, :users - User - belongs_to :org When I test the User object, I have been able to mock/stub methods of the Org object. Great! But - I still need to require 'org.rb' to setup my user tests - otherwise Datamapper will complain: "Cannot find the parent_model Org for User in org (NameError)" Sure I can require the associated object in my test setup, but would love to avoid having to do this, as it increases complexity as the number of associated classes grows. Is there a way to mock the Org object, without having to require it in my test setup ?? From dchelimsky at gmail.com Fri Nov 13 18:38:04 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 13 Nov 2009 15:38:04 -0800 Subject: [rspec-users] Using Mock / Datamapper / Associations In-Reply-To: References: Message-ID: <57c63afe0911131538w5f5228fan57ff5b26444a0308@mail.gmail.com> On Fri, Nov 13, 2009 at 10:04 AM, Arco wrote: > I'm using datamapper and have two associated classes: > - Org - has n, :users > - User - belongs_to :org > > When I test the User object, I have been able to mock/stub methods of > the Org object. Great! > > But - I still need to require 'org.rb' to setup my user tests - > otherwise Datamapper will complain: "Cannot find the parent_model Org > for User in org (NameError)" > > Sure I can require the associated object in my test setup, but would > love to avoid having to do this, as it increases complexity as the > number of associated classes grows. > > Is there a way to mock the Org object, without having to require it in > my test setup ?? > I don't know much about Datamapper, but if you're referencing an Org object then it seems reasonable to me that you'd have to require that file. Why it's not autoloaded I have no idea - have you tried a Datamapper list or IRC channel? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ashley.moran at patchspace.co.uk Sat Nov 14 08:54:54 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Sat, 14 Nov 2009 13:54:54 +0000 Subject: [rspec-users] Using Mock / Datamapper / Associations In-Reply-To: References: Message-ID: On Nov 13, 2009, at 6:04 pm, Arco wrote: > Is there a way to mock the Org object, without having to require it in > my test setup ?? Hi Arco Are you running the spec through something that loads a code loader (eg: for my specs, spec_helper.rb starts Merb in the test environment), or just running that one file on its own? That's the simplest way I can think this would be failing. Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran From celoserpa at gmail.com Sun Nov 15 22:50:13 2009 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Sun, 15 Nov 2009 21:50:13 -0600 Subject: [rspec-users] Stub a call that happens inside a block Message-ID: <1e5bcefd0911151950w5bf188ddi34e8521c31bb4eed@mail.gmail.com> Hello list, I had a hard time to find out a way to mock the singleton feed method of the following class: class RssReader def self.feed(feed_url) output = [] open(feed_url) do |http| response = http.read result = RSS::Parser.parse(response, false) result.items.each_with_index do |item, i| output << {:title => item.title, :description => item.description, :pubDate => item.pubDate, :link => item.link} end unless result.nil? end output end end Since it is being passed a block, I could not intercept the code inside the block, the specific code I'd like to stub is the http.read. I have tried to do: Http.should_receive(:read).and_return(xml) #xml being a fixture, loaded from a file. However, the stub is not applied. Any ideas on how this could be solved? The only way I could think is to avoid using the block... Thanks, Marcelo. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sun Nov 15 23:13:49 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 15 Nov 2009 20:13:49 -0800 Subject: [rspec-users] Stub a call that happens inside a block In-Reply-To: <1e5bcefd0911151950w5bf188ddi34e8521c31bb4eed@mail.gmail.com> References: <1e5bcefd0911151950w5bf188ddi34e8521c31bb4eed@mail.gmail.com> Message-ID: <57c63afe0911152013g784ab823g4709f3f580d75267@mail.gmail.com> On Sun, Nov 15, 2009 at 7:50 PM, Marcelo de Moraes Serpa < celoserpa at gmail.com> wrote: > Hello list, > > I had a hard time to find out a way to mock the singleton feed method of > the following class: > class RssReader > > def self.feed(feed_url) > output = [] > open(feed_url) do |http| > response = http.read > result = RSS::Parser.parse(response, false) > result.items.each_with_index do |item, i| > output << {:title => item.title, :description => item.description, > :pubDate => item.pubDate, :link => item.link} > end unless result.nil? > end > output > end > end > > Try this: describe "..." do it "..." do http = mock('http') RssReader.should_receive(:open).with('http://this.url')and_yield(http) http.should_receive(:read) .... ... RssReader.feed('http://this.url') end end Make sense? David > Since it is being passed a block, I could not intercept the code inside the > block, the specific code I'd like to stub is the http.read. I have tried to > do: > > Http.should_receive(:read).and_return(xml) #xml being a fixture, loaded > from a file. > > However, the stub is not applied. > > Any ideas on how this could be solved? The only way I could think is to > avoid using the block... > > Thanks, > > Marcelo. > > > > _______________________________________________ > 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 celoserpa at gmail.com Mon Nov 16 00:05:37 2009 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Sun, 15 Nov 2009 23:05:37 -0600 Subject: [rspec-users] Stub a call that happens inside a block In-Reply-To: <57c63afe0911152013g784ab823g4709f3f580d75267@mail.gmail.com> References: <1e5bcefd0911151950w5bf188ddi34e8521c31bb4eed@mail.gmail.com> <57c63afe0911152013g784ab823g4709f3f580d75267@mail.gmail.com> Message-ID: <1e5bcefd0911152105k1b07b9b2sab2d241bd2ba457d@mail.gmail.com> Yeah, thanks David :) On Sun, Nov 15, 2009 at 10:13 PM, David Chelimsky wrote: > On Sun, Nov 15, 2009 at 7:50 PM, Marcelo de Moraes Serpa < > celoserpa at gmail.com> wrote: > >> Hello list, >> >> I had a hard time to find out a way to mock the singleton feed method of >> the following class: >> class RssReader >> >> def self.feed(feed_url) >> output = [] >> open(feed_url) do |http| >> response = http.read >> result = RSS::Parser.parse(response, false) >> result.items.each_with_index do |item, i| >> output << {:title => item.title, :description => item.description, >> :pubDate => item.pubDate, :link => item.link} >> end unless result.nil? >> end >> output >> end >> end >> >> > Try this: > > describe "..." do > it "..." do > http = mock('http') > RssReader.should_receive(:open).with('http://this.url')and_yield(http) > http.should_receive(:read) .... > ... > RssReader.feed('http://this.url') > end > end > > Make sense? > > David > > >> Since it is being passed a block, I could not intercept the code inside >> the block, the specific code I'd like to stub is the http.read. I have tried >> to do: >> >> Http.should_receive(:read).and_return(xml) #xml being a fixture, loaded >> from a file. >> >> However, the stub is not applied. >> >> Any ideas on how this could be solved? The only way I could think is to >> avoid using the block... >> >> Thanks, >> >> Marcelo. >> >> >> >> _______________________________________________ >> 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 celoserpa at gmail.com Mon Nov 16 00:36:57 2009 From: celoserpa at gmail.com (Marcelo de Moraes Serpa) Date: Sun, 15 Nov 2009 23:36:57 -0600 Subject: [rspec-users] Stub a call that happens inside a block In-Reply-To: <57c63afe0911152013g784ab823g4709f3f580d75267@mail.gmail.com> References: <1e5bcefd0911151950w5bf188ddi34e8521c31bb4eed@mail.gmail.com> <57c63afe0911152013g784ab823g4709f3f580d75267@mail.gmail.com> Message-ID: <1e5bcefd0911152136x6aade8dat1eb02b6026e8e7ad@mail.gmail.com> Yes, thanks, David! On Sun, Nov 15, 2009 at 10:13 PM, David Chelimsky wrote: > On Sun, Nov 15, 2009 at 7:50 PM, Marcelo de Moraes Serpa < > celoserpa at gmail.com> wrote: > >> Hello list, >> >> I had a hard time to find out a way to mock the singleton feed method of >> the following class: >> class RssReader >> >> def self.feed(feed_url) >> output = [] >> open(feed_url) do |http| >> response = http.read >> result = RSS::Parser.parse(response, false) >> result.items.each_with_index do |item, i| >> output << {:title => item.title, :description => item.description, >> :pubDate => item.pubDate, :link => item.link} >> end unless result.nil? >> end >> output >> end >> end >> >> > Try this: > > describe "..." do > it "..." do > http = mock('http') > RssReader.should_receive(:open).with('http://this.url')and_yield(http) > http.should_receive(:read) .... > ... > RssReader.feed('http://this.url') > end > end > > Make sense? > > David > > >> Since it is being passed a block, I could not intercept the code inside >> the block, the specific code I'd like to stub is the http.read. I have tried >> to do: >> >> Http.should_receive(:read).and_return(xml) #xml being a fixture, loaded >> from a file. >> >> However, the stub is not applied. >> >> Any ideas on how this could be solved? The only way I could think is to >> avoid using the block... >> >> Thanks, >> >> Marcelo. >> >> >> >> _______________________________________________ >> 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 Mon Nov 16 02:02:44 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Mon, 16 Nov 2009 08:02:44 +0100 Subject: [rspec-users] undefined method `route_for In-Reply-To: <57c63afe0911130639w1168fdbav5aebcb019f563eb@mail.gmail.com> References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> <57c63afe0911130639w1168fdbav5aebcb019f563eb@mail.gmail.com> Message-ID: <37480320c538326c804860007ae1e26b@ruby-forum.com> Oh that means if i am using rails version 2.1.2 or more then i need to have rspec version 1.1.12. In that case i need to remove the latest version and install rspec 1.1.12. I will do it and update you asap. Thanks a lot David. -- Posted via http://www.ruby-forum.com/. From andy.koch at pc-doctor.com Mon Nov 16 14:32:35 2009 From: andy.koch at pc-doctor.com (Andy Koch) Date: Mon, 16 Nov 2009 11:32:35 -0800 (PST) Subject: [rspec-users] rails /lib module testing Message-ID: <227ab20e-54e3-4651-ac03-b4aadd433b31@x25g2000prf.googlegroups.com> I've seen several posts related, but not touching on what I'm wondering... I have a lib module that I'd like to do 'white-box' testing - similar to a Rails mvc. But I can't see how to get a handle on the internal instance vars in the method. here are some code snippets that probably best explain my situation... ######################################################### require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe AasmCrawler do context "create_message method" do it "should create a new Link message" do @link.should == Link.new end end end ######################################################### module AasmCrawler def create_message @link = Link.new end end ######################################################### I've tried "assigns[:link]" but "assigns" is not known. I've also seen comments to test this via a model where it is included - but that seems like WET testing, if this is used repeatedly why not test it once at the source? thanks for any help From elliot.winkler at gmail.com Mon Nov 16 20:38:47 2009 From: elliot.winkler at gmail.com (Elliot Winkler) Date: Mon, 16 Nov 2009 19:38:47 -0600 Subject: [rspec-users] rails /lib module testing In-Reply-To: <227ab20e-54e3-4651-ac03-b4aadd433b31@x25g2000prf.googlegroups.com> References: <227ab20e-54e3-4651-ac03-b4aadd433b31@x25g2000prf.googlegroups.com> Message-ID: <4B01FEA7.8000509@gmail.com> That's because assigns only works in a Rails functional test. If you're the author of the module, you could add a self.included block that then sets up an attr_reader :link, like so: def self.included(base) base.class_eval do attr_reader :link end end Then, all you have to say is @link.link.should == Link.new. Otherwise, you can access the instance variable within @link using instance_variable_get. So @link.instance_variable_get("@link").should == Link.new. -- Elliot On 11/16/09 1:32 PM, Andy Koch wrote: > I've seen several posts related, but not touching on what I'm > wondering... > > I have a lib module that I'd like to do 'white-box' testing - similar > to a Rails mvc. But I can't see how to get a handle on the internal > instance vars in the method. > > here are some code snippets that probably best explain my situation... > > ######################################################### > require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') > > describe AasmCrawler do > > context "create_message method" do > it "should create a new Link message" do > @link.should == Link.new > end > end > end > ######################################################### > module AasmCrawler > def create_message > @link = Link.new > end > end > ######################################################### > > I've tried "assigns[:link]" but "assigns" is not known. > > I've also seen comments to test this via a model where it is included > - but that seems like WET testing, if this is used repeatedly why not > test it once at the source? > > thanks for any help > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Tue Nov 17 07:53:22 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Tue, 17 Nov 2009 13:53:22 +0100 Subject: [rspec-users] undefined method `route_for In-Reply-To: <37480320c538326c804860007ae1e26b@ruby-forum.com> References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> <57c63afe0911130639w1168fdbav5aebcb019f563eb@mail.gmail.com> <37480320c538326c804860007ae1e26b@ruby-forum.com> Message-ID: <097b6352040480b2f8a6f78ea85769cd@ruby-forum.com> Amit Kulkarni wrote: > Oh that means if i am using rails version 2.1.2 or more then i need to > have rspec version 1.1.12. > In that case i need to remove the latest version and install rspec > 1.1.12. > I will do it and update you asap. > Thanks a lot David. Hi David, As per the doc i updated my gems.Version of my gems are : Rails : 2.1.2 Rspec : 1.1.12 Rspec-Rails : 1.1.12 But when i run my files same error is being displayed. I am working on Windows vista.Does this may impact running my spec? Please suggest. -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Tue Nov 17 10:11:14 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 17 Nov 2009 07:11:14 -0800 Subject: [rspec-users] undefined method `route_for In-Reply-To: <097b6352040480b2f8a6f78ea85769cd@ruby-forum.com> References: <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> <57c63afe0911130639w1168fdbav5aebcb019f563eb@mail.gmail.com> <37480320c538326c804860007ae1e26b@ruby-forum.com> <097b6352040480b2f8a6f78ea85769cd@ruby-forum.com> Message-ID: <57c63afe0911170711k4f04bdb8weadb244ccab7d540@mail.gmail.com> On Tue, Nov 17, 2009 at 4:53 AM, Amit Kulkarni wrote: > Amit Kulkarni wrote: > > Oh that means if i am using rails version 2.1.2 or more then i need to > > have rspec version 1.1.12. > > In that case i need to remove the latest version and install rspec > > 1.1.12. > > I will do it and update you asap. > > Thanks a lot David. > > Hi David, > As per the doc i updated my gems.Version of my gems are : > Rails : 2.1.2 > Rspec : 1.1.12 > Rspec-Rails : 1.1.12 > > But when i run my files same error is being displayed. > I am working on Windows vista.Does this may impact running my spec? > Please suggest. > This back and forth is not productive. Please zip up the app and send it to me so I can see the whole thing in context. Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Nov 17 11:46:59 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Tue, 17 Nov 2009 17:46:59 +0100 Subject: [rspec-users] undefined method `route_for In-Reply-To: <57c63afe0911170711k4f04bdb8weadb244ccab7d540@mail.gmail.com> References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> <57c63afe0911130639w1168fdbav5aebcb019f563eb@mail.gmail.com> <37480320c538326c804860007ae1e26b@ruby-forum.com> <097b6352040480b2f8a6f78ea85769cd@ruby-forum.com> <57c63afe0911170711k4f04bdb8weadb244ccab7d540@mail.gmail.com> Message-ID: Ok Fine.That sounds to be a good idea. Thanks -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Nov 17 18:04:23 2009 From: lists at ruby-forum.com (David Nawara) Date: Wed, 18 Nov 2009 00:04:23 +0100 Subject: [rspec-users] rspec-rails gem double quoting (My)SQL? Message-ID: Hi all, This seems like a plugin conflict (I haven't yet had success replicating this in a new project), but short version is: when I have "rspec-rails" in my environment.rb plugin config, table names are double quoted in mysql queries generated by my standard finders. rspec-rails commented out: SELECT * FROM `users` WHERE (`users`.`id` = '159564615') LIMIT 1 rspec-rails in enviroment.rb gem config: SELECT * FROM "users" WHERE ("users"."id" = '159564615') LIMIT 1 The double quotes break the SQL, and so no objects are returned from my queries. This happened after I updated to 1.2.9 gem versions when I couldn't get cucumber (0.4.4) to look for git submodules in my project. Any ideas? I'm pretty lost at the moment, and don't want to run without rspec (it makes me feel neked). Short version of my required gems: cucumber (0.4.4) mysql (2.8.1) rails (2.3.4) rspec (1.2.9) rspec-rails (1.2.9) /Dave -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Tue Nov 17 18:10:35 2009 From: lists at ruby-forum.com (David Nawara) Date: Wed, 18 Nov 2009 00:10:35 +0100 Subject: [rspec-users] rspec-rails gem double quoting (My)SQL? In-Reply-To: References: Message-ID: <1adbbb3490f9bc62814b9c7da7790829@ruby-forum.com> Forgot to mention: I'd love to track this down myself, but i'm not getting a backtrace as there is no error (just no results). Point me in the right direction and I'll do what I can to solve this. -- Posted via http://www.ruby-forum.com/. From tom at experthuman.com Wed Nov 18 05:53:55 2009 From: tom at experthuman.com (Tom Stuart) Date: Wed, 18 Nov 2009 10:53:55 +0000 Subject: [rspec-users] MockExpectationError actual args format for stubbed messages Message-ID: <27266F91-498F-4D5A-A88B-7C546A2D393C@experthuman.com> Hi, Is it realistic and desirable to tweak RSpec so that the MockExpectationError for a stubbed message works as specified in the attached spec patch? In short, we wasted some time today on a wild goose chase because a failing expectation error was saying "unexpected arguments, expected: (#, #), got: ([#, #])" which made it look like we were accidentally building an array around our arguments somewhere in our implementation. Ultimately it turned out that it was a genuine problem with equality between the Foo instances but we were distracted by the array notation for the actual arguments. Having looked at the RSpec specs I now see that this is intended behaviour because the error is reporting an array of argument arrays, one for each unexpected message. This is understandable but, I think, unnecessarily misleading; it would be much nicer if the most common case (only one unexpected message) looked like "got: (#, #)" and we found another syntax for showing multiple calls. In the spec patch I've suggested "got: (#, #), (#, #)" because that shows multiple messages while avoiding any confusion about whether actual arrays were involved. I realise this would involve some changes to the plumbing around ErrorGenerator so that the semantics of #raise_unexpected_message_args_error become "here is a (usually single-element) array of argument arrays" rather than the current hack of "here is an argument array (except occasionally it won't quite be, but always display it as though it is)". I'm happy to investigate, but before I do, does my suggestion meet with general approval? Cheers, -Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: format_args_for_stubbed_message_expectations.diff Type: application/octet-stream Size: 2070 bytes Desc: not available URL: From lists at ruby-forum.com Wed Nov 18 13:39:28 2009 From: lists at ruby-forum.com (David Nawara) Date: Wed, 18 Nov 2009 19:39:28 +0100 Subject: [rspec-users] rspec-rails gem changing connection adapter In-Reply-To: <1adbbb3490f9bc62814b9c7da7790829@ruby-forum.com> References: <1adbbb3490f9bc62814b9c7da7790829@ruby-forum.com> Message-ID: This thread should be titled: "rspec-rails gem changing connection adapter?" I did some puts's and found that something is changing the connection adapter to ActiveRecord::ConnectionAdapters::SQLite3Adapter, from my specified ActiveRecord::ConnectionAdapters::MysqlAdapter. Or maybe it's causing my connection settings not to apply? Still not sure if I'm barking up the wrong tree, but the problem still does fix itself when i comment out my rspec-rails gem. -- Posted via http://www.ruby-forum.com/. From joe at pinkpucker.net Wed Nov 18 14:12:53 2009 From: joe at pinkpucker.net (Joe Van Dyk) Date: Wed, 18 Nov 2009 11:12:53 -0800 Subject: [rspec-users] undefined method `register' for Polyglot:Module Message-ID: Getting this error. I have the treetop, polyglot, and rspec libraries in the load_path (not installed as a gem). Any ideas? What defines the register method? /home/jvandyk/dev/web/wpn_rails/../../rcommon/lib/test/treetop/lib/treetop.rb:16: undefined method `register' for Polyglot:Module (NoMethodError) from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber/parser/treetop_ext.rb:2:in `require' from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber/parser/treetop_ext.rb:2 from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber/parser.rb:4:in `require' from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber/parser.rb:4 from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber.rb:6:in `require' from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber.rb:6 -- Joe Van Dyk http://fixieconsulting.com From joe at pinkpucker.net Wed Nov 18 14:20:36 2009 From: joe at pinkpucker.net (Joe Van Dyk) Date: Wed, 18 Nov 2009 11:20:36 -0800 Subject: [rspec-users] undefined method `register' for Polyglot:Module In-Reply-To: References: Message-ID: Oh, hm. Looks like there's a lot of projects with the name 'polyglot'. Hm. On Wed, Nov 18, 2009 at 11:12 AM, Joe Van Dyk wrote: > Getting this error. ?I have the treetop, polyglot, and rspec libraries > in the load_path (not installed as a gem). ?Any ideas? ?What defines > the register method? > > /home/jvandyk/dev/web/wpn_rails/../../rcommon/lib/test/treetop/lib/treetop.rb:16: > undefined method `register' for Polyglot:Module (NoMethodError) > ? ? ? ?from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber/parser/treetop_ext.rb:2:in > `require' > ? ? ? ?from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber/parser/treetop_ext.rb:2 > ? ? ? ?from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber/parser.rb:4:in > `require' > ? ? ? ?from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber/parser.rb:4 > ? ? ? ?from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber.rb:6:in > `require' > ? ? ? ?from /home/jvandyk/dev/rcommon/lib/test/cucumber/bin/../lib/cucumber.rb:6 > > > -- > Joe Van Dyk > http://fixieconsulting.com > -- Joe Van Dyk http://fixieconsulting.com From matt at mattwynne.net Wed Nov 18 14:22:36 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 18 Nov 2009 19:22:36 +0000 Subject: [rspec-users] rspec-rails gem changing connection adapter In-Reply-To: References: <1adbbb3490f9bc62814b9c7da7790829@ruby-forum.com> Message-ID: <0FA40C49-D183-4EA9-8AC3-769839FE9A09@mattwynne.net> On 18 Nov 2009, at 18:39, David Nawara wrote: > This thread should be titled: "rspec-rails gem changing connection > adapter?" > > I did some puts's and found that something is changing the connection > adapter to ActiveRecord::ConnectionAdapters::SQLite3Adapter, from my > specified ActiveRecord::ConnectionAdapters::MysqlAdapter. Or maybe > it's > causing my connection settings not to apply? > > Still not sure if I'm barking up the wrong tree, but the problem still > does fix itself when i comment out my rspec-rails gem. Which version of the rspec-rails gem are you using? Can you check the value of RAILS_ENV before and after the connection adapter gets changed? There are plugins and various other things (including an old version of rspec-rails) that stomp on RAILS_ENV when they load. That might be the problem. cheers, Matt +447974 430184 matt at mattwynne.net http://mattwynne.net From lists at ruby-forum.com Wed Nov 18 14:34:28 2009 From: lists at ruby-forum.com (David Nawara) Date: Wed, 18 Nov 2009 20:34:28 +0100 Subject: [rspec-users] rspec-rails gem changing connection adapter In-Reply-To: <0FA40C49-D183-4EA9-8AC3-769839FE9A09@mattwynne.net> References: <1adbbb3490f9bc62814b9c7da7790829@ruby-forum.com> <0FA40C49-D183-4EA9-8AC3-769839FE9A09@mattwynne.net> Message-ID: Yeah I think you're right. I'm working on this now... I noticed the only RAILS_ENV I have set on sqlite is the test environment (in database.yml), and cucumber is now doing some ||= fun on the RAILS_ENV, so I'm following that trail. I suspect something (cucumber?) is setting me to the test or cucumber RAiLS_ENV. Thanks for the post! Matt Wynne wrote: > On 18 Nov 2009, at 18:39, David Nawara wrote: > >> does fix itself when i comment out my rspec-rails gem. > Which version of the rspec-rails gem are you using? > > Can you check the value of RAILS_ENV before and after the connection > adapter gets changed? There are plugins and various other things > (including an old version of rspec-rails) that stomp on RAILS_ENV when > they load. That might be the problem. > > cheers, > Matt > > +447974 430184 > matt at mattwynne.net > http://mattwynne.net -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Wed Nov 18 14:54:40 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 18 Nov 2009 11:54:40 -0800 Subject: [rspec-users] MockExpectationError actual args format for stubbed messages In-Reply-To: <27266F91-498F-4D5A-A88B-7C546A2D393C@experthuman.com> References: <27266F91-498F-4D5A-A88B-7C546A2D393C@experthuman.com> Message-ID: <57c63afe0911181154w6f643ef5l7295a68381056d5@mail.gmail.com> On Wed, Nov 18, 2009 at 2:53 AM, Tom Stuart wrote: > Hi, > > Is it realistic and desirable to tweak RSpec so that the > MockExpectationError for a stubbed message works as specified in the > attached spec patch? > > In short, we wasted some time today on a wild goose chase because a failing > expectation error was saying "unexpected arguments, expected: (#, > #), got: ([#, #])" which made it look like we > were accidentally building an array around our arguments somewhere in our > implementation. Ultimately it turned out that it was a genuine problem with > equality between the Foo instances but we were distracted by the array > notation for the actual arguments. > > Having looked at the RSpec specs I now see that this is intended behaviour > because the error is reporting an array of argument arrays, one for each > unexpected message. This is understandable but, I think, unnecessarily > misleading; it would be much nicer if the most common case (only one > unexpected message) looked like "got: (#, #)" and we found > another syntax for showing multiple calls. In the spec patch I've suggested > "got: (#, #), (#, #)" because that shows > multiple messages while avoiding any confusion about whether actual arrays > were involved. > > I realise this would involve some changes to the plumbing around > ErrorGenerator so that the semantics of #raise_unexpected_message_args_error > become "here is a (usually single-element) array of argument arrays" rather > than the current hack of "here is an argument array (except occasionally it > won't quite be, but always display it as though it is)". > > I'm happy to investigate, but before I do, does my suggestion meet with > general approval? > Approved! Please submit a lighthouse ticket and reference a patch from there. Thanks! David -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Nov 18 15:07:48 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 18 Nov 2009 12:07:48 -0800 Subject: [rspec-users] rspec-rails gem double quoting (My)SQL? In-Reply-To: References: Message-ID: <57c63afe0911181207q18137444s814f4bc5b659610d@mail.gmail.com> On Tue, Nov 17, 2009 at 3:04 PM, David Nawara wrote: > Hi all, > > This seems like a plugin conflict (I haven't yet had success replicating > this in a new project), but short version is: when I have "rspec-rails" > in my environment.rb plugin config, table names are double quoted in > mysql queries generated by my standard finders. > > rspec-rails commented out: > > SELECT * FROM `users` WHERE (`users`.`id` = '159564615') LIMIT 1 > > rspec-rails in enviroment.rb gem config: > > SELECT * FROM "users" WHERE ("users"."id" = '159564615') LIMIT 1 > > The double quotes break the SQL, and so no objects are returned from my > queries. This happened after I updated to 1.2.9 gem versions when I > couldn't get cucumber (0.4.4) to look for git submodules in my project. > > Any ideas? I'm pretty lost at the moment, and don't want to run without > rspec (it makes me feel neked). > > Short version of my required gems: > > cucumber (0.4.4) > mysql (2.8.1) > rails (2.3.4) > rspec (1.2.9) > rspec-rails (1.2.9) > > > /Dave I really don't think this is an rspec-rails issue, though I'm certainly happy to apply a patch if I'm wrong. The thing is that there is no code that I'm aware of in the rspec-rails gem that would impact what sql is generated. If you can find a way to repeat the error and zip up an app for me to look at I'd be glad to. Cheers, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Nov 18 15:08:33 2009 From: lists at ruby-forum.com (David Nawara) Date: Wed, 18 Nov 2009 21:08:33 +0100 Subject: [rspec-users] rspec-rails gem changing connection adapter In-Reply-To: References: <1adbbb3490f9bc62814b9c7da7790829@ruby-forum.com> <0FA40C49-D183-4EA9-8AC3-769839FE9A09@mattwynne.net> Message-ID: <00938bb26d14ae1461ea8861dccb4318@ruby-forum.com> I'm not totally there, but I'm pretty sure it's down to the authlogic plugin. Thanks for your help, and sorry about the misfire on rspec. (I didn't think that one made sense, but it's all I had at the time.) I've actually found I can comment out loading observers in my environment.rb and things will work, or i can remove my acts_as_authentic tag on my users and I'm OK. I'm mostly certain it's a plugin load order thing kicking me to the test environment. Regards, David -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Nov 18 17:17:47 2009 From: lists at ruby-forum.com (David Nawara) Date: Wed, 18 Nov 2009 23:17:47 +0100 Subject: [rspec-users] rspec-rails gem double quoting (My)SQL? In-Reply-To: <57c63afe0911181207q18137444s814f4bc5b659610d@mail.gmail.com> References: <57c63afe0911181207q18137444s814f4bc5b659610d@mail.gmail.com> Message-ID: <3c8a7450d27ab6f83f6dc39d5c163d14@ruby-forum.com> In case anyone feels like messing with this, I've replicated the problem in a minimal test application... The problem seems to be some sort of load issue. From what I can tell, it is due to three related items: 1) a user model with authlogic, 2) rspec-rails, and 3) a users observer. Removing any one of the three seems to "fix" the issue. I've noted the lines which you can comment out to see the problem resolve. (It should then load the development SQLite3 database with my test user). The visible symptom is: > SQLite3::SQLException: no such table: users: SELECT * FROM "users" Apparently the conflict pushes the app into the test environment. Gems: - authlogic 2.1.3 - rspec and rspec-rails 1.2.9 - rails 2.3.4 I'm on passenger 2.2.5, and I hope that's not a factor. I currently run stock Snow Leopard ruby. Any clue how I can further track this down? I don't see anything obvious with either rspec or authlogic fudging with the environment? Regards, David Nawara PS - I think I'll go post this in an authlogic forum now. Attachments: http://www.ruby-forum.com/attachment/4263/testapp.tgz -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Nov 18 18:26:39 2009 From: lists at ruby-forum.com (Robertico Gonzalez) Date: Thu, 19 Nov 2009 00:26:39 +0100 Subject: [rspec-users] Cucumber and IP PBX testing Message-ID: <6762cab9ece5aeac50cee2e0c9dea093@ruby-forum.com> Hi, I am new to Cucumber. I am a test engineer for an IP PBX. Has anyone tried to use Cucumber to test such application? Some of the actions that I need to perform are: Given: a) Configure parameters on a web site to change phone behavior b) Configure parameters on a web site to change trunk behavior c) Configure parameters on a web site to change system wide behavior When: a) Make a call from phone A to phone b b) Press Transfer or Conference softkey c) Configure Call Forward All from phone Then: a) Verify audio between two phones b) Verify phone displays c) Verify phone status prompt I imagine I need to translate these steps into Ruby to see if they pass or fail. I don't have control over the code that developer write for features, since I am just a tester. We write scripts in TCL to automate our test cases. Any pointers or suggestions are welcome. Regards, Robertico -- Posted via http://www.ruby-forum.com/. From lee.hambley at gmail.com Wed Nov 18 18:41:59 2009 From: lee.hambley at gmail.com (Lee Hambley) Date: Thu, 19 Nov 2009 00:41:59 +0100 Subject: [rspec-users] Cucumber and IP PBX testing In-Reply-To: <6762cab9ece5aeac50cee2e0c9dea093@ruby-forum.com> References: <6762cab9ece5aeac50cee2e0c9dea093@ruby-forum.com> Message-ID: Robertico, Provided you can match the items you need to click, select, fill in and alter with CSS (see assert_select: http://blog.labnotes.org/2006/09/04/assert_select-cheat-sheet/) selectors, you can do all of these things -- Lee Hambley Twitter: @leehambley | @capistranorb -------------- next part -------------- An HTML attachment was scrubbed... URL: From beccy_anne at hotmail.com Thu Nov 19 07:11:11 2009 From: beccy_anne at hotmail.com (bqaanne) Date: Thu, 19 Nov 2009 04:11:11 -0800 (PST) Subject: [rspec-users] Running simple rspec, no output Message-ID: <26421308.post@talk.nabble.com> Hi, I am very new to Ruby and Rspec, and found a simple tutorial online about rspec. It involves two files: bowling.rb and bowling_spec.rb # bowling_spec.rb require'rubygems' require 'spec' require 'bowling' describe Bowling do it "should score 0 for gutter game" do bowling = Bowling.new 20.times { bowling.hit(0) } bowling.score.should == 0 end end #bowling.rb class Bowling def hit(pins) end def score 1 end end When I run the spec, I expect to see some sort of output along these lines: "Bowling should score 0 for gutter game". When I run it (from text mate) there are no errors, and there is no output. I see the same result running it from the command line. Am I doing something wrong? Thanks, Beccy -- View this message in context: http://old.nabble.com/Running-simple-rspec%2C-no-output-tp26421308p26421308.html Sent from the rspec-users mailing list archive at Nabble.com. From grimen at gmail.com Wed Nov 18 10:05:13 2009 From: grimen at gmail.com (grimen) Date: Wed, 18 Nov 2009 07:05:13 -0800 (PST) Subject: [rspec-users] Gemspec development dependencies seems to be messed up Message-ID: <84e76cb5-a823-47d8-9bb5-a6e67ce98e32@b15g2000yqd.googlegroups.com> $ sudo gem install rspec-rails --development Password: ERROR: Error installing rspec-rails: rspec requires cucumber (>= 0.3, development) ...and when installed cucumber manually, it ends up with weird stuff. Is this RSpec issue or a RubyGems issue? From dchelimsky at gmail.com Thu Nov 19 11:13:50 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Nov 2009 08:13:50 -0800 Subject: [rspec-users] Running simple rspec, no output In-Reply-To: <26421308.post@talk.nabble.com> References: <26421308.post@talk.nabble.com> Message-ID: <57c63afe0911190813y5f632d9ayc00c35027fb472ce@mail.gmail.com> On Thu, Nov 19, 2009 at 4:11 AM, bqaanne wrote: > > Hi, > > I am very new to Ruby and Rspec, and found a simple tutorial online about > rspec. > > It involves two files: > bowling.rb and bowling_spec.rb > > # bowling_spec.rb > require'rubygems' > require 'spec' > require 'bowling' > > describe Bowling do > it "should score 0 for gutter game" do > bowling = Bowling.new > 20.times { bowling.hit(0) } > bowling.score.should == 0 > end > end > > #bowling.rb > class Bowling > def hit(pins) > end > > def score > 1 > end > end > > When I run the spec, I expect to see some sort of output along these lines: > "Bowling should score 0 for gutter game". > > When I run it (from text mate) there are no errors, and there is no output. > I see the same result running it from the command line. > > Am I doing something wrong? > > Thanks, > Beccy What command are you using from the command line? And what about in textmate? Do you have the RSpec tmbundle installed? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Thu Nov 19 12:30:48 2009 From: zach.dennis at gmail.com (Zach Dennis) Date: Thu, 19 Nov 2009 12:30:48 -0500 Subject: [rspec-users] Cucumber and IP PBX testing In-Reply-To: <6762cab9ece5aeac50cee2e0c9dea093@ruby-forum.com> References: <6762cab9ece5aeac50cee2e0c9dea093@ruby-forum.com> Message-ID: <85d99afe0911190930u18afa728ha37f03b1ecb08a89@mail.gmail.com> On Wed, Nov 18, 2009 at 6:26 PM, Robertico Gonzalez wrote: > Hi, > > I am new to Cucumber. ?I am a test engineer for an IP PBX. ?Has anyone > tried to use Cucumber to test such application? ?Some of the actions > that I need to perform are: > > Given: > a) Configure parameters on a web site to change phone behavior > b) Configure parameters on a web site to change trunk behavior > c) Configure parameters on a web site to change system wide behavior > > When: > a) Make a call from phone A to phone b > b) Press Transfer or Conference softkey > c) Configure Call Forward All from phone > > Then: > a) Verify audio between two phones > b) Verify phone displays > c) Verify phone status prompt > > I imagine I need to translate these steps into Ruby to see if they pass > or fail. ?I don't have control over the code that developer write for > features, since I am just a tester. We write scripts in TCL to automate > our test cases. > > Any pointers or suggestions are welcome. A while back I looked at using Twilio to do automated integration testing a phone system. I started talking with some of their engineers, but then the conversation just stopped. I didn't know if they got busy or thought I was crazy. :) You can setup twilio accounts, one as a receiver and one as the dialer. I got a proof of concept working with Cucumber as the driving force, but I haven't worked on that application in a while. Perhaps twilio has provided some tools for this by now. This probably isn't what you were looking for, but thought I'd share the idea in case anyone has interest, > > Regards, > Robertico > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- 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 lists at ruby-forum.com Thu Nov 19 15:27:00 2009 From: lists at ruby-forum.com (David Nawara) Date: Thu, 19 Nov 2009 21:27:00 +0100 Subject: [rspec-users] rspec-rails gem double quoting (My)SQL? In-Reply-To: <3c8a7450d27ab6f83f6dc39d5c163d14@ruby-forum.com> References: <57c63afe0911181207q18137444s814f4bc5b659610d@mail.gmail.com> <3c8a7450d27ab6f83f6dc39d5c163d14@ruby-forum.com> Message-ID: <5efa2903c30ee1184a55c4f81ec880a8@ruby-forum.com> The problem goes away when I ditch the gems and grab the plugins off github. (The archive is too large, or I'd upload that version.) Now I just have to get cucumber working with plugins, which is the reason I switched to gems in the first place? -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Thu Nov 19 16:50:47 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 19 Nov 2009 13:50:47 -0800 Subject: [rspec-users] Gemspec development dependencies seems to be messed up In-Reply-To: <84e76cb5-a823-47d8-9bb5-a6e67ce98e32@b15g2000yqd.googlegroups.com> References: <84e76cb5-a823-47d8-9bb5-a6e67ce98e32@b15g2000yqd.googlegroups.com> Message-ID: <57c63afe0911191350t66651e89r3057640f967fe8a@mail.gmail.com> On Wed, Nov 18, 2009 at 7:05 AM, grimen wrote: > $ sudo gem install rspec-rails --development > Password: > ERROR: Error installing rspec-rails: > rspec requires cucumber (>= 0.3, development) > > > ...and when installed cucumber manually, it ends up with weird stuff. > Can you be more specific? > Is this RSpec issue or a RubyGems issue? > I have no idea yet. I was able to run "sudo gem install rspec-rails --development" with no trouble. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy.koch at pc-doctor.com Fri Nov 20 01:02:28 2009 From: andy.koch at pc-doctor.com (Andy Koch) Date: Thu, 19 Nov 2009 22:02:28 -0800 (PST) Subject: [rspec-users] autospec not detecting new files Message-ID: <6f19008b-e641-438e-98fc-e9a9d8d5e37a@y32g2000prd.googlegroups.com> Hi, I have a project where autospec is not adding new files to it's test list. When I run 'rake spec' it finds and runs the spec files. Wondering if there is a cache file that autospec is using? I've searched for an answer, while I've learned lots of interesting other tidbits - no answer to what might be happening here. thanks for any help From sfeley at gmail.com Fri Nov 20 01:22:23 2009 From: sfeley at gmail.com (Stephen Eley) Date: Fri, 20 Nov 2009 01:22:23 -0500 Subject: [rspec-users] autospec not detecting new files In-Reply-To: <6f19008b-e641-438e-98fc-e9a9d8d5e37a@y32g2000prd.googlegroups.com> References: <6f19008b-e641-438e-98fc-e9a9d8d5e37a@y32g2000prd.googlegroups.com> Message-ID: <1fb4df0911192222kc10a139k28c9576a9a64edea@mail.gmail.com> On Fri, Nov 20, 2009 at 1:02 AM, Andy Koch wrote: > > I have a project where autospec is not adding new files to it's test > list. Autotest (which autospec is really just a wrapper around) builds its file list when it initializes. After that its looping is pretty specific. If you want to refresh it with all new changes, you can hit CTRL-C any time and it'll start again from scratch. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From beccy_anne at hotmail.com Fri Nov 20 04:51:38 2009 From: beccy_anne at hotmail.com (bqaanne) Date: Fri, 20 Nov 2009 01:51:38 -0800 (PST) Subject: [rspec-users] Running simple rspec, no output In-Reply-To: <57c63afe0911190813y5f632d9ayc00c35027fb472ce@mail.gmail.com> References: <26421308.post@talk.nabble.com> <57c63afe0911190813y5f632d9ayc00c35027fb472ce@mail.gmail.com> Message-ID: <26435264.post@talk.nabble.com> >What command are you using from the command line? And what about in >textmate? Do you have the RSpec tmbundle installed? When I run from the command line I use "ruby bowling_spec.rb" and it appears to just do nothing, but no errors are thrown. When I run in text mate, i just save the file and hit Apple+R to run the file. Again there is no output. I have not installed the RSpec tmbundle - having never heard of it before - I will do that and see what happens in text mate, however the fact that its not doing anything on the command line either suggests this is not the problem. -- View this message in context: http://old.nabble.com/Running-simple-rspec%2C-no-output-tp26421308p26435264.html Sent from the rspec-users mailing list archive at Nabble.com. From beccy_anne at hotmail.com Fri Nov 20 05:25:28 2009 From: beccy_anne at hotmail.com (bqaanne) Date: Fri, 20 Nov 2009 02:25:28 -0800 (PST) Subject: [rspec-users] Running simple rspec, no output In-Reply-To: <26435264.post@talk.nabble.com> References: <26421308.post@talk.nabble.com> <57c63afe0911190813y5f632d9ayc00c35027fb472ce@mail.gmail.com> <26435264.post@talk.nabble.com> Message-ID: <26436844.post@talk.nabble.com> Problem solved. I was being an idiot. I type in "spec bowling_spec.rb" at command line. And installed the text mate bundle as suggested to allow text mate to display the results. bqaanne wrote: > > > >>What command are you using from the command line? And what about in >>textmate? Do you have the RSpec tmbundle installed? > > When I run from the command line I use "ruby bowling_spec.rb" and it > appears to just do nothing, but no errors are thrown. When I run in text > mate, i just save the file and hit Apple+R to run the file. Again there is > no output. I have not installed the RSpec tmbundle - having never heard of > it before - I will do that and see what happens in text mate, however the > fact that its not doing anything on the command line either suggests this > is not the problem. > > > > > -- View this message in context: http://old.nabble.com/Running-simple-rspec%2C-no-output-tp26421308p26436844.html Sent from the rspec-users mailing list archive at Nabble.com. From grimen at gmail.com Fri Nov 20 08:26:49 2009 From: grimen at gmail.com (grimen) Date: Fri, 20 Nov 2009 05:26:49 -0800 (PST) Subject: [rspec-users] Gemspec development dependencies seems to be messed up In-Reply-To: <57c63afe0911191350t66651e89r3057640f967fe8a@mail.gmail.com> References: <84e76cb5-a823-47d8-9bb5-a6e67ce98e32@b15g2000yqd.googlegroups.com> <57c63afe0911191350t66651e89r3057640f967fe8a@mail.gmail.com> Message-ID: OK, I noticed this only happen on Ruby 1.9 and jruby. Seems to be native compilation errors, but I don't get why all these should be installed: Successfully installed prawn-core-0.5.1 Successfully installed prawn-layout-0.3.2 Successfully installed echoe-4.0 Successfully installed prawn-format-0.2.3 Successfully installed prawn-0.5.1 Successfully installed spork-0.7.3 Successfully installed cucumber-0.4.4 Successfully installed bmabey-fakefs-0.1.1.1 Successfully installed ZenTest-4.1.4 Successfully installed RubyInline-3.8.3 Successfully installed sexp_processor-3.0.3 Successfully installed ParseTree-3.0.4 Successfully installed ruby_parser-2.0.4 Successfully installed ruby2ruby-1.2.4 Successfully installed heckle-1.4.3 Successfully installed test-spec-0.10.0 Successfully installed markaby-0.5 Successfully installed metaid-1.0 Successfully installed camping-1.5.180 Successfully installed memcache-client-1.7.6 Successfully installed ruby-openid-2.0.4 Successfully installed eventmachine-0.12.10 Successfully installed thin-1.2.5 Successfully installed racc-1.4.6 Successfully installed rexical-1.0.4 Successfully installed rake-compiler-0.6.0 26 gems installed Are all these really development dependencies? grimen On Nov 19, 10:50?pm, David Chelimsky wrote: > On Wed, Nov 18, 2009 at 7:05 AM, grimen wrote: > > $ sudo gem install rspec-rails --development > > Password: > > ERROR: ?Error installing rspec-rails: > > ? ? ? ?rspec requires cucumber (>= 0.3, development) > > > ...and when installed cucumber manually, it ends up with weird stuff. > > Can you be more specific? > > > Is this RSpec issue or a RubyGems issue? > > I have no idea yet. I was able to run "sudo gem install rspec-rails > --development" with no trouble. > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Nov 20 09:00:54 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Nov 2009 06:00:54 -0800 Subject: [rspec-users] Gemspec development dependencies seems to be messed up In-Reply-To: References: <84e76cb5-a823-47d8-9bb5-a6e67ce98e32@b15g2000yqd.googlegroups.com> <57c63afe0911191350t66651e89r3057640f967fe8a@mail.gmail.com> Message-ID: <57c63afe0911200600s17c1d657nb04cbdf693225b5e@mail.gmail.com> On Fri, Nov 20, 2009 at 5:26 AM, grimen wrote: > OK, I noticed this only happen on Ruby 1.9 and jruby. Seems to be > native compilation errors, but I don't get why all these should be > installed: > > Successfully installed prawn-core-0.5.1 > Successfully installed prawn-layout-0.3.2 > Successfully installed echoe-4.0 > Successfully installed prawn-format-0.2.3 > Successfully installed prawn-0.5.1 > Successfully installed spork-0.7.3 > Successfully installed cucumber-0.4.4 > Successfully installed bmabey-fakefs-0.1.1.1 > Successfully installed ZenTest-4.1.4 > Successfully installed RubyInline-3.8.3 > Successfully installed sexp_processor-3.0.3 > Successfully installed ParseTree-3.0.4 > Successfully installed ruby_parser-2.0.4 > Successfully installed ruby2ruby-1.2.4 > Successfully installed heckle-1.4.3 > Successfully installed test-spec-0.10.0 > Successfully installed markaby-0.5 > Successfully installed metaid-1.0 > Successfully installed camping-1.5.180 > Successfully installed memcache-client-1.7.6 > Successfully installed ruby-openid-2.0.4 > Successfully installed eventmachine-0.12.10 > Successfully installed thin-1.2.5 > Successfully installed racc-1.4.6 > Successfully installed rexical-1.0.4 > Successfully installed rake-compiler-0.6.0 > 26 gems installed > > > Are all these really development dependencies? > Of rspec, no, but they are dependencies of rspec's dependencies, and their dependencies, and so on, and so on, and so on ... > > > grimen > > On Nov 19, 10:50 pm, David Chelimsky wrote: > > On Wed, Nov 18, 2009 at 7:05 AM, grimen wrote: > > > $ sudo gem install rspec-rails --development > > > Password: > > > ERROR: Error installing rspec-rails: > > > rspec requires cucumber (>= 0.3, development) > > > > > ...and when installed cucumber manually, it ends up with weird stuff. > > > > Can you be more specific? > > > > > Is this RSpec issue or a RubyGems issue? > > > > I have no idea yet. I was able to run "sudo gem install rspec-rails > > --development" with no trouble. > > > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy.koch at pc-doctor.com Fri Nov 20 10:25:16 2009 From: andy.koch at pc-doctor.com (Andy Koch) Date: Fri, 20 Nov 2009 07:25:16 -0800 (PST) Subject: [rspec-users] autospec not detecting new files In-Reply-To: <1fb4df0911192222kc10a139k28c9576a9a64edea@mail.gmail.com> References: <6f19008b-e641-438e-98fc-e9a9d8d5e37a@y32g2000prd.googlegroups.com> <1fb4df0911192222kc10a139k28c9576a9a64edea@mail.gmail.com> Message-ID: <77d09dcd-156a-40cb-a24c-a40ac01a097f@a39g2000pre.googlegroups.com> Yes, unfortunately that's the problem I'm experiencing. Ctl-C isn't refreshing to find the new files. I stop completely and restart and still no luck. I've added (for a Rails app) a new controller and helper spec file and they only run if I "spec ..." or "rake spec". autospec (autotest) seems stuck on it's current file list - almost as if it has a file cache somewhere that isn't getting refreshed On Nov 19, 10:22?pm, Stephen Eley wrote: > On Fri, Nov 20, 2009 at 1:02 AM, Andy Koch wrote: > > > I have a project where autospec is not adding new files to it's test > > list. > > Autotest (which autospec is really just a wrapper around) builds its > file list when it initializes. ?After that its looping is pretty > specific. > > If you want to refresh it with all new changes, you can hit CTRL-C any > time and it'll start again from scratch. > > -- > Have Fun, > ? ?Steve Eley (sfe... at gmail.com) > ? ?ESCAPE POD - The Science Fiction Podcast Magazine > ? ?http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Nov 20 12:57:16 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 20 Nov 2009 09:57:16 -0800 Subject: [rspec-users] autospec not detecting new files In-Reply-To: <77d09dcd-156a-40cb-a24c-a40ac01a097f@a39g2000pre.googlegroups.com> References: <6f19008b-e641-438e-98fc-e9a9d8d5e37a@y32g2000prd.googlegroups.com> <1fb4df0911192222kc10a139k28c9576a9a64edea@mail.gmail.com> <77d09dcd-156a-40cb-a24c-a40ac01a097f@a39g2000pre.googlegroups.com> Message-ID: <57c63afe0911200957s9f41e43of0c14f7db4de0420@mail.gmail.com> On Fri, Nov 20, 2009 at 7:25 AM, Andy Koch wrote: > On Nov 19, 10:22 pm, Stephen Eley wrote: > > On Fri, Nov 20, 2009 at 1:02 AM, Andy Koch > wrote: > > > > > I have a project where autospec is not adding new files to it's test > > > list. > > > > Autotest (which autospec is really just a wrapper around) builds its > > file list when it initializes. After that its looping is pretty > > specific. > > > > If you want to refresh it with all new changes, you can hit CTRL-C any > > time and it'll start again from scratch. > > > > -- > > Have Fun, > > Steve Eley (sfe... at gmail.com) > > ESCAPE POD - The Science Fiction Podcast Magazine > > http://www.escapepod.org > Yes, unfortunately that's the problem I'm experiencing. > > Ctl-C isn't refreshing to find the new files. I stop completely and > restart and still no luck. I've added (for a Rails app) a new > controller and helper spec file and they only run if I "spec ..." or > "rake spec". > What are the names and paths to these files? > autospec (autotest) seems stuck on it's current file list - almost as > if it has a file cache somewhere that isn't getting refreshed > RSpec maintains no cache for this. Autotest does maintain a temporary cache (of sorts), but CTRL-C has always worked for me to refresh it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy.koch at pc-doctor.com Fri Nov 20 13:35:03 2009 From: andy.koch at pc-doctor.com (Andy Koch) Date: Fri, 20 Nov 2009 10:35:03 -0800 (PST) Subject: [rspec-users] autospec not detecting new files In-Reply-To: <57c63afe0911200957s9f41e43of0c14f7db4de0420@mail.gmail.com> References: <6f19008b-e641-438e-98fc-e9a9d8d5e37a@y32g2000prd.googlegroups.com> <1fb4df0911192222kc10a139k28c9576a9a64edea@mail.gmail.com> <77d09dcd-156a-40cb-a24c-a40ac01a097f@a39g2000pre.googlegroups.com> <57c63afe0911200957s9f41e43of0c14f7db4de0420@mail.gmail.com> Message-ID: Hi David, I think it's standard directory structure... andy at hst-26-147 (master)->tree spec/ spec/ |-- controllers | |-- perforce_logs_controller_spec.rb | |-- public_controller_spec.rb | |-- user_sessions_controller_spec.rb | |-- user_sessions_routing_spec.rb | `-- users_controller_spec.rb |-- factories | |-- branch_options.rb | |-- module_states.rb | `-- user.rb |-- fixtures | |-- roles.yml | `-- user_sessions.yml |-- helpers | |-- perforce_logs_helper_spec.rb | |-- public_helper_spec.rb | |-- user_sessions_helper_spec.rb | `-- users_helper_spec.rb |-- models | |-- branch_option_spec.rb | `-- role_spec.rb |-- rcov.opts |-- spec.opts |-- spec_helper.rb `-- views |-- layouts | |-- public.html.haml_spec.rb | `-- public_navigation.html.haml_spec.rb |-- public | `-- perforcer_strings.html.haml_spec.rb `-- user_sessions `-- new.html.haml_spec.rb Autospec doesn't run the "perforce_logs...spec.rb" files. As shown here... andy at hst-26-147 (master)->autospec loading autotest/rails_rspec /opt/local/bin/ruby /opt/local/lib/ruby/gems/1.8/gems/rspec-1.2.9/bin/ spec --autospec spec/models/role_spec.rb spec/controllers/ public_controller_spec.rb spec/views/layouts/ public_navigation.html.haml_spec.rb spec/helpers/public_helper_spec.rb spec/views/layouts/public.html.haml_spec.rb spec/controllers/ users_controller_spec.rb spec/controllers/ user_sessions_routing_spec.rb spec/controllers/ user_sessions_controller_spec.rb spec/models/branch_option_spec.rb spec/helpers/users_helper_spec.rb spec/views/user_sessions/ new.html.haml_spec.rb spec/helpers/user_sessions_helper_spec.rb -O spec/spec.opts No server is running Running specs locally: .................................................... Finished in 2.200675 seconds 52 examples, 0 failures I have other Rails apps where Autospec works fine, just not this one. thanks On Nov 20, 9:57?am, David Chelimsky wrote: > On Fri, Nov 20, 2009 at 7:25 AM, Andy Koch wrote: > > On Nov 19, 10:22 pm, Stephen Eley wrote: > > > On Fri, Nov 20, 2009 at 1:02 AM, Andy Koch > > wrote: > > > > > I have a project where autospec is not adding new files to it's test > > > > list. > > > > Autotest (which autospec is really just a wrapper around) builds its > > > file list when it initializes. ?After that its looping is pretty > > > specific. > > > > If you want to refresh it with all new changes, you can hit CTRL-C any > > > time and it'll start again from scratch. > > > > -- > > > Have Fun, > > > ? ?Steve Eley (sfe... at gmail.com) > > > ? ?ESCAPE POD - The Science Fiction Podcast Magazine > > > ? ?http://www.escapepod.org > > Yes, unfortunately that's the problem I'm experiencing. > > > Ctl-C isn't refreshing to find the new files. ?I stop completely and > > restart and still no luck. ?I've added (for a Rails app) a new > > controller and helper spec file and they only run if I "spec ..." or > > "rake spec". > > What are the names and paths to these files? > > > autospec (autotest) seems stuck on it's current file list - almost as > > if it has a file cache somewhere that isn't getting refreshed > > RSpec maintains no cache for this. Autotest does maintain a temporary cache > (of sorts), but CTRL-C has always worked for me to refresh it. > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From sfeley at gmail.com Fri Nov 20 13:53:14 2009 From: sfeley at gmail.com (Stephen Eley) Date: Fri, 20 Nov 2009 13:53:14 -0500 Subject: [rspec-users] autospec not detecting new files In-Reply-To: References: <6f19008b-e641-438e-98fc-e9a9d8d5e37a@y32g2000prd.googlegroups.com> <1fb4df0911192222kc10a139k28c9576a9a64edea@mail.gmail.com> <77d09dcd-156a-40cb-a24c-a40ac01a097f@a39g2000pre.googlegroups.com> <57c63afe0911200957s9f41e43of0c14f7db4de0420@mail.gmail.com> Message-ID: <1fb4df0911201053u489db256y11e66e913da9e03e@mail.gmail.com> On Fri, Nov 20, 2009 at 1:35 PM, Andy Koch wrote: > > Autospec doesn't run the "perforce_logs...spec.rb" files. ?As shown > here... Random theory: try renaming the files temporary to remove the word "log" from the name. I'm wondering if it might be a wildcard matcher somewhere in the chain that overenthusiastically ignores log files. (If so, that's still an annoying glitch that needs to be fixed, but at least you'll have identified it.) You might also try another tool; I haven't tried this one yet -- I intend to -- but it appears to be more configurable: http://github.com/mynyml/watchr/ -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org From andy.koch at pc-doctor.com Fri Nov 20 15:27:00 2009 From: andy.koch at pc-doctor.com (Andy Koch) Date: Fri, 20 Nov 2009 12:27:00 -0800 (PST) Subject: [rspec-users] autospec not detecting new files In-Reply-To: <1fb4df0911201053u489db256y11e66e913da9e03e@mail.gmail.com> References: <6f19008b-e641-438e-98fc-e9a9d8d5e37a@y32g2000prd.googlegroups.com> <1fb4df0911192222kc10a139k28c9576a9a64edea@mail.gmail.com> <77d09dcd-156a-40cb-a24c-a40ac01a097f@a39g2000pre.googlegroups.com> <57c63afe0911200957s9f41e43of0c14f7db4de0420@mail.gmail.com> <1fb4df0911201053u489db256y11e66e913da9e03e@mail.gmail.com> Message-ID: <579599c8-2ccf-462a-bc2e-5d46d5d9c8c3@e4g2000prn.googlegroups.com> YES!! that was it... [~/gits/perforcer] andy at hst-26-147 (master)->mv spec/controllers/ perforce_logs_controller_spec.rb spec/controllers/ perforce_controller_spec.rb [~/gits/perforcer] andy at hst-26-147 (master)->autospec loading autotest/rails_rspec /opt/local/bin/ruby /opt/local/lib/ruby/gems/1.8/gems/rspec-1.2.9/bin/ spec --autospec spec/models/role_spec.rb spec/controllers/ public_controller_spec.rb spec/views/layouts/ public_navigation.html.haml_spec.rb spec/helpers/public_helper_spec.rb spec/views/layouts/public.html.haml_spec.rb spec/controllers/ users_controller_spec.rb spec/controllers/ user_sessions_routing_spec.rb spec/controllers/ user_sessions_controller_spec.rb spec/models/branch_option_spec.rb spec/controllers/perforce_controller_spec.rb spec/helpers/ users_helper_spec.rb spec/views/user_sessions/new.html.haml_spec.rb spec/helpers/user_sessions_helper_spec.rb -O spec/spec.opts No server is running Running specs locally: ..................................................... Finished in 2.381309 seconds 53 examples, 0 failures OK, that's a gotcha learned, thanks On Nov 20, 10:53?am, Stephen Eley wrote: > On Fri, Nov 20, 2009 at 1:35 PM, Andy Koch wrote: > > > Autospec doesn't run the "perforce_logs...spec.rb" files. ?As shown > > here... > > Random theory: try renaming the files temporary to remove the word > "log" from the name. ?I'm wondering if it might be a wildcard matcher > somewhere in the chain that overenthusiastically ignores log files. > > (If so, that's still an annoying glitch that needs to be fixed, but at > least you'll have identified it.) > > You might also try another tool; I haven't tried this one yet -- I > intend to -- but it appears to be more configurable:http://github.com/mynyml/watchr/ > > -- > Have Fun, > ? ?Steve Eley (sfe... at gmail.com) > ? ?ESCAPE POD - The Science Fiction Podcast Magazine > ? ?http://www.escapepod.org > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Nov 20 16:11:02 2009 From: lists at ruby-forum.com (Jon Pincus) Date: Fri, 20 Nov 2009 22:11:02 +0100 Subject: [rspec-users] Introductory recommendations? Message-ID: Hi all, I'm with a team of engineers who are new to RSpec, and I'm looking for some good introductory material. Ideally it would be something like the two-part Railscast on Cucumber ( http://asciicasts.com/episodes/155-beginning-with-cucumber ) which doesn't assume detailed knowledge of TDD. I found David Chelimsky's Intro at http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/ ... anything else that people would recommend? Thanks much! jon -- Posted via http://www.ruby-forum.com/. From elliot.winkler at gmail.com Sat Nov 21 01:28:44 2009 From: elliot.winkler at gmail.com (Elliot Winkler) Date: Sat, 21 Nov 2009 00:28:44 -0600 Subject: [rspec-users] spec_helper getting reloaded after specs run under Textmate/Spork Message-ID: <4B07889C.6020108@gmail.com> I'm having the hardest time trying to figure out something weird I've suddenly run into. So I'm using Spork to run my specs. Naturally I've got TM_RSPEC_OPTS in Textmate set to --drb and I'm running `spork` from the command line to fire up the Spork server. However, if I have a spec file open in Textmate and I press Command-R, then the specs in the file get executed twice. I did a quick test by having spec_helper print out something at the bottom of the file and then wrote up a quick one-example spec file. When I ran it, I saw the spinner spin, the debug line got printed to the window, the output from the specs appeared, and then the spinner spun some more and the debug line appeared again (but a duplicate set of specs didn't appear because I think RSpec's smart about not re-running tests). So it definitely looks like spec_helper is getting loaded again, after all the specs are run. (I know spec_helper should be run twice, once during preloading, once during execution. But not again, AFTER execution.) At first I thought it might be only specific to my project, but I tried creating a fresh Rails project, installing RSpec into it, and creating and running a quick spec file, but the same thing happened -- spec_helper seems to get loaded again. I also tried wiping and reinstalling the rspec, rspec-rails, and spork gems, but that didn't work either. Just to emphasize, this is only when Spork is running. If I leave TM_RSPEC_OPTS at --drb but fail to leave the Spork server open, the specs only get run once as they should. Also, this is only for Textmate -- I've got --drb in my spec.opts and `rake spec` works just fine when Spork is running. So I really don't know who the culprit is: Spork, RSpec bundle, or maybe it's just me. I noticed in Lighthouse a few people have had this same problem, but those were a while back and anyway this seems to be different. David, can you think of a reason why something like this would be happening? Exit status maybe? Or maybe this is more of a Spork question. -- Elliot From dumbogdan at gmail.com Fri Nov 20 22:06:43 2009 From: dumbogdan at gmail.com (Bogdan Dumitru) Date: Fri, 20 Nov 2009 19:06:43 -0800 (PST) Subject: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9 In-Reply-To: <57c63afe0911080730j19983a93v869c61f221b814ed@mail.gmail.com> References: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> <57c63afe0911041428s4dae12caj171d5bf56982df11@mail.gmail.com> <906e5e28-5243-432f-99a7-5033f359bbe0@h14g2000pri.googlegroups.com> <57c63afe0911080730j19983a93v869c61f221b814ed@mail.gmail.com> Message-ID: The syntax for use_fakefs changed in version 0.2.1 and the fixtures for rspec are generating errors, but it can be solved easily. Have to change ... describe "smth" do extend FakeFS::SpecHelpers use_fakefs ... end To... extend FakeFS::SpecHelpers use_fakefs describe "smth" do ... end As it seems the use_fakefs method now takes the describe block as a parameter and thus the error regarding the wrong number of parameters. On Nov 8, 3:30?pm, David Chelimsky wrote: > On Sun, Nov 8, 2009 at 2:35 AM, Conrad Taylor wrote: > > David, I'm still seeing the issue. ?Thus, here's a transcript of my > > activity: > > >http://pastie.org/688639 > > $ gem which fakefs > (checking gem bmabey-fakefs-0.1.1.1 for fakefs) > /Users/david/.rvm/gems/ruby/1.9.1/gems/bmabey-fakefs-0.1.1.1/lib/fakefs.rb > > What version of fakefs are you using? > > > > > -Conrad > > > On Nov 4, 2:28 pm, David Chelimsky wrote: > > > On Tue, Nov 3, 2009 at 7:25 AM, Conrad Taylor > > wrote: > > > > Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. > > > > Hi Conrad, > > > > If this was a problem in the gem, it is now fixed: > > > > $ rvm 1.9.1 > > > $ which ruby > > > /Users/david/.rvm/ruby-1.9.1-p243/bin/ruby > > > $ rake spec > > > ... > > > 1522 examples, 0 failures, 2 pending > > > > Cheers, > > > David > > > > > I'm > > > > getting the following error message when I run the specs: > > > > > /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ > > > > option_parser_spec.rb:21:in `block (2 levels) in ': > > > > wrong number of arguments (0 for 1) (ArgumentError) > > > > > After analyzing the error message, it appears that "use_fakefs" method > > > > on lines 21 and 522 of the > > > > > option_parser_spec.rb > > > > > should take an argument. > > > > > -Conrad > > > > > _______________________________________________ > > > > rspec-users mailing list > > > > rspec-us... at rubyforge.org > > > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > > > 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 > > > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From grimen at gmail.com Sat Nov 21 11:31:32 2009 From: grimen at gmail.com (grimen) Date: Sat, 21 Nov 2009 08:31:32 -0800 (PST) Subject: [rspec-users] Gemspec development dependencies seems to be messed up In-Reply-To: <57c63afe0911200600s17c1d657nb04cbdf693225b5e@mail.gmail.com> References: <84e76cb5-a823-47d8-9bb5-a6e67ce98e32@b15g2000yqd.googlegroups.com> <57c63afe0911191350t66651e89r3057640f967fe8a@mail.gmail.com> <57c63afe0911200600s17c1d657nb04cbdf693225b5e@mail.gmail.com> Message-ID: <164bf9b0-3370-4c19-af47-ea915217d89b@m38g2000yqd.googlegroups.com> OK, thanks - I've misunderstood that gem command it seems. grimen On Nov 20, 3:00?pm, David Chelimsky wrote: > On Fri, Nov 20, 2009 at 5:26 AM, grimen wrote: > > OK, I noticed this only happen on Ruby 1.9 and jruby. Seems to be > > native compilation errors, but I don't get why all these should be > > installed: > > > Successfully installed prawn-core-0.5.1 > > Successfully installed prawn-layout-0.3.2 > > Successfully installed echoe-4.0 > > Successfully installed prawn-format-0.2.3 > > Successfully installed prawn-0.5.1 > > Successfully installed spork-0.7.3 > > Successfully installed cucumber-0.4.4 > > Successfully installed bmabey-fakefs-0.1.1.1 > > Successfully installed ZenTest-4.1.4 > > Successfully installed RubyInline-3.8.3 > > Successfully installed sexp_processor-3.0.3 > > Successfully installed ParseTree-3.0.4 > > Successfully installed ruby_parser-2.0.4 > > Successfully installed ruby2ruby-1.2.4 > > Successfully installed heckle-1.4.3 > > Successfully installed test-spec-0.10.0 > > Successfully installed markaby-0.5 > > Successfully installed metaid-1.0 > > Successfully installed camping-1.5.180 > > Successfully installed memcache-client-1.7.6 > > Successfully installed ruby-openid-2.0.4 > > Successfully installed eventmachine-0.12.10 > > Successfully installed thin-1.2.5 > > Successfully installed racc-1.4.6 > > Successfully installed rexical-1.0.4 > > Successfully installed rake-compiler-0.6.0 > > 26 gems installed > > > Are all these really development dependencies? > > Of rspec, no, but they are dependencies of rspec's dependencies, and their > dependencies, and so on, and so on, and so on ... > > > > > > > grimen > > > On Nov 19, 10:50 pm, David Chelimsky wrote: > > > On Wed, Nov 18, 2009 at 7:05 AM, grimen wrote: > > > > $ sudo gem install rspec-rails --development > > > > Password: > > > > ERROR: ?Error installing rspec-rails: > > > > ? ? ? ?rspec requires cucumber (>= 0.3, development) > > > > > ...and when installed cucumber manually, it ends up with weird stuff. > > > > Can you be more specific? > > > > > Is this RSpec issue or a RubyGems issue? > > > > I have no idea yet. I was able to run "sudo gem install rspec-rails > > > --development" with no trouble. > > > > _______________________________________________ > > > 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 > > > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From andy.koch at pc-doctor.com Sat Nov 21 12:24:46 2009 From: andy.koch at pc-doctor.com (Andy Koch) Date: Sat, 21 Nov 2009 09:24:46 -0800 (PST) Subject: [rspec-users] Introductory recommendations? In-Reply-To: References: Message-ID: <6b934f68-ad0c-4e0d-9130-a7cad5c3989c@x5g2000prf.googlegroups.com> http://www.pragprog.com/titles/achbd/the-rspec-book On Nov 20, 1:11?pm, Jon Pincus wrote: > Hi all, > > I'm with a team of engineers who are new to RSpec, and I'm looking for > some good introductory material. ?Ideally it would be something like the > two-part Railscast on Cucumber (http://asciicasts.com/episodes/155-beginning-with-cucumber) which > doesn't assume detailed knowledge of TDD. > > I found David Chelimsky's Intro athttp://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-pa... > ... anything else that people would recommend? > > Thanks much! > > jon > -- > Posted viahttp://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From andy.koch at pc-doctor.com Sat Nov 21 12:34:15 2009 From: andy.koch at pc-doctor.com (Andy Koch) Date: Sat, 21 Nov 2009 09:34:15 -0800 (PST) Subject: [rspec-users] [rails] strange regex validation failure Message-ID: <7b33d068-6636-453c-8b8b-2ab9cbfa8188@u18g2000pro.googlegroups.com> Hi, I'm getting invalid results when testing a Regex in a format validation on a Rails model. Code is... # in Model # allow '- n/a -' or alphanum with _ -- no spaces validates_format_of :test_name, :with => /\A[A-Za-z0-9_]+\z/, :unless => lambda{|x| x.test_name == '- n/a -'} # in spec hardware_test = Factory.build(:hardware_test, :test_name => '- n/a -') hardware_test.should be_valid, "'#{hardware_test.test_name}' - should be valid" # spec result 3) 'HardwareTest should properly validate test_name format' FAILED '- n/a -' - should be valid ./spec/models/hardware_test_spec.rb:34: # finally, from console andy at hst-26-147 (Rails234)->sc Loading development environment (Rails 2.3.4) >> a = HardwareTest.new(:test_name => '- n/a -') => # >> a.valid? => true Granted the console is in dev, not test, but I still don't get it. Literally pulled on my hair on this one. I've tried altering the Regex many times - adding the :unless => lambda was my last effort. I can't see how this isn't passing. Thanks for any help From cdemyanovich at gmail.com Sat Nov 21 13:00:16 2009 From: cdemyanovich at gmail.com (Craig Demyanovich) Date: Sat, 21 Nov 2009 13:00:16 -0500 Subject: [rspec-users] [rails] strange regex validation failure In-Reply-To: <7b33d068-6636-453c-8b8b-2ab9cbfa8188@u18g2000pro.googlegroups.com> References: <7b33d068-6636-453c-8b8b-2ab9cbfa8188@u18g2000pro.googlegroups.com> Message-ID: <61c885db0911211000k1c530746x62fbcb728edd9512@mail.gmail.com> Hi Andy, Nothing jumps out at me at the moment. If you think there might be a difference between dev and test, you could launch script/console with the test env. and try it again on the console. $ script/console test Regards, Craig -- Craig Demyanovich Mutually Human Software http://mutuallyhuman.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From andy.koch at pc-doctor.com Sat Nov 21 12:55:42 2009 From: andy.koch at pc-doctor.com (Andy Koch) Date: Sat, 21 Nov 2009 09:55:42 -0800 (PST) Subject: [rspec-users] [rails] strange regex validation failure In-Reply-To: <7b33d068-6636-453c-8b8b-2ab9cbfa8188@u18g2000pro.googlegroups.com> References: <7b33d068-6636-453c-8b8b-2ab9cbfa8188@u18g2000pro.googlegroups.com> Message-ID: <8f8fcb82-a550-4bdf-b310-ca3c2900fdf4@e4g2000prn.googlegroups.com> wait, nevermind turns out there was a callback that was being hidden - and triggering a different error all's well On Nov 21, 9:34?am, Andy Koch wrote: > Hi, > > I'm getting invalid results when testing a Regex in a format > validation on a Rails model. > > Code is... > > # in Model > # allow '- n/a -' or alphanum with _ -- no spaces > validates_format_of :test_name, :with => /\A[A-Za-z0-9_]+\z/, :unless > => lambda{|x| x.test_name == '- n/a -'} > > # in spec > hardware_test = Factory.build(:hardware_test, :test_name => '- n/a -') > hardware_test.should be_valid, "'#{hardware_test.test_name}' - should > be valid" > > # spec result > 3) > 'HardwareTest should properly validate test_name format' FAILED > '- n/a -' - should be valid > ./spec/models/hardware_test_spec.rb:34: > > # finally, from console > andy at hst-26-147 (Rails234)->sc > Loading development environment (Rails 2.3.4)>> a = HardwareTest.new(:test_name => '- n/a -') > > => # test_description: nil, test_reviewed: false, interactive: false, > loopback: false, factory: false, media: false, test_category_id: nil, > created_at: nil, updated_at: nil, creator_id: nil, updater_id: nil>>> a.valid? > > => true > > Granted the console is in dev, not test, but I still don't get it. > Literally pulled on my hair on this one. ?I've tried altering the > Regex many times - adding the :unless => lambda was my last effort. > > I can't see how this isn't passing. > > Thanks for any help > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From cagraff at cox.net Sat Nov 21 16:44:28 2009 From: cagraff at cox.net (Carl Graff) Date: Sat, 21 Nov 2009 13:44:28 -0800 Subject: [rspec-users] Introductory recommendations? In-Reply-To: <6b934f68-ad0c-4e0d-9130-a7cad5c3989c@x5g2000prf.googlegroups.com> References: <6b934f68-ad0c-4e0d-9130-a7cad5c3989c@x5g2000prf.googlegroups.com> Message-ID: <4B085F3C.20901@cox.net> The RSpec Book from Pragmatic Programmers is excellent IMO. Best, Carl Andy Koch wrote: > http://www.pragprog.com/titles/achbd/the-rspec-book > > On Nov 20, 1:11 pm, Jon Pincus wrote: > >> Hi all, >> >> I'm with a team of engineers who are new to RSpec, and I'm looking for >> some good introductory material. Ideally it would be something like the >> two-part Railscast on Cucumber (http://asciicasts.com/episodes/155-beginning-with-cucumber) which >> doesn't assume detailed knowledge of TDD. >> >> I found David Chelimsky's Intro athttp://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-pa... >> ... anything else that people would recommend? >> >> Thanks much! >> >> jon >> -- >> Posted viahttp://www.ruby-forum.com/. >> _______________________________________________ >> 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 lists at ruby-forum.com Sat Nov 21 20:12:41 2009 From: lists at ruby-forum.com (Jon Pincus) Date: Sun, 22 Nov 2009 02:12:41 +0100 Subject: [rspec-users] Introductory recommendations? In-Reply-To: <6b934f68-ad0c-4e0d-9130-a7cad5c3989c@x5g2000prf.googlegroups.com> References: <6b934f68-ad0c-4e0d-9130-a7cad5c3989c@x5g2000prf.googlegroups.com> Message-ID: <5ac2b94f346e6e5d4dc699309d4b7b5f@ruby-forum.com> Thanks Andy and Carl. I've bought The RSpec Book and there's a wealth of good information, but the tutorial in Chapter 5 ("Getting Started with RSpec") starts with mock objects and the quirks of should_receive.with ... that seems like a pretty advanced place to start for those who aren't familiar with TDD (or BDD). I'm hoping for something more straightforward. jon -- Posted via http://www.ruby-forum.com/. From elliot.winkler at gmail.com Mon Nov 23 10:46:27 2009 From: elliot.winkler at gmail.com (Elliot Winkler) Date: Mon, 23 Nov 2009 09:46:27 -0600 Subject: [rspec-users] spec_helper getting reloaded after specs run under Textmate/Spork In-Reply-To: <4B07889C.6020108@gmail.com> References: <4B07889C.6020108@gmail.com> Message-ID: <4B0AAE53.9040703@gmail.com> Thought I should mention I'm fully updated to TextMate 1.5.9 and I'm also on Leopard. I tried wiping out my TextMate bundles and re-installing TextMate, but I'm still seeing the problem, both in my project and a fresh project. Going to try a previous version of TextMate next, and then another computer... -- Elliot On 11/21/09 12:28 AM, Elliot Winkler wrote: > I'm having the hardest time trying to figure out something weird I've > suddenly run into. So I'm using Spork to run my specs. Naturally I've > got TM_RSPEC_OPTS in Textmate set to --drb and I'm running `spork` from > the command line to fire up the Spork server. However, if I have a spec > file open in Textmate and I press Command-R, then the specs in the file > get executed twice. I did a quick test by having spec_helper print out > something at the bottom of the file and then wrote up a quick > one-example spec file. When I ran it, I saw the spinner spin, the debug > line got printed to the window, the output from the specs appeared, and > then the spinner spun some more and the debug line appeared again (but a > duplicate set of specs didn't appear because I think RSpec's smart about > not re-running tests). So it definitely looks like spec_helper is > getting loaded again, after all the specs are run. (I know spec_helper > should be run twice, once during preloading, once during execution. But > not again, AFTER execution.) > > At first I thought it might be only specific to my project, but I tried > creating a fresh Rails project, installing RSpec into it, and creating > and running a quick spec file, but the same thing happened -- > spec_helper seems to get loaded again. I also tried wiping and > reinstalling the rspec, rspec-rails, and spork gems, but that didn't > work either. > > Just to emphasize, this is only when Spork is running. If I leave > TM_RSPEC_OPTS at --drb but fail to leave the Spork server open, the > specs only get run once as they should. > > Also, this is only for Textmate -- I've got --drb in my spec.opts and > `rake spec` works just fine when Spork is running. > > So I really don't know who the culprit is: Spork, RSpec bundle, or maybe > it's just me. I noticed in Lighthouse a few people have had this same > problem, but those were a while back and anyway this seems to be different. > > David, can you think of a reason why something like this would be > happening? Exit status maybe? Or maybe this is more of a Spork question. > > -- Elliot From dchelimsky at gmail.com Mon Nov 23 11:09:14 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 23 Nov 2009 10:09:14 -0600 Subject: [rspec-users] spec_helper getting reloaded after specs run under Textmate/Spork In-Reply-To: <4B07889C.6020108@gmail.com> References: <4B07889C.6020108@gmail.com> Message-ID: <57c63afe0911230809v108c6952m44b4108dc8b6b715@mail.gmail.com> On Sat, Nov 21, 2009 at 12:28 AM, Elliot Winkler wrote: > I'm having the hardest time trying to figure out something weird I've > suddenly run into. So I'm using Spork to run my specs. Naturally I've got > TM_RSPEC_OPTS in Textmate set to --drb and I'm running `spork` from the > command line to fire up the Spork server. However, if I have a spec file > open in Textmate and I press Command-R, then the specs in the file get > executed twice. I did a quick test by having spec_helper print out something > at the bottom of the file and then wrote up a quick one-example spec file. > When I ran it, I saw the spinner spin, the debug line got printed to the > window, the output from the specs appeared, and then the spinner spun some > more and the debug line appeared again (but a duplicate set of specs didn't > appear because I think RSpec's smart about not re-running tests). So it > definitely looks like spec_helper is getting loaded again, after all the > specs are run. (I know spec_helper should be run twice, once during > preloading, once during execution. But not again, AFTER execution.) > > At first I thought it might be only specific to my project, but I tried > creating a fresh Rails project, installing RSpec into it, and creating and > running a quick spec file, but the same thing happened -- spec_helper seems > to get loaded again. I also tried wiping and reinstalling the rspec, > rspec-rails, and spork gems, but that didn't work either. > > Just to emphasize, this is only when Spork is running. If I leave > TM_RSPEC_OPTS at --drb but fail to leave the Spork server open, the specs > only get run once as they should. > > Also, this is only for Textmate -- I've got --drb in my spec.opts and `rake > spec` works just fine when Spork is running. > > So I really don't know who the culprit is: Spork, RSpec bundle, or maybe > it's just me. I noticed in Lighthouse a few people have had this same > problem, but those were a while back and anyway this seems to be different. > > David, can you think of a reason why something like this would be > happening? Exit status maybe? Or maybe this is more of a Spork question. > Sounds like a spork question to me :) I was able to duplicate your experience, but I don't have any initial thoughts about why this would be happening. > > -- Elliot > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Mon Nov 23 12:45:46 2009 From: lists at ruby-forum.com (Peter Ritchie) Date: Mon, 23 Nov 2009 18:45:46 +0100 Subject: [rspec-users] Cucumber Cygwin Message-ID: <1a0ea03077848f0abf1e89a51a3741c0@ruby-forum.com> Stuck as to what dependency is calling for cucumber 0.4.4 - we want to stick to 0.4.3 but Cygwin installation not allowing it - OK on Mac /usr/bin/ruby.exe -I "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.3/lib:lib" "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.3/bin/cucumber" --color --tags ~@wip --strict --format pretty Missing these required gems: cucumber >= 0.4.4 You're running: ruby 1.8.7.72 at /usr/bin/ruby.exe rubygems 1.3.5 at /home/peter.ritchie/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8 Any help would be appreciated -- Posted via http://www.ruby-forum.com/. From aslak.hellesoy at gmail.com Mon Nov 23 13:02:04 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 23 Nov 2009 19:02:04 +0100 Subject: [rspec-users] Cucumber Cygwin In-Reply-To: <1a0ea03077848f0abf1e89a51a3741c0@ruby-forum.com> References: <1a0ea03077848f0abf1e89a51a3741c0@ruby-forum.com> Message-ID: <8d961d900911231002q7f1567d6i21246849d09958fa@mail.gmail.com> > Stuck as to what dependency is calling for cucumber 0.4.4 - config/environments/cucumber.rb? (Failing that - search for the string "0.4.4" among your project's files) > we want to > stick to 0.4.3 but Cygwin installation not allowing it - OK on Mac > What's stopping you from running 0.4.4? In any case, if you need 0.4.3: gem uninstall cucumber gem install cucumber 0.4.3 script/generate cucumber > > > /usr/bin/ruby.exe -I > "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.3/lib:lib" > "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.3/bin/cucumber" --color --tags > ~@wip --strict --format pretty > Missing these required gems: > ?cucumber ?>= 0.4.4 > > You're running: > ?ruby 1.8.7.72 at /usr/bin/ruby.exe > ?rubygems 1.3.5 at /home/peter.ritchie/.gem/ruby/1.8, > /usr/lib/ruby/gems/1.8 > > > Any help would be appreciated > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon Nov 23 13:02:39 2009 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 23 Nov 2009 19:02:39 +0100 Subject: [rspec-users] Cucumber Cygwin In-Reply-To: <1a0ea03077848f0abf1e89a51a3741c0@ruby-forum.com> References: <1a0ea03077848f0abf1e89a51a3741c0@ruby-forum.com> Message-ID: <8d961d900911231002w5fce440fo956df08300ed506f@mail.gmail.com> > Stuck as to what dependency is calling for cucumber 0.4.4 - we want to > stick to 0.4.3 but Cygwin installation not allowing it - OK on Mac > Cucumber has its own mailing list: http://groups.google.com/group/cukes > > > /usr/bin/ruby.exe -I > "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.3/lib:lib" > "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.3/bin/cucumber" --color --tags > ~@wip --strict --format pretty > Missing these required gems: > ?cucumber ?>= 0.4.4 > > You're running: > ?ruby 1.8.7.72 at /usr/bin/ruby.exe > ?rubygems 1.3.5 at /home/peter.ritchie/.gem/ruby/1.8, > /usr/lib/ruby/gems/1.8 > > > Any help would be appreciated > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From ben at benmabey.com Mon Nov 23 12:47:27 2009 From: ben at benmabey.com (Ben Mabey) Date: Mon, 23 Nov 2009 10:47:27 -0700 Subject: [rspec-users] spec_helper getting reloaded after specs run under Textmate/Spork In-Reply-To: <57c63afe0911230809v108c6952m44b4108dc8b6b715@mail.gmail.com> References: <4B07889C.6020108@gmail.com> <57c63afe0911230809v108c6952m44b4108dc8b6b715@mail.gmail.com> Message-ID: <4B0ACAAF.3090704@benmabey.com> David Chelimsky wrote: > > > On Sat, Nov 21, 2009 at 12:28 AM, Elliot Winkler > > wrote: > > I'm having the hardest time trying to figure out something weird > I've suddenly run into. So I'm using Spork to run my specs. > Naturally I've got TM_RSPEC_OPTS in Textmate set to --drb and I'm > running `spork` from the command line to fire up the Spork server. > However, if I have a spec file open in Textmate and I press > Command-R, then the specs in the file get executed twice. I did a > quick test by having spec_helper print out something at the bottom > of the file and then wrote up a quick one-example spec file. When > I ran it, I saw the spinner spin, the debug line got printed to > the window, the output from the specs appeared, and then the > spinner spun some more and the debug line appeared again (but a > duplicate set of specs didn't appear because I think RSpec's smart > about not re-running tests). So it definitely looks like > spec_helper is getting loaded again, after all the specs are run. > (I know spec_helper should be run twice, once during preloading, > once during execution. But not again, AFTER execution.) > > At first I thought it might be only specific to my project, but I > tried creating a fresh Rails project, installing RSpec into it, > and creating and running a quick spec file, but the same thing > happened -- spec_helper seems to get loaded again. I also tried > wiping and reinstalling the rspec, rspec-rails, and spork gems, > but that didn't work either. > > Just to emphasize, this is only when Spork is running. If I leave > TM_RSPEC_OPTS at --drb but fail to leave the Spork server open, > the specs only get run once as they should. > > Also, this is only for Textmate -- I've got --drb in my spec.opts > and `rake spec` works just fine when Spork is running. > > So I really don't know who the culprit is: Spork, RSpec bundle, or > maybe it's just me. I noticed in Lighthouse a few people have had > this same problem, but those were a while back and anyway this > seems to be different. > > David, can you think of a reason why something like this would be > happening? Exit status maybe? Or maybe this is more of a Spork > question. > > > Sounds like a spork question to me :) I was able to duplicate your > experience, but I don't have any initial thoughts about why this would > be happening. Hmm.. I can't think of why this would happen either. Tim Harper is a textmate user so if you post this question to the spork mailing list he could probably help you. (Spork ML: http://groups.google.com/group/sporkgem) -Ben From lists at ruby-forum.com Mon Nov 23 13:32:49 2009 From: lists at ruby-forum.com (Peter Ritchie) Date: Mon, 23 Nov 2009 19:32:49 +0100 Subject: [rspec-users] Cucumber Cygwin In-Reply-To: <8d961d900911231002q7f1567d6i21246849d09958fa@mail.gmail.com> References: <1a0ea03077848f0abf1e89a51a3741c0@ruby-forum.com> <8d961d900911231002q7f1567d6i21246849d09958fa@mail.gmail.com> Message-ID: <2e31aa3270c45ab583f0de8754833ab1@ruby-forum.com> Aslak Helles?y wrote: >> Stuck as to what dependency is calling for cucumber 0.4.4 - > > config/environments/cucumber.rb? > > (Failing that - search for the string "0.4.4" among your project's > files) > >> we want to >> stick to 0.4.3 but Cygwin installation not allowing it - OK on Mac >> > > What's stopping you from running 0.4.4? > > In any case, if you need 0.4.3: > > gem uninstall cucumber > gem install cucumber 0.4.3 > script/generate cucumber Thank you for that, I have searched for 0.4.4 in the project and no instance. Main collaborator is using 0.4.3 but we are updating to see if it fixes it. Many thanks and for link to cucumber list. Peter -- Posted via http://www.ruby-forum.com/. From elliot.winkler at gmail.com Mon Nov 23 13:43:42 2009 From: elliot.winkler at gmail.com (Elliot Winkler) Date: Mon, 23 Nov 2009 12:43:42 -0600 Subject: [rspec-users] spec_helper getting reloaded after specs run under Textmate/Spork In-Reply-To: <4B0ACAAF.3090704@benmabey.com> References: <4B07889C.6020108@gmail.com> <57c63afe0911230809v108c6952m44b4108dc8b6b715@mail.gmail.com> <4B0ACAAF.3090704@benmabey.com> Message-ID: <4B0AD7DE.9070509@gmail.com> Great, I'm glad it's not just me :) I'll ask there. -- Elliot On 11/23/09 11:47 AM, Ben Mabey wrote: > David Chelimsky wrote: >> >> >> On Sat, Nov 21, 2009 at 12:28 AM, Elliot Winkler >> > wrote: >> >> I'm having the hardest time trying to figure out something weird >> I've suddenly run into. So I'm using Spork to run my specs. >> Naturally I've got TM_RSPEC_OPTS in Textmate set to --drb and I'm >> running `spork` from the command line to fire up the Spork server. >> However, if I have a spec file open in Textmate and I press >> Command-R, then the specs in the file get executed twice. I did a >> quick test by having spec_helper print out something at the bottom >> of the file and then wrote up a quick one-example spec file. When >> I ran it, I saw the spinner spin, the debug line got printed to >> the window, the output from the specs appeared, and then the >> spinner spun some more and the debug line appeared again (but a >> duplicate set of specs didn't appear because I think RSpec's smart >> about not re-running tests). So it definitely looks like >> spec_helper is getting loaded again, after all the specs are run. >> (I know spec_helper should be run twice, once during preloading, >> once during execution. But not again, AFTER execution.) >> >> At first I thought it might be only specific to my project, but I >> tried creating a fresh Rails project, installing RSpec into it, >> and creating and running a quick spec file, but the same thing >> happened -- spec_helper seems to get loaded again. I also tried >> wiping and reinstalling the rspec, rspec-rails, and spork gems, >> but that didn't work either. >> >> Just to emphasize, this is only when Spork is running. If I leave >> TM_RSPEC_OPTS at --drb but fail to leave the Spork server open, >> the specs only get run once as they should. >> >> Also, this is only for Textmate -- I've got --drb in my spec.opts >> and `rake spec` works just fine when Spork is running. >> >> So I really don't know who the culprit is: Spork, RSpec bundle, or >> maybe it's just me. I noticed in Lighthouse a few people have had >> this same problem, but those were a while back and anyway this >> seems to be different. >> >> David, can you think of a reason why something like this would be >> happening? Exit status maybe? Or maybe this is more of a Spork >> question. >> >> >> Sounds like a spork question to me :) I was able to duplicate your >> experience, but I don't have any initial thoughts about why this would >> be happening. > > > Hmm.. I can't think of why this would happen either. Tim Harper is a > textmate user so if you post this question to the spork mailing list he > could probably help you. (Spork ML: > http://groups.google.com/group/sporkgem) > > -Ben > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rafaelmazza at gmail.com Mon Nov 23 16:21:55 2009 From: rafaelmazza at gmail.com (rafaelmazza) Date: Mon, 23 Nov 2009 13:21:55 -0800 (PST) Subject: [rspec-users] rspec + autotest + rails engines Message-ID: <561f8dfc-5979-4986-92e3-b148b682fd4d@e20g2000vbb.googlegroups.com> Hi everyone, I'm developing a rails app with several engines. I was wondering if it's possible to autospec all my engine's specs. I've tried putting the following content into my .autotest (in the app's root directory): Autotest.add_hook :initialize do |at| # find all my plugins with an spec directory engine_plugins = Dir['vendor/plugins/*'].select{|dir| File.directory? ("#{dir}/spec")} engine_plugins.each do |plugin_path| at.add_mapping %r%^#{plugin_path}/app/models/(.*)\.rb$% do |_, m| at.files_matching "#{plugin_path}/spec/models/#{m[1]}_spec.rb" end end end But when any plugin's model is changed, for example, it seems that nothing happens. Has anybody tried it before? Thanks in advance! From dchelimsky at gmail.com Mon Nov 23 21:35:53 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 23 Nov 2009 20:35:53 -0600 Subject: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9 In-Reply-To: References: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> <57c63afe0911041428s4dae12caj171d5bf56982df11@mail.gmail.com> <906e5e28-5243-432f-99a7-5033f359bbe0@h14g2000pri.googlegroups.com> <57c63afe0911080730j19983a93v869c61f221b814ed@mail.gmail.com> Message-ID: <57c63afe0911231835m34f5c50eya4ad20c59811de7d@mail.gmail.com> On Fri, Nov 20, 2009 at 9:06 PM, Bogdan Dumitru wrote: > The syntax for use_fakefs changed in version 0.2.1 and the fixtures > for rspec are generating errors, but it can be solved easily. > Have to change ... > describe "smth" do > extend FakeFS::SpecHelpers > use_fakefs > ... > end > To... > extend FakeFS::SpecHelpers > use_fakefs describe "smth" do ... end > > As it seems the use_fakefs method now takes the describe block as a > parameter and thus the error regarding the wrong number of parameters. > I had to do this slightly differently, but got it to work with fakefs-0.2.1. Fixed in git. Cheers, David > > > On Nov 8, 3:30 pm, David Chelimsky wrote: > > On Sun, Nov 8, 2009 at 2:35 AM, Conrad Taylor > wrote: > > > David, I'm still seeing the issue. Thus, here's a transcript of my > > > activity: > > > > >http://pastie.org/688639 > > > > $ gem which fakefs > > (checking gem bmabey-fakefs-0.1.1.1 for fakefs) > > > /Users/david/.rvm/gems/ruby/1.9.1/gems/bmabey-fakefs-0.1.1.1/lib/fakefs.rb > > > > What version of fakefs are you using? > > > > > > > > > -Conrad > > > > > On Nov 4, 2:28 pm, David Chelimsky wrote: > > > > On Tue, Nov 3, 2009 at 7:25 AM, Conrad Taylor > > > wrote: > > > > > Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. > > > > > > Hi Conrad, > > > > > > If this was a problem in the gem, it is now fixed: > > > > > > $ rvm 1.9.1 > > > > $ which ruby > > > > /Users/david/.rvm/ruby-1.9.1-p243/bin/ruby > > > > $ rake spec > > > > ... > > > > 1522 examples, 0 failures, 2 pending > > > > > > Cheers, > > > > David > > > > > > > I'm > > > > > getting the following error message when I run the specs: > > > > > > > /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ > > > > > option_parser_spec.rb:21:in `block (2 levels) in ': > > > > > wrong number of arguments (0 for 1) (ArgumentError) > > > > > > > After analyzing the error message, it appears that "use_fakefs" > method > > > > > on lines 21 and 522 of the > > > > > > > option_parser_spec.rb > > > > > > > should take an argument. > > > > > > > -Conrad > > > > > > > _______________________________________________ > > > > > rspec-users mailing list > > > > > rspec-us... at rubyforge.org > > > > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > > > 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 > > > > > > > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From scott at railsnewbie.com Mon Nov 23 22:36:34 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 23 Nov 2009 22:36:34 -0500 Subject: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9 In-Reply-To: <57c63afe0911231835m34f5c50eya4ad20c59811de7d@mail.gmail.com> References: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> <57c63afe0911041428s4dae12caj171d5bf56982df11@mail.gmail.com> <906e5e28-5243-432f-99a7-5033f359bbe0@h14g2000pri.googlegroups.com> <57c63afe0911080730j19983a93v869c61f221b814ed@mail.gmail.com> <57c63afe0911231835m34f5c50eya4ad20c59811de7d@mail.gmail.com> Message-ID: <250E720D-BCBF-45CC-8155-9F95BFB698A7@railsnewbie.com> On Nov 23, 2009, at 9:35 PM, David Chelimsky wrote: > On Fri, Nov 20, 2009 at 9:06 PM, Bogdan Dumitru wrote: > The syntax for use_fakefs changed in version 0.2.1 and the fixtures > for rspec are generating errors, but it can be solved easily. > Have to change ... > describe "smth" do > extend FakeFS::SpecHelpers > use_fakefs > ... > end > To... > extend FakeFS::SpecHelpers > use_fakefs describe "smth" do ... end > > As it seems the use_fakefs method now takes the describe block as a > parameter and thus the error regarding the wrong number of parameters. > > I had to do this slightly differently, but got it to work with fakefs-0.2.1. Fixed in git. > > Cheers, > David You can use include, too: module SpecHelpers def self.extended(example_group) example_group.use_fakefs(example_group) end def self.included(example_group) example_group.extend self end .. end Scott > > > > On Nov 8, 3:30 pm, David Chelimsky wrote: > > On Sun, Nov 8, 2009 at 2:35 AM, Conrad Taylor wrote: > > > David, I'm still seeing the issue. Thus, here's a transcript of my > > > activity: > > > > >http://pastie.org/688639 > > > > $ gem which fakefs > > (checking gem bmabey-fakefs-0.1.1.1 for fakefs) > > /Users/david/.rvm/gems/ruby/1.9.1/gems/bmabey-fakefs-0.1.1.1/lib/fakefs.rb > > > > What version of fakefs are you using? > > > > > > > > > -Conrad > > > > > On Nov 4, 2:28 pm, David Chelimsky wrote: > > > > On Tue, Nov 3, 2009 at 7:25 AM, Conrad Taylor > > > wrote: > > > > > Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. > > > > > > Hi Conrad, > > > > > > If this was a problem in the gem, it is now fixed: > > > > > > $ rvm 1.9.1 > > > > $ which ruby > > > > /Users/david/.rvm/ruby-1.9.1-p243/bin/ruby > > > > $ rake spec > > > > ... > > > > 1522 examples, 0 failures, 2 pending > > > > > > Cheers, > > > > David > > > > > > > I'm > > > > > getting the following error message when I run the specs: > > > > > > > /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ > > > > > option_parser_spec.rb:21:in `block (2 levels) in ': > > > > > wrong number of arguments (0 for 1) (ArgumentError) > > > > > > > After analyzing the error message, it appears that "use_fakefs" method > > > > > on lines 21 and 522 of the > > > > > > > option_parser_spec.rb > > > > > > > should take an argument. > > > > > > > -Conrad > > > > > > > _______________________________________________ > > > > > rspec-users mailing list > > > > > rspec-us... at rubyforge.org > > > > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > _______________________________________________ > > > > 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 > > > > > > > > _______________________________________________ > > 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 > > _______________________________________________ > 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 Nov 23 23:12:46 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 23 Nov 2009 22:12:46 -0600 Subject: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9 In-Reply-To: <250E720D-BCBF-45CC-8155-9F95BFB698A7@railsnewbie.com> References: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> <57c63afe0911041428s4dae12caj171d5bf56982df11@mail.gmail.com> <906e5e28-5243-432f-99a7-5033f359bbe0@h14g2000pri.googlegroups.com> <57c63afe0911080730j19983a93v869c61f221b814ed@mail.gmail.com> <57c63afe0911231835m34f5c50eya4ad20c59811de7d@mail.gmail.com> <250E720D-BCBF-45CC-8155-9F95BFB698A7@railsnewbie.com> Message-ID: <57c63afe0911232012o1e475de7v21164e6054c02cd9@mail.gmail.com> On Mon, Nov 23, 2009 at 9:36 PM, Scott Taylor wrote: > > On Nov 23, 2009, at 9:35 PM, David Chelimsky wrote: > > On Fri, Nov 20, 2009 at 9:06 PM, Bogdan Dumitru wrote: > >> The syntax for use_fakefs changed in version 0.2.1 and the fixtures >> for rspec are generating errors, but it can be solved easily. >> Have to change ... >> describe "smth" do >> extend FakeFS::SpecHelpers >> use_fakefs >> ... >> end >> To... >> extend FakeFS::SpecHelpers >> use_fakefs describe "smth" do ... end >> >> As it seems the use_fakefs method now takes the describe block as a >> parameter and thus the error regarding the wrong number of parameters. >> > > I had to do this slightly differently, but got it to work with > fakefs-0.2.1. Fixed in git. > > Cheers, > David > > > You can use include, too: > > module SpecHelpers > def self.extended(example_group) > example_group.use_fakefs(example_group) > end > > def self.included(example_group) > example_group.extend self > end > .. > end > That's exactly what I did :) http://github.com/dchelimsky/rspec/commit/65485d8be96cd0cb474dc29b6778180349c2d8ee Cheers, David > > Scott > > > > >> >> >> On Nov 8, 3:30 pm, David Chelimsky wrote: >> > On Sun, Nov 8, 2009 at 2:35 AM, Conrad Taylor >> wrote: >> > > David, I'm still seeing the issue. Thus, here's a transcript of my >> > > activity: >> > >> > >http://pastie.org/688639 >> > >> > $ gem which fakefs >> > (checking gem bmabey-fakefs-0.1.1.1 for fakefs) >> > >> /Users/david/.rvm/gems/ruby/1.9.1/gems/bmabey-fakefs-0.1.1.1/lib/fakefs.rb >> > >> > What version of fakefs are you using? >> > >> > >> > >> > > -Conrad >> > >> > > On Nov 4, 2:28 pm, David Chelimsky wrote: >> > > > On Tue, Nov 3, 2009 at 7:25 AM, Conrad Taylor >> > > wrote: >> > > > > Hi, 'rake spec' failed to run on Ruby 1.9.1p243 and RSpec 1.2.9. >> > >> > > > Hi Conrad, >> > >> > > > If this was a problem in the gem, it is now fixed: >> > >> > > > $ rvm 1.9.1 >> > > > $ which ruby >> > > > /Users/david/.rvm/ruby-1.9.1-p243/bin/ruby >> > > > $ rake spec >> > > > ... >> > > > 1522 examples, 0 failures, 2 pending >> > >> > > > Cheers, >> > > > David >> > >> > > > > I'm >> > > > > getting the following error message when I run the specs: >> > >> > > > > /opt/local/lib/ruby/gems/1.9.1/gems/rspec-1.2.9/spec/spec/runner/ >> > > > > option_parser_spec.rb:21:in `block (2 levels) in > (required)>': >> > > > > wrong number of arguments (0 for 1) (ArgumentError) >> > >> > > > > After analyzing the error message, it appears that "use_fakefs" >> method >> > > > > on lines 21 and 522 of the >> > >> > > > > option_parser_spec.rb >> > >> > > > > should take an argument. >> > >> > > > > -Conrad >> > >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From scott at railsnewbie.com Mon Nov 23 23:37:55 2009 From: scott at railsnewbie.com (Scott Taylor) Date: Mon, 23 Nov 2009 23:37:55 -0500 Subject: [rspec-users] Error executing specs using Ruby 1.9.1p243 and RSpec 1.2.9 In-Reply-To: <57c63afe0911232012o1e475de7v21164e6054c02cd9@mail.gmail.com> References: <679d5e35-711a-4da0-9293-9f8684901c49@13g2000prl.googlegroups.com> <57c63afe0911041428s4dae12caj171d5bf56982df11@mail.gmail.com> <906e5e28-5243-432f-99a7-5033f359bbe0@h14g2000pri.googlegroups.com> <57c63afe0911080730j19983a93v869c61f221b814ed@mail.gmail.com> <57c63afe0911231835m34f5c50eya4ad20c59811de7d@mail.gmail.com> <250E720D-BCBF-45CC-8155-9F95BFB698A7@railsnewbie.com> <57c63afe0911232012o1e475de7v21164e6054c02cd9@mail.gmail.com> Message-ID: <99FD7024-13A3-4F7B-A2EA-DC9C37E40207@railsnewbie.com> On Nov 23, 2009, at 11:12 PM, David Chelimsky wrote: > > > On Mon, Nov 23, 2009 at 9:36 PM, Scott Taylor wrote: > > On Nov 23, 2009, at 9:35 PM, David Chelimsky wrote: > >> On Fri, Nov 20, 2009 at 9:06 PM, Bogdan Dumitru wrote: >> The syntax for use_fakefs changed in version 0.2.1 and the fixtures >> for rspec are generating errors, but it can be solved easily. >> Have to change ... >> describe "smth" do >> extend FakeFS::SpecHelpers >> use_fakefs >> ... >> end >> To... >> extend FakeFS::SpecHelpers >> use_fakefs describe "smth" do ... end >> >> As it seems the use_fakefs method now takes the describe block as a >> parameter and thus the error regarding the wrong number of parameters. >> >> I had to do this slightly differently, but got it to work with fakefs-0.2.1. Fixed in git. >> >> Cheers, >> David > > You can use include, too: > > module SpecHelpers > def self.extended(example_group) > example_group.use_fakefs(example_group) > end > > def self.included(example_group) > example_group.extend self > end > .. > end > > That's exactly what I did :) > > http://github.com/dchelimsky/rspec/commit/65485d8be96cd0cb474dc29b6778180349c2d8ee Hadn't realized the docs were wrong in the README. Now they are updated: http://github.com/defunkt/fakefs/commit/ceffec3023a2c790cd567275168ed6d6e5bf4ba9 Thanks for the heads up. Scott -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Tue Nov 24 06:01:07 2009 From: lists at ruby-forum.com (Peter Ritchie) Date: Tue, 24 Nov 2009 12:01:07 +0100 Subject: [rspec-users] Cucumber Cygwin In-Reply-To: <2e31aa3270c45ab583f0de8754833ab1@ruby-forum.com> References: <1a0ea03077848f0abf1e89a51a3741c0@ruby-forum.com> <8d961d900911231002q7f1567d6i21246849d09958fa@mail.gmail.com> <2e31aa3270c45ab583f0de8754833ab1@ruby-forum.com> Message-ID: <5a40dc7bd34c4d3a98097c280bb67e71@ruby-forum.com> Peter Ritchie wrote: > Aslak Helles?y wrote: >>> Stuck as to what dependency is calling for cucumber 0.4.4 - >> >> config/environments/cucumber.rb? >> >> (Failing that - search for the string "0.4.4" among your project's >> files) >> >>> we want to >>> stick to 0.4.3 but Cygwin installation not allowing it - OK on Mac >>> >> >> What's stopping you from running 0.4.4? >> >> In any case, if you need 0.4.3: >> >> gem uninstall cucumber >> gem install cucumber 0.4.3 >> script/generate cucumber > > Thank you for that, I have searched for 0.4.4 in the project and no > instance. > > Main collaborator is using 0.4.3 but we are updating to see if it fixes > it. Many thanks and for link to cucumber list. > > Peter We updated to run 0.4.4 which has moved the problem on. We now get /usr/bin/ruby.exe -I "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.4/lib:lib" "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.4/bin/cucumber" --color --tags ~@wip --strict --format pretty undefined local variable or method `capture_model' for main:Object (NameError) ./features/step_definitions/pickle_steps.rb:4 It only happens on Windows - works fine on Mac I posted this problem on Cuke but it does not seem to have got past the moderator (at least it has not appeared). Thanks Peter -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Tue Nov 24 10:11:09 2009 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 24 Nov 2009 15:11:09 +0000 Subject: [rspec-users] Cucumber Cygwin In-Reply-To: <5a40dc7bd34c4d3a98097c280bb67e71@ruby-forum.com> References: <1a0ea03077848f0abf1e89a51a3741c0@ruby-forum.com> <8d961d900911231002q7f1567d6i21246849d09958fa@mail.gmail.com> <2e31aa3270c45ab583f0de8754833ab1@ruby-forum.com> <5a40dc7bd34c4d3a98097c280bb67e71@ruby-forum.com> Message-ID: <9CB584FE-8651-431A-8B20-FEDA489C30A4@mattwynne.net> On 24 Nov 2009, at 11:01, Peter Ritchie wrote: > Peter Ritchie wrote: >> Aslak Helles?y wrote: >>>> Stuck as to what dependency is calling for cucumber 0.4.4 - >>> >>> config/environments/cucumber.rb? >>> >>> (Failing that - search for the string "0.4.4" among your project's >>> files) >>> >>>> we want to >>>> stick to 0.4.3 but Cygwin installation not allowing it - OK on Mac >>>> >>> >>> What's stopping you from running 0.4.4? >>> >>> In any case, if you need 0.4.3: >>> >>> gem uninstall cucumber >>> gem install cucumber 0.4.3 >>> script/generate cucumber >> >> Thank you for that, I have searched for 0.4.4 in the project and no >> instance. >> >> Main collaborator is using 0.4.3 but we are updating to see if it >> fixes >> it. Many thanks and for link to cucumber list. >> >> Peter > > We updated to run 0.4.4 which has moved the problem on. We now get > > /usr/bin/ruby.exe -I > "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.4/lib:lib" > "/usr/lib/ruby/gems/1.8/gems/cucumber-0.4.4/bin/cucumber" --color -- > tags > ~@wip --strict --format pretty > undefined local variable or method `capture_model' for main:Object > (NameError) > ./features/step_definitions/pickle_steps.rb:4 > > It only happens on Windows - works fine on Mac > > I posted this problem on Cuke but it does not seem to have got past > the > moderator (at least it has not appeared). Everyone head over to... http://groups.google.com/group/cukes/browse_thread/thread/de6e8cdf8585f9ca cheers, Matt http://mattwynne.net +447974 430184 From krasimir.angelov at gmail.com Wed Nov 25 11:02:20 2009 From: krasimir.angelov at gmail.com (Krasimir Angelov) Date: Wed, 25 Nov 2009 18:02:20 +0200 Subject: [rspec-users] Stubbing helper methods in controller specs when integrate_views is On Message-ID: Hi all, I'm using rspec-caching-test-plugin to test caching (obviously) in my controller specs. Because views are also involved in caching integrate_views have to be turned On. The problem comes when mock is passed to a helper, for examle link_to_profile(profile) where porfile = mock_model(Profile) The error thrown is "can't convert Spec::Mocks::Mock into String". Usually when dealing with view specs in this case I'm just doing template.stub!(:link_to_profile => '/link/to/profile') and specing the helper method in separate helper spec, but in this case (controller spec with integrate_views turned On) I have no access to template object. Is there any way to stub helper method or I just have to give away mocks and use real records created with FactoryGirl instead? Regards, K. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cagraff at cox.net Wed Nov 25 12:49:31 2009 From: cagraff at cox.net (Carl Graff) Date: Wed, 25 Nov 2009 09:49:31 -0800 Subject: [rspec-users] Introductory recommendations? In-Reply-To: <5ac2b94f346e6e5d4dc699309d4b7b5f@ruby-forum.com> References: <6b934f68-ad0c-4e0d-9130-a7cad5c3989c@x5g2000prf.googlegroups.com> <5ac2b94f346e6e5d4dc699309d4b7b5f@ruby-forum.com> Message-ID: <4B0D6E2B.4080609@cox.net> I agree that mocks are one of the harder concepts to grasp. In my case - although I will probably get some flack - I created some simple real objects first, then tried to mimic their behavior with mocks. When you are first leaning sometimes I find it better to start with a known real object then to see how to do it in cucumber or RSpec. Mind you this is just training wheels to give you confidence in your mock objects. Jon Pincus wrote: > Thanks Andy and Carl. I've bought The RSpec Book and there's a wealth > of good information, but the tutorial in Chapter 5 ("Getting Started > with RSpec") starts with mock objects and the quirks of > should_receive.with ... that seems like a pretty advanced place to start > for those who aren't familiar with TDD (or BDD). I'm hoping for > something more straightforward. > > jon > From pat.maddox at gmail.com Wed Nov 25 13:07:46 2009 From: pat.maddox at gmail.com (Pat Maddox) Date: Wed, 25 Nov 2009 10:07:46 -0800 Subject: [rspec-users] Introductory recommendations? In-Reply-To: References: Message-ID: <2c7e61990911251007j12d4b652u5b5540327fa6c74e@mail.gmail.com> Pair with them. How big's the team? Lots of ways you can do this. If there are 5 other devs, you can pair with one each day, bam, training in a week. If there are 10, you pair with 5 for one week, then have those guys pair with the other guys over the next week (rotating every day). Does anybody in your organization have any experience with RSpec? It's likely somebody's played with it some. Lean on them. Pick up the RSpec book and pair as much as you can. Pat On Fri, Nov 20, 2009 at 1:11 PM, Jon Pincus wrote: > Hi all, > > I'm with a team of engineers who are new to RSpec, and I'm looking for > some good introductory material. ?Ideally it would be something like the > two-part Railscast on Cucumber ( > http://asciicasts.com/episodes/155-beginning-with-cucumber ) which > doesn't assume detailed knowledge of TDD. > > I found David Chelimsky's Intro at > http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/ > ... anything else that people would recommend? > > Thanks much! > > jon > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Wed Nov 25 13:38:38 2009 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 25 Nov 2009 18:38:38 +0000 Subject: [rspec-users] Introductory recommendations? In-Reply-To: <2c7e61990911251007j12d4b652u5b5540327fa6c74e@mail.gmail.com> References: <2c7e61990911251007j12d4b652u5b5540327fa6c74e@mail.gmail.com> Message-ID: +1 And have a coding dojo ASAP. It's much easier to learn when you're having fun. On 25 Nov 2009, at 18:07, Pat Maddox wrote: > Pair with them. How big's the team? Lots of ways you can do this. > If there are 5 other devs, you can pair with one each day, bam, > training in a week. If there are 10, you pair with 5 for one week, > then have those guys pair with the other guys over the next week > (rotating every day). Does anybody in your organization have any > experience with RSpec? It's likely somebody's played with it some. > Lean on them. > > Pick up the RSpec book and pair as much as you can. > > Pat > > On Fri, Nov 20, 2009 at 1:11 PM, Jon Pincus > wrote: >> Hi all, >> >> I'm with a team of engineers who are new to RSpec, and I'm looking >> for >> some good introductory material. Ideally it would be something >> like the >> two-part Railscast on Cucumber ( >> http://asciicasts.com/episodes/155-beginning-with-cucumber ) which >> doesn't assume detailed knowledge of TDD. >> >> I found David Chelimsky's Intro at >> http://blog.davidchelimsky.net/2007/05/14/an-introduction-to-rspec-part-i/ >> ... anything else that people would recommend? >> >> Thanks much! >> >> jon >> -- >> 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 cheers, Matt http://mattwynne.net +447974 430184 From closson.evan at gmail.com Wed Nov 25 20:11:51 2009 From: closson.evan at gmail.com (evanclosson) Date: Wed, 25 Nov 2009 17:11:51 -0800 (PST) Subject: [rspec-users] Un-recognised routes that do exist, using namespaces & subdomain checking In-Reply-To: <57c63afe0911110455s26ceb8f5ga5072f8b1280e390@mail.gmail.com> References: <29e1f9a2-b379-40c9-aa38-263d5b730c0d@l13g2000yqb.googlegroups.com> <57c63afe0911101448w7d494c50g76b18a2dc1126155@mail.gmail.com> <038eeaaa-b06e-448b-b469-6325d33a4fec@l13g2000yqb.googlegroups.com> <57c63afe0911101654i522db6cbq41e69b54c29e6cfe@mail.gmail.com> <48c7cd94-e130-4e0f-95fe-f4346a137e98@m16g2000yqc.googlegroups.com> <57c63afe0911110454n19e1f657i88793805b30056b2@mail.gmail.com> <57c63afe0911110455s26ceb8f5ga5072f8b1280e390@mail.gmail.com> Message-ID: <70bf62b1-d958-414b-ab0b-47d460b44352@s31g2000yqs.googlegroups.com> Was able to get past this testing issue for the moment. In the interest of time I dropped some example code on my site pending a more permanent solution. Hope it helps... http://www.evanclosson.com/devlog/testingrouteswithrspecandsubdomainfu On Nov 11, 7:55?am, David Chelimsky wrote: > On Wed, Nov 11, 2009 at 4:54 AM, David Chelimsky wrote: > > > > > On Wed, Nov 11, 2009 at 3:12 AM, DEfusion wrote: > > >> Hi David, > > >> Yeah I had used the new style in the past and got the same issue, I > >> just accidentally reverted to the old style. > > >> Anyway changing to the new style using route_to as suggested doesn't > >> resolve the issue, the same 2 routes give the same error, but the > >> telling thing is the failure message shows that the subdomain wasn't > >> passed, or at least received by the routing: > > >> ActionController::RoutingError in 'Foo::MonkeysController should > >> route' > >> No route matches "/monkeys/1" with > >> {:port=>80, :method=>:get, :host_with_port=>"test.host", :subdomain=>nil, > >> :domain=>"test.host", :host=>"test.host"} > >> If you're expecting this failure, we suggest { :get => "/monkeys/ > >> 1" }.should_not be_routable > > >> Even if I specifically set @request.host = 'foo.some.com' before the > >> test it still errors saying host_with_port=>'test.host' > > > OK. I haven't used subdomain-fu before, but I'm guessing that it's either > > getting loaded or invoked after rspec, or the two are monkey patching the > > same things and creating a conflict. > > > Would you do me a favor and slap together a small demo app with the > > specific version of rspec and subdomain-fu that you are using bundled > > (vendor/gems preferable), zip it up and submit it in a ticket to > >http://rspec.lighthouseapp.com? > > Of course, the app should demonstrate the failure :) Forgot that little > tidbit. > > > > > Thx, > > David > > >> -D > > >> On Nov 11, 12:54 am, David Chelimsky wrote: > >> > On Tue, Nov 10, 2009 at 4:10 PM, DEfusion > >> wrote: > >> > > Removing the :sub domain conditions from the namespace does fix the > >> > > issue, and moving the sub domain conditions to the individual route > >> > > definitions causes them all to fail. > > >> > > On Nov 10, 11:59 pm, DEfusion wrote: > >> > > > Okay I've managed to re-create my original problem by trying to use > >> > > > params_from to verify the routing (which was another area I was > >> > > > experiencing problems with before). > > >> > > > Note each one of the routes I'm defining here all return fine in the > >> > > > browser, they hit the appropriate controller and run the show > >> action, > >> > > > however as you can see by the comments 2 of the specs fail to find > >> the > >> > > > routes defined. > > >> > > >http://gist.github.com/231408 > > >> > Can you try using route_to instead of params_from().should ==? > > >> > Seehttp://github.com/dchelimsky/rspec-rails/blob/master/Upgrade.rdoc > > >> > Let me know if that works better. > > >> > David > > >> > > > -D > > >> > > > On Nov 10, 11:25 pm, DEfusion wrote: > > >> > > > > Now that is weird. I tried to make an isolated example for you and > >> > > > > that worked fine. So I put un-commented my spec bit by bit and it > >> > > > > works fine. > > >> > > > > I'm sure I've had this problem before. If I do re-create it I'll > >> post > >> > > > > more details here. > > >> > > > > =D > > >> > > > > On Nov 10, 10:48 pm, David Chelimsky > >> wrote: > > >> > > > > > On Tue, Nov 10, 2009 at 2:25 PM, DEfusion < > >> david.sp... at gmail.com> > >> > > wrote: > >> > > > > > > I'm getting really cheesed off with RSpec not matching some of > >> my > >> > > > > > > routes when controller testing when I have subdomain checking > >> > > > > > > (courtesy of subdomain-fu) on namespaces. These routes appear > >> in > >> > > the > >> > > > > > > rake routes output, and work fine via HTTP requests . > > >> > > > > > > The really annoying thing is it's working fine for routes that > >> > > aren't > >> > > > > > > at the root of the namespace. > > >> > > > > > > E.g. ?say I have > > >> > > > > > > map.namespace :foo, :path_prefix => '', :conditions => { > >> :subdomain > >> > > => > >> > > > > > > 'foo' } do |foo| > > >> > > > > > > ? ?foo.bars, :controller => 'bars', :only => [:show] do |bar| > >> > > > > > > ? ? ? ?bar.resources some_things .... > >> > > > > > > ? ?end > > >> > > > > > > ? ?foo.resources :monkeys > >> > > > > > > end > > >> > > > > > > My specs for bars/some_things all resolve the routes fine > >> (e.g. > >> > > doing > >> > > > > > > get :index etc.) > > >> > > > > > > Any spec that tries to hit monkeys/ give me a no route matches > >> even > >> > > > > > > though these routes exist > > >> > > > > > > ? ?No route matches {:controller=>"foo/monkeys", > >> :action=>"update"} > > >> > > > > > > I've tried setting both @request.host and request.host to > >> > > > > > > foo.test.host but that doesn't make a blind bit of difference. > > >> > > > > > > Maybe RSpec is doing something different with the request, as > >> if I > >> > > > > > > monkey patch the routing with the following I never get the > >> dumps > >> > > when > >> > > > > > > using RSpec even though both these are called pretty early on > >> in > >> > > route > >> > > > > > > recognition. > > >> > > > > > > module Foo > > >> > > > > > > ?module RouteSetExtensions > >> > > > > > > ? ?def self.included(base) > >> > > > > > > ? ? ?base.alias_method_chain :extract_request_environment, > >> :debug > >> > > > > > > ? ? ?base.alias_method_chain :recognize_path, :debug > >> > > > > > > ? ?end > > >> > > > > > > ? ?def recognize_path_with_debug(path, environment={}) > >> > > > > > > ? ? ?puts path > >> > > > > > > ? ? ?puts environment.to_yaml > >> > > > > > > ? ? ?recognize_path_without_debug(path, environment) > >> > > > > > > ? ?end > > >> > > > > > > ? ?def extract_request_environment_with_debug(request) > >> > > > > > > ? ? ?env = extract_request_environment_without_debug(request) > >> > > > > > > ? ? ?puts env.to_yaml > >> > > > > > > ? ? ?env > >> > > > > > > ? ?end > >> > > > > > > ?end > > >> > > > > > > end > > >> > > > > > > ActionController::Routing::RouteSet.send :include, > >> > > > > > > Foo::RouteSetExtensions > > >> > > > > > > So as you can probably tell, I'm out of ideas so I wondered if > >> > > anyone > >> > > > > > > had any thoughts. > > >> > > > > > Please post the failing spec and the exact failure message. > > >> > > > > > Thx, > >> > > > > > David > > >> > > > > > _______________________________________________ > >> > > > > > 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 > > >> > > > _______________________________________________ > >> > > > 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 > > >> > _______________________________________________ > >> > 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 > > > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Wed Nov 25 21:31:48 2009 From: lists at ruby-forum.com (Zhenning Guan) Date: Thu, 26 Nov 2009 03:31:48 +0100 Subject: [rspec-users] how to test a observer model? Message-ID: I have a user_observer, code like this: def after_create(user) UserMailer.deliver_signup_notification(user) user.random_key = random_key_method user.save end before do @user = mock_model(User) @user_observer = UserObserver.instance end UserMailer.should_receive(:deliver_signup_notification).with(@user) @user_observer.after_create(@user) --------------------------------------- how can I test the random_key process? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Nov 26 02:21:27 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Thu, 26 Nov 2009 08:21:27 +0100 Subject: [rspec-users] undefined method `route_for In-Reply-To: References: <57c63afe0911100659s296f97e2i96827851ea429bd@mail.gmail.com> <57c63afe0911110446n57225546ib288100d05cee61c@mail.gmail.com> <4A036CC1-A71C-48A8-A511-5CB829C8DEF8@gmail.com> <57c63afe0911121957h1449181bm93a1eb2f8a1fe3c9@mail.gmail.com> <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> <57c63afe0911130639w1168fdbav5aebcb019f563eb@mail.gmail.com> <37480320c538326c804860007ae1e26b@ruby-forum.com> <097b6352040480b2f8a6f78ea85769cd@ruby-forum.com> <57c63afe0911170711k4f04bdb8weadb244ccab7d540@mail.gmail.com> Message-ID: <5d0aadafba7ad1b891fca2111c341e9f@ruby-forum.com> Amit Kulkarni wrote: > Ok Fine.That sounds to be a good idea. > Thanks Hi David, Good news,My routing scenarios are working now. I dont know how but it did.I was going to mail you the app but it is working fine now. -- Posted via http://www.ruby-forum.com/. From ashley.moran at patchspace.co.uk Thu Nov 26 06:45:06 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Thu, 26 Nov 2009 11:45:06 +0000 Subject: [rspec-users] Introductory recommendations? In-Reply-To: References: <2c7e61990911251007j12d4b652u5b5540327fa6c74e@mail.gmail.com> Message-ID: On Nov 25, 2009, at 6:38 pm, Matt Wynne wrote: > +1 > > And have a coding dojo ASAP. It's much easier to learn when you're having fun. > > On 25 Nov 2009, at 18:07, Pat Maddox wrote: > >> Pair with them. How big's the team? Lots of ways you can do this. +2 +1 For the pairing, it's the most efficient way to share knowledge. But I suggest making it clear it's training. I've done it where the other person was under the impression that the point of the exercise to produce production code, and became frustrated with how slow it is. +1 For the Coding Dojo (which involves pairing anyway). Had no idea how much fun these are until I ran one. It's especially valuable for the amount of cognitive dissonance it generates - pretty much every line of code is a point of discussion. I think that given the task of training a team of 5 now, I'd give serious thought to a Coding Dojo on a Friday, then pairing with each developer the next week. Or maybe, facilitating pairs pulled and rotated from the team (ie three people at a workstation). Ashley -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran From dchelimsky at gmail.com Thu Nov 26 08:01:46 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 26 Nov 2009 07:01:46 -0600 Subject: [rspec-users] undefined method `route_for In-Reply-To: <5d0aadafba7ad1b891fca2111c341e9f@ruby-forum.com> References: <1c7ec52a97eaaf0945deaa7461ba76c4@ruby-forum.com> <57c63afe0911122356n78f5c09fk89abea677f702dea@mail.gmail.com> <57c63afe0911130639w1168fdbav5aebcb019f563eb@mail.gmail.com> <37480320c538326c804860007ae1e26b@ruby-forum.com> <097b6352040480b2f8a6f78ea85769cd@ruby-forum.com> <57c63afe0911170711k4f04bdb8weadb244ccab7d540@mail.gmail.com> <5d0aadafba7ad1b891fca2111c341e9f@ruby-forum.com> Message-ID: <57c63afe0911260501g764cb865q8f500247bced26bd@mail.gmail.com> On Thu, Nov 26, 2009 at 1:21 AM, Amit Kulkarni wrote: > Amit Kulkarni wrote: > > Ok Fine.That sounds to be a good idea. > > Thanks > > Hi David, > Good news,My routing scenarios are working now. > I dont know how but it did.I was going to mail you the app but it is > working fine now. > > Excellent! -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Thu Nov 26 13:15:15 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 26 Nov 2009 18:15:15 +0000 Subject: [rspec-users] how to test a observer model? In-Reply-To: References: Message-ID: <88FA97E8-E731-499E-9DD6-BF501A7A1E9E@mattwynne.net> On 26 Nov 2009, at 02:31, Zhenning Guan wrote: > I have a user_observer, code like this: > > def after_create(user) > UserMailer.deliver_signup_notification(user) > user.random_key = random_key_method > user.save > end > > > before do > @user = mock_model(User) > @user_observer = UserObserver.instance > end > > UserMailer.should_receive(:deliver_signup_notification).with(@user) > @user_observer.after_create(@user) > --------------------------------------- > > how can I test the random_key process? You can do something like this to sense the value passed to the user object: it "should generate a key for the user which is 30 characters long" do @user.should_receive(:random_key=) do |value| value.length.should == 30 end @user_observer.after_create(@user) end Obviously the precise specifications of the key are up to you and your stakeholders, but that should show you how you can test it. cheers, Matt http://mattwynne.net +447974 430184 From matt at mattwynne.net Thu Nov 26 13:23:41 2009 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 26 Nov 2009 18:23:41 +0000 Subject: [rspec-users] Stubbing helper methods in controller specs when integrate_views is On In-Reply-To: References: Message-ID: <6F3E67E6-A0A6-4CE9-ABD3-5E7F8F292497@mattwynne.net> On 25 Nov 2009, at 16:02, Krasimir Angelov wrote: > Hi all, > > I'm using rspec-caching-test-plugin to test caching (obviously) in > my controller specs. Because views are also involved in caching > integrate_views have to be turned On. > The problem comes when mock is passed to a helper, for examle > > link_to_profile(profile) > > where porfile = mock_model(Profile) > > The error thrown is "can't convert Spec::Mocks::Mock into String". > Usually when dealing with view specs in this case I'm just doing > > template.stub!(:link_to_profile => '/link/to/profile') > > and specing the helper method in separate helper spec, but in this > case (controller spec with integrate_views turned On) I have no > access to template object. > > Is there any way to stub helper method or I just have to give away > mocks and use real records created with FactoryGirl instead? You have a couple of options, I think: (1) Try mocking enough of the object's interface that the Rails helper will happily build a link to it. I think that just means stubbing a #to_param method on it. (2) Use rspec-rails' mock_model method to build the mock object, which will basically do that for you. (3) Use rspec-rails' stub_model method to build the mock object, which creates a real model object instance (like FactoryGirl would) except with the database connection crippled. Okay that was three options. cheers, Matt http://mattwynne.net +447974 430184 From lists at ruby-forum.com Thu Nov 26 20:35:07 2009 From: lists at ruby-forum.com (Zhenning Guan) Date: Fri, 27 Nov 2009 02:35:07 +0100 Subject: [rspec-users] how to test a observer model? In-Reply-To: <88FA97E8-E731-499E-9DD6-BF501A7A1E9E@mattwynne.net> References: <88FA97E8-E731-499E-9DD6-BF501A7A1E9E@mattwynne.net> Message-ID: Matt Wynne wrote: > You can do something like this to sense the value passed to the user > object: > Obviously the precise specifications of the key are up to you and your > stakeholders, but that should show you how you can test it. > > cheers, > Matt > > http://mattwynne.net > +447974 430184 thank you. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Nov 26 22:24:59 2009 From: lists at ruby-forum.com (Emerson Macedo) Date: Fri, 27 Nov 2009 04:24:59 +0100 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: References: Message-ID: <1760b15679abae1b81565bbe97bd547d@ruby-forum.com> Fernando Perez wrote: > Hi, > > Let's take the example of the depot app. In my controller I set @order. > Then in the view comes the bad stuff: > > @order.items.each do |item| > item.product.title > end > > Now I'm having problems specing item.product.title. A quick and dirty > fix is to trade a for for an underscore, so I create Item#product_title: > > def product_title > product.title > end > > The problem is that I have a few models that act the same way, so I > would find myself writing lot's of these little instance methods, and > the solution looks a bit stupid to me. So how do you handle such issue? > > I thought about composed_of, but AWDWR's examples still break Demeter's > law and that annoys me. > > > Thanks in advance Hi, please try the Law of Demeter gem Its a DRY way to apply Law of Demeter with demeter gem http://github.com/emerleite/demeter http://gemcutter.org/gems/demeter -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Nov 27 04:21:01 2009 From: lists at ruby-forum.com (Amit Kulkarni) Date: Fri, 27 Nov 2009 10:21:01 +0100 Subject: [rspec-users] Display Rspec output in an html file In-Reply-To: <744c997fb5fe43cbb5987ef33930c18b@ruby-forum.com> References: <6bb97fe564ebbb30e16ad7e753473ca0@ruby-forum.com> <6E9E130A-B144-4AAC-9EEF-CA69E189D553@mattwynne.net> <744c997fb5fe43cbb5987ef33930c18b@ruby-forum.com> Message-ID: Amit Kulkarni wrote: > Any suggestions on the above topic Hello, I want to print my output in an html file. I am using command rake spec:controllers --format html:result.html from the root directory But it is not working. Please suggest -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Nov 27 05:58:09 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 27 Nov 2009 04:58:09 -0600 Subject: [rspec-users] Display Rspec output in an html file In-Reply-To: References: <6bb97fe564ebbb30e16ad7e753473ca0@ruby-forum.com> <6E9E130A-B144-4AAC-9EEF-CA69E189D553@mattwynne.net> <744c997fb5fe43cbb5987ef33930c18b@ruby-forum.com> Message-ID: <57c63afe0911270258r73d1b432wdbcc999a93a8bdd8@mail.gmail.com> On Fri, Nov 27, 2009 at 3:21 AM, Amit Kulkarni wrote: > Amit Kulkarni wrote: > > Any suggestions on the above topic > > Hello, > I want to print my output in an html file. > I am using command rake spec:controllers --format html:result.html from > the root directory > But it is not working. > Please suggest > --format is a spec command option: spec spec/controllers --format html:result.html The rake task doesn't support command line options. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Nov 27 06:07:57 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 27 Nov 2009 05:07:57 -0600 Subject: [rspec-users] Depot app, Demeter's law and troubles cleanly specing In-Reply-To: <1760b15679abae1b81565bbe97bd547d@ruby-forum.com> References: <1760b15679abae1b81565bbe97bd547d@ruby-forum.com> Message-ID: <57c63afe0911270307r58816ce5wa874a87d1416a6ca@mail.gmail.com> On Thu, Nov 26, 2009 at 9:24 PM, Emerson Macedo wrote: > Fernando Perez wrote: > > Hi, > > > > Let's take the example of the depot app. In my controller I set @order. > > Then in the view comes the bad stuff: > > > > @order.items.each do |item| > > item.product.title > > end > > > > Now I'm having problems specing item.product.title. A quick and dirty > > fix is to trade a for for an underscore, so I create Item#product_title: > > > > def product_title > > product.title > > end > > > > The problem is that I have a few models that act the same way, so I > > would find myself writing lot's of these little instance methods, and > > the solution looks a bit stupid to me. So how do you handle such issue? > > > > I thought about composed_of, but AWDWR's examples still break Demeter's > > law and that annoys me. > > > > > > Thanks in advance > > Hi, please try the Law of Demeter gem > > Its a DRY way to apply Law of Demeter with demeter gem > Interesting. There is a plugin still floating around called Demeter's Revenge that does a similar thing with associations rather than attributes. So, in the demeter gem, you can do this: @post.author_name # same as @post.author.name Whereas in demeters_revenge you can do this: @post.create_author # same as @post.author.create Be nice if both sets of behaviour were in one gem :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From apremdas at gmail.com Fri Nov 27 13:29:22 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 27 Nov 2009 18:29:22 +0000 Subject: [rspec-users] Spec helper configuration problem Message-ID: <88fd8ddc0911271029x28d0c2ddtdd2ccbf6c43152a9@mail.gmail.com> Hi all, I have a rails application whose specs run on about eight different boxes, but I can't get them to work on my integration server. The bit thats breaking concerns some modules that I have in spec/support/modules which are loaded by the following line in spec_helper # get any macros etc Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f} one of these modules includes the other modules, and this generates the following stacktrace /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant OrderSpecHelper::BasketSpecHelper (NameError) from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in `const_missing' from ./spec/helpers/../support/modules/order_spec_helper.rb:2 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in `require' the line causing this is order_spec_helper.rb:2 module OrderSpecHelper include BasketSpecHelper and BasketSpecHelper is defined in /support/modules/basket_spec_helper.rb and is coded something like module BasketSpecHelper ... I wonder if anyone has any ideas about the cause of this problem or some ideas about possible solutions Many thanks Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Fri Nov 27 14:59:38 2009 From: ben at benmabey.com (Ben Mabey) Date: Fri, 27 Nov 2009 12:59:38 -0700 Subject: [rspec-users] Spec helper configuration problem In-Reply-To: <88fd8ddc0911271029x28d0c2ddtdd2ccbf6c43152a9@mail.gmail.com> References: <88fd8ddc0911271029x28d0c2ddtdd2ccbf6c43152a9@mail.gmail.com> Message-ID: <4B102FAA.5070401@benmabey.com> Andrew Premdas wrote: > Hi all, > > I have a rails application whose specs run on about eight different > boxes, but I can't get them to work on my integration server. The bit > thats breaking concerns some modules that I have in > spec/support/modules which are loaded by > the following line in spec_helper > > # get any macros etc > Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f} > > > one of these modules includes the other modules, and this generates > the following stacktrace > /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant OrderSpecHelper::BasketSpecHelper (NameError) > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in `const_missing' > from ./spec/helpers/../support/modules/order_spec_helper.rb:2 > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' > from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in `require' > the line causing this is order_spec_helper.rb:2 > > module OrderSpecHelper > include BasketSpecHelper > > and BasketSpecHelper is defined in > /support/modules/basket_spec_helper.rb > > > and is coded something like > > module BasketSpecHelper > ... > > I wonder if anyone has any ideas about the cause of this problem or > some ideas about possible solutions I've ran into similar issues. The problem in my case was the my integration server was running linux but our dev boxes were OSx. The issue was file ordering being different for the Dir::[] method on the OSes. Try adding a sort call like so: Dir[File.dirname(__FILE__) + "/support/**/*.rb"].sort.each {|f| require f} HTH, Ben From html-kurs at gmx.de Fri Nov 27 19:35:51 2009 From: html-kurs at gmx.de (Martin) Date: Sat, 28 Nov 2009 01:35:51 +0100 Subject: [rspec-users] spork doesn't find helpers Message-ID: <4B107067.1080407@gmx.de> Hi, I'm running into a problem with spork: The helper methods in app/helpers/simpler_helper.rb are not found when using spork: > rake spec (in longPath/test1) ..F.......................... 1) ActionView::TemplateError in '/items/index.html.erb renders a list of items' undefined method `simpleFunction' for # On line #7 of app/views/items/index.html.erb 4:
5: 6: 7: <%= simpleFunction() %> 8: <% @items.each do |item| %> 9: 10: But 'simpeFunction' is defined in app/helpers/simpler_helper.rb. Running rake spec without spork works correctly. Can you point me the right direction please? Thanks, Martin From html-kurs at gmx.de Fri Nov 27 19:52:46 2009 From: html-kurs at gmx.de (Martin) Date: Sat, 28 Nov 2009 01:52:46 +0100 Subject: [rspec-users] spork doesn't find helpers In-Reply-To: <4B107067.1080407@gmx.de> References: <4B107067.1080407@gmx.de> Message-ID: <4B10745E.8090005@gmx.de> I forgot to tell you the versions I'm using: spork: 0.7.3 rspec: 1.2.9 rails: 2.3.5 > Hi, > > I'm running into a problem with spork: > The helper methods in app/helpers/simpler_helper.rb are not found when > using spork: > > > rake spec > (in longPath/test1) > ..F.......................... > > 1) > ActionView::TemplateError in '/items/index.html.erb renders a list of > items' > undefined method `simpleFunction' for # > On line #7 of app/views/items/index.html.erb > > 4: > 5: > 6: > 7: <%= simpleFunction() %> > 8: <% @items.each do |item| %> > 9: > 10: > > But 'simpeFunction' is defined in app/helpers/simpler_helper.rb. > > Running rake spec without spork works correctly. > > Can you point me the right direction please? > > Thanks, > Martin > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Sat Nov 28 06:16:43 2009 From: matt at mattwynne.net (Matt Wynne) Date: Sat, 28 Nov 2009 11:16:43 +0000 Subject: [rspec-users] spork doesn't find helpers In-Reply-To: <4B10745E.8090005@gmx.de> References: <4B107067.1080407@gmx.de> <4B10745E.8090005@gmx.de> Message-ID: <0229DDC3-CD16-4D2C-85BC-8E941DDA5C4F@mattwynne.net> I should try asking about this on http://groups.google.com/group/sporkgem On 28 Nov 2009, at 00:52, Martin wrote: > I forgot to tell you the versions I'm using: > > spork: 0.7.3 > rspec: 1.2.9 > rails: 2.3.5 > > >> Hi, >> I'm running into a problem with spork: >> The helper methods in app/helpers/simpler_helper.rb are not found >> when using spork: >> > rake spec >> (in longPath/test1) >> ..F.......................... >> 1) >> ActionView::TemplateError in '/items/index.html.erb renders a list >> of items' >> undefined method `simpleFunction' for # >> On line #7 of app/views/items/index.html.erb >> 4: >> 5: >> 6: >> 7: <%= simpleFunction() %> >> 8: <% @items.each do |item| %> >> 9: >> 10: >> But 'simpeFunction' is defined in app/helpers/simpler_helper.rb. >> Running rake spec without spork works correctly. >> Can you point me the right direction please? >> Thanks, >> Martin >> _______________________________________________ >> 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 http://mattwynne.net +447974 430184 From rogerpack2005 at gmail.com Sun Nov 29 01:33:05 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Sat, 28 Nov 2009 22:33:05 -0800 (PST) Subject: [rspec-users] surprising... Message-ID: <69c47f23-5014-423b-b263-ca162c4447a0@m38g2000yqd.googlegroups.com> It is somewhat surprising to me, as a newbie, to have to assert a.should be_a(Hash) That extra space in there feels awkward. Suggestion: allow for constructs like a.should.be_a(Hash) Thoughts? Much thanks. -r From dchelimsky at gmail.com Sun Nov 29 08:53:53 2009 From: dchelimsky at gmail.com (David Chelimsky) Date: Sun, 29 Nov 2009 07:53:53 -0600 Subject: [rspec-users] surprising... In-Reply-To: <69c47f23-5014-423b-b263-ca162c4447a0@m38g2000yqd.googlegroups.com> References: <69c47f23-5014-423b-b263-ca162c4447a0@m38g2000yqd.googlegroups.com> Message-ID: <57c63afe0911290553r24236678me64827698d21011d@mail.gmail.com> On Sun, Nov 29, 2009 at 12:33 AM, rogerdpack wrote: > It is somewhat surprising to me, as a newbie, to have to assert > a.should be_a(Hash) > > That extra space in there feels awkward. > > Suggestion: > > allow for constructs like > a.should.be_a(Hash) > > Thoughts? > You're about 4 years late to the party. We were playing around with a variety of options back in 2005 and went with the current syntax because it gave us the most flexibility and the highest level of decoupling, making it easier for others to create their own matcher libraries. While it would be technically feasible to support should.matcher, doing so now would cause more confusion for more people than be helpful, IMO. If you're really excited about that syntax (with the dots), there are other frameworks (test/spec and expectations to name two) that use it or something similar, so you might want to give those a peek as well. Good luck! Cheers, David > Much thanks. > -r > _______________________________________________ > 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 Mon Nov 30 06:14:00 2009 From: apremdas at gmail.com (Andrew Premdas) Date: Mon, 30 Nov 2009 11:14:00 +0000 Subject: [rspec-users] Spec helper configuration problem In-Reply-To: <4B102FAA.5070401@benmabey.com> References: <88fd8ddc0911271029x28d0c2ddtdd2ccbf6c43152a9@mail.gmail.com> <4B102FAA.5070401@benmabey.com> Message-ID: <88fd8ddc0911300314vde47705y3c9555e330d08a04@mail.gmail.com> 2009/11/27 Ben Mabey > Andrew Premdas wrote: > >> Hi all, >> >> I have a rails application whose specs run on about eight different boxes, >> but I can't get them to work on my integration server. The bit thats >> breaking concerns some modules that I have in spec/support/modules which are >> loaded by >> the following line in spec_helper >> >> # get any macros etc >> Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f} >> >> >> one of these modules includes the other modules, and this generates the >> following stacktrace >> >> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:440:in >> `load_missing_constant': uninitialized constant >> OrderSpecHelper::BasketSpecHelper (NameError) >> from >> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in >> `const_missing' >> from ./spec/helpers/../support/modules/order_spec_helper.rb:2 >> from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `gem_original_require' >> from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in >> `require' >> from >> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:158:in >> `require' >> the line causing this is order_spec_helper.rb:2 >> >> module OrderSpecHelper >> include BasketSpecHelper >> and BasketSpecHelper is defined in >> /support/modules/basket_spec_helper.rb >> >> >> and is coded something like >> >> module BasketSpecHelper >> ... >> >> I wonder if anyone has any ideas about the cause of this problem or some >> ideas about possible solutions >> > > I've ran into similar issues. The problem in my case was the my > integration server was running linux but our dev boxes were OSx. The issue > was file ordering being different for the Dir::[] method on the OSes. Try > adding a sort call like so: > > Dir[File.dirname(__FILE__) + "/support/**/*.rb"].sort.each {|f| require f} > > HTH, > Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Ben, That fixed it :) many thanks once again All best Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: From ashley.moran at patchspace.co.uk Mon Nov 30 06:45:35 2009 From: ashley.moran at patchspace.co.uk (Ashley Moran) Date: Mon, 30 Nov 2009 11:45:35 +0000 Subject: [rspec-users] surprising... In-Reply-To: <69c47f23-5014-423b-b263-ca162c4447a0@m38g2000yqd.googlegroups.com> References: <69c47f23-5014-423b-b263-ca162c4447a0@m38g2000yqd.googlegroups.com> Message-ID: <1B7A8C72-C3D8-42DC-BBB1-CF6771BB2C0E@patchspace.co.uk> On Nov 29, 2009, at 6:33 am, rogerdpack wrote: > It is somewhat surprising to me, as a newbie, to have to assert > a.should be_a(Hash) Hi Roger Once you see the matcher (ie be_a) as something that returns a matcher object, it makes a lot more sense. My brain is now wired to give much more weight to the thing on the right. You might find it instructive/enlightening/life-changing (possibly) to have a go at writing some custom matchers. From the RSpec docs[1]: bob.current_zone.should eql(Zone.new("4")) becomes -> bob.should be_in_zone("4") which is implemented with -> Spec::Matchers.define :be_in_zone do |zone| match do |player| player.in_zone?(zone) end end Although I've just realised that RSpec's dynamic be_* matcher actually gives you that for free... HTH Ashley [1] http://rspec.rubyforge.org/rspec/1.2.9/classes/Spec/Matchers.html -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashleymoran From rick.denatale at gmail.com Mon Nov 30 08:29:38 2009 From: rick.denatale at gmail.com (Rick DeNatale) Date: Mon, 30 Nov 2009 08:29:38 -0500 Subject: [rspec-users] surprising... In-Reply-To: <57c63afe0911290553r24236678me64827698d21011d@mail.gmail.com> References: <69c47f23-5014-423b-b263-ca162c4447a0@m38g2000yqd.googlegroups.com> <57c63afe0911290553r24236678me64827698d21011d@mail.gmail.com> Message-ID: On Sun, Nov 29, 2009 at 8:53 AM, David Chelimsky wrote: > On Sun, Nov 29, 2009 at 12:33 AM, rogerdpack > wrote: >> >> It is somewhat surprising to me, as a newbie, to have to assert >> a.should be_a(Hash) >> >> That extra space in there feels awkward. >> >> Suggestion: >> >> allow for constructs like >> a.should.be_a(Hash) >> >> Thoughts? > > You're about 4 years late to the party. We were playing around with a > variety of options back in 2005 and went with the current syntax because it > gave us the most flexibility and the highest level of decoupling, making it > easier for others to create their own matcher libraries. While it would be > technically feasible to support should.matcher, doing so now would cause > more confusion for more people than be helpful, IMO. I might be wrong, but IIRC RSpec used to use the .matcher form in the early days. And when it did there was a lot more in the way of methods added to Kernel, and that's one of the reasons I avoided RSpec back then, way too much Heisenberg effect. With the current design, there's very little added to all Ruby objects, just Kernel#should and Kernel#should_not and that's it. I guess that's the decoupling you're talking about. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale From brad.forsyth at inspire2go.com Mon Nov 30 12:48:00 2009 From: brad.forsyth at inspire2go.com (Brad) Date: Mon, 30 Nov 2009 09:48:00 -0800 (PST) Subject: [rspec-users] Problem with ActionMailer in controller specs - works in model specs Message-ID: <074e018f-1085-48ee-bb34-65d167499708@o31g2000vbi.googlegroups.com> I am having a problem with my controller tests that include ActionMailer. The tests work for the model test, e.g. I have a UserNotifier model that sends account activation e-mails and the spec's work fine. When I run the UsersController spec's that test some of the same functionality (e.g. uses the UserNotifier model), I get: ArgumentError in ... wrong number of arguments (0 for 1) .../lib/action_mailer/base.rb:551:in 'content_type' The UserNotifier model tests also fail when I run a complete test (e.g. spec spec). It passes when I run it standalone. This happens using both Rails 2.3.4 and the latest 2.3.5. Is this a controller spec setup issue? Thanks for any guidance... Brad From rogerpack2005 at gmail.com Mon Nov 30 15:36:04 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Mon, 30 Nov 2009 12:36:04 -0800 (PST) Subject: [rspec-users] surprising... In-Reply-To: References: <69c47f23-5014-423b-b263-ca162c4447a0@m38g2000yqd.googlegroups.com> <57c63afe0911290553r24236678me64827698d21011d@mail.gmail.com> Message-ID: > And when it did there was a lot more in the way of methods added to > Kernel, and that's one of the reasons I avoided RSpec back then, way > too much Heisenberg effect. > > With the current design, there's very little added to all Ruby > objects, just Kernel#should and Kernel#should_not and that's it. ?I > guess that's the decoupling you're talking about. Thanks for the feedback. -r
Client123123
Client222/td> > ?222
> ? ?Client123 > ? > ? ?123 > ?
Name
<%=h item.name %>
Name
<%=h item.name %>
Name
<%=h item.name %>