Re: [rspec-users] Missing template in helper specs with a render
On Fri, 2009-06-05 at 22:40 -0500, David Chelimsky wrote: There is no support for rendering in helper specs as of yet. Please file a feature request if you think there should be. I have, personally, never rendered from a helper. Anybody else? We do this for example to render a set of unrelated items into a single timeline-based view. The helper sorts out the ordering and renders each object in it using a specific partial. Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] mocking does not work
On Thu, 2008-10-30 at 14:47 +0800, Leon Du wrote: The spec it should expose a newly created logo as @logo do Logo.should_receive(:new).with({'these' = 'params'}).and_return(mock_logo(:save = true)) Logo.should_receive(:company=).with(mock_model(Company)) post :create, :logo = {:these = 'params'} assigns(:logo).should equal(mock_logo) end The instance of Logo should receive the company= method, not the class, so: @logo = mock_logo Logo.should_receive(:new).and_return(@logo) @logo.should_receive(:company=) I would probably use stub! instead here and move this code into a before block, and just keep the post and assigns lines in the it block. Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Gems installation
On Mon, 2008-10-27 at 15:54 +0100, Juanma Cervera wrote: I have a problem trying to use cucumber with webrat. I thought I could use the gems versions of rspec, rspec-rails, cucumber and webrat, in fact I think that I could manage to do it two weeks ago, but now that I updated the versions of the rspec, rspec-rails and cucumber, I am getting a errors like this undefined method `visits' for #ActionController::Integration::Session:0xb702e6a0 (NoMethodError) I just ran into this myself. I added a require 'webrat' to env.rb to fix it. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Anyone seen weird autotest behaviour on trunk?
On Fri, 2008-06-06 at 08:12 -0500, David Chelimsky wrote: On Jun 6, 2008, at 12:42 AM, Hans de Graaff wrote: I'm not sure if this is the right fix, as it may also be a bug that the last semi-colon is missing from the backtrace list? That could be from different versions of Ruby. I'm not sure there is any harm in removing the second ':' - does anybody else think there is? FWIW I'm using ruby 1.8.6 pl 114 here. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] autotest only passing spec files to rspec once
On Fri, 2008-04-11 at 17:16 +0200, Andy Orahood wrote: When I run autotest it works fine the first time, generating the command line: /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts spec/models/timespan_spec.rb spec/models/article_spec.rb ... rest of my spec files and all my specs get run. After the first runthrough, however, autotest pauses for a second and then, without me saving any files, generates another command line without any of the spec files: /usr/bin/ruby1.8 -S script/spec -O spec/spec.opts This happens because a file got saved that did not match a pattern that autotest can handle. It may even be your test.log. Run 'autotest -v' to see what is really going on and add_exception in the autotest initialize hook to avoid checking those files. Arguably autotest shouldn't even do this empty run when it doesn't find any matching files. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Anyone seen weird autotest behaviour on trunk?
On Tue, 2008-04-01 at 08:48 +0100, Ashley Moran wrote: Hmm, exact same revision as me. Are we the only one s having problems? I've also noticed errors along the lines of ActionController not found and expected XXX to respond to respond_to? (or something - that from the developer that sits behind me). We are seeing the exact same thing with Zentest 3.9.2 and RSpec 1.1.4. The thing I noticed yesterday is that autotest seems to want to run the model or controller directly instead of the spec file, just like in Ashley's original mail. Obviously this leads to an error because that doesn't load spec_helper which in turn doesn't load the rails framework. Presto: ActiveRecord has not been initialized. The real question is: why is autotest running specs with the wrong names? Did anyone resolve this yet? Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] rails rspec silently failing
On Tue, 2008-02-05 at 23:50 -0500, Will Schenk wrote: This is both running the file directly or using script/spec. If I leave the spec file as is, and I comment out a line @order.send_order_to_google_checkout in the _controller_ then it runs fine, i.e. it gets to the fail statement. Since you don't include the actual controller code it's a bit hard to help out here, but it's better form to just mock this code in your controller spec. You can then vary the different responses from the google checkout and see if your controller handles them correctly. The actual interaction with google checkout should be described with examples in the order_spec.rb file. Right now you are testing the whole stack and it becomes very hard to track down what is going wrong exactly. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Autotest with rspec HTML output
On Sun, 2007-11-11 at 17:21 +0100, aslak hellesoy wrote: I think the simplest and best thing here would be a pure browser solution with autorefresh. It should only be a matter of tweaking the HTML output a little to: * Implement autorefresh. Ajax based would require a lite server (webrick). Or just META refresh would work on the file system. I've been using this approach on and off for a while, using the META refresh technique both off of the file system and through a web server. I don't right now because it was taking up a bit too much screen space. Now that I've got a second monitor to hook up that may change again. I've been using a refresh rate of 30s, but that's actually already too slow. I guess a better solution would be to be able to trigger an action after specs have run. The actual command could just be a shell command defined in the spec.opts file, so that people can do whatever is the right thing for their platform and environment. * Tweak the HTML output to only output the red specs, not the green ones. That would be useful. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Problem with view spec - works inside the browser but spec fails with nil object
You are trying to test a lot of things at the same time, which is one of the reasons that it is now hard to diagnose a problem. I would tackle this by a) writing a separate spec for the partial _question_for_candidate b) write a separate spec for the helper that renders the question b) in the view spec for /survey/show use should_receive to determine that the helper is actually being called c) not use any fixtures in the view specs but instead use mocks for that: it's faster and you can check exactly what needs to happen instead of relying on what happens to be in the fixture. I'm afraid that I don't see immediately why your current setup won't work, but untangling things along the lines sketched above should hopefully get you to a situation where it becomes easier to see what happens. before(:each) do assigns[:configurations] = {:survey_name = 'Whatever'} assigns[:questions] = Array.new assigns[:questions][4] = questions(:faixa_etaria) I am a little bit suspicious about this construction, though. I'm not sure whether assigns is a normal Array in this case, so I'd create the Array and populate it before handing it to assigns: @questions = Array.new @questions[4] = ... assigns[:questions] = @questions Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Can't delete app/helpers
On Fri, 2007-11-02 at 15:58 +0100, Chris Olsen wrote: Hans de Graaff wrote: Looks like you still have a (possibly generated?) spec for this helper. Kind regards, Hans I do, but the issue is that it requires the app/helpers/addresses_helper.rb file, which is that one that I am trying to delete. If there is still a spec file that references the helper then it can't be removed without causing spec failures. You should also remove the spec for the helper for the specs to run without problems. If that sounds obvious then you might be trying to do something more complicated in which case some more explanation of what you are trying to achieve would be helpful. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] rake spec:rcov failing
On Sat, 2007-10-27 at 13:10 -0400, Scott Taylor wrote: Running rails 1.2.3, rcov (0.8.0.2), rspec trunk (2865) - When running rake spec:rcov, I'm getting the following: Finished in 245.717813 seconds 856 examples, 0 failures, 48 pending /usr/local/lib/ruby/1.8/rexml/text.rb:292:in `normalize': private method `gsub' called for 0:Fixnum (NoMethodError) I guess you are using a really new version of ruby? The latest patch levels seem to include a version of rexml that isn't compatible with rcov. The rcov code thinks it can pass Fixnum's as the value of an attribute while building the HTML summary page, but apparently the latest version of rexml no longer allows this. I haven't had time to figure out if this change in rexml is intentional or not, and thus whether rexml or rcov needs fixing. Kind regards, Hans de Graaff signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Can't delete app/helpers
On Fri, 2007-11-02 at 00:39 +0100, Chris Olsen wrote: A stacktrace would help /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S script/spec -O spec/spec.opts spec/views/addresses/show.rhtml_spec.rb spec/helpers/addresses_helper_spec.rb Looks like you still have a (possibly generated?) spec for this helper. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] locals in partials
On Fri, 2007-10-12 at 12:47 -0400, Jonathan Linowes wrote: that works for you? I'm basically doing the same thing but the render /pages/_page_menu.html.erb, :locals = { :pages = @foo } render :partial = 'pages/page_menu', :locals = {:pages = @foo} Note the :partial. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] locals in partials
On Fri, 2007-10-12 at 10:33 -0400, Jonathan Linowes wrote: hiya, in specing a partial, how can i assign a local var that is normally passed via :locals ? i tried adding :locals = to the render call but that doesnt seem to take it 'should include :var' render :partial = 'your/partial', :locals = {:var = 'value'} response.should ... end Something like that should work. Otherwise, please post your code, that'll make it a lot easier to help out. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] controller.expect_render has me beat!
On Fri, 2007-09-14 at 17:51 -0400, sinclair bain wrote: def update ... if @config.update_attributes ( params[:new_config] ) redirect_to :action = :index else render :action = :edit, :id = params[:id] # this line here end ... end it 'should render the edit config url on an unsuccessful save' do @config.should_receive(:update_attributes).once.and_return(false) controller.expect_render( :action = :edit, :id = 1 ).once # my prob do_update end I'm not sure what do_update is doing? I assume it is doing a post? In any case params are normally strings, so doing controller.expect_render(:action = :edit, :id = '1').once will most likely work. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] testing behaviour or testing code?
On Sat, 2007-08-25 at 00:01 -0700, David Green wrote: I wasn't testing my views at all, instead relying on integrate_views to catch any problems. This time round I wrote view specs, which is a little more work but testing only one MVC aspect in isolation really makes things simpler. I realise now that the old way, I was using controller specs to test integration rather than controllers. I'm actually doing a bit of both. I write all my controller specs without integrate_views, with separate specs for the views. On top of that I'm also including very simple specs for each action in the controller including views and relying on fixtures, mostly like this: it 'should be a valid page' do get :index response.should be_xhtml end Even though all the behaviour is tested without views and fixtures, this additional check helps to find problems in the interaction between views, controller, and model, and it is the only way I know to validate the pages as XHTML. Kind regards, Hans signature.asc Description: This is a digitally signed message part ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users