[rspec-users] Troubles with route_for

2010-01-10 Thread Nick Hoffman
Hey guys. I'm having some trouble with a route spec. In routes.rb , I have: map.connect 'foods/search/:name', :controller => :foods, :action => :search foods_controller_spec.rb has: http://codepad.org/dg3FERKw Unfortunately, that fails: http://codepad.org/lck4r1S0 After reading the rspec-rail

Re: [rspec-users] Troubles with route_for

2010-01-10 Thread Nick Hoffman
Amit Kulkarni wrote: > Nick Hoffman wrote: >> Hey guys. I'm having some trouble with a route spec. In routes.rb , I >> have: >> map.connect 'foods/search/:name', :controller => :foods, :action => >> :search >> >> foods_controller_spe

Re: [rspec-users] Troubles with route_for

2010-01-11 Thread Nick Hoffman
David Chelimsky wrote: > I'd recommend using the route_to matcher that was added in 1.2.9 > instead. > > http://codepad.org/fLcxyA9N > http://rspec.rubyforge.org/rspec-rails/1.2.9/classes/Spec/Rails/Matchers.html#M29 > > It's more reliable, and aligns better with the rspec matchers API. > >

Re: [rspec-users] Troubles with route_for

2010-01-12 Thread Nick Hoffman
Randy Harmon wrote: > On 1/11/10 9:22 PM, Nick Hoffman wrote: >>> Cheers, >>> David >>> >> Thanks for that, David. I updated my spec (http://codepad.org/F828X7Fg). >> For some reason though, it's still failing: http://codepad.org/s65Ckubc >&

Re: [rspec-users] Troubles with route_for

2010-01-12 Thread Nick Hoffman
By the way, does this spec: {:get => '/path'}.should route_to(...) make this spec redundant?: params_from(:get, '/path').should == {...} They read the same, but it feels like they each check one end of the route's translation. -- Posted via http://www.ruby-forum.com/. ___

Re: [rspec-users] Troubles with route_for

2010-01-13 Thread Nick Hoffman
David Chelimsky wrote: > On Tue, Jan 12, 2010 at 11:35 AM, Nick Hoffman > wrote: > >> By the way, does this spec: >>{:get => '/path'}.should route_to(...) >> make this spec redundant?: >>params_from(:get, '/path').should

Re: [rspec-users] Troubles with route_for

2010-01-13 Thread Nick Hoffman
David Chelimsky wrote: > On Wed, Jan 13, 2010 at 10:20 AM, Nick Hoffman > wrote: > >> > Yes - route_to checks both sides of the translation. >> >> Great, thanks for that, David! > > > Thank Randy Harmon for this one. It was he who recognized and solve

Re: [rspec-users] Troubles with route_for

2010-01-23 Thread Nick Hoffman
Hey guys. I have two different paths that lead to the same controller and action: map.connect 'foods/search/:name', :controller => 'foods', :action => 'search' map.food':name', :controller => 'foods', :action => 'search' Unfortunately, the spec for the second route fails be

[rspec-users] GET a path in a controller spec

2010-01-31 Thread Nick Hoffman
One of my controller actions sends a redirect if the request URI begins with /foods/search 34 def search 35return redirect_to "/#{params[:name]}" if request.request_uri.match /^\/foods\/search/ Unfortunately, I can't figure out how to spec this. >From everything that I've read while res

[rspec-users] Is share_examples_for deprecated?

2010-03-06 Thread Nick Hoffman
API Dock says that "share_examples_for" is deprecated. If that's correct, what should we be using instead? http://apidock.com/rspec/Spec/Extensions/Main/share_examples_for Thanks, Nick -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing l

Re: [rspec-users] Is share_examples_for deprecated?

2010-03-06 Thread Nick Hoffman
Pat Maddox wrote: > describe "something something", :shared => true do > ... > end > > describe "chunky bacon" do > it_should_behave_like "something something" > end Thanks, mate. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing li

Re: [rspec-users] Is share_examples_for deprecated?

2010-03-06 Thread Nick Hoffman
Pat Maddox wrote: > describe "something something", :shared => true do > ... > end > > describe "chunky bacon" do > it_should_behave_like "something something" > end BTW, is rspec.info supposed to be up-to-date? It still recommends using "shared_examples_for". http://rspec.info/documentatio

Re: [rspec-users] Is share_examples_for deprecated?

2010-03-07 Thread Nick Hoffman
David Chelimsky wrote: > So this presents an interesting problem :) > > My intent some time back was to deprecate :shared => true, not > share_examples_for (which is aliased with shared_examples_for). Based > on that, the rspec.info site is correct and Pat is incorrect. However, > Pat didn't know

