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 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 > def comple

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 som

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 s

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 wrote: > http://pastie.org/pastes/661816 > > hi, > please have a look at m

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 wrote: > Hi > please any body can help me to learn the basics of Facto

Re: [rspec-users] stub! and stubs

2009-10-21 Thread Pat Maddox
On Mon, Oct 12, 2009 at 6:26 PM, Scott Taylor 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 any_instance, e

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 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. There, the control

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 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 there's an unknown UserC

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 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| >    expected.to_set ==

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 anybod

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 Chelims

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. Wh

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 wrote: > > raise_error already catches any type of exception, error or not: > > > > class BlahException < Exception; end > > class BlahError < StandardError; end > > > > lambda { raise BlahExce

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 wrot

Re: [rspec-users] get to a different controller

2010-01-05 Thread Pat Maddox
The spec has Admin::BaseController as the described type. So of course it's going to test against that. If you want to test a different class, you need to describe that instead! On Jan 5, 2010, at 9:36 AM, Phillip Koebbe wrote: > I'm trying to implement a base controller that other controller

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

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

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 > wrote: >> >> On Jan 18, 2010, at 9:31 am, Pat Maddox wrote: >> >>> define_simple_predicate_matcher :rise_from_the_ashes?

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_pr

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 obvi

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 F

Re: [rspec-users] Question About Cleaning Up Specs?

2010-02-19 Thread Pat Maddox
I disagree with the crowd on the basis that these examples are lazy. Very close to what I do though. Imagine you had one other example in there: it "should assign the post to the view" do post :create assigns[:post].should == @post end Then you wouldn't really need the other should_receive

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 before_f

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] 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] Applying an rspec matcher against the elements of a collection

2010-02-23 Thread Pat Maddox
I'm going to argue that your design is off, and then ignore the rest of your post :) class Person < Struct.new(:name, :age) VOTING_AGE = 18 def voter? age >= VOTING_AGE end end Now your tests become very simple: Person.new('Jenny', 17).should_not be_voter Person.new('Bob', 18).should

Re: [rspec-users] Applying an rspec matcher against the elements of a collection

2010-02-24 Thread Pat Maddox
. > > On Feb 23, 1:43 pm, Pat Maddox wrote: >> I'm going to argue that your design is off, and then ignore the rest of your >> post :) > > Fair enough :) The 'design' in my example was made up on the spot to > try and illustrate the kind of issues I

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 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 Thiyagarajan. Welcome t

Re: [rspec-users] Is share_examples_for deprecated?

2010-03-06 Thread Pat Maddox
describe "something something", :shared => true do ... end describe "chunky bacon" do it_should_behave_like "something something" end On Mar 6, 2010, at 2:31 PM, Nick Hoffman wrote: > API Dock says that "share_examples_for" is deprecated. If that's > correct, what should we be using instea

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 wrote

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 latest-and-

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] 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 wro

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'

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] [Cucumber:4066] Cucumber vs, RSpec

2010-04-21 Thread Pat Maddox
Cucumber features are the best tool I know of for capturing requirements from my customer. RSpec specs are the best tool I know of for communicating intent and gauging code quality among the developer team. I'm not sure how exactly you're quantifying a 90/10 or 80/20 split. I would expect tha

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 ass

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

2010-04-27 Thread Pat Maddox
Rails apps (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 > wrote: >> Cucumber featur

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 ==

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

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

2010-08-15 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 t

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] 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] 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] 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'

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 >

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 wrote: > I went ba

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 wrote:

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 che

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:)" 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 stdout

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 m

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] 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 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 compare them as

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

2011-01-31 Thread Pat Maddox
On Jan 27, 2011, at 6:53 PM, Rick DeNatale wrote: > On Thu, Jan 27, 2011 at 6:16 PM, David Chelimsky 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_ spec. >> >> Perhaps :any is a b

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 r

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 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 release note

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 pra

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

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', >:subjec

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 a

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('h

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 p

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 > Active

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

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] 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[:face

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 spec

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 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 >>&g

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 out

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] 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 >

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 tha

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

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 co

