Displaying 20 results from an estimated 52 matches for "assert_raise".
Did you mean:
assert_raises
2006 May 06
6
assert_raises --> how does it work?
Hi,
I have this code fragment:
def test_delete_concept
assert_not_nil Concept.find(concepts(:entreprise).id)
get :delete_concept, {:concept_id => concepts(:entreprise).id}
assert_raises :RecordNotFound,
Concept.find(concepts(:entreprise).id)
end
basicaly, on the first line, I make sure that the concept exist in the
DB. On the second line I delete the concept fron the DB.
Finaly, this is where I have a problem, on the third line, I want to see
if the record was deleted. I t...
2006 Nov 22
1
Using assert_raise
When Im writing tests and I do:
assert_raise RuntimeError, raise("raising")
Then I run the test is says the test failed and I have 1 error:
RuntimeError: hey
Should assert_raise catch that error and say the test passed?
Thanks for your time and help.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~----------...
2006 Jul 18
2
Testing which RuntimeError is raised
I am just starting to use unit testing. Way cool. But I am not finding
very clear docs on assert_raise. I have managed to write a test that
tells me that the destroy I am trying to test fails with a
RuntimeError (as it should). However, I would really like to test that
it rails for the specific reason I have in my model. How can I get
more specific? Am I going to have to create my own exception clas...
2004 Feb 01
2
test_services test case
...r is unavailable" error message that was popping up on some
systems. I couldn''t duplicate this on my XP Pro box, but it does show up on
my Win2k box.
Quick review - this is the test case from tc_service.rb
def test_services
assert_nothing_raised{ Service.services{ } }
assert_raises(NotImplementedError){ Service.services } # no non-block
a = []
Service.services{ |s| a.push(s) }
assert_kind_of(Struct::Win32Service,a.first)
end
I added some more information to the error messages, and it turns out that
the failure is caused by the call to OpenSCManager() in t...
2008 Oct 24
1
rescue_from and assert_raise
Since commit 5e3517ea7b9fbd460f772bffc9212d882011f2bc, rescue_from is
now being handled in tests. I''ve been using rescue_from to handle
custom exceptions and testing that those exceptions are raised in
functional tests with assert_raise. This no longer works now. What''s
the proper way to test this now?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-...
2006 Dec 28
0
problem with assert_raise in Unit Test
...time_logs << time_logs(:first)
will generate
ActiveRecord::StatementInvalid: Mysql::Error: #23000Duplicate entry
''20'' for key 2: UPDATE time_logs SET `task_id` = 1, `date_created` =
NULL, `time_charge_id` = 20, `hours` = 2.0, `log_entry` = NULL WHERE id
= 2
However,
assert_raise ActiveRecord::StatementInvalid do
charge.time_logs << time_logs(:first)
end
will generate
<ActiveRecord::StatementInvalid> exception expected but none was
thrown.
What am I doing wrong?
--~--~---------~--~----~------------~-------~--~----~
You received this message bec...
2006 Jan 28
1
Unit Tests Behavior
Hi,
Working on unit tests and I have a few cascade delete constraints I am
testing.
The unit tests stop at the first assert_raise test. Is this typical?
def test_destroy_all_cascade_delete
assert_equal 1, Iep.find(:first).client_id
assert_equal 1, Encounter.find(:first).client_id
@client.destroy
assert_raise(ActiveRecord::RecordNotFound) { Iep.find(1) } <-- Stops
testing here
assert_raise...
2006 Mar 08
0
Unit tests dynamic finders
...er: "No"
answers.yml:
first_answer:
id: 1
question_id: 1
question_test.rb:
class QuestionTest < Test::Unit::TestCase
fixtures :categories, :questions, :answers
def test_destroy
question = questions(:first)
id = question.id
question.destroy
assert_raise(ActiveRecord::RecordNotFound) {Question.find(1)}
assert_raise(ActiveRecord::RecordNotFound) {Answer.find(1)}
assert_raise(ActiveRecord::RecordNotFound)
{Answer.find_by_question_id(1)} <<TROUBLE, ACTUALLY SUCCEEDS
#assert_raise(ActiveRecord::RecordNotFound) {Answer.fin...
2009 Jul 08
1
[PATCH: host-browser replacement 0/3] replacement of host-browser on ovirt-server
The purpose of this patch is to replace the identify function in
host-browser.rb with a new script, host-register.rb.
host-register.rb is a qmf ruby console that interfaces with the newly
added matahari qmf agent on the ovirt node. While it stores node data
in the database with the same behavior as the original host-browser
implementation, it acquires the data using the amqp protocol (and
2016 Feb 15
1
[PATCH] Start adding return values tests for bindings
...nc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+require File::join(File::dirname(__FILE__), 'test_helper')
+
+class TestLoad < MiniTest::Unit::TestCase
+ def test_rint
+ g = Guestfs::Guestfs.new()
+
+ assert_equal 10, g.internal_test_rint("10")
+
+ assert_raises(Guestfs::Error) {
+ g.internal_test_rinterr()
+ }
+ end
+
+ def test_rint64
+ g = Guestfs::Guestfs.new()
+
+ assert_equal 10, g.internal_test_rint64("10")
+
+ assert_raises(Guestfs::Error) {
+ g.internal_test_rint64err()
+ }
+ end
+
+ def test_rbool
+ g =...
2009 Jul 10
2
[PATCH: server 0/3] Add host-register.rb (replaces host-browser.rb in part)
Removes node identification functionality from host-browser.rb and adds a new script,
host-register.rb, that takes over that functionality.
The chief difference is that host-browser used a simple TCP server setup to get data
from the node, while host-register uses the qpid bus to do so. Specifically, it
communicates with the matahari qmf agent added to the node in two related patchsets to
node
2017 Jun 15
0
[PATCH v6 10/41] mllib, v2v: Split out OCaml utils bindings ‘common/mlutils’.
...rinter 52 (drive_index "ba");
+ assert_equal ~printer 701 (drive_index "zz");
+ assert_equal ~printer 702 (drive_index "aaa");
+ assert_equal ~printer 18277 (drive_index "zzz");
+ let exn = Invalid_argument "drive_index: invalid parameter" in
+ assert_raises exn (fun () -> drive_index "");
+ assert_raises exn (fun () -> drive_index "abc123");
+ assert_raises exn (fun () -> drive_index "123");
+ assert_raises exn (fun () -> drive_index "Z");
+ assert_raises exn (fun () -> drive_index "aB&q...
2009 Jun 29
0
[PATCH server] Add svc_vm_actions method to VmService.
...:production_mysqld_vm).description}: shutdown_vm was successfully queued.",
+ svc_vm_action(vms(:production_mysqld_vm).id, 'shutdown_vm', nil))
+ end
+
+ # Ensure that if a non-existant action is passed in, ActionError
+ # is thrown
+ def test_svc_vm_action_invalid_action
+ assert_raise ActionError do
+ svc_vm_action(vms(:production_httpd_vm).id, 'stop_vm', nil)
+ end
+ end
+
+ # Ensure that if a user with the wrong permissions is passed in,
+ # PermissionError is thrown
+ def test_svc_vm_action_invalid_user
+ set_login_user('fred')
+ assert_raise...
2006 May 17
0
teardown not cleaning the BD?
...).id, :limit => 1)
#make sure it is present
assert_not_nil ClientVariation.find_by_variation_id
(first_variation.id)
#delete the record from the DB
get :delete_concept, {:concept_id => concepts(:entreprise).id}
#search for the record, if not there, raises an exception
assert_raises(ActiveRecord::RecordNotFound) {
Concept.find(concepts(:entreprise).id) }
#search for the variation, if not there, raises an exception
#this is the line that generate the faillure
assert_raises(ActiveRecord::RecordNotFound) {
Variation.find_by_concept_id(concepts(:entreprise).id) }...
2009 Jun 29
2
One more fix
This resend includes the rebase, but fixes a problem I just noticed with nil/empty checks.
2009 Jun 29
2
Resend of Cloud UI/service patches
This is a resend of the 2-patch series from a week or so ago, needed to be rebased due to some commits on next
2009 Jun 22
2
Patch series for Cloud Vm Actions
The following two patches should be applied in the order:
* [PATCH server] Add svc_vm_actions method to VmService.
* [PATCH server] Cloud UI layer to initiate actions on vms.
The service layer patch should work fine on its own (and not break
anything), but cloud patch relies on service being there.
2012 Feb 23
1
Bug in nested_attributes_for: question about best way to patch
..._is_truthy
@ship.pirate.destroy
[1, ''1'', true, ''true''].each do |truth|
pirate = @ship.reload.create_pirate(:catchphrase => ''Arr'')
@ship.update_attributes(:pirate_attributes => { :id =>
pirate.id, :_destroy => truth })
assert_raise(ActiveRecord::RecordNotFound) { pirate.reload }
end
end
I''ve also a partial patch developed: http://pastie.org/3438962
The problem is that to trigger the record deletion, the association
still needs to be there to be walked on the save call.
I have two question:
1. Does everyone agree...
2004 Mar 09
6
win32-mmap test suite
...rt_equal("0.0.1",Mmap::VERSION,"Bad version")
end
def test_new
assert_nothing_raised{ Mmap.new("Foo") }
assert_nothing_raised{ Mmap.new("Foo",16*1024) }
assert_nothing_raised{ Mmap.new("Foo",16*1024,"test") }
assert_raises(ArgumentError){
Mmap.new("Foo",16*1024,"test",true,true,10,true) }
assert_raises(TypeError){ Mmap.new("Foo",1) }
end
end
_________________________________________________________________
Get business advice and resources to improve your work life, from bCe...
2019 Feb 25
0
[PATCH 2/3] v2v: add Var_expander
...+ ()
+
+let test_list () =
+ assert_equal_string "x %{NONE}" (Var_expander.replace_list "%{FOO} %{NONE}" [("FOO", "x")]);
+ ()
+
+let test_scan_variables () =
+ let assert_invalid_variable var =
+ let str = "%{" ^ var ^ "}" in
+ assert_raises (Var_expander.Invalid_variable var)
+ (fun () -> Var_expander.scan_variables str)
+ in
+ assert_equal_stringlist [] (Var_expander.scan_variables "");
+ assert_equal_stringlist [] (Var_expander.scan_variables "foo");
+ assert_equal_stringlist ["FOO&q...