Re: [rspec-users] Is share_examples_for deprecated?

2010-03-15 Thread Nick Hoffman
emdub wrote: > I think what is easiest/cleanest in the code should prevail :) I > personally like "shared_examples_for", but can easily adapt to > whatever decision is made. > > On a semi-related note. Where do I require my shared specs so > it_should_behave_like can find my shared example groups?

[rspec-users] stub vs stub!

2010-03-19 Thread Nick Hoffman
RSpec's changelog says that in version 1.2.5: "also alias_method :stub, :stub!, so you can stub with less bang" which I've been taking advantage of a lot. However, I just ran into a situation where using #stub caused an error to occur, and changing to #stub! caused the error the disappear. Any

Re: [rspec-users] stub vs stub!

2010-03-19 Thread Nick Hoffman
Pat Maddox wrote: > I've never heard of CurbFu, but according to > http://github.com/gdi/curb-fu/blob/master/lib/curb-fu.rb#L43 it defines > a stub method already. So you're hitting that one, which expects two > arguments. stub! goes to RSpec's mocking framework. > > Pat Good catch! Thanks,

Re: [rspec-users] lots of nil problems!

2010-03-19 Thread Nick Hoffman
Patrick Collins wrote: > Hi, > > I have this in my controller action: > > from_address = Setting.find_by_name("shipping_from_address").address > > and my spec fails: > > NoMethodError in 'Admin::ShippingLabelsController should render a pdf > file' > undefined method `address' for nil:NilClass

Re: [rspec-users] lots of nil problems!

2010-03-19 Thread Nick Hoffman
patrick99e99 wrote: >> Patrick, please create a new thread for this, since it doesn't have >> anything to do with the current topic. > > Wow that is weird.. I replied to the previous thread in my email > client but removed the subject-- as I assumed that was what kept > things associated with thr

Re: [rspec-users] lots of nil problems!

2010-03-19 Thread Nick Hoffman
Hey Patrick. > I have this in my controller action: > > from_address = Setting.find_by_name("shipping_from_address").address > > and my spec fails: > > NoMethodError in 'Admin::ShippingLabelsController should render a pdf > file' > undefined method `address' for nil:NilClass > > yet in the con

[rspec-users] Speccing the creation of a singleton resource

2010-04-20 Thread Nick Hoffman
Hey guys. I'm writing a Rails gem that's used by controllers. The gem creates a singleton resource at run-time, along the lines of: controller_name = ...dynamically generated... ActionController::Routing::Routes.draw do |map| map.resource controller_name, :only => :show end I'm trying to f

[rspec-users] Specs for controllers and rescue_from

