Re: [rspec-users] Rspec Style

2013-10-30 Thread Pat Maddox
Curtis, hey man, I saw your post in the rspec list archives (http://rubyforge.org/pipermail/rspec-users/2013-August/021811.html). I use context with pattern A: describe UsersController do describe POST create do it creates a user do ... end context with bad data do it

Re: [rspec-users] An open source project with very good use of Cucumber?

2012-06-24 Thread Pat Maddox
On Friday, June 22, 2012 3:34:51 AM UTC-6, Joshua Muheim wrote: Hey everybody I came here through the RSpec Book, so I grant myself to ask something about Cucumber here. ;) I'm still very new to the topic and read a lot of different opinions about how to do great Cucumber scenarios.

Re: [rspec-users] Sending rails errors to rspec output

2011-12-22 Thread Pat Maddox
On Dec 22, 2011, at 12:33 PM, LeeQ leequare...@gmail.com wrote: Ah, I see what you are saying. But no, I still want the exception to act like an exception. My problem is that I'll have a test fail for reasons unknown, and I then I need to open the test logs to find the exception. I'd

Re: [rspec-users] Problem with RSpec, Rails or Me? (I know the answer is me!!)

2011-12-19 Thread Pat Maddox
On Dec 19, 2011, at 11:00 AM, Ants Pants wrote: This could just be my lack of knowledge of how Rails works but from the following code in my RSpec test $stderr.puts BEFORE: #{@invitation.meeting.event.event_type.event_type_time_units.inspect} Can you please share your RSpec code

Re: [rspec-users] modelling roles and responsibilities

2011-12-07 Thread Pat Maddox
On Dec 7, 2011, at 1:57 AM, Nikolay Sturm wrote: * David Chelimsky [2011-12-07]: reading Growing Object-Oriented Software, guided by tests, I came across the distinction of class, role and responsibility. While classes are classes and responsibilities could be mapped to public methods, I

Re: [rspec-users] need some advice on the best way to structure testable shared methods

2011-11-15 Thread Pat Maddox
On Nov 14, 2011, at 4:57 PM, Patrick J. Collins wrote: Can anyone suggest a better way? Really tough to follow that example, so apologies if I'm off. I use the template method pattern for stuff like this. My shared example group references a method that isn't implemented. Example groups that

Re: [rspec-users] problems matching generated html output...

2011-11-03 Thread Pat Maddox
On Nov 3, 2011, at 4:07 PM, Patrick J. Collins wrote: So, I am writing tests for a presenter class that outputs html markup. Actually now that I am thinking about it.. Would you guys recommend that I use something like Nokogiri to parse the content and test for things like number of

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

2011-10-12 Thread Pat Maddox
Yes it's by design, no you cannot circumvent it. What you can do is use mocks to avoid expensive DB hits, or have multiple expectations in a single example. Pat p.s. This is Ruby, so you absolutely *can* circumvent it. How to do that and whether it's worth the trouble is up to you to figure

Re: [rspec-users] instance variables from outer before blocks don't persist?

2011-10-12 Thread Pat Maddox
On Oct 12, 2011, at 4:59 PM, Patrick J. Collins wrote: ... But I just tried doing this in RSpec with before :each, and it seems that my @foo ivar is non existant inside the inner context.. Is this the way it's supposed to be? post the whole example

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] how to test identical behavior without being redundant?

2011-09-26 Thread Pat Maddox
https://www.relishapp.com/rspec/rspec-core/docs/example-groups/shared-examples On Sep 26, 2011, at 2:11 PM, Patrick J. Collins wrote: I've got many models that have this declared: has_many :notifications, :as = :notifiable, :dependent = :destroy ... And so I have many model specs such

Re: [rspec-users] preferred place for methods used by both rspec and cucumber?

2011-09-23 Thread Pat Maddox
I use spec/support or Rails.root/bdd_support not a big deal really. just pick a place and require em On Sep 21, 2011, at 7:35 PM, Patrick J. Collins wrote: Hi, I have some helper methods such as: def mock_omniauth OmniAuth.config.test_mode = true OmniAuth.config.mock_auth[:facebook]

Re: [rspec-users] Best way to test tasks

2011-08-02 Thread Pat Maddox
On Aug 2, 2011, at 4:41 PM, Piter Fcbk wrote: I have a task that runs frequently in order to get/import data from another system. Because of this I wanted to know which is the best way to test tasks in order to create the tests needed. Thanks in advance. I write simple objects that

Re: [rspec-users] testing framework in 44 lines of ruby

2011-06-13 Thread Pat Maddox
On Jun 12, 2011, at 10:52 AM, Patrick J. Collins wrote: What do you mean by on target? Are you asking if the implementations are the same, or similar? Or are you asking if attest meets the same goals as RSpec? More specifically, I meant the way he implements describe blocks and the should

