Displaying 20 results from an estimated 2000 matches similar to: "Stub that returns hash values"
2007 May 08
4
help with rspec''ing controller
Hi,
I''m a rspec newbie. I''m having trouble with rspec''ing a simple
controller to Create a record.
I''ve tried a couple of approaches and still get errors:
Mock ''remedy'' expected :save! with (any args) once, but received it 0
times
-or-
Mock ''Remedy'' received unexpected message :save with (no args).
Here are my two
2007 Oct 21
10
Preferred mock framework
Hi
In light of the fact that RSpec mocks are going into maintenance mode
in the near future, I was wondering what everyone was switching to.
I liked the look of FlexMock most, so gave that a shot. However,
there''s a few things that don''t work well with RSpec due to the
traditional differences in the way Test::Unit cases are written vs
RSpec specs. (One spec per
2007 Feb 28
12
Specifying that code is called in a block
Not sure if this is possible currently.
I have a section of code like this:
ActiveRecord::Base.transaction do
cow.save!
duck.save!
dog.save!
end
(Names changed to protect the innocent.)
I''d like to specify that the saves run in a transaction. I can do
ActiveRecord::Base.should_receive(:transaction).and_yield
But is there any way to specify that the code is
2012 Apr 05
5
rspec: identical tests fails when repeated
I''m doing RSpec controller testing with CanCan authorization, and I''m
seeing something I''ve never seen in RSpec before: the same test run
twice fails on the second one. I am NOT doing before(:all) or other
things that should cause state to persist between tests:
Here''s the relevant code:
context "POST create" do
context "with user logged
2013 Aug 30
3
rspec-puppet not working
I''m trying to get rspec-puppet working and have run into a problem. I have
a VM running ubuntu lucid, have installed rubygems 1.3.5 from the apt
package and have install rspec-puppet (and other required gems), and rake,
using gem install.
I''ve run rspec-puppet-init in the module I want to test, and have created a
very basic spec file for one of the classes in my module.
2008 May 18
2
Using Hash to mock classes that respond to :
Hi
I''ve been doing this a while now. If I have a class that responds to :
[], and all I''m interested in stubbing is that method, then instead of
using a mock I just create a hash. (Similarly, you could create an
array when you are testing an Enumerable object.)
Example from code I just worked on, where uses MigrationGraph#[] looks
up graph vertices by name:
2006 Dec 21
3
Speccing private class methods
Hi
How can I specify that a private method of a class gets called? If
you run the code below, only spec (1) passes. Spec (2) is what I
found causing problems in my code, and class (3) is my failed attempt
to work around it. (3 really puzzles me - why is a private class
method not accessible via send?)
Another problem is that stub! makes public methods, which changes the
behaviour of
2007 Jun 14
4
Can''t run RSpec files in TextMate
Hi
Not sure if this is the place to ask this or not. I''ve upgraded to
RSpec 1.0.5, installed the latest TextMate bundle, but whenever I do
"Run Behaviour Descriptions in selected files/directories" I get this:
/Users/ashleymoran/Library/Application Support/TextMate/Pristine Copy/
Bundles/RSpec.tmbundle/Support/lib/spec_mate.rb:18:in `run_files'':
private method
2007 Oct 17
15
Any tips on teaching BDD with RSpec?
Hi
I hope this is not OT. I''m training my replacement at work to do BDD
Rails development. He''s done a CS/maths degree but has no
professional programming experience, so he''s never NOT done a project
without BDD. In a way I am jealous of his unspoilt situation :)
I''ve gone about things this way:
* first teach him some Ruby (he did mainly Java at
2012 Nov 23
1
Bug?
root@graff:~# xm usb-list-assignable-devices
1-6 : ID 14dd:0002 Peppercon AG Multidevice
2-2 : ID 051d:0002 American Power Conversion Smart-UPS 3000 RM XL FW:691.16.I USB FW:7.3
root@graff:~# xm usb-hc-create bosch-w2k3-pv 1 1
root@graff:~# xm usb-list bosch-w2k3-pv
Idx BE state usb-ver BE-path
0 0 1 USB1.1 /local/domain/0/backend/vusb/55/0
2007 Jul 24
11
Mock or Stub strategy for validates_uniqueness_of
Hi,
I''m a bit stuck with mocking a unit test of a join model with regards to a
validates_uniqueness_of clause.
I have
class Book < AR:B
has_many :clippings
various validates_presence_of etc
end
class Clip < AR:B
has_many :clippings
various validates_presence_of etc
end
class Clipping < AR:B
belongs_to :book
belongs_to :clip
validates_uniqueness_of :clip_id,
2007 Oct 29
9
Problems with mongrel on NetBSD
I seem to have a (recent) problem with mongrel on NetBSD. I''m running
a development release of NetBSD (called NetBSD-current 4.99.34).
When I start mongrel, it listens on the IPv6 wildcard address, but not
on the IPv4 wildcard:
=> Booting Mongrel (use ''script/server webrick'' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with
2007 Jul 10
2
Multiple calls to a class method
Hi
Just wrote myself a Date.extract_from_rails_hash to handle parsing
the "date(1i)", "date(2i)" parameters created in the controller
params. I''ve got a method that needs to call this either once or
twice, depending on the contents of the form (one section of the form
is rendered conditionally). So I had two specs for the case where
the second form section
2009 Oct 14
14
spec-ing private methods?
On Wed, Oct 14, 2009 at 5:49 PM, Scott Taylor <scott at railsnewbie.com> wrote:
>
> On Oct 14, 2009, at 3:36 PM, Joaquin Rivera Padron wrote:
>
> hello there,
> how do you tipically spec private methods? The thing is ? have something
> like this:
>
> def some_method
> ?? complex_method + other_complex_methods
> end
>
> private
> def complex_method...
2007 Jul 11
21
"they" synonym for "it"?
I''ve noticed that I phrase a lot of shared behaviours in plural, eg
describe "All payment_details views"
How about a "they" alias to "it" so you can write
describe "All payment_details views", :shared => true do
they "should have a card number field" do
# ...
end
end
WDYT?
Ashley
2007 Apr 10
6
getting output of STDOUT in spec
Consider the following method:
def name_to_terminal
puts "Scott Taylor"
end
How would I spec this out?
Scott
2014 Jan 21
2
After USB boot problems on Gigabyte GA-M55Plus-S3G
the closest i have gotten to a consistent way to test a MS-DOS filesystem
setup is:
dd if=/dev/zero of=binary.img bs=1M count=500
i="$(losetup -f --show binary.img )"
parted binary.img mklabel msdos -s -m
dd if=/usr/lib/syslinux/mbr.bin of="${i}"
parted binary.img mkpart primary -a optimal -s -m 0% 100%
parted binary.img set 1 boot on
mkfs.ext4 $(kpartx -savu "${i}"
2008 May 17
5
Help needed
Hi All,
I am new to rspec and it seems that I don''t understand some basics.
I need to have a XML import which should parse through XML data
and saves all that in various mysql tables. The XML part works just
fine and I can test this with rspec. However when I try to execute
it "should find country object for DE" do
I get an error. @user.country is a one-to-many relation in
2014 Feb 01
5
xorriso or genisoimage syntax assistance
Could someone help me get the syntax for `genisoimage' and/or `xorriso'
correct? Apparently it is not in many linux distros so below my little
HOWTO shows how to compile it. ( which adds tons of crap that can go wrong)
mkdir -p ISO_root/isolinux
cp /usr/lib/syslinux/[i,m,v]* ISO_root/isolinux
cat > ISO_root/isolinux/isolinux.cfg << EOF
UI menu.c32
label isolinuxtests
EOF
# Most
2010 Feb 17
3
2nd REPOST: mbox vs maildir
I'm going to assume this is just not possible, or that no one has an
answer, which would lead me back to uw-imap since it does work as-is.
So I'll post it again, hoping that there is a solution for this setup
and that folks have just been too busy to help think about it and/or
help come up with a possible solution.
-----
Ignoring my previous message just for a second, I realized