2010-11-20 Thread Nick Hoffman
Hey guys. My ApplicationController rescues Mongoid::Errors::DocumentNotFound errors like this: class ApplicationController < ActionController::Base rescue_from Mongoid::Errors::DocumentNotFound, :with => :resource_not_found protected def resource_not_found(error) flash[:alert] = t(

Re: [rspec-users] Stubbing renders

2008-09-28 Thread Nick Hoffman
On 2008-09-28, at 16:33, Nick Hoffman wrote: Hi guys. I'm curious to know why this method of stubbing a render fails: ActionController::Base.stub!(:render_to_string).and_return 'something' And why this is [one of] the correct methods: controller.stub_render :partial => '

[rspec-users] Stubbing renders

2008-09-28 Thread Nick Hoffman
Hi guys. I'm curious to know why this method of stubbing a render fails: ActionController::Base.stub!(:render_to_string).and_return 'something' And why this is [one of] the correct methods: controller.stub_render :partial => '/some/partial' Cheers, Nick __

[rspec-users] Not seeing an RJS change

2008-09-28 Thread Nick Hoffman
I'm writing specs for an XHR, and am having troubles getting my specs to see that a is being hidden. === map_filter.rjs 19 else 20 puts "map_filter.rjs> else!" 21 # Display the filter errors. 22 page['map-filter-errors'].hide 23 page['map-filter-errors'].replace_html @map_filter_err

Re: [rspec-users] Not seeing an RJS change

2008-09-28 Thread Nick Hoffman
On 2008-09-28, at 17:20, Nick Hoffman wrote: 431 it 'should hide the map filter errors ' do 432 do_xhr @xhr_params 433 response.should have_rjs 434 # response.should have_rjs(:hide, 'map-filter-errors') 435 end I just discovered

Re: [rspec-users] Not seeing an RJS change

2008-09-29 Thread Nick Hoffman
On 2008-09-29, at 07:58, David Chelimsky wrote: On Sun, Sep 28, 2008 at 10:59 PM, Nick Hoffman <[EMAIL PROTECTED]> wrote: On 2008-09-28, at 17:20, Nick Hoffman wrote: 431 it 'should hide the map filter errors ' do 432 do_xhr @xhr_params 433

Re: [rspec-users] Not seeing an RJS change

2008-09-29 Thread Nick Hoffman
On 2008-09-29, at 13:19, Steve Schafer wrote: I think it's a parsing problem, rather than an idiom problem. I think he read it as if "offhand" were the object of "that is offhand," which doesn't make much sense. Hah, you're right, Steve =) ___ rspe

Re: [rspec-users] Not seeing an RJS change

2008-09-29 Thread Nick Hoffman
On 2008-09-29, at 19:33, Zach Dennis wrote: Having chained_replace_html is a hack to separate the regular expressions based on if you used Way #1 or Way #2. Interesting. Thanks for that explanation. I have stopped relying on using RJS selectors to test against generated JavaScript. I have als

Re: [rspec-users] can I get more details in the "rake spec" output (e.g. for eql fail, what was the actual value that was returned)???

2008-10-07 Thread Nick Hoffman
On 2008-10-07, at 00:25, Greg Hauptmann wrote: 'Recurring.add projections (perform credit card payment) should calculate amount based on offset provided' FAILED expected no Exception, got #exception> ==> Actually does show exception name, but doesn't give a back trace? Is there a way to see t

Re: [rspec-users] What makes specs run against the test database?

2008-10-08 Thread Nick Hoffman
On 2008-10-08, at 19:50, Wes Gamble wrote: I just did a test where I ran one spec and deep deep within the code under test, I printed out the DB connection of the AR class of a given object, like so: <..snip..> which shows that I am hitting my development database. Why would I see this outp

Re: [rspec-users] Refactoring and using each

2008-10-09 Thread Nick Hoffman
On 2008-10-08, at 07:01, Jeroen van Dijk wrote: Hi all, I'm new to this list and new to RSpec so I have been trying out RSpec the last couple of days and I find it very a natural way of testing. So first of all thanks for providing this framework. Now, I have written some tests for my cont

[rspec-users] How to improve this spec

2008-10-11 Thread Nick Hoffman
Hi guys. One of my specs is very weak, and I'd really like to improve it. Lines 111-116 are what I'm having trouble speccing, and depend on lines 105-109. 105 # Grab all of the properties, filtering using the given conditions. 106 @properties = Property.find :all, :conditions =

Re: [rspec-users] How to improve this spec

2008-10-12 Thread Nick Hoffman
On 2008-10-11, at 17:31, Mark Wilden wrote: If you mocked the Property.find call, you'd have @properties. Hah, good point. Apologies for the obvious question. Cheers, Nick ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/ma

Re: [rspec-users] Checking that a controller created a separate model object

2008-10-12 Thread Nick Hoffman
On 2008-10-12, at 22:33, O. Frabjous-Dey wrote: Hi everyone, RSpec newbie here. I'm looking forward to interacting with the community as I learn more about TDD, RSpec, Rails, and... TDD through RSpec in Rails. Having watched the Peepcode screencasts and read a lot of documentation, I'm tr

Re: [rspec-users] Checking that a controller created a separate model object

2008-10-13 Thread Nick Hoffman
On 2008-10-12, at 23:49, O. Frabjous-Dey wrote: Hi Nick, The :new action comes straight from script/generate rspec_scaffold: def new @group = Group.new respond_to do |format| format.html end end I took out the XML rendering, but left in the respond_to block just in cas

Re: [rspec-users] Checking that a controller created a separate model object

2008-10-13 Thread Nick Hoffman
On 2008-10-13, at 17:14, O. Frabjous-Dey wrote: I thought some more about the issue and I think I'm approaching the problem the wrong way to begin with. As I understand it, part of the philosophy of RSpec is that using mocks and stubs when testing controllers and views instead of touching t

[rspec-users] How to spec accessing a constant

2008-10-15 Thread Nick Hoffman
Hi guys. One of my methods uses a constant in another method, like this: class A def something "foo: #{B::BAR}" end end When writing the spec for A#something , how would you mock or stub #{B::BAR}, and how would you set an expectation that B::BAR is used? Thanks, Nick ___

Re: [rspec-users] How to spec accessing a constant

2008-10-15 Thread Nick Hoffman
On 2008-10-15, at 16:39, Craig Demyanovich wrote: Probably, I would just check the outcome of the method instead of checking interaction with a constant. Craig So you guys wouldn't worry about the spec for class A being coupled to this constant in class B? -Nick __

Re: [rspec-users] How to spec accessing a constant

2008-10-16 Thread Nick Hoffman
On 2008-10-15, at 21:59, Craig Demyanovich wrote: Since class A is coupled to class B, the specs for A are also coupled to class B through class A. Thus, I wouldn't worry about the coupling. Why does a method of class A directly access a constant of class B? Does the constant belong in class

Re: [rspec-users] How to spec accessing a constant

2008-10-16 Thread Nick Hoffman
On 2008-10-16, at 15:12, Craig Demyanovich wrote: Cool. Having seen something a little more concrete, I like your design decisions. In this case, I'd go with Scott's recommendation of hiding the constant behind a method. Regards, Craig Thanks for taking a look, Craig, and giving me your op

Re: [rspec-users] Surprising mock behavior

2008-10-17 Thread Nick Hoffman
On 2008-10-17, at 14:55, Mark Thomson wrote: ..snip.. It seems as if "should_receive" is queuing up the messages that come into the file object and when it tests an expectation it just looks at the next one in line. If it doesn't match then the expectation will fail. Hi Mark. From my unde

Re: [rspec-users] Where are those tables listed for fixtures?

2008-10-17 Thread Nick Hoffman
On 2008-10-17, at 14:46, Rasmus Rasmussen wrote: I'm sorry if this is posted in wrong forum. I am new to all of this with rails and rspec. Something got messed up when I changed a table's name from 'works' to 'work_periods'. Now the fixture:load thing does not work. Obviously the old table

Re: [rspec-users] specifying a controller's layout

2008-10-17 Thread Nick Hoffman
On 2008-10-17, at 17:16, David Chelimsky wrote: Cool. Don't forget the seldom used #head, though I don't know what to call it: when_heading_to? I looked through the docs at http://rspec.rubyforge.org/rspec/1.1.8/ for #head , but the closest thing I found was #header , which is undocumented.

Re: [rspec-users] Test HTML output from Rails helper

2008-10-18 Thread Nick Hoffman
On 2008-10-18, at 09:16, Pat Maddox wrote: Scott Taylor <[EMAIL PROTECTED]> writes: You'd be able to write a spec like the following: it "should link with the correct name" do helper.should_receive(:link_to).with("foo", {:controller => "foo", :action => "foo"}) helper.my_method("foo") end

Re: [rspec-users] RSpec-Rails bug with to_xml?

2008-10-20 Thread Nick Hoffman
On 2008-10-20, at 09:19, Zach Dennis wrote: Look up "integrate_views" on the rspec-rails docs: http://rspec.rubyforge.org/rspec-rails/1.1.8/ Also there is a section called "Integration Model". Read that. If you have any further questions don't hesitate to ask. HTH, Hi Zach. I searched for "

Re: [rspec-users] RSpec-Rails bug with to_xml?

2008-10-20 Thread Nick Hoffman
On 2008-10-20, at 11:24, David Chelimsky wrote: It's Integration Mode, not Model :) http://rspec.rubyforge.org/rspec-rails/1.1.8/classes/Spec/Rails/Example/ControllerExampleGroup.html Ah! Thanks for the clarification, David. No worries about the typo, Zach. My fingers often have a mind of the

Re: [rspec-users] Accessing the model class from within an rspec-rails spec

2008-10-29 Thread Nick Hoffman
On 2008-10-28, at 09:09, Cameron Booth wrote: describe User do it_should_validate_presence_of :name end I can get it working if I pass in User as an argument: describe User do it_should_validate_presence_of User, :name end Hi Cameron. I haven't played with RSpec's internals at all, but

Re: [rspec-users] spec'ing the :conditions argument of a find

2008-10-30 Thread Nick Hoffman
On 2008-10-28, at 10:52, Rémi Gagnon wrote: Let's see, I want to spec the :conditions args to make sure the right args is passed to the query. Product.find(:all, :conditions => ["inte_no = ? and vaat_id_type_statut_pcpa = ?", inte_no, 7], :limit => 2, :order => "trns_dt_appl_prod

Re: [rspec-users] Mailing list playing catch up with anyone else?

2008-10-30 Thread Nick Hoffman
On 2008-10-30, at 10:56, Zach Dennis wrote: Last night it seemed like the mailing list was playing catchup, as I got a flood of emails from the past few days. Has anyone else seen this? Yup! When I checked my email this morning, I found 61 new messages from the rspec-users ML. ___

Re: [rspec-users] Working outside-in with Cucumber and RSpec

2008-10-31 Thread Nick Hoffman
On 2008-10-30, at 15:31, Pat Maddox wrote: eh I dunno. I mean, I completely agree that hard-to-write tests often expose bad code. But there isn't any gray area when it comes to designing Rails controllers, in my opinion. I see an action that's more than five lines long and I know it's wrong

Re: [rspec-users] Fwd: spec_server not working...

2008-10-31 Thread Nick Hoffman
On 2008-10-31, at 17:52, Matt Darby wrote: Same thing unfortunately. It also happens when I add --drb to spec/ spec.opts and run autotest/autospec as well. G'day Matt. This probably won't be of much help, but I've never been able to run my specs against spec_server. I always get this error:

[rspec-users] Stubbing #javascript_include_tag in a helper spec

2008-10-31 Thread Nick Hoffman
When writing specs for a helper method, how do you set an expectation for #javascript_include_tag ? describe NeighbourhoodsHelper do describe '#initialise_map' do it 'should include the "foo" JS file' do # expectation here helper.foobar end end end I've tried replacing

Re: [rspec-users] Stubbing #javascript_include_tag in a helper spec

2008-10-31 Thread Nick Hoffman
On 2008-10-31, at 18:50, David Chelimsky wrote: Assuming that you intend to have a helper method that calls out to javascript_include_tag, then: helper.should_receive :javascript_include_tag Let us know if that works for you. Hah, so easy. Why didn't I think of that? =P Thanks, mate! _

Re: [rspec-users] Working outside-in with Cucumber and RSpec

2008-11-01 Thread Nick Hoffman
On 2008-10-31, at 20:17, Pat Maddox wrote: Nick Hoffman <[EMAIL PROTECTED]> writes: I can make this 22-line action a bit shorter? =) http://refactormycode.com/codes/575-dry-up-a-controller-action I should have known I'd get called out on this :) I pushed around some stuff t

