Displaying 20 results from an estimated 5000 matches similar to: "scaffold_resource should create specs instead of tests"
2006 Nov 03
10
[PLUGIN] rspec_resource_generator - RESTful scaffold generator with RSpec specifications
rspec_resource_generator
========================
By Pat Maddox
Use this generator to generate RESTful scaffolding with RSpec specifications.
Syntax is exactly the same as the scaffold_resource generator:
./script/generate rspec_resource ModelName [field:type field:type]
When you run this generator, it will create a migration, model, and
model spec file. In addition, it gives you a RESTful
2007 Apr 07
5
Integration Specs On Rails
Now that RSpec is nearing 1 dot oh, are there any plans to implement
an integration testing equivalent in RSpec On Rails?
2007 Nov 17
7
Down with Lambda!!
Rspec is all about using natural language to define behavior. In this
context, I feel that lambda is sorely out of place. I was chatting on
#irc and a pal of mine (wycats) proposed an interesting alternative:
alias_method :doing, :lambda
so instead of something like
lambda {post :create, {:title => nil}}.should
raise_error(ActiveRecord::RecordInvalid)
we get
doing {post :create, {:title
2006 Oct 31
5
How to run edge RSpec (on Rails)?
I''m interested in tracking edge development of the RSpec on Rails
plugin and I''m a bit confused.
The installation guide
(http://rspec.rubyforge.org/documentation/rails/install.html) says,
"You''ll have to install the RSpec core gem first." It also says,
"Take note of what rspec version you''re installing ? it''s very
important that you
2007 Mar 27
3
Stubbing out method for all instances
I am using the acts_as_state_machine plugin to control state of an
object in my app, however when testing this I need to be able to stub
out the guard conditions so that state will change when I fire off an
event without depending on other models.
Guard conditions simply return true or false so I have an instance
method:
def encoded?
<check state of other objects>
return true
2007 Feb 23
2
Deferred success for specs?
I''ve started using specs as a to-do list. I write explicitly
violated specs so I know what to come back to. But a lot of the
time, that means if I start to work on another piece of functionality
covered by the same spec, it''s hard to tell what I''m working on now
from the explicit failues.
I run all my specs through TextMate to use the HTML output, so I go
by
2006 Nov 19
6
artificial sugar causes cancer
All,
If you look at http://rubyforge.org/tracker/index.php?func=detail&aid=6760&group_id=797&atid=3149
you''ll see that Chad (the submitter) found the source of the bug.
Unfortunately, the source of *this* bug is the *solution* to a
*previous bug* in which Rails was replacing RSpec''s method missing
with its own.
When we settled on underscores, my one reservation was
2006 Dec 21
3
Stubbing an instance method on a class
Hi all,
I''m not sure if I''ve missed it, but I couldn''t find any docs for
stubbing an instance method on a class. For example:
class Foo; end
Foo.stub!(:my_instance_method).and_return(nil)
The reason (I think) I need this is because a certain class
(Test::Unit::TestCase) expects an argument (name of method) to new and
throws an exception if that instance method
2007 Sep 20
4
alias :calling :lambda
Sprinkling my examples with ''lambda'' has always seemed like a bit of a
wart to me. I''ve gotten into the habit of adding ''alias :calling
:lambda'' to my spec suites. My examples then look like:
calling { Foo }.should raise_error
calling { Bar }.should_not raise_error
Is there a reason that RSpec core has chosen not to make exception
expectations more
2007 May 04
2
Custom Matcher and NAME NOT GENERATED annoyance
Hello RSpec users,
Have been using RSpec since 0.8.2 (not too long ago, I must say). and
been creating my custom matchers since was defined as "good practice".
Also, auto-generated names for the examples is very helpful, I''m
trying to take advantage of it.
Since I often prior code/define all the "examples", I have created a
few matchers to fulfill associations and
2007 Feb 07
3
odd mock behavior
I''m seeing some odd behavior around the should_receive() when given a
block combined with some cardinality.
For example, with the following...
my_mock.should_receive(:foo).twice do |i|
puts i
end
... the spec passes but i never gets puts''ed.
With the following...
my_mock.should_receive(:foo) do |i|
puts i
end
... i gets puts''ed twice but the spec fails because
2007 Jan 16
2
Links in view specs
Hi
I have this simple view (used by the Gap controller):
<h1>Gap#index</h1>
<%= link_to "Get a GAP quote", :action => "get_quote" %>
And this spec:
context "A rendered gap/index" do
setup do
render ''gap/index''
end
specify "should have a link to the get_quote page" do
2007 Oct 23
9
Running rails specs outside of the normal project tree
I want to create a spec/regressions directory with various
regressions (for my rails project). I tried the following:
describe LoginController, "regression for user creation when
steves_sister does not exist", :behavior_type => :controller do
controller_name :login
before :each do
@params = {
"commit"=>"Create Account",
2007 May 22
5
rails edge
hi,
first time trying rspec, and rails edge. Are there any known issues
running rspec with rails edge?
for one, apparently script/generate scaffold_resource has been
renamed just "resource". Do I just search/replace "scaffold_resource"
with "resource" in file rspec_resource_generator.rb ? Somethings
still missing.
before i get "Couldn''t find
2007 Jan 05
2
Using RESTful routes in controller tests
Why can''t I use the RESTful route helpers in my specs?
In my controller I''m doing a redirect: redirect_to list_path(:id =>
@item.list_id)
Now when I write: controller.should_redirect_to list_path(:id => 2)
I''m getting the following error:
NoMethodError in ''POST on /lists/2/items should redirect to index on
succesful POST''
You have a nil object
2007 Jun 22
11
Nicer failure message formatting
Hi
Are there any tools around that make rspec''s failure messages easier
to read?
unit_diff from ZenTest doesn''t seem to work - unless I missed something.
A simple but very helpful improvement would be to use more line-
breaks, e.g.
Current output:
expected "this is a very long string blah blah", got "this is a very
very long string blah blah" (using
2006 Oct 21
2
Usage Error
rake spec seems to work fine, but I keep getting a usage error at the
end of the spec run:
/usr/local/bin/ruby -I"/usr/local/lib/ruby/gems/1.8/gems/rspec-0.6.4/
lib" "/usr/local/lib/ruby/gems/1.8/gems/rspec-0.6.4/bin/spec"
Usage: spec [options] (FILE|DIRECTORY|GLOB)+
--diff Show unified diff of Strings
that are expected to be equal when
2004 Nov 30
2
$LOAD_PATH patch
Hey all,
I dunno if anyone else saw
http://rubyforge.org/tracker/index.php?func=detail&aid=1087&group_id=85&
atid=413
I just noticed it today (ack!) - I now have a monitor on patches. :)
Any thoughts?
Dan
2007 Apr 11
13
View Specs Fail with "protected method render"
I''ve got rspec and zentest installed as well as the rspec rails plugin, and
my model/controller specs all pass and work well. I can''t seem to get views
to work though - 100% of the specs fail with:
NoMethodError in ''/users/show.rhtml should render attributes in <p>''
protected method `render'' called for
2007 Nov 15
1
''lazy'' url generation in view specs
Hi,
I would like to use the ''lazy'' style of url generation in my views,
omitting parameters from my calls to url_for (and named route
methods) that are then filled in from the current request parameters.
Example:
url_for(:action => ''index'') will fill in (:controller => ''posts'') if
params[:controller] is ''posts''