Re: [rspec-users] Mock/stub ActiveMerchant? (or other cascading/multiple inheritance situation)

2011-04-28 Thread Pat Maddox
On Apr 28, 2011, at 4:37 PM, David Kahn wrote: I am a bit new to mocking. I am trying to stub the ActiveMerchant::Billing::PaypalGateway#authorize method but not clear how to do it. This is my code and spec. This is the pertinent code: module Payment def gateway

Re: [rspec-users] Mocks and CL Programs

2011-04-07 Thread Pat Maddox
On Apr 3, 2011, at 8:24 AM, andyl wrote: I am using rspec/aruba to do integration tests of a command-line program i'm writing. I'd like to use something like FakeWeb to stub the network calls in the command-line program. But with aruba, the program under test runs in a separate

Re: [rspec-users] stubbing directly vs using stub method

2011-04-02 Thread Pat Maddox
On Apr 2, 2011, at 6:20 AM, Kai Schlamp wrote: I use RSpec mock and stub like this: hit = mock(hit, :stored = 5) This works fine, but when using this instead: hit = mock(hit).stub(:stored) { 5 } Not that it's really necessary, but to make this work you can do: hit = mock('hit').tap

Re: [rspec-users] Test Design Question #1

2011-03-31 Thread Pat Maddox
What do you mean that it's leaking into the other test? If you have transactions turned on, then any records inserted into the db will be removed for the next test. My guess is that other tests just don't set up the required data...which is a problem with ActiveRecord callbacks and observers.

Re: [rspec-users] Test Design Question #2

2011-03-31 Thread Pat Maddox
Use mocks to define your interface, not to define TCPSocket directly. I would suggest running a TCP server just to test your wrapping object. Pat On Mar 30, 2011, at 9:34 AM, Curtis j Schofield wrote: I am designing a test around a class that interacts with TCPSocket - I have used a mock

Re: [rspec-users] Stubs and Object Constructor

2011-03-23 Thread Pat Maddox
On Mar 20, 2011, at 9:38 PM, andyl wrote: OK - I got this working using mocha and the 'any_instance' method. A gist with working examples is here: https://gist.github.com/879029 It looks like rspec mocks had an 'any_instance' method, but it was removed because it promoted 'bad

Re: [rspec-users] Testing routes with a prefix

2011-03-23 Thread Pat Maddox
On Mar 22, 2011, at 6:50 PM, Radhesh Kamath wrote: Hi experts, I am trying to test routing in my application, where all routes are enclosed in a namespace like so: scope 'v1' do resource :blah end collection do something end end end Is there a clean way to set 'v1'

Re: [rspec-users] RSPEC how to post to a controller? What's wrong with this?

2011-03-23 Thread Pat Maddox
On Mar 19, 2011, at 2:32 PM, Mobyye wrote: I'm trying to post to my controller in RSPEC by doing: it should store create an IncomingMail record do lambda { post :create, :from = 'xx', :to = 'xx', :cc = 'xx', :subject = 'xx',

Re: [rspec-users] Support for rspec-2 and rails 2.3.x

2011-02-27 Thread Pat Maddox
On Feb 24, 2011, at 6:09 PM, Wilson Bilkovich wrote: On Thu, Feb 24, 2011 at 8:39 AM, Ross Kaffenberger rossk...@gmail.com wrote: Anyone have rspec-2 working with rails 2.3.x? We're looking at this route as an incremental step towards upgrading to rails 3. I saw David C mention in the rpec-2

Re: [rspec-users] ordering dependency in tests?

2011-02-24 Thread Pat Maddox
cattr_accessor, class vars / class instance vars, constants, globals...all things that maintain state across test runs, and so could lead to errors like this. I'd start looking there. Pat On Feb 24, 2011, at 9:55 AM, Fearless Fool wrote: I'm baffled. If I do: $ bundle exec ruby -S

Re: [rspec-users] Comparing two XML documents

2011-01-31 Thread Pat Maddox
I load my XML docs into a hash using Hash#from_xml and then compare the hashes. On Jan 26, 2011, at 7:26 AM, Matt Wynne m...@mattwynne.net wrote: I have a problem. I have a test that needs to assert that one XML document looks exactly like another XML document. I couldn't find a way to

Re: [rspec-users] Difference between :each and :all

2011-01-31 Thread Pat Maddox
On Jan 27, 2011, at 6:53 PM, Rick DeNatale rick.denat...@gmail.com wrote: On Thu, Jan 27, 2011 at 6:16 PM, David Chelimsky dchelim...@gmail.com wrote: On Jan 27, 2011, at 5:11 PM, John Feminella wrote: That's not quite right. :each runs before _each_ spec, while :all runs once, before _any_

