similar to: Using unit_record and rspec (previously "Keeping unit tests from hitting the DB")

Displaying 20 results from an estimated 6000 matches similar to: "Using unit_record and rspec (previously "Keeping unit tests from hitting the DB")"

2007 Aug 18
12
Test::Unit to RSpec
So I''ve just started working on a rails project which currently has something like 7500 LOC. All of the tests are written in Test::Unit, although the test coverage is pretty poor: rcov says that 25% of the code is covered, while rake stats shows the code to test ratio as 1:0.1 (800 lines of test code). I guess I''m wondering what would generally be advisable here. Is it
2008 Jan 19
6
Quiet Backtrace in RSpec
I''m using RSpec on Rails and would like to clean up the backtraces, so I went looking for an RSpec equivalent to ThoughtBot''s Quiet Backtrace gem<http://thoughtbot.com/projects/quietbacktrace>. I found Spec::Runner::QuietBacktraceTweaker in the RDOCS, but I can''t figure out how to use it. Can I add something to spec_helper.rb that will utilize
2007 Oct 30
1
Facets and/or Nested Describes
I have to confess that I did not know about facets before reading Ashley Moran''s post: http://aviewfromafar.net/2007/10/21/quick-and-dirty-facets-in-rspec-trunk Not knowing about the facets solution, I made a couple of feature requests for nested describes: http://rubyforge.org/tracker/index.php?func=detail&aid=14980&group_id=797&atid=3152
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 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?
2006 May 28
1
Unit tests hitting development database, not testing...
I''ve been working through the AWDWR book (both hard copy first edition and "beta book" pdf of second and I''m running into some problems when running unit tests. Integration tests and functional tests are behaving correctly and are operating against the test database. However unit tests try to operate against the development database and fail. (ie rake test:unit
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
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 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 Sep 16
4
How far to go with ActiveRecord unit tests without hitting the database?
I''m currently try to push my limits a little bit with some of my unit testing -- trying to avoid saving ActiveRecord objects to the database and take advantage of mock/stub objects. How far should I expect to get in this direction? From what I can tell, ActiveRecord seems to fight me when it comes to associations. In other words, many associations seem to require database queries.
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 Oct 04
3
spec task prints usage
A small feature request. When running the spec rake task, if any of the folders ''spec/models'', ''spec/controller'', or ''spec/views'' doesn''t exist or if they don''t contain any specs, the spec usage is printed. In my case I didn''t have a views directory. I was able to get rid of the usage output by creating the
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
2017 Jan 16
2
Building xapian-bindings
I'm posting this here to help others who might be having the same issue. I maintain xapian-core ruby gem. I was trying to upgrade to 1.4.2 and had some issues. The generated makefile doesn’t work because of the following: docs/rdocs/index.html: docs/xapian.rb rm -rf docs/rdocs $(MKDIR_P) docs cd docs && $(RDOC) --op rdocs `test -f xapian.rb||echo '$(abs_srcdir)/'`xapian.rb
2007 Dec 09
1
[rspec-devel] rspec_on_rails (trunk - r3070) works with Rails 2.0.1
I figured most of it out. The Spec::Rails stuff was something in the code which has been fixed by revision 3099. The test methods partially make sense. Since the test/unit code has been integrated, methods with test in them are automatically turned into specs. However, the test? method is in a lib file that isn''t directly loaded into the specs. It is a convenience method: def
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 Oct 12
1
Edge rspec - running Test::Unit tests
With rspec 1.0.8 I can run Test::Unit tests and rspec tests using: rake default and all tests and specs run. With edge rspec the Test::Unit tests return with the message: [list of tests] Finished in 4.5e-05 seconds 0 examples, 0 failures How can I get Test::Unit and rspec to happily co-exist again? Thanks, Alvin
2007 Aug 12
1
Test::Unit to RSpec Converter
Hey, just posting in case this is of interest. I just recently wrote a Rails plugin to convert Rails Test::Unit cases to RSpec. http://www.davidjrice.co.uk/articles/2007/8/12/ruby-on-rails-plugin- test-unit-to-rspec-converter it''s not going to work 100% in every case, but it''s really helped me convert old tests to the lovely RSpec :) Best, Dave --- David Rice
2006 Nov 25
2
Comparison between RSpec and test/unit
I''m curious, Christian Neukirchen has released test/unit[1] that seems to mirror much of RSpec, but built on Test::Unit, so in some ways less brittle from a Rails-integration perspective, and also allowing you to mix the two together as appropriate. So, has anyone made an informed comparison? I''m new enough that I don''t really know the finer points yet. The syntax is
2007 May 19
0
RSpec 1.0
The RSpec Development Team is extraordinarily pleased to announce the release of RSpec-1.0.0. == RSpec RSpec provides a Domain Specific Language for describing and verifying the behaviour of Ruby code with executable examples. Some people like to call these examples "tests". In fact, they are. But we believe that tests have equally important value as documentation and as a design aid,