Re: [rspec-users] Caboosers drop RSpec

2008-11-04 Thread Nick Hoffman
On 2008-11-04, at 10:32, Fernando Perez wrote: You say these guys should have come over and posted to this mailing- list or submitted bugs. But when I read the posts here, most of the time, when someone has a problem he gets pointed to the unfriendly documentation pages or worse, the very thin d

[rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Nick Hoffman
I had a look around for how to stub Time.now , #from_now , etc, and came across this, which was useful: http://devblog.michaelgalero.com/2007/11/23/actioncontroller-rspec-stub-timenow/ Unfortunately, my situation is slightly different, and causes that solution to not be applicable. This is wh

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 14:42, David Chelimsky wrote: The problem is there is no Singleton Class for 1, probably an efficiency in Ruby since 1 is, itself, a Singleton. All of these frameworks try to manipulate methods on the object's singleton class. So no mocking/stubbing on Fixnums. Apparently. Not

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 14:55, Fernando Perez wrote: And I get the following error message: -- Mock 'Order_1' received unexpected message :amount= with (50) -- Well I know that @cart.amount will be set to 50, but why is RSpec complaining about that? If I put @cart.should_receive(:amount).with(50), r

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 15:02, Ben Mabey wrote: Hey Nick, It is generally a bad idea to stub/mock a method on the object you are verifying the behaviour of. I would recommend a state-based approach of testing this method as opposed to the interaction-based one you are pursuing. The reason being

Re: [rspec-users] Stubbing times: #from_now et al.

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 15:10, Mark Wilden wrote: What I can't figure out is this: >> 1.day => 1 day >> 1.day.class => Fixnum Is 1.day an ActiveSupport::Duration or a Fixnum? ///ark It's an ActiveSupport::Duration : 48 def days 49 ActiveSupport::Duration.new(self * 24.hours,

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 15:23, Fernando Perez wrote: This throws the error: expected 50, got 0 (using .eql?) This is because you told @cart to return 0 when #amount is called on it: @cart = mock_model(Order, :id => 1, :amount => 0, :tax => 0) I think maybe you're confusing what the arguments to #m

Re: [rspec-users] RSpec whines when I set the value of an object

2008-11-05 Thread Nick Hoffman
On 2008-11-05, at 15:23, Fernando Perez wrote: Hmmm, I don't have this problem as I am using ruby-forum.com to browse threads, it is x100 times more readable with basic color highlighting. I'll do my best to include quotes for people who use regular mail clients. So here is my controller code: -

Re: [rspec-users] Testing variables in controllers?

2008-11-06 Thread Nick Hoffman
On 2008-11-06, at 09:36, Ramon Tayag wrote: How do you test that your controller fetched the right records? I have an action that returns a different set of records based on whether or not the current_user is the "owner" of the profile being viewed. Code is here http://pastie.org/308685. "cont

[rspec-users] Running an entire #describe block

2008-11-10 Thread Nick Hoffman
I know that it's possible to run a single spec example (IE: #it block) with the -e option for script/spec . Is it possible to run an entire context (IE: #describe block)? Cheers, Nick ___ rspec-users mailing list rspec-users@rubyforge.org http://rub

Re: [rspec-users] Running an entire #describe block

2008-11-10 Thread Nick Hoffman
On 2008-11-10, at 14:06, Mark Wilden wrote: On Mon, Nov 10, 2008 at 10:53 AM, Nick Hoffman <[EMAIL PROTECTED]> wrote: I know that it's possible to run a single spec example (IE: #it block) with the -e option for script/spec . Is it possible to run an entire context (IE: #des

[rspec-users] Specs for authorisation

2008-11-10 Thread Nick Hoffman
I'm writing specs to check that certain user types are authorised to access certain controller actions. In addition to writing specs for authorised user types and for users who aren't logged-in, I feel that I should write specs for all of the other user types. However, the number of example

Re: [rspec-users] Running an entire #describe block

2008-11-10 Thread Nick Hoffman
On 2008-11-10, at 17:12, Mark Wilden wrote: On Mon, Nov 10, 2008 at 1:26 PM, Nick Hoffman <[EMAIL PROTECTED]> wrote: On 2008-11-10, at 14:06, Mark Wilden wrote: On Mon, Nov 10, 2008 at 10:53 AM, Nick Hoffman <[EMAIL PROTECTED]> wrote: I know that it's possible to run a si

[rspec-users] How to expect no layout

2008-11-10 Thread Nick Hoffman
Hey guys. I've told one of my controllers to not render a layout for a certain action: layout false, :only => :map_info_window Now I'm trying to spec that, but this: it 'should not render a layout' do controller.expect_render :layout do_get end fails with this: Spec::Mocks::Moc

Re: [rspec-users] How to expect no layout

2008-11-11 Thread Nick Hoffman
On 2008-11-11, at 05:46, Fernando Perez wrote: Nick Hoffman wrote: Hey guys. I've told one of my controllers to not render a layout for a certain action: layout false, :only => :map_info_window Now I'm trying to spec that, but this: it 'should not r

Re: [rspec-users] Specs for authorisation

2008-11-11 Thread Nick Hoffman
On 2008-11-11, at 00:53, Pat Maddox wrote: Nick Hoffman <[EMAIL PROTECTED]> writes: I'm writing specs to check that certain user types are authorised to access certain controller actions. In addition to writing specs for authorised user types and for users who aren't logged-i

Re: [rspec-users] Specing based on user roles

2008-11-11 Thread Nick Hoffman
On 2008-11-11, at 17:24, Fernando Perez wrote: I've really moved away from shared example groups and started writing more targeted macros. So I might do something like this: def for_roles *roles roles.each do |role| before(:each) { login_as role } yield end end describe OrdersController

[rspec-users] Mixing in spec helper methods

2008-11-11 Thread Nick Hoffman
I've written a module for my specs that contains a helper method, and am mixing the module into my specs with #include . It seems that the method must be called with an #it block. If it isn't, this error occurs: ... in `method_missing': undefined method `it_should_behave_like_an_action_that

Re: [rspec-users] Mixing in spec helper methods

2008-11-12 Thread Nick Hoffman
On 2008-11-11, at 19:31, Ben Mabey wrote: Nick Hoffman wrote: I've written a module for my specs that contains a helper method, and am mixing the module into my specs with #include . It seems that the method must be called with an #it block. If it isn't, this error occurs

Re: [rspec-users] Mixing in spec helper methods

2008-11-12 Thread Nick Hoffman
On 2008-11-11, at 19:39, Pat Maddox wrote: Nick Hoffman <[EMAIL PROTECTED]> writes: I've written a module for my specs that contains a helper method, and am mixing the module into my specs with #include . It seems that the method must be called with an #it block. If it isn't, t

Re: [rspec-users] Mixing in spec helper methods

2008-11-12 Thread Nick Hoffman
On 2008-11-11, at 19:49, David Chelimsky wrote: On Tue, Nov 11, 2008 at 6:39 PM, Pat Maddox <[EMAIL PROTECTED]> wrote: You can even do it for particular example group types if you want: Spec::Runner.configure do |config| config.extend AuthSpecHelpers, :type => :controller end Note that config

Re: [rspec-users] Mixing in spec helper methods

2008-11-12 Thread Nick Hoffman
On 2008-11-11, at 19:31, Ben Mabey wrote: Nick Hoffman wrote: I've written a module for my specs that contains a helper method, and am mixing the module into my specs with #include . It seems that the method must be called with an #it block. If it isn't, this error occurs

Re: [rspec-users] Mixing in spec helper methods

2008-11-13 Thread Nick Hoffman
On 2008-11-12, at 16:38, Ben Mabey wrote: Nick Hoffman wrote: After digesting that post again, especially the contents of #self.included , I noticed that one could alternatively do this: module AssignMacro def self.extended(receiver) receiver.extend ExampleGroupMethods receiver.send

Re: [rspec-users] testing an action which requires picture

2008-11-14 Thread Nick Hoffman
On 2008-11-14, at 06:29, Mano ah wrote: can i know how to test a picture upload which dosent interact with db my code is def scan #--- if request.post? image = Image.new image.blob= params[:image][:blob] image.save_picture end -- Hi Mano. It doesn't really m

[rspec-users] How to kill a running spec

2008-11-16 Thread Nick Hoffman
Hi guys. Occasionally, I'll want to kill a long spec process that's running. Usually I hit CTRL+c to kill a running process, but doing that for a running spec just causes "^C" to be printed to the terminal, and whichever spec example was running to fail. I've also tried using /bin/kill to k

Re: [rspec-users] How to kill a running spec

2008-11-16 Thread Nick Hoffman
On 2008-11-16, at 15:21, Pat Maddox wrote: I just hold ctl+c until it quits out. Pat Hahha, brute force it, eh? ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] How to kill a running spec

2008-11-17 Thread Nick Hoffman
On 2008-11-16, at 17:46, Scott Taylor wrote: On Nov 16, 2008, at 2:40 PM, Nick Hoffman wrote: Hi guys. Occasionally, I'll want to kill a long spec process that's running. Usually I hit CTRL+c to kill a running process, but doing that for a running spec just causes "^C"

[rspec-users] Mocking and stubbing model relationships

2008-11-17 Thread Nick Hoffman
Before writing specs for a one-to-many relationship between two models, I did some research and found that some people were creating proxy mocks, and others were using Matthew Heidemann's #stub_association! (which essentially does that for, but in a nice, DRY way): http://www.ruby-forum.

Re: [rspec-users] testing an action which requires picture

2008-11-20 Thread Nick Hoffman
On 2008-11-18, at 01:53, Mano ah wrote: Nick Hoffman wrote: On 2008-11-14, at 06:29, Mano ah wrote: image = Image.new image.blob= params[:image][:blob] image.save_picture end -- Hi Mano. It doesn't really matter whether or not your "picture" model i

Re: [rspec-users] Mocking and stubbing model relationships

2008-11-20 Thread Nick Hoffman
On 2008-11-18, at 07:33, Rahoul Baruah wrote: On 18 Nov 2008, at 05:41, Nick Hoffman wrote: Before writing specs for a one-to-many relationship between two models, I did some research and found that some people were creating proxy mocks, and others were using Matthew Heidemann&#

Re: [rspec-users] Mocking and stubbing model relationships

2008-11-20 Thread Nick Hoffman
On 2008-11-18, at 15:49, Ben Mabey wrote: Nick Hoffman wrote: Before writing specs for a one-to-many relationship between two models, I did some research and found that some people were creating proxy mocks, and others were using Matthew Heidemann's #stub_association! (which essent

Re: [rspec-users] Mocking and stubbing model relationships

2008-11-20 Thread Nick Hoffman
On 2008-11-19, at 12:26, Chris Flipse wrote: I've actually taken this old gem and enhanced it a bit module Spec::Mocks::Methods def stub_association!(association_name, methods_to_be_stubbed ={}) mock_assn = Spec::Mocks::Mock.new(association_name.to_s) stub_association_with(association_

[rspec-users] How to spec a Rails helper method

2008-11-23 Thread Nick Hoffman
I'm trying to write specs for a helper method that I'm creating, but my specs are failing to find the helper method # app/helpers/properties_helper.rb module PropertiesHelper def format_utilities(utilities) end end # spec/helpers/properties_helper_spec.rb require File.expand_path(File.dirn

Re: [rspec-users] restful_authentication's "permission_denied" and rspec

2008-11-24 Thread Nick Hoffman
On 2008-11-21, at 09:20, Ramon Tayag wrote: Hi everyone, WIth restful_authentication you get a method "permission_denied" that you just slap onto the controller when you don't want a user to gain access to something. In this method Rails does a bunch of stuff then basically tries to be smart an

Re: [rspec-users] How to spec a Rails helper method

2008-11-24 Thread Nick Hoffman
On 2008-11-24, at 00:39, Zach Dennis wrote: Try: helper.format_utilities Thanks everyone! I should have searched the API rather than Google. I'll do that next time. Cheers, Nick ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyf

Re: [rspec-users] calling a step from a step

2008-11-24 Thread Nick Hoffman
On 2008-11-24, at 11:16, James Byrne wrote: I have this: When /obtain the party (.*)/ do |n| n case Hi James. Shouldn't that be "case n"? -Nick ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] calling a step from a step

2008-11-24 Thread Nick Hoffman
On 2008-11-24, at 11:47, James Byrne wrote: Missing slash at end of regex /When /should determine the party (.*)/ Sig Thanks. Hey, it happens to the best of us, mate. At least it's an easy fix! ___ rspec-users mailing list rspec-users@rub

Re: [rspec-users] Q: object.id is deprecated. How to mock?

2008-11-25 Thread Nick Hoffman
On 2008-11-25, at 14:04, s.ross wrote: In Rails, the primary key, by default 'id', is used all over the place. However, Ruby now deprecates the use of constructs like: @post = Post.find(:first) @post_id = @post.id ..snip.. Thanks, Steve Hi Steve. Ruby deprecated Object#id in favour of Objec

Re: [rspec-users] rails associations

2008-11-25 Thread Nick Hoffman
On 2008-11-25, at 22:07, David Parker wrote: Hello! So I'm having some problems working out some probably really easy associations in Rails. I've Googled around and read some things on different Rails forums and blogs, but I just haven't seen many solid examples. Anyway, my question is

Re: [rspec-users] Rails project as a template for other projects (off topic)

2008-12-04 Thread Nick Hoffman
On 2008-12-04, at 13:34, Andrew Premdas wrote: This is of topic but I have a feeling I might get some useful advice here - hope you don't mind I've created a rails project that I want to use as a basis for other rails project. I was wondering if anyone had any tips on workflow for doing th

[rspec-users] NameError when passing a URL helper to a method

2008-12-04 Thread Nick Hoffman
Hi guys. I just wrote a small spec helper method to DRY up some of my specs, and found that passing a URL helper (Eg: #photos_url) to a method results in a NameError error. I extracted the problem into its own short spec file to isolate it. Any thoughts on what's going on?: http://gist.githu

Re: [rspec-users] NameError when passing a URL helper to a method

2008-12-04 Thread Nick Hoffman
On 2008-12-04, at 17:06, Zach Dennis wrote: On Thu, Dec 4, 2008 at 3:41 PM, Nick Hoffman <[EMAIL PROTECTED]> wrote: Hi guys. I just wrote a small spec helper method to DRY up some of my specs, and found that passing a URL helper (Eg: #photos_url) to a method results in a NameError er

Re: [rspec-users] NameError when passing a URL helper to a method

2008-12-04 Thread Nick Hoffman
On 2008-12-04, at 17:43, Nick Hoffman wrote: The only solution that I can think of is to do this: before :each do @account_url = account_url end it_should_redirect_to 'the account page', @account_url Actually, that suggestion above of mine doesn't work. It fails with:

Re: [rspec-users] Rails project as a template for other projects (off topic)

2008-12-05 Thread Nick Hoffman
On 2008-12-05, at 01:51, Andrew Premdas wrote: Scott Working on this, assuming I have a cloned project 'foo' from my base project base and I'm working on foo. So I implement something new and then think this should be in base any ideas how to manage this. Was thinking maybe of having a bas

Re: [rspec-users] proxy associantion on controllers

2008-12-05 Thread Nick Hoffman
On 2008-12-05, at 10:06, Daniel Lopes wrote: Thanks for help and sorry for insistance but I don't understand aspects on rspec ( I think not understand how we use mocks and stubs): Hi Daniel. If you're a bit unsure about when to use mocks vs stubs, have a read of this article by Martin Fowler

Re: [rspec-users] NameError when passing a URL helper to a method

2008-12-05 Thread Nick Hoffman
On 2008-12-04, at 19:56, Pat Maddox wrote: Nick Hoffman <[EMAIL PROTECTED]> writes: On 2008-12-04, at 17:43, Nick Hoffman wrote: The only solution that I can think of is to do this: before :each do @account_url = account_url end it_should_redirect_to 'the account page

  1   2   3   >