Re: [rspec-users] Aidmock - safe mocking

2011-01-18 Thread Pat Maddox
On Jan 18, 2011, at 2:30 PM, Wilker wrote: Yeah, unfortunately I'm not receiving too much feedback about it for now, so, I'm just using for myself and trying to make it better. I will try to spread more and more the idea, so make more people wanna try it, its a different concept and I mean

Re: [rspec-users] require confusion

2011-01-18 Thread Pat Maddox
Yeah 'spec/*' is RSpec 1.x and 'rspec/*' is RSpec 2.x. The stuff you're seeing on the web is referring to RSpec 1.x. On Jan 18, 2011, at 9:44 PM, Katrina Owen wrote: That sounds suspiciously like something on your system thinks it is RSpec 1.x whereas something else thinks it's RSpec 2.x.

Re: [rspec-users] unit vs. functional specs

2010-12-18 Thread Pat Maddox
Why don't functional specs count towards your coverage metric? It sounds like you're shooting for 100% unit test coverage -- why? If you write code in order to make your functional specs pass, then that code was TDD'd...right? Pat On Dec 10, 2010, at 2:29 PM, Andrew Wagner

Re: [rspec-users] Count error on lambda should change

2010-12-18 Thread Pat Maddox
Sounds like a validation failure. My guess is that you're re-using the factory-created record's attributes, and your example fails because of a uniqueness validation. This would explain the rollback if you're using the create! or save! method. Pat On Dec 13, 2010, at 3:08 PM, djangst

Re: [rspec-users] Rspec Rails Nested Resources

2010-12-18 Thread Pat Maddox
Try assigns(:correspondence) instead. If that doesn't work, I would inspect the value of @job.correspondences.build (when run in the test). It's possible that stub_model is causing #build to return nil -- I don't remember the behavior off the top of my head and don't have a Ruby available to

Re: [rspec-users] [Mock]How do I check order of method argument ?

2010-12-18 Thread Pat Maddox
mock.should_receive(:write).with(\n).ordered Append .ordered as above On Dec 17, 2010, at 6:12 AM, niku -E:) n...@niku.name wrote: Hello. My name is niku. I'm using rspec 2.2.1 /tmp% rspec --version 2.2.1 I tested http://gist.github.com/744935 and passed. /tmp% rspec

Re: [rspec-users] Mocking a Model Class and a View with RSpec-Rails

2010-12-08 Thread Pat Maddox
On Dec 7, 2010, at 8:40 PM, Shea Levy wrote: Hi all, I'm new to RSpec and to TDD/Agile methods in general (by new I mean I'm about 4/5 of the way through The RSpec Book and haven't yet actually implemented the practices in my projects), so this question may seem silly. Suppose I'm using

Re: [rspec-users] Controller specs for sub-controllers

2010-12-08 Thread Pat Maddox
On Dec 6, 2010, at 4:29 AM, Dean wrote: I'm completely new to RSpec (and fairly new to Rails, too.) I'm working on an existing application that has an Admin::BaseController and sub-controllers such as Admin:TestimonialsController: class Admin::BaseController ApplicationController end

Re: [rspec-users] Testing initialize methods and chained methods

2010-10-19 Thread Pat Maddox
On Oct 19, 2010, at 12:56 AM, Oscar Del Ben wrote: I'm having some troubles understanding how to test a couple of things. Usually, if I'm having trouble testing something, it means that my design could probably be improved or changed, but in these cases I think I'm doing the right thing.

Re: [rspec-users] spec for derived classes question

2010-09-21 Thread Pat Maddox
search this page for shared example groups http://rspec.info/documentation/ On Sep 20, 2010, at 12:07 PM, Gene Angelo wrote: I assume spec tests be repeated for derived classes? Is there such a thing in rspec as deriving specs? -- Posted via http://www.ruby-forum.com/.

Re: [rspec-users] how to invoke multiple controllers in the same describe block?

2010-09-03 Thread Pat Maddox
Lille wrote: Hi, I seek to authenticate and then test other routing in RSpec, but the standard RSpec vernacular... describe SomeController do it blah-blah do get :new ... end end ...doesn't seem to allow me to post my login data, as in the following pseudo-code: describe

Re: [rspec-users] rspec command for rspec-2.0.0.beta.19

2010-08-16 Thread Pat Maddox
What does gem list rspec show? And echo $PATH ? On Aug 10, 2010, at 9:17 AM, Brad Pauly wrote: I've just uninstalled all versions of rspec and installed rspec-2.0.0.beta.19 and rspec-rails-2.0.0.beta.19 for a rails project and I can't find the rspec command. Based on what bundler is telling

Re: [rspec-users] RSpec and Factory Girl: Destroying an object

