Displaying 20 results from an estimated 10000 matches similar to: "got/expects causes mental layering violation"
2007 Aug 27
7
Foreign key constraints, fixtures, and rake task
I''ve got a spec that loads a fixture in the "before" block. This works
fine running scripts/spec, but when I run rake spec instead, I get:
ActiveRecord::StatementInvalid in ''User in fixture :quentin with an IM
service but no IM name should be invalid''
Mysql::Error: Cannot delete or update a parent row: a foreign key
constraint fails
2006 Oct 17
3
Should fixtures be transactional?
I started using the new Model.should_have(1).records expectation in
rspec_on_rails, and quickly realized that my fixtures were remaining
loaded, even in contexts that didn''t use them. Bug or feature?
Jay Levitt
2007 Aug 13
2
Backtrace tweaker - broken or me?
Using 1.0.8, I just realized that I''ve been scrolling through pages of
backtraces when rspec is supposed to clean them up for me. This is a
new development machine, so I''m not sure if older versions worked or
not. I''m running Ruby 1.8.6, Rails edge, Mac OS X 10.4.10.
I''ve verified that the QuietBacktraceTweaker is the one that''s running.
2007 Aug 16
17
undefined method `mock_model'' for [RSpec example]:#<Class:0x25550a8>
I am getting:
undefined method `mock_model'' for [RSpec example]:#<Class:0x25550a8>
with my view specs after upgrading to 1.0.8. Is anyone else seeing this?
To isolate the message I did the following setup:
- create new rails project (with edge)
- installed rspec and rspec_on_rails
- ran rake spec
- ran script/generate rspec_scaffold products
- tried to run a builtin view
2006 Nov 07
7
should_redirect_to in advance - feels unnatural
I can understand that it''s easier for rspec to set up a mock in advance
of the controller call. But it makes it difficult to do something like:
context "The HarkController, given Louie the logged-in user" do
setup do
post :login, :username => ''louie'', :password => ''atest''
end
specify "should redirect Louie to the home
2007 Jan 21
35
Collection proxies need to be stubbed ?
Hi all !
I just started writing specs on a new project. I would just like to
validate that this is the way you would write it. I know about mocks,
stubs and expectations. I don''t think this is a problem for me.
My question really boils down to:
def index
@projects = current_user.projects.active
end
My spec needs to return the proxy, no ? Here''s my code:
context "A
2007 Aug 30
7
mock_model in spec/lib
Has anyone else run into a problem with trying to use mock_model in spec/lib ?
For some reason, I can take the same spec, put it in spec/models, have it run
fine, but put it in spec/lib, and have it complain about not being able to find
#mock_model
Thanks,
Edward
2007 Aug 06
2
Specifying custom rails FormBuilders
I want to write a spec for a custom form builder, but I''m not really
sure where it should live or how to include the right rspec_on_rails
contexts. Ideally, I should be able to write a spec like:
describe LabelledBuilder do
it "should let me create a text field" do
object = mock(object)
object.stub!(:attribute).and_return("Test String")
render
2006 Nov 10
3
Stubbing Time.now in trunk
I''m a big fan of stubbing Time.now so it returns a known value. I used
to be able to use stubba and say:
@time_now = Time.parse("Jan 1 2001")
Time.stubs(:now).returns(lambda{@time_now})
However, something in trunk broke that. Fine, rspec''s got its own
stubbing lib now, so I tried switching to that:
@time_now = Time.parse("Jan 1 2001")
2007 Sep 16
10
I lost the RSpec fight
I''ve been working on a Rails project with one other developer; he was
using Test::Unit, and I was using RSpec. That works OK for a while, but
obviously it starts causing pain when you have to check in two places to
see if a piece of code is properly tested/spec''d, you can''t use TextMate
shortcuts to switch back and forth between code and test, you have to
duplicate
2006 Nov 06
1
Integration testing: coupling of get and post on forms
This is such a vague request it''s not even worthy of a ticket, but:
When rspec does support integration testing, it''d be really nice to be
able to do things like this plugin does for standard Rails tests:
http://www.jasongarber.com/articles/2006/10/24/easier-testing-of-forms-form_test_helper
In a nutshell, it finally closes the loop between "the empty form sent
by a
2006 Nov 07
1
RSpec/Selenium start_browser_once patch?
The 0.7.0 vendor/selenium/README.txt references a
"start_browser_once.patch" file. This doesn''t seem to be included in
either the rspec or selenium-rc distributions, and Google finds
nothing... where might I find that patch?
Jay Levitt
2007 Oct 15
14
Top Quoting?
Sort of off-topic and don''t mean to complain, but many on this list
use top quoting. That works ok if you don''t quote the whole previous
thread. However, I''m finding that scrolling forever to locate the
reply on longer threads is getting tedious. What''s the rationale for
top-quoting?
Thx.
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 Sep 06
5
Removing/overriding/unstubbing a stub?
We''re using Mocha stubs to stub out a slow-performing network request in
a Test::Unit class. But naturally, we don''t want to stub it out in the
few tests that actually verify the functionality of that network request.
Is there a way to do the stub in "setup", but override it for the few
tests that need the original functionality?
(I realize that in this case, the
2007 Sep 04
16
Failure Messages in RSpec
Having used JUnit and Test::Unit, I''m quite used to having the ability to
insert a failure message, which helps when tests fail.
For instance, the example RSpec that is generated for a model class
specifies that the model class is valid. Assuming this were supposed to be
true, and it failed, I''ve now got to duplicate the code in the test in order
to find out why it
2007 Feb 02
7
Coming Soon...
Dear spec''ers,
As many of you already know, we''re gearing up for a pretty big 0.8
release of RSpec in the next couple of weeks. I''m writing in advance
because I want to give you a heads up about upcoming changes and how
they may impact your existing specs.
Two important things to note first:
1. We will provide a translator that you''ll be able to use to
2007 Aug 24
26
testing behaviour or testing code?
hypothetical question for all you BDD experts:
I want to make sure that a :list action always returns widgets in
alphabetical order. There''s at least 2 ways of doing this:
it "should fetch items in alphabetical order" do
Widget.should_receive(:find).with(:order => "name ASC")
get :list
end
it "should fetch items in alphabetical order" do
[:red,
2008 Aug 20
9
I want RSpec for CSS layout.
I don''t even know how it''d be possible (through Selenium?), but I want it.
I want to see if my stupid CSS hacks break. I want to say:
describe "#nav-column" do
body = something("#body-column")
it "should line up at the top" do
dom[:top].should_be == body.dom[:top]
end
it "should always be to the right" do
2006 Apr 02
7
RANT: belongs_to -> refers_to
Every once in a while, I pipe up and whine that "belongs_to" should really
be ''refers_to" [http://dev.rubyonrails.org/ticket/2130]. It''s time again.
I''ve got a bunch of stuff going onto eBay, so, like any good engineer, I
don''t just post it manually: I design a Rails-based inventory database that
creates a semantically-correct XHTML/CSS auction