Re: [rspec-users] Shoulda
Are you willing to provide a simple example? Andy Matt Wynne wrote: We do something similar to this, though we use a convention to set @klass to the class being spec'd in the top-level example group, rather than deriving it as they do in that sample. In view specs we also use a convention to always have a do_render method available, so that we can bring in similarly shared / generated examples. It's great for speccing two sublcasses which have some common behaviour, where it feels wrong to spec the (abstract) base class. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Shoulda
On Tue, Sep 30, 2008 at 8:41 AM, Andy Freeman [EMAIL PROTECTED] wrote: Are you willing to provide a simple example? I'm using the same example as the articled you linked to originally as the base. This way you should be able to clearly see the differences. http://gist.github.com/13804 Zach Andy Matt Wynne wrote: We do something similar to this, though we use a convention to set @klass to the class being spec'd in the top-level example group, rather than deriving it as they do in that sample. In view specs we also use a convention to always have a do_render method available, so that we can bring in similarly shared / generated examples. It's great for speccing two sublcasses which have some common behaviour, where it feels wrong to spec the (abstract) base class. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Shoulda
Also, a nice thing about RSpec is that when you do describe an actual object, ie: describe Foo, you can determine this by asking the example group what it's described type is. This makes things a lot simpler and cleaner than having to hack away strings, or guess based on the name of your test. Zach On Tue, Sep 30, 2008 at 8:57 AM, Zach Dennis [EMAIL PROTECTED] wrote: On Tue, Sep 30, 2008 at 8:41 AM, Andy Freeman [EMAIL PROTECTED] wrote: Are you willing to provide a simple example? I'm using the same example as the articled you linked to originally as the base. This way you should be able to clearly see the differences. http://gist.github.com/13804 Zach Andy Matt Wynne wrote: We do something similar to this, though we use a convention to set @klass to the class being spec'd in the top-level example group, rather than deriving it as they do in that sample. In view specs we also use a convention to always have a do_render method available, so that we can bring in similarly shared / generated examples. It's great for speccing two sublcasses which have some common behaviour, where it feels wrong to spec the (abstract) base class. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Fwd: ZenTest Autotest and 1.1.5
On Tue, Sep 30, 2008 at 8:02 AM, Ashley Moran [EMAIL PROTECTED] wrote: Begin forwarded message: Use either the installed autospec (not autotest) or script/autospec commands (for rails apps). http://rspec.info/rdoc/files/History_txt.html Cheers, David Hmmm, when I run autospec, all I get is /opt/local/bin/ruby -S spec/spec_helper.rb ... -O spec/spec.opts Then... nothing. Any ideas? I just noticed that too on a new project. It's the spec_helper that's causing the trouble, so it needs to be ignored. Put this in a .autotest file at the root of your project: Autotest.add_hook :initialize do |at| at.add_exception /spec\/spec_helper\.rb/ end Cheers, David Thanks Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Best way to determine if RSpec is loaded?
On 29 Sep 2008, at 13:28, David Chelimsky wrote: In theory it should be fine, but when you're running a suite of examples you're going to eventually want to load up everything in the app, no? True! But I've had a lot of loading issues lately, when autotest runs a single file and everything breaks. The one advantage I know of is if the whole app is available, you can mock(My::Class) and it'll tell you if you're mocking something that doesn't exist. That's good, right? RSpec's mocks don't do that (tell you when a mocked method doesn't really exist). Are you using a mocking frawework that does? Ah, I was referring no the class, not the method. I like being told My::Class doesn't exist, it's a motivation to create the files and write it should do something do violated end I find that helps drive development down the app's layers. Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Fwd: ZenTest Autotest and 1.1.5
On 30 Sep 2008, at 14:06, David Chelimsky wrote: I just noticed that too on a new project. It's the spec_helper that's causing the trouble, so it needs to be ignored. Put this in a .autotest file at the root of your project: Autotest.add_hook :initialize do |at| at.add_exception /spec\/spec_helper\.rb/ end Thanks! Just out of interest, why does that fix it? Here's my spec_helper.rb: require 'rubygems' require 'spec' # only added since using autospec lib_path = File.expand_path(File.join(File.dirname(__FILE__), '../ lib')) $:.unshift(lib_path) unless $:.include?(lib_path) require 'followme' module InMemoryDatabase def setup_in_memory_database DataMapper.setup(:default, sqlite3::memory:) FollowMe::Database::Migrator.reset_database! end end Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Cucumber::ArityMismatchError
Hi, We are receiving an ArityMismatchError when we feel we have a valid RegEx error C:/svnprojects/olc_stories/lib/framework/common_steps/verification_steps.rb:48:in `/verify the email with the subject of '[\w\x2E\-\s]*'/' create_staff_user.feature:15:in `And verify the email with the subject of 'xxx.xx.xxx.xxx.com - Your Account Details' scenario step And verify the email with the subject of 'xxx.xx.xxx.xxx.com - Your Account Details' implemented step Then /verify the email with the subject of '[\w\x2E\-\s]*'/ do |email_subject| verify_an_email_has_been_sent(email_subject) end Aidy ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber::ArityMismatchError
On Tue, Sep 30, 2008 at 3:59 PM, aidy lewis [EMAIL PROTECTED] wrote: Hi, We are receiving an ArityMismatchError when we feel we have a valid RegEx error C:/svnprojects/olc_stories/lib/framework/common_steps/verification_steps.rb:48:in `/verify the email with the subject of '[\w\x2E\-\s]*'/' create_staff_user.feature:15:in `And verify the email with the subject of 'xxx.xx.xxx.xxx.com - Your Account Details' scenario step And verify the email with the subject of 'xxx.xx.xxx.xxx.com - Your Account Details' implemented step Then /verify the email with the subject of '[\w\x2E\-\s]*'/ do |email_subject| verify_an_email_has_been_sent(email_subject) end There are no groups in your regexp. You probably want this: /verify the email with the subject of '([\w\x2E\-\s]*)'/ Aslak Aidy ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Fwd: ZenTest Autotest and 1.1.5
On Tue, Sep 30, 2008 at 8:15 AM, Ashley Moran [EMAIL PROTECTED] wrote: On 30 Sep 2008, at 14:06, David Chelimsky wrote: I just noticed that too on a new project. It's the spec_helper that's causing the trouble, so it needs to be ignored. Put this in a .autotest file at the root of your project: Autotest.add_hook :initialize do |at| at.add_exception /spec\/spec_helper\.rb/ end Thanks! Just out of interest, why does that fix it? Here's my spec_helper.rb: require 'rubygems' require 'spec' # only added since using autospec I've always included require 'spec' because it lets me use the ruby command or rdebug on a specific spec file. I just temporarily disabled the autospec mechanism and ran autotest directly and the same project had the same problem if I didn't have 'spec/spec_helper.rb' set as an exception in .autotest. So whatever the problem is, I don't think it is introduced by wrapping autotest in autospec. Not really sure what's up w/ this. Anybody else have this experience? lib_path = File.expand_path(File.join(File.dirname(__FILE__), '../lib')) $:.unshift(lib_path) unless $:.include?(lib_path) require 'followme' module InMemoryDatabase def setup_in_memory_database DataMapper.setup(:default, sqlite3::memory:) FollowMe::Database::Migrator.reset_database! end end Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber::ArityMismatchError
On Tue, Sep 30, 2008 at 8:59 AM, aidy lewis [EMAIL PROTECTED] wrote: Hi, We are receiving an ArityMismatchError when we feel we have a valid RegEx error C:/svnprojects/olc_stories/lib/framework/common_steps/verification_steps.rb:48:in `/verify the email with the subject of '[\w\x2E\-\s]*'/' create_staff_user.feature:15:in `And verify the email with the subject of 'xxx.xx.xxx.xxx.com - Your Account Details' scenario step And verify the email with the subject of 'xxx.xx.xxx.xxx.com - Your Account Details' implemented step Then /verify the email with the subject of '[\w\x2E\-\s]*'/ do |email_subject| verify_an_email_has_been_sent(email_subject) end Please file bug reports at http://rspec.lighthouseapp.com. Cheers, David Aidy ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber::ArityMismatchError
Aslak 2008/9/30 aslak hellesoy [EMAIL PROTECTED]: There are no groups in your regexp. You probably want this: /verify the email with the subject of '([\w\x2E\-\s]*)'/ Aslak Apologies. Thank You. Aidy ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Using the response object in stories
I have this statement in the layout of my application (using haml) - if request.env[HTTP_USER_AGENT].include?(MSIE) = stylesheet_link_tag 'blueprint/ie.css' = stylesheet_link_tag 'confirm_ie.css' The problem is that request.env[HTTP_USER_AGENT] is nil when I go to some page in the features I write with cucumber and webrat This is the error I get You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include? (ActionView::TemplateError) On line #23 of layouts/application.html.haml ¿How can I stub these methods for the reponse object? Thanks Juan M. Cervera -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Shoulda
David Chelimsky wrote: On Tue, Sep 30, 2008 at 7:59 AM, Zach Dennis [EMAIL PROTECTED] wrote: Also, a nice thing about RSpec is that when you do describe an actual object, ie: describe Foo, you can determine this by asking the example group what it's described type is. This makes things a lot simpler and cleaner than having to hack away strings, or guess based on the name of your test. Zach On Tue, Sep 30, 2008 at 8:57 AM, Zach Dennis [EMAIL PROTECTED] wrote: On Tue, Sep 30, 2008 at 8:41 AM, Andy Freeman [EMAIL PROTECTED] wrote: Are you willing to provide a simple example? I'm using the same example as the articled you linked to originally as the base. This way you should be able to clearly see the differences. http://gist.github.com/13804 Here's a variation on that with a helper for defining macros that I'm thinking of adding to rspec. Lemme know what you think: http://gist.github.com/13821 Cheers, David +1 I like it. For rspec-rails it would also be nice to be able to say: define_macros(:for = :controller) do ... end define_macros(:for = :models) do ... end etc... Also, instead of yielding within another block you can simply pass in the given block as an arg: def define_macros(macro_block) Spec::Example::ExampleGroupMethods.extend Module.new(macro_block) end You probably knew this but I thought I would point it out because it seems that it would give you better performance. (I have not tested that assumption at all.) -Ben ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] How do BOTH these examples pass?
Hi I'm, being thick, right?: describe RssReader do before(:each) do @uri = mock(URI) ::RSS::Parser.stub!(:parse).and_return(:parsed_rss) @rss_reader = RssReader.new(@uri) end describe when the RSS content loads do # ... end describe when there is an HTTP error do before(:each) do # second argument to OpenURI::HTTPError.new is an IO @uri.stub!(:read).and_raise(OpenURI::HTTPError.new(Fake HTTPError, nil)) end # ... it should not attempt to parse the RSS do ::RSS::Parser.should_receive(:parse) @rss_reader.rss end it should not attempt to parse the RSS do ::RSS::Parser.should_not_receive(:parse) @rss_reader.rss end end end Here's the output: % spec -c -fs rss_reader_spec.rb RssReader when the RSS content loads - should parse the RSS - should give access to the items RssReader when there is an HTTP error - should attempt to parse the RSS - should not attempt to parse the RSS - should fail gracefully Finished in 0.030693 seconds 5 examples, 0 failures And the code (not the final state I want it in, mind): class RssReader def initialize(uri) @uri = uri end def rss rss_body = begin @uri.read rescue OpenURI::HTTPError = e nil end ::RSS::Parser.parse(rss_body, false) end end Any ideas anyone? Thanks Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber - stub! or mock?
On Sep 15, 2008, at 4:35 PM, Pat Maddox wrote: I don't think you're really supposed to mock or stub when using cucumber. We need to stub time in some of our scenarios, which exist to to verify behavior over time. We're looking into a before/after to support mocking/stubbing for this scenario. Cheers, Luke -- Luke Melia [EMAIL PROTECTED] http://www.lukemelia.com/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] How do BOTH these examples pass?
On 30 Sep 2008, at 15:51, Ashley Moran wrote: it should not attempt to parse the RSS do Or, it should attempt to parse the RSS do Please excuse the typo... Ashley -- http://www.patchspace.co.uk/ http://aviewfromafar.net/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber - stub! or mock?
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: I don't think you're really supposed to mock or stub when using cucumber. We need to stub time in some of our scenarios, which exist to to verify behavior over time. We're looking into a before/after to support mocking/stubbing for this scenario. There's no direct hooks into the mock framework and I don't think there should be, but you can roll your own in the supplied Before/After methods: Before do #do some magic w/ time end After do #undo some magic w/ time end Those run before and after every scenario. Cheers, Luke -- Luke Melia [EMAIL PROTECTED] http://www.lukemelia.com/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] RSpec makes me want to write better code
I like them much better than the gremlins. On 30 Sep 2008, at 14:09, Dan North wrote: We do have pixies! They do all the magic stuff. How else do you think it happens? ;) 2008/9/27 aslak hellesoy [EMAIL PROTECTED] On Sat, Sep 27, 2008 at 10:32 PM, David Chelimsky [EMAIL PROTECTED] wrote: On Sat, Sep 27, 2008 at 2:29 PM, Mark Wilden [EMAIL PROTECTED] wrote: On Sat, Sep 27, 2008 at 11:26 AM, Dan North [EMAIL PROTECTED] wrote: It seems these conversations come up time and again because Rails overloads the idea of model. In a Rails app the model serves as both your domain model and your persistence strategy, because of the coupling inherent in the Active Record pattern. Interesting. This coupling actually brought me to one of my first a-ha! moment in Rails (similar to when I first learned about the ++ operator in C). Finally, I thought, I don't have to do anything to set up the butt-simple relationships between models and tables that are found (as you say) in 90% of web apps (and other applications, too). Rails allows models as complicated as you want, and it also allows you to do work in the database when you need to (I know find_by_sql is a dirty word, but it allows me to perform pivots on multiple tables of millions of rows, where AR simply could not handle the SQL). But it makes the overwhelmingly common case simple, and I like that. So I've found that this model-db coupling to be a powerful feature of Rails. I know it's saved me a lot of work, because I've had to do it manually so many other times in the last 25 years. If it's not sufficient or appropriate in any particular case, I don't have to use it. I know this view puts me on the wrong side of the contest you speak of (which I frankly didn't even know I'd entered). And yes, using Rails the way I (and many others) do involves trade-offs. But the one trade-off it doesn't require is with TSTTCPW, which is the guiding philosophy in everything I do. I guess this makes me an AR pixie. :) I *think* Dan means underlying magic code when he uses the word pixie. Dan always says pixies for stuff he doesn't understand. They don't have pixies in England I think. Aslak ///ark ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber - stub! or mock?
On Tue, Sep 30, 2008 at 10:26 AM, Scott Taylor [EMAIL PROTECTED] wrote: 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: I don't think you're really supposed to mock or stub when using cucumber. We need to stub time in some of our scenarios, which exist to to verify behavior over time. We're looking into a before/after to support mocking/stubbing for this scenario. There's no direct hooks into the mock framework and I don't think there should be, but you can roll your own in the supplied Before/After methods: Before do #do some magic w/ time end After do #undo some magic w/ time end Those run before and after every scenario. How would you do this? I guess you could just require spec/mocks/mock, mock / stub as usual, and then in the After block call Spec::Mocks::Space#reset_all ? That could work. And actually, I'd be OK w/ the idea of stubs, just not message expectations (mocks). Aslak? Scott ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Using the response object in stories
I'm sure it's possible, but sorry I don't know how offhand. I'll tell you what I know and see if it's enough to help you figure it out for yourself. The code you write in cucumber steps (which calls webrat) runs inside the context of a rails ActionController::Integration::Session. Have a look at the docs for that - somebody must have done this before for rails. You can play with this in script/console by calling the 'app' object e.g. $ script/console app.post /session, :username = 'matt', :password = 'secret' If you want it to behave just like in your steps, require 'webrat' so that the ActionController::Integration::Session class is monkey- patched with the webrat goodness. On 30 Sep 2008, at 15:25, Juanma Cervera wrote: I have this statement in the layout of my application (using haml) - if request.env[HTTP_USER_AGENT].include?(MSIE) = stylesheet_link_tag 'blueprint/ie.css' = stylesheet_link_tag 'confirm_ie.css' The problem is that request.env[HTTP_USER_AGENT] is nil when I go to some page in the features I write with cucumber and webrat This is the error I get You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include? (ActionView::TemplateError) On line #23 of layouts/application.html.haml ¿How can I stub these methods for the reponse object? Thanks Juan M. Cervera -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber - stub! or mock?
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: I don't think you're really supposed to mock or stub when using cucumber. We need to stub time in some of our scenarios, which exist to to verify behavior over time. We're looking into a before/after to support mocking/stubbing for this scenario. There's no direct hooks into the mock framework and I don't think there should be, but you can roll your own in the supplied Before/After methods: Before do #do some magic w/ time end After do #undo some magic w/ time end Those run before and after every scenario. How would you do this? I guess you could just require spec/mocks/ mock, mock / stub as usual, and then in the After block call Spec::Mocks::Space#reset_all ? You can do magic without mocks... orig_now = Time.method(:now) Before do now = Time.now (class Time; self; end).send(:define_method, :now) { now } end After do (class Time; self; end).send(:define_method, :now) { orig_now.call } end Pat ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber - stub! or mock?
On Sep 30, 2008, at 12:04 PM, Pat Maddox wrote: 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: I don't think you're really supposed to mock or stub when using cucumber. We need to stub time in some of our scenarios, which exist to to verify behavior over time. We're looking into a before/after to support mocking/stubbing for this scenario. There's no direct hooks into the mock framework and I don't think there should be, but you can roll your own in the supplied Before/After methods: Before do #do some magic w/ time end After do #undo some magic w/ time end Those run before and after every scenario. How would you do this? I guess you could just require spec/mocks/ mock, mock / stub as usual, and then in the After block call Spec::Mocks::Space#reset_all ? You can do magic without mocks... orig_now = Time.method(:now) Before do now = Time.now (class Time; self; end).send(:define_method, :now) { now } end After do (class Time; self; end).send(:define_method, :now) { orig_now.call } end Sure. If our mocks were macros, wouldn't it expand into this code? Scott ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Shoulda
On Tue, Sep 30, 2008 at 10:38 AM, Ben Mabey [EMAIL PROTECTED] wrote: David Chelimsky wrote: On Tue, Sep 30, 2008 at 7:59 AM, Zach Dennis [EMAIL PROTECTED] wrote: Also, a nice thing about RSpec is that when you do describe an actual object, ie: describe Foo, you can determine this by asking the example group what it's described type is. This makes things a lot simpler and cleaner than having to hack away strings, or guess based on the name of your test. Zach On Tue, Sep 30, 2008 at 8:57 AM, Zach Dennis [EMAIL PROTECTED] wrote: On Tue, Sep 30, 2008 at 8:41 AM, Andy Freeman [EMAIL PROTECTED] wrote: Are you willing to provide a simple example? I'm using the same example as the articled you linked to originally as the base. This way you should be able to clearly see the differences. http://gist.github.com/13804 Here's a variation on that with a helper for defining macros that I'm thinking of adding to rspec. Lemme know what you think: http://gist.github.com/13821 Cheers, David +1 I like it. For rspec-rails it would also be nice to be able to say: define_macros(:for = :controller) do ... end define_macros(:for = :models) do ... end etc... Also, instead of yielding within another block you can simply pass in the given block as an arg: def define_macros(macro_block) Spec::Example::ExampleGroupMethods.extend Module.new(macro_block) end You probably knew this but I thought I would point it out because it seems that it would give you better performance. (I have not tested that assumption at all.) I like David's suggestion and I also like Ben's suggestion on top of it. +1 to both. -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Using the response object in stories
Thanks Matt. I have check the rails api and see that I can pass a hash with the headers as a parameter with the post command. post /session, {:username = 'matt', :password = 'secret'}, {:HTTP_USER_AGENT = MSIE} and this works for me, by now, I don't know if I will have some more troubles with webrat. Thanks. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Using the response object in stories
Cool. Be aware that you're by-passing webrat by using the post method - that's one of the 'raw' rails calls that webrat wraps up in its elegant set of methods. It may be that you can pass this same hash to clicks_button but I don't know - you'd have to check the webrat source. On 30 Sep 2008, at 17:21, Juanma Cervera wrote: Thanks Matt. I have check the rails api and see that I can pass a hash with the headers as a parameter with the post command. post /session, {:username = 'matt', :password = 'secret'}, {:HTTP_USER_AGENT = MSIE} and this works for me, by now, I don't know if I will have some more troubles with webrat. Thanks. -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Spec for 'an array should not include an item'
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 so I'm not capable of explaining why it doesn't work, but hopefully someone can set me straight. Thanks -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Spec for 'an array should not include an item'
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 so I'm not capable of explaining why it doesn't work, but hopefully someone can set me straight. Thanks What's the error you're getting? Because, assuming that stuff is hooked up properly, this ought to work fine. Pat ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Spec for 'an array should not include an item'
Pat Maddox wrote: 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 so I'm not capable of explaining why it doesn't work, but hopefully someone can set me straight. Thanks What's the error you're getting? Because, assuming that stuff is hooked up properly, this ought to work fine. Pat ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users Also, what is your data? The matcher may not work as expected due to nuances in your data. For example, STI tends to mess things up in cases like this. -Ben ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Cucumber: please make gem install aslakhellesoy-cucumber or gem install cucumber work again
Subject says most of it. I'd love to use Cucumber in my project but I need to be able to install it in a Rails app and by a particular version number. I forked it and struggled with getting GitHub gems deployer to behave itself. Maybe a canonical version can be kept and updated in RubyForge occasionally because of occasional gem problems with GitHub? Evan ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber - stub! or mock?
On Sep 30, 2008, at 10:55 AM, Luke Melia wrote: We need to stub time in some of our scenarios, which exist to to verify behavior over time. We're looking into a before/after to support mocking/stubbing for this scenario. Thanks for everyone's thoughts. I understand that mocks are generally an anathema to story tests. We've decided to use them to solve this particular problem, though, and rely on our own self-discipline to not abuse their presence. Here's what we're going with for now in our env.rb: require 'spec/mocks' require File.expand_path(File.join(File.dirname(__FILE__), .., .., vendor, plugins, rspec, plugins, mock_frameworks, rspec)) include Spec::Plugins::MockFramework Before do setup_mocks_for_rspec end After do begin verify_mocks_for_rspec ensure teardown_mocks_for_rspec end end Luke -- Luke Melia [EMAIL PROTECTED] http://www.lukemelia.com/ ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber: please make gem install aslakhellesoy-cucumber or gem install cucumber work again
On Tue, Sep 30, 2008 at 9:02 PM, Evan David Light [EMAIL PROTECTED] wrote: Subject says most of it. I'd love to use Cucumber in my project but I need to be able to install it in a Rails app and by a particular version number. You can do that with git pull and git checkout. Would it help if detailed instructions were posted to the wiki? I forked it and struggled with getting GitHub gems deployer to behave itself. Maybe a canonical version can be kept and updated in RubyForge occasionally because of occasional gem problems with GitHub? Yes, I'll probably do that soon. GitHub fails to build the gem every time for me (not occasionally). http://logicalawesome.lighthouseapp.com/projects/8570-github/tickets/945 Aslak Evan ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Cucumber: please make gem install aslakhellesoy-cucumber or gem install cucumber work again
On Sep 30, 2008, at 5:20 PM, aslak hellesoy wrote: On Tue, Sep 30, 2008 at 9:02 PM, Evan David Light [EMAIL PROTECTED] wrote: Subject says most of it. I'd love to use Cucumber in my project but I need to be able to install it in a Rails app and by a particular version number. You can do that with git pull and git checkout. Would it help if detailed instructions were posted to the wiki? Not so much. I can get the repo, build, and install the gem. I'm trying to make it easier for members of my team who get a copy of our repo but need to install the dependent gems. Maybe a canonical version can be kept and updated in RubyForge occasionally because of occasional gem problems with GitHub? Yes, I'll probably do that soon. GitHub fails to build the gem every time for me (not occasionally). http://logicalawesome.lighthouseapp.com/projects/8570-github/tickets/945 It's worse than that for me: it keeps disabling the Rubygems setting in the Admin screen. I lose a little bit of love for GitHub over such an important feature working incorrectly. Evan___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Shoulda
What's not to like?! Despite the fact that a new RSpec version was just released, it would be nice to see a new version released right away with this concept built in so that a RSpec version of Shoulda could start rolling. :) David Chelimsky wrote: On Tue, Sep 30, 2008 at 7:59 AM, Zach Dennis [EMAIL PROTECTED] wrote: On Tue, Sep 30, 2008 at 8:41 AM, Andy Freeman [EMAIL PROTECTED] wrote: Are you willing to provide a simple example? I'm using the same example as the articled you linked to originally as the base. This way you should be able to clearly see the differences. http://gist.github.com/13804 Here's a variation on that with a helper for defining macros that I'm thinking of adding to rspec. Lemme know what you think: http://gist.github.com/13821 Cheers, David -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Why no rspec-rails gem?
I released 1.1.5 yesterday, including rspec-1.1.5 and rspec- rails-1.1.5 gems. It works fantastic. Thanks for a quality release. I've freed up about 100 of megs on my hard drive already. Cheers, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Shoulda
On Tue, Sep 30, 2008 at 10:18 PM, Andy Freeman [EMAIL PROTECTED] wrote: David Chelimsky wrote: On Tue, Sep 30, 2008 at 7:59 AM, Zach Dennis [EMAIL PROTECTED] wrote: On Tue, Sep 30, 2008 at 8:41 AM, Andy Freeman [EMAIL PROTECTED] wrote: Are you willing to provide a simple example? I'm using the same example as the articled you linked to originally as the base. This way you should be able to clearly see the differences. http://gist.github.com/13804 Here's a variation on that with a helper for defining macros that I'm thinking of adding to rspec. Lemme know what you think: http://gist.github.com/13821 What's not to like?! Despite the fact that a new RSpec version was just released, it would be nice to see a new version released right away with this concept built in so that a RSpec version of Shoulda could start rolling. :) Not quite sure how we got from discussing an idea to release planning, but the idea of a shoulda-like library built on this is a good one. If you're planning on writing one, no need to wait for this to appear in rspec. It's 3 lines of code that you could include in such a library until such time as it is released w/ RSpec. Cheers, David Cheers, David ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Shoulda
On Tue, Sep 30, 2008 at 9:38 AM, Ben Mabey [EMAIL PROTECTED] wrote: David Chelimsky wrote: On Tue, Sep 30, 2008 at 7:59 AM, Zach Dennis [EMAIL PROTECTED] wrote: Also, a nice thing about RSpec is that when you do describe an actual object, ie: describe Foo, you can determine this by asking the example group what it's described type is. This makes things a lot simpler and cleaner than having to hack away strings, or guess based on the name of your test. Zach On Tue, Sep 30, 2008 at 8:57 AM, Zach Dennis [EMAIL PROTECTED] wrote: On Tue, Sep 30, 2008 at 8:41 AM, Andy Freeman [EMAIL PROTECTED] wrote: Are you willing to provide a simple example? I'm using the same example as the articled you linked to originally as the base. This way you should be able to clearly see the differences. http://gist.github.com/13804 Here's a variation on that with a helper for defining macros that I'm thinking of adding to rspec. Lemme know what you think: http://gist.github.com/13821 Cheers, David +1 I like it. For rspec-rails it would also be nice to be able to say: define_macros(:for = :controller) do ... end define_macros(:for = :models) do ... end etc... Also, instead of yielding within another block you can simply pass in the given block as an arg: def define_macros(macro_block) Spec::Example::ExampleGroupMethods.extend Module.new(macro_block) end Close but not quite. Here are two similar examples that work: def define_macros(block) Spec::Example::ExampleGroupMethods.module_eval(block) end def define_macros(block) Spec::Example::ExampleGroupMethods.extend Module.new(block.call) end I think the first is nicer if we're not too concerned with control or traceability, but the second, w/ the Module.new on a separate line, would support maintaining references to the module (if that would be useful). Cheers, David You probably knew this but I thought I would point it out because it seems that it would give you better performance. (I have not tested that assumption at all.) -Ben ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Shoulda
I was actually teasing... :) As far as writing one... already on it! David Chelimsky wrote: On Tue, Sep 30, 2008 at 10:18 PM, Andy Freeman [EMAIL PROTECTED] wrote: Here's a variation on that with a helper for defining macros that I'm thinking of adding to rspec. Lemme know what you think: http://gist.github.com/13821 What's not to like?! Despite the fact that a new RSpec version was just released, it would be nice to see a new version released right away with this concept built in so that a RSpec version of Shoulda could start rolling. :) Not quite sure how we got from discussing an idea to release planning, but the idea of a shoulda-like library built on this is a good one. If you're planning on writing one, no need to wait for this to appear in rspec. It's 3 lines of code that you could include in such a library until such time as it is released w/ RSpec. Cheers, David -- Posted via http://www.ruby-forum.com/. ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users