2010-05-14 Thread Pat Maddox
On May 14, 2010, at 8:09 AM, Daniel Salmeron Amselem wrote: Hi, I have a problem when testing the deletion of a record from the database. I am using RSpec methods to check if my account object is being destroyed. The factory creates an account object and saves it into the DB. Also the

Re: [rspec-users] Running code on error

2010-04-29 Thread Pat Maddox
Could you share a bit more about what you are actually trying to achieve? On Apr 28, 2010, at 1:51 PM, Ryan S wrote: describe Test do after(:each) do if ERRORS #execute custom code here end it should explode do #Test.explode -- fizzle Test.explode.should == KABOOM end

Re: [rspec-users] [Cucumber:4100] Cucumber vs, RSpec

2010-04-27 Thread Pat Maddox
(where SRP violations are pretty much built-in). They just make your test suite a bit slower, limit reuse, etc... things that are valuable to us but typically not as valuable as just shipping. Pat On Wed, Apr 21, 2010 at 7:05 PM, Pat Maddox mailingli...@patmaddox.com wrote: Cucumber

Re: [rspec-users] [Cucumber:4144] Cucumber vs, RSpec

2010-04-22 Thread Pat Maddox
On Apr 22, 2010, at 9:57 AM, Zach Moazeni wrote: I'll jump in here as I was one of the guys who presented a shift in my testing strategies at the Great Lakes Ruby Bash. To give some context, I've built projects that were very focused on isolation tests that used Rspec and Mocks to assert

Re: [rspec-users] Anyone used RSpec to write specs for rake tasks?

2010-04-19 Thread Pat Maddox
Put the interesting bits in a basic Ruby class and test that, then make the Rake tasks a very thin layer over the class. On Apr 19, 2010, at 8:46 AM, Rick DeNatale wrote: I released a new gem this past weekend which adds a new rake task for Jeweler to generate a release announcement. I

Re: [rspec-users] raise_error suggestion

2010-04-14 Thread Pat Maddox
On Apr 14, 2010, at 12:28 PM, rogerdpack wrote: I remember reading a post where somebody mentioned something like sometimes after a refactoring, a test block like lambda { ... }.should raise_error catches a NoMethodError in error, thus is actually failing, but the user isn't

Re: [rspec-users] Can I use mocking in this way?

2010-04-05 Thread Pat Maddox
Sounds like a lot of work On Apr 3, 2010, at 9:08 PM, Julian Leviston wrote: Sorry I meant send AND __send__ Julian. On 04/04/2010, at 11:45 AM, Julian Leviston wrote: On 04/04/2010, at 7:32 AM, David Chelimsky wrote: On Sat, Apr 3, 2010 at 8:56 AM, Vojto Rinik zero0...@gmail.com

Re: [rspec-users] Best way to match several attributes of an object?

