Re: [rspec-users] testing a render of a partial in a helper

2011-10-11 Thread nathanvda
Ignore this, I had a different problem in my code causing this. On Oct 5, 9:28 pm, nathanvda wrote: > I am trying to spec my helpers, and I find a few of my helpers > actually render a partial. > > My code: > >     module PageHelper >       def settings_menu >         render :partial => '_shared/

[rspec-users] Attempting to speed up my controller specs: using before all fails?

2011-10-11 Thread nathanvda
I have a simple controller test, containing a.o. the following code: context "POST :create" do before (:each) do post :create, :user_id => @user.id, :account => { .. some data ... } end it { response.status.should == 201 } it { response.location.sho

[rspec-users] Rails view spec expectations/matchers

2011-10-11 Thread Christopher J. Bottaro
>From looking at the RSpec Rails documentation (https://www.relishapp.com/rspec/rspec-rails/docs/view-specs/view-spec) it seems like rendered is just a string and you can't really do any assert_select type stuff out of the box. After Googling around, it seems that the RSpec authors decided that

[rspec-users] rspec dry run

2011-10-11 Thread grace xu
We count how many examples before start executing example, we used to use --dry--run option to achieve this. Now dry run is removed in Rspec 2, do you have a way that we can count examples without executing examples? Thanks. _

[rspec-users] URL helpers in model specs

2011-10-11 Thread Nick
Hey guys. One of my models uses a Rails URL helper. In IRB, the method works. However, when I run the specs for the method, the URL helper doesn't exist. The only solution I've found is to include Rails.application.routes.url_helpers in both the model and the example group. Obviously, that's n

Re: [rspec-users] Rails view spec expectations/matchers

2011-10-11 Thread David Chelimsky
On Oct 8, 2011, at 1:30 PM, Christopher J. Bottaro wrote: > >From looking at the RSpec Rails documentation > >(https://www.relishapp.com/rspec/rspec-rails/docs/view-specs/view-spec) it > >seems like rendered is just a string and you can't really do any > >assert_select type stuff out of the bo

Re: [rspec-users] URL helpers in model specs

2011-10-11 Thread Matt Wynne
On 10 Oct 2011, at 18:02, Nick wrote: > Hey guys. One of my models uses a Rails URL helper. In IRB, the method works. > However, when I run the specs for the method, the URL helper doesn't exist. > > The only solution I've found is to include > Rails.application.routes.url_helpers in both the

Re: [rspec-users] understanding rspec predicates

2011-10-11 Thread Patrick J. Collins
> On Oct 10, 2011, at 8:17 PM, Patrick J. Collins wrote: > > > I know I can do: > > > > blah.should be_empty > > > > or > > > > blah.should have_key(:to_my_house) > > > > ... > > > > But, is there a way to do: > > > > str = "lmaonade omg rotfcopter!" > > > > str.should start_with("lmao") >

Re: [rspec-users] understanding rspec predicates

2011-10-11 Thread Pat Maddox
On Oct 11, 2011, at 5:22 PM, Patrick J. Collins wrote: > Having a spec that does: > > @my_model.alert_flag?.should be_true > > Seemed a little goofy to me... So I did: You can do @my_model.should be_alert_flag A custom matcher isn't worth it in this case, in my opinion. Pat ___

Re: [rspec-users] understanding rspec predicates

2011-10-11 Thread David Chelimsky
On Oct 11, 2011, at 7:38 PM, Pat Maddox wrote: > On Oct 11, 2011, at 5:22 PM, Patrick J. Collins wrote: >> Having a spec that does: >> >>@my_model.alert_flag?.should be_true >> >> Seemed a little goofy to me... So I did: > > You can do > > @my_model.should be_alert_flag That name feels

Re: [rspec-users] understanding rspec predicates

2011-10-11 Thread Pat Maddox
On Oct 11, 2011, at 6:19 PM, David Chelimsky wrote: > On Oct 11, 2011, at 7:38 PM, Pat Maddox wrote: > >> On Oct 11, 2011, at 5:22 PM, Patrick J. Collins wrote: >>> Having a spec that does: >>> >>> @my_model.alert_flag?.should be_true >>> >>> Seemed a little goofy to me... So I did: >> >>

Re: [rspec-users] URL helpers in model specs

2011-10-11 Thread Nick
Hey Matt. Thanks for replying. I deleted that gist by accident earlier today. Despite that, the problem's solved by including Rails.application.routes.url_helpers in my model. My Rails console sessions include Rails.application.routes.url_helpers automatically, which is why it worked in IRB but

Re: [rspec-users] understanding rspec predicates

2011-10-11 Thread Patrick J. Collins
> > I'd rename it to something like "has_alert_flag?" or "flagged_for_alert?" > > so I could say "model.should have_alert_flag" or "model.should > > be_flagged_for_alert". Ok, for whatever reason I wasn't 100% clear on this.. So the rule is, any predicate method that starts with "has_" can be rep

[rspec-users] assert_select - to do negative tests - need help with syntax please :)

2011-10-11 Thread Gordon
Hi all, I am trying to figure out how to use assert_select properly. When I created a new resource in rails 3 called Brands, the view specs for brands had a test which read: # Run the generator again with the --webrat flag if you want to use webrat matchers assert_select "form", :acti