similar to: ActiveRecord Validations - validates_uniqueness_of

Displaying 20 results from an estimated 2000 matches similar to: "ActiveRecord Validations - validates_uniqueness_of"

2006 Oct 05
0
ActiveRecord Validations - validates_uniqueness_of
David Chelimsky <dchelimsky at gmail.com> wrote: > What I would really want to ensure here is that Person validates > uniqueness of email, not how it does it. What I would do is something > like: > > def test_person_should_validate_uniqueness_of_email > assert_true Person.new(:email => "a at b.com").save > assert_false Person.new(:email => "a at
2006 Sep 13
2
Problem with RSpec and Mocha/Stubba
I''ve recently upgraded to the latest versions of Mocha and RSpec (0.3.2 and 0.6.3 respectively) and I''m no longer able to use Mocha/ Stubba with RSpec. Its actually only Stubba I''m interested in as I use RSpec''s built-in mocking library. I require stubba in my spec file but whenever I try and run my spec it fails with the error: Unintialized constant
2006 Nov 21
5
stubbing in development environment
Hi guys. Quite happy with mocha for testing. It''s been a bit of an eye opener for me, and I expect to begin using it heavily. One other thing I''d like to do is stub out particular class methods in development. Is there a way I can do this with mocha? Jason
2006 Oct 25
5
Mocha, Stubba and RSpec
Hi, I''ve been reading with interest the threads trying to integrate Mocha and Stubba with RSpec. So far, I''ve made the two changes in spec_helper.rb suggested, but discovered another one that neither of the archives mentions: If you use traditional mocking: object = mock or the stub shortcut : object = stub(:method => :result), you run into namespace conflicts with
2006 Sep 18
2
Mocha + Selenium-on-rails loading problem ?
Hello All, I need to stub two class methods before a selenium call. The .rsel is : require ''mocha'' SalesConfigWork.stubs(:load_work_data) SalesConfigWork.stubs(:delete_work_data) setup :fixtures => :sales_config_works open "/" The Selenium test runner result is : undefined method `stubs'' for SalesConfigWork:Class Extracted source (around line *#0*):
2007 Apr 11
1
Fwd: [ mocha-Bugs-5892 ] Using a setup method in test_case_class destroys subsequent test cases
---------- Forwarded message ---------- From: noreply at rubyforge.org <noreply at rubyforge.org> Date: 11-Apr-2007 15:24 Subject: [ mocha-Bugs-5892 ] Using a setup method in test_case_class destroys subsequent test cases To: noreply at rubyforge.org Bugs item #5892, was opened at 2006-09-25 07:49 You can respond by visiting:
2006 Sep 25
3
Problem stubbing instances referred to by constants
Hi James, An instance retains its mocha between tests if that instance is pointed to by a constant. The simplest failing test is something like (add as a new file in mocha/test).. #--code-- require File.join(File.dirname(__FILE__), "test_helper") require ''stubba'' class WemStubbaTest < Test::Unit::TestCase Arr = [1, 2, 3] def test_a
2006 Aug 17
1
expectations on stubs (stubba) or mock methods on existing classes?
Hello, First, thanks for releasing Mocha. As someone who''s been practicing TDD much longer than I''ve been using Rails, one of my biggest complaints has always been the fact that the "Unit" tests are more like intefration tests because of how tightly coupled the domain model is when using ActiveRecord. Stubba looks like it could really help aleviate this problem. The
2006 Sep 03
1
Slimmed down version for inclusion in Rails?
I''m pushing a major overhaul in testing the Rails codebase. Mocha and stubba make my life easy so that''s what I''m using. The first major patch using them is in RailTies (http://dev.rubyonrails.org/ticket/5970) now. I spoke to DHH today about using it in the other libraries and I think it''ll be ok, but they really want to include as little code as needed. I
2006 Dec 14
3
Stubbing constructiors
This works: class X def X.initialize( stuff ) end end X.initialize("bla") However stubbing it doesn,t: require ''test/unit'' require ''stubba'' class X def X.initialize( stuff ) end end class XTest < Test::Unit::TestCase def test_ X.stubs(:initialize).with("bla")
2006 Sep 08
1
A quick guide to Mocha
Hello :) Having just gone through the (admittedly simple) API of Mocha to learn how it works, I wrote a quick guide (190 lines) to help others get up to speed. I''ve attached it as RDOC and as HTML. It is a first draft - please help me improve by giving feedback ! Contents : Overview - Quick overview of Mocha Unit testing, mock object and stubs - Very quick introduction to mock
2006 Aug 14
14
A mock which extends rather than replaces a class?
While running tests, we would like to instrument some of the classes under test. We still want the classes to do exactly what they currently do, but we would like them to do more when running in the test environment. Clearly we can (and currently do) just extend the objects "on the fly" where necessary, but this is a bit messy - we''d like some centralised way to always
2006 Oct 13
6
If I stub do I have to mock as well?
Hi, I''m new to mocha and stubba but eager to learn. I have a rails functional test in which I would like to stub an instance method of particular class to always return true. I tried the following: def test_post_checkout Order.any_instance.stubs(:successful?).returns(true) post :checkout assert_response :redirect assert_equal "Checkout was successful.",
2006 Oct 26
2
Mocha and SimplyHelpful
Hi, I''m getting a conflict between the Mocha plugin and the Rails SimplyHelpful plugin. For some reason the dom_id method from SimplyHelpful is not being found in my views when the Mocha plugin is installed. The dom_id method if used in the controller works properly. This is the error I get when running the tests: 1) Error: test_truth(HmmControllerTest):
2006 Aug 15
3
Testing deleting files
In unit or functional test, is there a way to check that a file has been deleted? It seems that running the test does not really execute deleting files, which is good because I don''t want it to actually delete the files. But can I check that the deletion should have been performed in test environment? thanks, - reynard -------------- next part -------------- An HTML attachment was
2007 Aug 31
48
Deprecating the mocking framework?
I saw in one of Dave C.''s comments to a ticket that "our current plan is to deprecate the mocking framework." I hadn''t heard anything about that, but then again I haven''t paid super close attention to the list. Are we planning on dumping the mock framework in favor of using Mocha (or any other framework one might want to plug in?). Pat
2006 Sep 03
2
Fwd: Dealing with exec?
---------- Forwarded message ---------- From: Kevin Clark <kevin.clark at gmail.com> Date: 01-Sep-2006 20:31 Subject: Dealing with exec? To: James Mead <jamesmead44 at gmail.com> Hey James, Sorry to bug you. I was curious how you''d handle a call to exec in a method you were testing. Kernel.stubs(:exec)... doesn''t seem to work but I''m not sure where else an
2007 Jun 11
12
Mocking system/`
This drives me insane on a regular basis. How does one mock system(''blah'') or `blah` ? Adding expectations on Kernel doesn''t do it. Adding expectations on Object just makes me sad: Object.any_instance.expects(:system).with(''ls'') # => #<Mock:0x12b584e>.system(''ls'') - expected calls: 0, actual calls: 1 And this really
2007 May 07
6
mock frameworks
Just curious - now that rspec (as of 0.9) let''s you choose your mock framework, how many of you are actually using (or planning to use) mocha or flexmock? Anybody planning to use any other mock framework besides rspec, mocha or flexmock? Thanks, David
2006 Dec 15
3
how to install from svn?
When trying to run Chris samples I get error: /usr/lib/ruby/gems/1.8/gems/mocha-0.3.2/lib/smart_test_case.rb:3: uninitialized constant Test (NameError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' from /usr/lib/ruby/gems/1.8/gems/mocha-0.3.2/lib/mocha.rb:1 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:33:in