2010-03-31 Thread Pat Maddox
On Mar 30, 2010, at 7:23 AM, George wrote: When you need to check several properties of an object, what is the best way to match them all? I'm using the 'satisfy' matcher at the moment but perhaps there's a better way than this: flight.should satisfy { |f| f.booking_code

Re: [rspec-users] Specing Ruby Game Development ???

2010-03-24 Thread Pat Maddox
Not I, but let me know if you come across anything please. Sounds interesting. On Mar 24, 2010, at 12:36 PM, Peter Fitzgibbons wrote: HI Folks, Roll Call for anyone using Rspec for Ruby Game Development (Rubygame, GOSU, TkRuby, etc.) ??? I'm having trouble finding the

Re: [rspec-users] stub vs stub!

2010-03-19 Thread Pat Maddox
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 On Mar 19, 2010, at 10:00 AM, Nick Hoffman

Re: [rspec-users] Hi All

2010-03-03 Thread Pat Maddox
On Mar 3, 2010, at 5:26 AM, David Chelimsky wrote: On Wed, Mar 3, 2010 at 2:16 AM, vtr thiyagaraja...@gmail.com wrote: Hi All, This is Thiyagarajan Veluchamy from India, i am new to rspec. gI need to learn rspec. Can anyone guide me, how to start properly. Advance Thanks, Hi

Re: [rspec-users] Shared Helpers

2010-02-23 Thread Pat Maddox
I just use a factory method. describe 'Authorize.net CIM gateway', :shared = true do describe 'saving a card' do describe 'preconditions' do it should raise an error if the card is not saved do lambda { gateway.save_credit_card(Factory.build(:credit_card, :user =

Re: [rspec-users] Of ActiveRecord, arel, and train wrecks

2010-02-22 Thread Pat Maddox
From a mocking / stubbing perspective, how is this different from Article.all(:conditions = ['published_at = ?', Time.now], :include = :comments) ? i.e. in both cases wouldn't you do class Article def self.active_published all :conditions = ['published_at = ?', Time.now], :include =

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

2010-02-21 Thread Pat Maddox
Extract redirect logic to an object or helper and test that. UrlRewriter.new.rewrite('/foods/search/almonds').should == '/almonds' helper.rewrite_url('/foods/search/almonds').should == '/almonds' and then you will see that this should probably be called higher up in the call stack, in a

Re: [rspec-users] adding to the callbacks that rspec-rails adds

2010-02-19 Thread Pat Maddox
Look in spec/spec_helper.rb for the configuration block, and hook up your custom stuff there: Spec::Runner.configured do |config| config.before(:each) { AfterFixturesLoaded.custom_stuff1 } config.after(:each) { AfterFixturesLoaded.custom_stuff1 } end Pat On Feb 16, 2010, at 8:48 AM, Ben

Re: [rspec-users] error: stack level too deep

2010-01-21 Thread Pat Maddox
Please provide more context. There should be a stack trace that tells you at which line the error occurs. This problem typically occurs when you have a method that calls itself and has no return mechanism. Sometimes that can be a sloppily implemented method_missing. I can't see anything

Re: [rspec-users] default to just call the method?

2010-01-20 Thread Pat Maddox
exactamundo On Jan 20, 2010, at 7:27 AM, Corey Haines wrote: Is something like this what you were thinking of? http://gist.github.com/281907 On Jan 18, 2010, at 9:31 am, Pat Maddox wrote: define_simple_predicate_matcher :rise_from_the_ashes? As an extension, how about

Re: [rspec-users] default to just call the method?

2010-01-18 Thread Pat Maddox
On Jan 15, 2010, at 6:19 AM, Ashley Moran wrote: On 14 Jan 2010, at 17:02, Rick DeNatale wrote: -1 You can already say a.should include(1:4) which is clearer IMHO. I assume Roger was referring to the general case though (which I still don't like) - and just happened to pick

Re: [rspec-users] testing named_scope

2010-01-18 Thread Pat Maddox
class User ActiveRecord::Base named_scope :admins, :conditions = {:admin = true} end describe User, admins do it should include users with admin flag do admin = User.create! :admin = true User.admin.should include(admin) end it should not include users without admin flag do

Re: [rspec-users] default to just call the method?

2010-01-18 Thread Pat Maddox
On Jan 18, 2010, at 7:12 AM, David Chelimsky wrote: On Mon, Jan 18, 2010 at 9:03 AM, Ashley Moran ashley.mo...@patchspace.co.uk wrote: On Jan 18, 2010, at 9:31 am, Pat Maddox wrote: define_simple_predicate_matcher :rise_from_the_ashes? As an extension, how about

Re: [rspec-users] RESTful controller specs in rails

2010-01-04 Thread Pat Maddox
I use resource_controller, and then don't need to write controller specs because it's all boiler-plate. If I add any custom behavior that needs more focused testing than cucumber provides, I can just write a couple specs to cover it. Pat On Jan 4, 2010, at 11:16 AM, Nicolás Sanguinetti

Re: [rspec-users] no should raise_exception

2009-12-23 Thread Pat Maddox
On Dec 22, 2009, at 2:08 PM, David Chelimsky wrote: On Tue, Dec 22, 2009 at 9:33 AM, rogerdpack rogerpack2...@gmail.com wrote: raise_error already catches any type of exception, error or not: class BlahException Exception; end class BlahError StandardError; end lambda { raise

Re: [rspec-users] spec'ing controllers

2009-12-16 Thread Pat Maddox
http://archive.patmaddox.com/blog/2009/1/15/how-i-test-controllers-2009-remix is my take on things. Due for an update though looks like :) On Dec 16, 2009, at 8:56 AM, Stefan Kanev wrote: Hey guys. I switched completely to RSpec and Cucumber this spring and I am really happy with. While

Re: [rspec-users] New RSpec methods to Object proposal: should_all and should_none

2009-12-09 Thread Pat Maddox
[...@admin, @allowed_user].should all(be_allowed_to_visit(url)) [...@admin, @allowed_user].should all_be_allowed_to_visit(url) I prefer the first so as not to introduce more magic but if it catches on then moving to the second might be worthwhile. Pat On Dec 9, 2009, at 5:27 AM, David

Re: [rspec-users] Introductory recommendations?

2009-11-25 Thread Pat Maddox
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

Re: [rspec-users] have_same_elements_of proposal

2009-10-28 Thread Pat Maddox
Already in. [1,2].should =~ [2,1] Pat On Wed, Oct 28, 2009 at 4:44 PM, Rodrigo Rosenfeld Rosas lboc...@yahoo.com.br wrote: How about having this matcher along the default available matchers? require 'set' Spec::Matchers.define :have_same_elements_of do |expected|  match do |actual|    

Re: [rspec-users] spec-ing private methods?

2009-10-21 Thread Pat Maddox
Break your object up. It's too big. On Wed, Oct 14, 2009 at 12:36 PM, Joaquin Rivera Padron joahk...@gmail.com wrote: hello there, how do you tipically spec private methods? The thing is Ï have something like this: def some_method    complex_method + other_complex_methods end private

Re: [rspec-users] Stub that returns hash values

2009-10-21 Thread Pat Maddox
wait why do you want to do this?? Just use a regular hash and do state-based assertions on it. Or determine the role that this hash-like thing is doing, and use a mock to define a proper interface. Ashley's solution works but I am very skeptical that the approach is a good one. Can you post

Re: [rspec-users] how to mock active record relationships

2009-10-21 Thread Pat Maddox
user = mock('user') controller.stub(:current_user).and_return user friendships_proxy = mock('friendships proxy') user.stub(:friendships).and_return friendships_proxy friendship = mock('friendship') friendhips_proxy.stub(:build).and_return friendship Try to avoid chains like this. Makes the test

Re: [rspec-users] Can't get running a simple rspec test: assigns is always nil

2009-10-21 Thread Pat Maddox
Is this all of the code, or did you remove some stuff? I copied the code in a new rails app and the test passed. What versions of rspec rspec-rails are you running? Pat On Tue, Oct 20, 2009 at 5:23 AM, Alexander Seidl li...@ruby-forum.com wrote: http://pastie.org/pastes/661816 hi, please

Re: [rspec-users] Slides from Uses Abuses of Mocks Stubs at NWRUG

2009-10-21 Thread Pat Maddox
Response written as I go through the slides, and late at night under sleep deprivation ;) * 57 juicy slides in half an hour? Damn dude. * Not a fan of the defining an interface service example. A single method named #query that accepts a string that appears to have the real command is not much

Re: [rspec-users] Factory_girl Need help

2009-10-21 Thread Pat Maddox
or check out fixjour (http://github.com/nakajima/fixjour/) which is better imo because it has a better API and fewer surprises (associations in factory girl always confuse me) Pat On Mon, Oct 5, 2009 at 3:32 AM, Mithun Perera li...@ruby-forum.com wrote: Hi please any body can help me to learn

Re: [rspec-users] stub! and stubs

2009-10-21 Thread Pat Maddox
On Mon, Oct 12, 2009 at 6:26 PM, Scott Taylor sc...@railsnewbie.com wrote: On Oct 12, 2009, at 9:14 PM, David Chelimsky wrote: On Oct 12, 2009, at 9:37 PM, Sam Woodard wrote: I have an interesting setup:  I am using rspec for mocking but I have mocha installed which give me access to

Re: [rspec-users] controller code doesn't seem to be called within rspec test

2009-10-21 Thread Pat Maddox
On Wed, Oct 21, 2009 at 6:56 AM, Alexander Seidl li...@ruby-forum.com wrote: I started a new test: Have a look at my new code: http://pastie.org/663455 1) The categories_controller is NOT called from the test! 2) I created another example with a message_controller and associated tests.

Re: [rspec-users] Can't get running a simple rspec test: assigns is always nil

2009-10-21 Thread Pat Maddox
On Wed, Oct 21, 2009 at 3:58 AM, Alexander Seidl li...@ruby-forum.com wrote: hi pat, thats all of the code that will be executed in categories_controller_spec.rb. the rest is commented out. Looks like this may be the same issue as the other thread. You didn't show all the code, because

Re: [rspec-users] Integrate or isolate views?

2009-07-01 Thread Pat Maddox
If your controllers are fat, test in isolation. For skinny controllers I will sometimes forgo controller specs altogether and implicitly verify the integration through cucumber features. Sometimes there's something funky that makes the cucumber failure output difficult to interpret, and

Re: [rspec-users] Integrate or isolate views?

2009-07-01 Thread Pat Maddox
On Sun, Jun 28, 2009 at 11:56 AM, Sarah Allensa...@ultrasaurus.com wrote: I find that testing views independently is useful just to catch HTML errors that can sometime creep in during a re-factor.  These check important details that would be more tedious using cucumber +1 Pat

Re: [rspec-users] Mock should receive no messages?

2009-06-04 Thread Pat Maddox
On Wed, Jun 3, 2009 at 10:46 AM, Sebastian W. li...@ruby-forum.com wrote: Hello all, Is there a way to explicitly tell a mock to expect no messages and give an error if it does? I believe this is the default behavior, but thought it might be nice for code readers to see. Document it in the

Re: [rspec-users] Does rspec support something like Assumptions in JUnit 4.4?

2009-06-01 Thread Pat Maddox
You can put expectations in your before block, and that'll give you the behavior you want. before(:each) do @org_root_prop = java.lang.System.getProperty(root) @org_root_prop.should_not be_nil @org_root_prop.trim.should_not be_empty end If either of those expectations fail then the

Re: [rspec-users] Any way to continue on Assertion Failure

2009-06-01 Thread Pat Maddox
Let's say I've got this spec: describe Team, add_player do it should add a player to the team do team = Team.new player = Player.new :name = Pat team.add_player player team.should have(1).players team.players.first.name.should == Pat end end and for some reason

Re: [rspec-users] Does rspec support something like Assumptions in JUnit 4.4?

2009-06-01 Thread Pat Maddox
(on System.getProperty in this case)?      Arthur Smith Pat Maddox wrote: You can put expectations in your before block, and that'll give you the behavior you want. before(:each) do   @org_root_prop = java.lang.System.getProperty(root)   @org_root_prop.should_not be_nil

Re: [rspec-users] Using Rails observers and testability

2009-05-05 Thread Pat Maddox
On Mon, May 4, 2009 at 12:39 PM, Zach Dennis zach.den...@gmail.com wrote: On Mon, May 4, 2009 at 1:57 PM, BJ Clark b...@aboutus.org wrote: Fernando, They are easier to spec with Pat Maddox's no peeping toms plugin. http://github.com/pat-maddox/no-peeping-toms/tree/master I use Pat's

Re: [rspec-users] cucumber - when to stub/mock

2009-05-05 Thread Pat Maddox
Don't mock the Geolp library directly. Wrap it with an API that fits your domain better. Then write a very simple object that implements the same API but doesn't hit the network. You can use a switch somewhere in env.rb to use your fake implementation or the Geolp one. Pat On Sunday, May 3,

Re: [rspec-users] Cucumber .should contain(expected) does but fails anyway

2009-04-24 Thread Pat Maddox
On Wed, Apr 22, 2009 at 12:18 PM, David Chelimsky dchelim...@gmail.com wrote: On Wed, Apr 22, 2009 at 2:09 PM, James Byrne li...@ruby-forum.com wrote: David Chelimsky wrote: On Wed, Apr 22, 2009 at 1:45 PM, James Byrne li...@ruby-forum.com wrote: this worked: I am not throwing out RSpec or

Re: [rspec-users] specs for attributes with default values on the SQL layer

2009-04-18 Thread Pat Maddox
On Sat, Apr 18, 2009 at 3:09 AM, svoop sv...@delirium.ch wrote: Pat Maddox pat.mad...@... writes: Okay I must be dense because I'm not sure what you mean by it gets in the way of refactoring. Actually, scratch that, because... And you're right about how it behaves...that's exactly how

Re: [rspec-users] best practice for model callbacks?

2009-04-16 Thread Pat Maddox
What is the thing that's being done in a callback and also sometimes called by clients? Usually the semantics are different and you don't want to treat them exactly the same... At any rate, you can be creative with shared example groups to get rid of the duplication. Something like describe

Re: [rspec-users] specs for attributes with default values on the SQL layer

2009-04-16 Thread Pat Maddox
On Thu, Apr 16, 2009 at 10:43 AM, svoop sv...@delirium.ch wrote: Hi I'm not sure what would be best practise to treat this case. Migration: t.boolean :fetched, :null = false, :default = false Model: validates_inclusion_of :fetched, :in = [true, false] Spec: it do  article =

Re: [rspec-users] specs for attributes with default values on the SQL layer

2009-04-16 Thread Pat Maddox
On Thu, Apr 16, 2009 at 1:15 PM, svoop sv...@delirium.ch wrote: What do you mean by it blocks refactorings?  This isn't any different from the first example, with the exception that you provide a value instead of letting the default kick in... article = Article.new article.fetched   # =

Re: [rspec-users] How to write a spec file for a helper

2009-04-13 Thread Pat Maddox
On Mon, Apr 13, 2009 at 8:17 AM, David Chelimsky dchelim...@gmail.com wrote: On Mon, Apr 13, 2009 at 12:09 PM, Salil Gaikwad li...@ruby-forum.com wrote: How to write a spec file for a following helper module ArtistsHelper def round_to(x)    (self * 10**x).round.to_f / 10**x end end in

Re: [rspec-users] Mocking: brittle specs and tight coupling?

2009-04-12 Thread Pat Maddox
On Sun, Apr 12, 2009 at 8:27 PM, Phlip phlip2...@gmail.com wrote: My current day-job's most important project has a test suite that suffered from abuse of that concept. The original team, without enough refactoring Would you have called it abuse were the tests well-factored? I don't think it

Re: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit

2009-04-10 Thread Pat Maddox
On Fri, Apr 10, 2009 at 8:49 AM, Lenny Marks le...@aps.org wrote: On Apr 10, 2009, at 12:51 AM, Ben Mabey wrote: Gavin Hughes wrote: Then I should be on /users/3/posts/8/comments/2/edit What's the solution for parsing out and matching and arbitrarily deep nested route? Hi Gavin, Let me

Re: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit

2009-04-10 Thread Pat Maddox
On Fri, Apr 10, 2009 at 9:40 AM, Pat Maddox pat.mad...@gmail.com wrote: I would just test that at the controller level I would _specify_ that at the controller level. BAD BDD evangelist :P ___ rspec-users mailing list rspec-users@rubyforge.org http

Re: [rspec-users] Then I should be on /users/3/posts/8/comments/2/edit

2009-04-09 Thread Pat Maddox
I'm not sure, cause I've never tried to write a step like that. I would rather do Then I should see Editing 'My sweet comment' Even better would be to actually edit the comment and make sure that it changed. So maybe When I edit the comment to be My new comment Then I should see My new comment

Re: [rspec-users] [Cucumber] Welcome Ben Mabey to the official Cucumber team

2009-04-08 Thread Pat Maddox
On Tue, Apr 7, 2009 at 2:19 PM, aslak hellesoy aslak.helle...@gmail.com wrote: Ben Mabey has accepted my invitation to be on the core Cucumber team. Ben has been a long time contributor to Cucumber's ecosystem and knows it inside out. Here is a quote from IRC today:   mabes: Yeah but you're

Re: [rspec-users] rake db:test:prepare and pending migrations

2009-04-07 Thread Pat Maddox
On Tue, Apr 7, 2009 at 10:32 AM, James B. Byrne byrn...@harte-lyne.ca wrote: I have run into a minor glitch and would like to know what others think.  I am working on a test/expectation and as part of the process of debugging I am rolling back db:migrations one step at a time to discover

Re: [rspec-users] Problems installing the rspec and rspec-rails gems

2009-04-04 Thread Pat Maddox
The rspec gem did install successfully, not sure what those doc warnings are. Did you install rspec-rails as well? Pat On Sat, Apr 4, 2009 at 4:08 PM, Mike Williams li...@ruby-forum.com wrote: Hello, Just purchased my first mac for Ruby on Rails development and I'm in the process of setting

Re: [rspec-users] Are there any example specs for content importers to learn from

2009-03-21 Thread Pat Maddox
That's basically what I do. http://gist.github.com/82981 shows one I wrote a couple days ago. I yield each object because there are like 400k records and I can't keep them in memory. Might be a little nicer to yield the params hash and let the caller build the object, but I don't need that

Re: [rspec-users] RSpec style and truthiness

2009-03-20 Thread Pat Maddox
On Thu, Mar 19, 2009 at 8:42 PM, David Chelimsky dchelim...@gmail.com wrote: On Thu, Mar 19, 2009 at 10:20 PM, Stephen Eley sfe...@gmail.com wrote: 2009/3/19 Rick DeNatale rick.denat...@gmail.com: Even 'should be' is a bit grating.  I'm tempted to write a pair of matchers like be_truthy and

Re: [rspec-users] Having a problem with new webrat matchers in cucumber 2

2009-03-20 Thread Pat Maddox
I think, if it is not already on the wiki, that cucumber users might be encouraged to put any local additions to support/env.rb into a separate file like support/local_env.rb.  Running script/generate cucumber to upgrade an existing project leaves those with customized env.rb files with two

Re: [rspec-users] [Cucumber 0.2] Failure to use should

2009-03-19 Thread Pat Maddox
Right, you need to add require 'spec/expectations' because Cucumber doesn't know about RSpec's matchers by default. Pat 2009/3/19 Yi hayafi...@gmail.com: This is my env.rb # Sets up the Rails environment for Cucumber ENV[RAILS_ENV] ||= test require File.expand_path(File.dirname(__FILE__) +

Re: [rspec-users] Speccing module which should be included in controller

2009-03-18 Thread Pat Maddox
On Mar 18, 2009, at 5:03 AM, Harm wrote: This works by the grace that my routes file has a fallback map.connect ':controller/:action/:id'. I never use that fallback only for this particular test. Is there anyway to get rid of this entry in my routes.rb? map.connect ':controller/:action/:id'

Re: [rspec-users] mock_model with Rspec/Rspec-rails 1.2 and Rails 2.3

2009-03-18 Thread Pat Maddox
On Mar 17, 2009, at 11:37 PM, David Chelimsky wrote: 2009/3/18 Tom Meier t...@zudio.com.au: With the above settings when our specs run (while on rails 2.3 and rspec 1.2), the following error occurs : undefined method `mock_model=' for #User:0x2d5887c The error says mock_model=, which

  1   2   3   4   5   6   >