Re: [rspec-users] Advice on using Rspec as a data validation engine

2011-12-22 Thread Pat Maddox
On Dec 13, 2011, at 9:32 PM, Bill Christian wrote: > I have a project that collects various application configurations across a > couple thousand servers and wants to validate settings are following > recommended values. For example, all weblogic servers should have a minimum > memory heap siz

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

2011-12-22 Thread Pat Maddox
On Dec 22, 2011, at 12:33 PM, LeeQ 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 > like those exception

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 scenar

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

Re: [rspec-users] Why no rspec-rails gem?

2008-09-28 Thread Pat Maddox
Tim Harper <[EMAIL PROTECTED]> writes: > I was getting a little tired of adding 2 plugins every time I create a > new rails project, so I just built an rspec-rails gemspec, and it > works perfectly well. Does anybody know why there isn't a public > rspec-rails gem? I don't know if I should be as

Re: [rspec-users] Should change not comparing arrays how I expected

2008-09-28 Thread Pat Maddox
Michael Latta <[EMAIL PROTECTED]> writes: > David, > > It seems to me that the root of the problem is that the specification > is incorrect. Since Rails returns association proxies the > specification fails because it does not specify what the behavior > should be. I would suggest that instead o

Re: [rspec-users] Cucumber - stub! or mock?

2008-09-30 Thread Pat Maddox
Scott Taylor <[EMAIL PROTECTED]> writes: > On Sep 30, 2008, at 11:06 AM, David Chelimsky wrote: > >> On Tue, Sep 30, 2008 at 9:55 AM, Luke Melia <[EMAIL PROTECTED]> >> wrote: >>> On Sep 15, 2008, at 4:35 PM, Pat Maddox wrote: >>> >>>&g

Re: [rspec-users] Spec for 'an array should not include an item'

2008-09-30 Thread Pat Maddox
Neil Cauldwell <[EMAIL PROTECTED]> writes: > Does anyone know how I can write a spec along the lines of this (but a > working implementation); > >it "should not include inactive users" do > do_get > assigns[:results].should_not include(users(:inactive_user)) >end > > I'm a newbie

Re: [rspec-users] How do BOTH these examples pass?

2008-10-01 Thread Pat Maddox
Ashley Moran <[EMAIL PROTECTED]> writes: > *does* pass the specs, both the one that says parse should be called, > and the one that say it shouldn't! But why? I'm prepared to admit > I'm just missing something really really really obvious (it happens > often), but how can: > > it "should atte

Re: [rspec-users] Spec for 'an array should not include an item'

2008-10-01 Thread Pat Maddox
Neil Cauldwell <[EMAIL PROTECTED]> writes: > Is my stubbing breaking this? I hope not because Thinking SPhinx isn't > determining the scope of the search in relation to the 'active' state of > the users; the search is built on top of a named scope on the User > model; > > # GET /searches/peopl

Re: [rspec-users] How do BOTH these examples pass?

2008-10-01 Thread Pat Maddox
Ashley Moran <[EMAIL PROTECTED]> writes: > On 1 Oct 2008, at 15:23, Pat Maddox wrote: > >> I think this may be a bug that I introduced recently. Fortunately I >> also think someone already wrote a patch :) Check out >> http://rspec.lighthouseapp.com/projects/

Re: [rspec-users] Spec for 'an array should not include an item'

2008-10-01 Thread Pat Maddox
Neil Cauldwell <[EMAIL PROTECTED]> writes: > Pat Maddox wrote: >> Neil Cauldwell <[EMAIL PROTECTED]> writes: >>> >>> respond_to do |format| >>> format.html >>> format.xml { render :xml => @results } >>> end

Re: [rspec-users] Spec for 'an array should not include an item'

