Displaying 20 results from an estimated 64 matches for "raise_error".
2008 Jan 30
9
catching errors, rspec basics
...(nil,20)
end
it "should have a stats of 80 when passed a flux of 10" do
@audience.stats = 10
@audience.stats.should == 8000
end
it "should return an error when passed a string" do
@audience.stats = ''Market Goblin''
@audience.stats.should raise_error
end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080129/2df90486/attachment.html
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 sugary?
2007 May 20
9
How to test for exceptions
...uld raise an error if record is invalid" do
stub_authorized_login
Venue.should_receive(:find).and_return(@venue)
@venue.should_receive(:update_attributes!).with("name" => "random text").and_return(false)
lambda {post :create, {:venue => @venue}}.should raise_error(ActiveRecord::RecordInvalid)
end
end
describe VenuesController, "on create" do
before(:each) do
@venue = mock("venue")
@venue.stub!(:new_record?).and_return(true)
@venue.stub!(:to_param).and_return(''1'')
Venue.stub!(:new).and_return(@venue)...
2019 Aug 13
4
ORC v2 question
...timization:\n" << *M << "\n";
>
> I expect that output to be the same for both ORC and ORCv2. If not something is going wrong with IR optimization.
Well for ORCV2 there is no change before and after.
I also get this message:
JIT session error: Symbols not found: { raise_error }
Yes raise_error and all other extern functions are explicitly added as
global symbols.
>
> CodeGen optimization seems a more likely culprit: JITTargetMachineBuilder and ExecutionEngineBuilder have different defaults for their CodeGen opt-level. JITTargetMachineBuilder defaults to CodeGenO...
2007 Nov 17
7
Down with Lambda!!
...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 => nil}}.should
raise_error(ActiveRecord::RecordInvalid)
Now it reads like a sentence..much cleaner and less abstract to those of
us who are not Ruby wizards (yet)
Chatting with other folks and they are hyped on the idea.
What...
2009 May 02
10
Problem verifying routing error
Hi,
When upgrading to rspec/rspec-rails 1.2.6 gem (from 1.1.12), I''m having
a new problem verifying routes that should not exist.
This is to support something like this in routes.rb:
map.resources :orders do |orders|
orders.resources :items, :except => [:index,:show]
end
I used to use lambda {}.should_raise( routing error ), but it stopped
detecting any raised error.
2008 Mar 17
4
RSpec''ing model association callbacks
Hi all,
i''m learning rspec and i must admit i really love it.
But at the time i started learning it, i already
developed my models classes and their callbacks.
Now i''m trying to get a 100% coverage of my code but i
cannot reach it because i do not understand how to
spec my callbacks.
Look at this for example:
----------------- User Model
class User < ActiveRecord::Base
2017 Jul 31
0
[PATCH v11 02/10] daemon: Embed the ocaml-augeas library in the daemon.
...de <augeas.h>
+
+#include <caml/alloc.h>
+#include <caml/memory.h>
+#include <caml/mlvalues.h>
+#include <caml/fail.h>
+#include <caml/callback.h>
+#include <caml/custom.h>
+
+typedef augeas *augeas_t;
+
+/* Raise an Augeas.Error exception. */
+static void
+raise_error (const char *msg)
+{
+ caml_raise_with_string (*caml_named_value ("Augeas.Error"), msg);
+}
+
+/* Map OCaml flags to C flags. */
+static int flag_map[] = {
+ /* AugSaveBackup */ AUG_SAVE_BACKUP,
+ /* AugSaveNewFile */ AUG_SAVE_NEWFILE,
+ /* AugTypeCheck */ AUG_TYPE_CHECK,
+ /* Aug...
2007 Apr 17
1
updating textmate bundle
Just to let you know - in the textmate bundle the snippet shra =>
"Should raise error" is missing an open parenthesis. The snippet
code should be this:
lambda { $1 }.should raise_error(${2:error})
$0
and not this:
lambda { $1 }.should raise_error${2:error})
$0
Best,
Scott
2017 Aug 09
0
[PATCH v12 02/11] common: Bundle the ocaml-augeas library for use by the daemon.
...de <augeas.h>
+
+#include <caml/alloc.h>
+#include <caml/memory.h>
+#include <caml/mlvalues.h>
+#include <caml/fail.h>
+#include <caml/callback.h>
+#include <caml/custom.h>
+
+typedef augeas *augeas_t;
+
+/* Raise an Augeas.Error exception. */
+static void
+raise_error (const char *msg)
+{
+ caml_raise_with_string (*caml_named_value ("Augeas.Error"), msg);
+}
+
+/* Map OCaml flags to C flags. */
+static int flag_map[] = {
+ /* AugSaveBackup */ AUG_SAVE_BACKUP,
+ /* AugSaveNewFile */ AUG_SAVE_NEWFILE,
+ /* AugTypeCheck */ AUG_TYPE_CHECK,
+ /* Aug...
2007 Sep 05
3
Rspec Caveman questions.
...g this, and ask 2 caveman
questions
My first is "Why lambda in rpsec"? It doesn''t strike me as "reads like
english" or "easily understandable." I understand it''s place in ruby (um,
kind of :), but my thinking is:
lambda { do_something_risky }.should raise_error
would be more understandable (and fun!) written as:
running { something_risky }.should raise_error
My second question is: For those folks who are getting up to speed with ruby
and rails AND digesting rspec along the way, there is a lot of incoming DSL.
As I started with rails before rspec, I fou...
2013 Dec 12
2
Stdlib and Defined Types
All,
Does anyone know of a way to add a file-centric backtrace to the validate
functions in the Stdlib?
If you use a validator in a defined type, you end up not having any idea
what actually threw the error.
Though much has moved to parameterized classes, there are still times when
defines are useful and it would be nice to know what calling
class/define/stack was blowing up.
Thanks,
Trevor
2007 Apr 17
8
Verifying that a block calls a method
I have something like the following:
def my_fun
my_fun2 do
raise Error
end
end
I know that I can verify that the method receives my_fun2. How can I
mock/stub out the example to verify that it calls raise Error?
Scott
2012 Jan 15
1
NoMethodError: undefined method `expect'
Ideas?
ruby-1.9.2-p290 :002 > require ''rspec''
=> true
ruby-1.9.2-p290 :003 > RSpec::Version::STRING
=> "2.8.0"
ruby-1.9.2-p290 :004 > describe ''division by zero'' do
ruby-1.9.2-p290 :005 > expect { 2/0 }.to raise_error
ruby-1.9.2-p290 :006?> end
NoMethodError: undefined method `expect'' for #<Class:0x007fe272270590>
from (irb):5:in `block in irb_binding''
from
.../.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:201:in
`module_eval''
from .../.rvm/...
2009 Aug 10
2
testing exception notification plugin with rspec
....gmane.org
but the spec fails :
ActionMailer::Base.delivery_method = ''test''
ActionMailer::Base.perform_deliveries = false
ActionMailer::Base.deliveries = []
@size_before = ActionMailer::Base.deliveries.count
lambda { get ''dummy_method_raises_exception'' }.should raise_error
(RuntimeError)
ActionMailer::Base.deliveries.count.should eql(@size_before + 1) <====
here I got 0 and not 1
Does someone have an idea about this problem?
Thank you by advance
-Yoann
2007 Oct 26
5
specing rescue, ensure and else blocks of an Exception
...d retrieve a Foo instance, identified by ID and throw an
exception, because of bad parameters" do
Foo.should_receive(:find).with("1").and_return(@foo)
@foo.should_receive(:update_attributes!).with
(valid_params).and_return(@foo)
get :action, :id => 1
response.should raise_error
end
or
it "should retrieve a Foo instance, identified by ID and throw an
exception, because of bad parameters" do
Foo.should_receive(:find).with("1").and_return(@foo)
lambda { @foo.should_receive(:update_attributes!).with
(valid_params).and_return(@foo) }.should raise...
2008 Jan 31
4
RSpec-1.1.3
...release.
* Tightened up exceptions list in autotest/rails_spec. Closes #264.
* Applied patch from Ryan Davis for ZenTest-3.9.0 compatibility
* Applied patch from Kero to add step_upcoming to story listeners. Closes #253.
* Fixed bug where the wrong named error was not always caught by
"should raise_error"
* Applied patch from Luis Lavena: No coloured output on Windows due
missing RUBYOPT. Closes #244.
* Applied patch from Craig Demyanovich to add support for "should_not
render_template" to rspec_on_rails. Closes #241.
* Added --pattern (-p for short) option to control what files get...
2007 Nov 21
7
describe scope
Hi,
Googling ''RSpec describe scope'' didn''t yield much, so apologies if
this question has been dealt with.
It seem well known that a ruby class is ''visible'' between describes,
and if this is a problem then you should use some counter as prefix or
suffix:
''class Item_001; ... end''
Is there any work underway, or sheduled release where
2011 Aug 10
5
ControllerExampleGroup.bypass_rescue
...2''. I had been using it on occasion for things like:
describe CorrespondencesController do
...
describe ''#show'' do
it "should raise an AuthorizationError if current user is not the correspondent " do
bypass_rescue
...
expect { do_get }.to raise_error(AuthorizationError)
I know there are conflicting opinions on whether or not it''s a good idea to directly check for exceptions this way, but I''ve always felt that this was appropriate for testing a controller action in isolation where the responsibility of the action under test wa...
2011 Mar 04
5
How to intercept an instance method from StdLib (1.9.2)
...call my method, but
it never seems to get invoked.
Pathname.stub(:exist?).and_return(false)
The whole example:
it "should raise an error if RVM''s install root does not exist" do
Pathname.stub(:exist?).and_return(false)
lambda{ B3::Bdd::Helpers.rvm_path}.should
raise_error(RuntimeError, "File not found:")
end
Appreciate any tips.
--
????'' ??? ??????, ???'' ?????? ?? ????
[The fox knows many things, but the hedgehog knows one big thing.]
? Archilochus, Greek poet (c. 680 BC ? c. 645 BC)
http://wiki.hedgehogshiatus.com