similar to: spec template for CRUD?

Displaying 20 results from an estimated 7000 matches similar to: "spec template for CRUD?"

2007 Apr 11
10
DRYer controller specs
So, I''ve been following the recommendations for controller specs here: http://blog.davidchelimsky.net/articles/2006/11/09/tutorial-rspec-stubs-and-mocks Most notably: a single expectation per specify block; the setup block contains only stubs; mock expectations each get their own specify block. (I''m still using 0.8, so I haven''t gotten the describe/it goodness yet.) I
2007 Jul 16
4
Accessing content_for html in view specs?
Hi All, Hope all is going well. I''ve got a few views that create some content using ''content_for'' blocks <% content_for :blah do %> ..... <% end %> Has anyone worked out a way to be able to access the html that''s generated inside those blocks? Since they''re not part of the view, have_tag('''') seems to miss them,
2006 Jun 14
3
In memory IndexReader bug?
Hi All, Hope all is going well. I''m having trouble with the following code creating an in memory index reader - it seems to be attempting to read from a file regardless. Here''s the simple code: require ''rubygems'' require ''ferret'' a = Ferret::Index::Index.new r = Ferret::Index::IndexReader.new(nil) Running the code on my OS X machine
2007 Jan 05
4
How To Spec Controllers with Finders
Given this code (which renders rjs), I''m faced with the fixture- driven way of spec-ing or mocking. How the heck to you mock this so the code at line (2) and (4) work right? I''m still struggling with mocks but it seems like this can be done. Forgive the naivety of this question. 1. def change_quantity 2. @line_item = LineItem.find_by_id(params[:id]) 3. unless
2006 Jun 13
5
Grep style output?
Hi All, Hope all is going well. Was just wondering if anyone has implemented a grep style output page of hits using Ferret as the index/query engine? Any thoughts about how best to implement it? The previous thread discussess highlighting - would that be the best approach to follow or is there a better way? Cheers, Marcus -- Posted via http://www.ruby-forum.com/.
2007 Apr 12
11
Test if view renders appropriate partial?
Hello, I am testing out a partial that calls another, general purpose partial as part of its processing. Is there a class I can mock in Rails views to accomplish what I need? That is, could I do something like the following: SomeClass.should_receive(:render).with(:partial => "foo", :locals => { :bars => bars }) I tried breakpointing the view, and it looks like I am greeted
2007 May 10
5
Shared behavior and_raise problem, and site aestetics
Hello, Is anyone else having trouble with the and_raise method on mocks, with respect to shared behaviors? If I do the following instead: foo.should_receive(:bar).and_return { raise } everything seems to work. I have been supplying no arguments to and_raise, by the way. Also, you may want to make the background in the code examples on the home page a little lighter. I am hardly able to
2007 Apr 28
7
[ rspec-Patches-9605 ] Patch for ER 9472, shared behaviour
Hi all - I''ve applied (to trunk) Bob Cotton''s patch which supports shared behaviours (link to tracker below). I''m still toying w/ names, so please be aware that until this is released w/ 0.9 it should be considered experimental and there will NOT be translation support for it. It will definitely be included in some form - just the names (specifically
2007 Dec 04
1
spec''ing shared controller methods
I want to isolate and spec methods that are shared by controllers, and live in application.rb. Whereas I usually also provide examples in individual controllers that use these methods, not necessarily all the edge cases and I''d like to isolate the examples. This is the approach I''m taking (thanks to bryanl for suggestions and http://pastie.caboo.se/123626). WDYT? This
2007 May 15
3
nested blocks
Hello, Does anyone have an explanation for why the following code results in the error that follows? I also would value any criticisms of my approach (i.e., defining it_should_populate_collections). Thanks -Chris #Code def it_should_populate_collections(condition=nil) it "should populate any necessary collections #{condition}" do [*@collections_to_populate].each do
2007 Jul 06
1
Edge, link_to and mocks
Hi All, Anyone noticed that using the newer link_to syntax in edge currently fails with mocked objects in view specs or helpers. eg. if you have something like the following in your view (or equivalent in a helper): <%= link_to @dog.name, @dog %> as opposed to the current 1.2 syntax: <%= link_to @dog.name, dog_path(@dog) %> Using a mock_model as the ''dog''
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 Jul 26
2
rspec_resource error
First of all hi, I''m new to the list, and rather new to rspec as will probably show in myquestion. I have tried installing rspec and rspec_on_rails as plugs both using "script/install" and "piston import" commands using the "current release install instructions" here [1]. However, there doesn''t seem to be any mention of the rspec_resource
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
7
describe AddressesController, "handling GET /addresses" do
Hello, I''m working with scaffold generated controller test code for handling GET requests. Address is the model being tested. Address belongs_to Company, Company has_many addresses. In my addresses_controller I have: before_filter :get_company def index @addresses = @company.addresses.find(:all) respond_to do |format| format.html # index.html.erb format.xml {
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 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
2007 Nov 01
8
Specifying mixins
Hi folks, Can anyone share some accumulated wisdom about the best way to spec mixins in general, and (Jamis Buck-style) ActiveRecord "concerns" in particular? The standard situation here is that there''s a bunch of functionality, related by concept if not by implementation, that one wants to inherit in many different classes (e.g. ActiveRecord models) without having to
2007 Nov 13
2
More Rails Pattern Examples?
Hi, I have been reading the documentation and examples on the rspec site. There are two "patterns" from Rails that I am not clear how to implement that are kind of related, and so I am not sure how to start. Does anyone have any examples of how to write rspecs for these? 1/ Nested resources. 2/ Resources that are specific to the current_user. In other words, I only want to
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