2008-10-01 Thread Pat Maddox
Neil Cauldwell <[EMAIL PROTECTED]> writes: > Pat Maddox wrote: >> Neil Cauldwell <[EMAIL PROTECTED]> writes: >> >>>> >>> (which it doesn't, therefore suggesting the spec is broken); >>>def do_get >>> ThinkingSphinx

Re: [rspec-users] Spec for 'an array should not include an item'

2008-10-01 Thread Pat Maddox
Neil Cauldwell <[EMAIL PROTECTED]> writes: > Pat Maddox wrote: >> Neil Cauldwell <[EMAIL PROTECTED]> writes: >> >>>>> ...so shouldn't the spec fail if we're returning all the users fixtures >>>> which is true. [1,2,3]

Re: [rspec-users] How do BOTH these examples pass?

2008-10-01 Thread Pat Maddox
Ashley Moran <[EMAIL PROTECTED]> writes: > On Oct 01, 2008, at 6:39 pm, David Chelimsky wrote: > >> There were a couple of other bugs introduced in 1.1.5 so I would like >> to get out a 1.1.6 very soon. Probably over the weekend if we can get >> them all fixed. > > > Cool thanks David. > > It's no

Re: [rspec-users] how to catch a missing image (rspec-rails)

2008-10-02 Thread Pat Maddox
Evan Dorn <[EMAIL PROTECTED]> writes: > I want to make sure all external resources called for by my views (like > images) actually exist. How do I write an rspec that will fail when an > image included on the page isn't present? > > > For example, let's say in application.html.erb, I include src

Re: [rspec-users] Difference between gem and plugin

2008-10-03 Thread Pat Maddox
"Zach Dennis" <[EMAIL PROTECTED]> writes: > On Fri, Oct 3, 2008 at 4:46 PM, Donald French <[EMAIL PROTECTED]> wrote: >> Can someone tell me the difference ins the gem versions and the plugin >> versions? do they work together? need both? >> > > You do not need both. The plugin versions are for Rub

[rspec-users] What questions do you have about testing?

2008-10-05 Thread Pat Maddox
Hey everyone, We're doing a panel on testing at the Voices That Matter conference (http://www.voicesthatmatter.com/ruby2008/ - you should go :). Obie set up a google moderator thing [1] to collect questions for the panel. I invite you all to put some questions up on there. They can be questions

Re: [rspec-users] What questions do you have about testing?

2008-10-05 Thread Pat Maddox
Scott Taylor <[EMAIL PROTECTED]> writes: > On Oct 5, 2008, at 11:11 AM, Pat Maddox wrote: > >> Hey everyone, >> >> We're doing a panel on testing at the Voices That Matter conference >> (http://www.voicesthatmatter.com/ruby2008/ - you should go :). Obie

Re: [rspec-users] Newbie question about mock_model and should_receive....

2008-10-06 Thread Pat Maddox
Rémi Gagnon <[EMAIL PROTECTED]> writes: > Hello, > > I mocked a model and I need to test when I set for instance '000' to an > attribute 'A' that B attibute is set to ''. I don't want to stub or > mock the B(accessors) to that value cause I want to make sure my > controller will do that. > >

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-06 Thread Pat Maddox
What are you currently seeing? afaik, you should currently see all the dots and a few F's when specs fail, and then after that you'll see detailed failure messages including backtraces. Pat "Greg Hauptmann" <[EMAIL PROTECTED]> writes: > Hi, > > Can I get more details in the "rake spec" output

[rspec-users] gem generators on 1.2.6

2008-10-07 Thread Pat Maddox
In a 1.2.6 app (don't ask), I don't see the generators available to me with the gems installed. However the documentation makes it look like it should work: Generator gems are also available: 1. gem search -r generator 2. gem install login_generator 3. ./script/generate login I've confirmed

Re: [rspec-users] gem generators on 1.2.6

2008-10-07 Thread Pat Maddox
> I've confirmed that with a fresh rails (2.x) app it works fine. Is > this supposed to work with 1.2.6? Are there any workarounds that > people have? Is my app just fucked atm? erm, I've also confirmed that with a fresh rails 1.2.6 app it DOESN'T see the gem generators. I'm pretty suspicious

  1   2   3   4   5   6   7   >