similar to: Specifying mixins

Displaying 20 results from an estimated 3000 matches similar to: "Specifying mixins"

2007 Jun 27
2
Controller specs not shareable?
Hi I just wondered if there was a reason why Rails controller specs are not shareable? eg describe "All XHR POSTs to /gap/calculate_quote", :shared => true do controller_name :gap # ... end describe "XHR POST /gap/calculate_quote with valid details" do it_should_behave_like "All XHR POSTs to /gap/calculate_quote" # ... end blows up with
2007 Oct 21
8
Interesting shared behaviour side-effect
Given the following ApplicationController specs: describe ApplicationController, "one facet", :shared => true do it ''foo'' ... it ''bar'' ... end describe ApplicationController, "some other facet", :shared => true do it ''abc'' ... it ''xyz'' ... end describe
2008 Dec 09
7
subclassing vs mixins, which one should be used?
Hey all, I have two models in my rails project that share a lot of traits. They each have the same 4 properties, and now I need to add 2-3 methods to each one that will be the same. In the spirit of DRY I am looking for a solution to write these methods only once. Both of these models already inherit from ActiveRecord . . . and I didn''t know if it was safe to just "whip up" a
2007 Aug 04
5
reusable specs - almost there
I have a lot of controllers with virtually identical functionality for most actions. I''ve been using shared behaviours to DRY things up a bit, but I still have to create separate behaviours for each context before I can use the shared behaviours what I have now is a generic file which contains all the behaviours and examples common to all the controllers, and that file gets loaded from
2007 Jun 21
9
it_should_behave_like
I''m trying to use it_should_behave_like, and something seems to be wonky with the syntax. When I add :shared=>true, the DSL complains that the next line is the fixture declaration: /vendor/plugins/rspec/lib/spec/dsl/behaviour_eval.rb:137:in `method_missing'': undefined method `fixtures'' for #<Spec::DSL::EvalModule:0x324a2cc> (NoMethodError) Here''s the
2007 Nov 21
22
Getting Class in Shared Behaviours
Hi, I want to be able to get at the described class in my shared behaviour. I''m sure an example will say it better than my words describe "my shared", :shared => true do it "should tell me what the class is its describing" do how_do_i_get_the_user_class_here end end describe User do it_should_behave_like "my shared" #... end So in my
2007 Dec 18
16
shared behav
hi, i want to make a behavior shared between models, the examples need to create new instances etc. Is there a way to pass the model class to the shared behavior? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071218/5b400cc5/attachment-0001.html
2007 May 04
11
spec template for CRUD?
Hello, Has anyone already come up with a set of shared behaviours that someone could leverage when adhering to a CRUD concept, with respect to controllers? Relatedly, it would be nice if there were a way to share generalized behaviour specs. -Chris
2006 Jan 23
3
prototype.js: enumerable mixin for hash broken
Hello everyone. I am not sure if this is the right place to post, please redirect me if there is a mailinglist more specifically dealing with prototype.js. After playing around with the very inspiring prototype library I have found a rather annoying thing, that makes the usefulness of the Enumerable mixin for Hashes questionable, if I am not totally wrong (again :-). Here an example:
2007 May 24
25
Specs for ApplicationController, where to put them?
The Rails ApplicationController (app/controllers/application.rb) serves as an abstract superclass for all other controllers in a Rails application and is a good place to put methods and filters which you want all of your controllers to use. In my case I''m using it to provide methods such as "current_user" and "logged_in?" etc. By default, RSpec
2006 Nov 14
11
RESTful mixin, mixin repo?
Hi, I just put together a little mixin to provide pseudo-RESTful services in camping apps. Basically, it looks for a hidden _verb field in form posts, and sets the @method to the supplied value (e.g. put or delete - which browsers don''t support). This lets you define put and delete methods in your controllers. Groovy. Code: http://pastie.caboo.se/22613 Is there any permanent repo of
2006 May 10
1
model mixin module madness
If I have several models which exhibit the same functionality, it seems makes sense to create a mixin, ''include'' it in each model and save myself some work and repeated code. Where can I define a module which will be available to all models? I can''t seem to find a documented place for them. Alternatively, is there a Rails-standard way of achieving the effect? Ben
2009 Feb 02
2
ActiveRecord::AssociationTypeMismatch (User(#54754560) expected, got User(#54510280))
i keep getting this AssociationTypeMismatch error. i think this could be a bug related to ruby/rails when using mixins. heres a short version of my code: # user.rb require ''friend_invitation'' require ''friendship'' class User < ActiveRecord::Base include FriendInvitationUser, FriendshipUser ... end # friendship.rb ... module FriendshipUser def
2006 Jan 15
6
PROPOSAL: Validations as Mixin
It seems to me that Validations are quite useful for many objects, even ones having nothing to do with ActiveRecord. Common examples are Contact Us forms, multi-step forms, web service paramater validations, etc. I took a look at the source for Validations, and it seems that it is very independent from ActiveRecord. I caught only three depenedencies: 1. validates_numericy --> depends on
2006 Nov 14
3
[UHH] any blogs sprung from camping?
Hello, I just joined the camping list. I was trolling the archives when I saw this: -- The biggest problem in Camping is authentication. This is a problem I propose to solve by providing an extension. That little bit of code uses the path to allow/disallow urls. That way it is unobstrusive. In the future I would also like to make an OpenID client and server for Camping. -- I was wondering if
2007 Aug 29
2
DRY specs for RESTful controllers
Hi, I''m developing a RESTful Rails application whose code and specs are becoming increasingly repetitive: every controller does pretty much the same set of things (give or take the occasional twiddle), for example, and so every controller spec is almost identical modulo some names, constants and strings. The make_resourceful plugin, which autogenerates the boilerplate REST
2007 Aug 06
2
used the described Class in a shared behavior
Is it possible to access the described class in a shared behavior? I''m trying to do something like this: describe "Siberian feline", :shared => true do described_class_instance_as :feline, :name => "fluffy", :breed => "Siberian" # or maybe before(:all) do @feline = described_class.new(:name => "fluffy", :breed =>
2006 Jun 22
4
Authorization Plugin 1.0 release candidate + 3 test apps
In honor of RailsConf, I''m releasing an authorization plugin with 3 test apps that show you how to use the system. A reasonably lengthy description can be found here: http://www.writertopia.com/developers/authorization I will also be talking about the plugin''s architecture in my RailsConf talk on Saturday. Some features: - Nice English-like way of expressing permissions through
2006 Feb 19
1
NOOB: ratings/voting mixin or code example?
so as to not reinvent the wheel, are there any exisiting examples or mixins for a star rating system? basically what i''m looking to do is show pictures of local models which will be voted on by users, and the model with the most votes will get her photo in a calendar. anyone able to point me in the right direction... tutorials, code, whatever would be greatly appreciated! -A --
2008 Nov 22
1
Testing Environment for Plugints
Hello, I''m currently creating my first plugin in rails. It creates a model and a mixin for controllers. For testing purposes I need a test controller (sort of a mock) to which I can include my mixin and test wether the mixed in methods work. My problem is in order to do this I either have to setup my test enviorment in a rails app outside of my plugin or I have to replicate a whole rails