similar to: Mocking global variables in rspec

Displaying 20 results from an estimated 20000 matches similar to: "Mocking global variables in rspec"

2013 Mar 02
0
Problems getting rspec testing working in OSX?
Hey Gang, Running into a weird error when trying to follow puppetlabs'' blog: https://puppetlabs.com/blog/the-next-generation-of-puppet-module-testing/ I''m running 10.8.2, using default ruby, in an attempt to make my home env a little more sane, (ran into weird rbenv issues at work, which I won''t go into here) The google tells me not a whole lot. Appreciate any help
2013 Aug 15
0
Rspec, Puppet Custom Functions and Mocking..
Hey, I could use some advice here. We''ve had a puppet module out for a while (https://github.com/Nextdoor/puppet_thycotic) that provides us a way to retrieve private keys, passwords, etc from Thycotic''s SecretServerOnline.com service. This module was written in a hurry almost 2 years ago and has never had any real attention paid to it internally until now. We''re
2009 Mar 15
0
rspec 1.2.0 Released
rspec version 1.2.0 has been released! Behaviour Driven Development for Ruby. Changes: ### Version 1.2.0 WARNINGS: * If you use the ruby command to run specs instead of the spec command, you''ll need to require ''spec/autorun'' or they won''t run. This won''t affect you if you use the spec command or the Spec::Rake::SpecTask that ships with
2007 Jul 16
4
RSpec - concerns about mocking
I''m getting into RSpec more after getting the awesome Peepcode screencast about it. So far I love it, but coming form Test::Unit with Rails, I have some concerns about the recommendation to mock models and database calls in controller and view specs. Lets say you have a method on your User model called User.find_activated, and you have models specs for it. Then in your controller specs
2007 Dec 14
13
RSpec-1.1.0 is released
The RSpec Development Team is pleased as glug (that''s kind of like punch, but more festive) to announce RSpec-1.1.0. Thanks to all who have contributed patches over the last few months. Big thanks to Dan North and Brian Takita for their important work on this release. Dan contributed his rbehave framework which is now the Story Runner. Brian patiently did a TON of refactoring around
2008 Mar 05
7
mocking successive return values
I''m having a problems mocking successive return values. I don''t know if I''m doing something wrong or if this is a limitation of rspec mocks. Any ideas of what I may be doing wrong? I''m trying to test the generate_quote_number method. It generates a quote number, looks to see if it is in the db already. If it is, it calls itself to try again. I want
2007 Dec 07
0
weird behavior of mocking ruby class methods
Hello everyone: After I played with Rspec for three months, I realized a weird behavior of mocking ruby classes (e.g. File). Please let me post a sample code before I point out the problems: #file_reader.rb (to be tested) class FileReader def do_read File.read(''asd.txt'') end end #file_reader_spec.rb describe FileReader, "do_read" do it
2007 Oct 18
4
Mocking models provided in Rails plugins
Hey folks, How do I mock a model that is given to me by a Rails plugin? I''m trying to mock Session from the restful_authentication plugin but I get a number of errors telling me RSpec doesn''t recognize Session. NameError in ''SessionsController handling GET /sessions/new should be successful'' uninitialized constant Session An example of my usage:
2008 Oct 16
1
Mocking documentation
Can I make a suggestion for the RSpec documentation? In the discussion of Spec::Mocks (http://rspec.info/documentation/mocks/), it would be helpful for there to be some explanation of mock_model. There''s a reference to mock_model in an example in the section on controller specs, but as far I can see no indication of how it differs from mock. If I''ve just missed it please let
2010 Jun 10
1
RSpec 2: uninitialized constant - mocking belongs_to AR relation
gems/ruby-1.9.2-head/bundler/gems/rspec- core-2398fcadf5beb256bed9c548c59445d3b4c8a047-master/lib/rspec/core/ backward_compatibility.rb:26:in `const_missing'': uninitialized constant Message::User (NameError) from /Users/kristianconsult/.rvm/gems/ruby-1.9.2-head/bundler/gems/ rspec-expectations-996c752171a0a0e16347e934dadc25767e31186c-master/lib/
2008 Jun 01
0
Mixing mocking frameworks?
First, it was great meeting a bunch of you at RailsConf. Recently I''ve run into a problem using RSpec, namely its support for multiple mocking frameworks. Wait you say, isn''t that a good thing? Yes, it is until you end up mixing frameworks. I was writing my latest app, and I choose to get the app working and then add in the authentication system. So I went and wrote all
2010 May 07
2
Rspec beta8: helper methods issues
Hello everybody, I am experiencing the following problems, I googled quickly but I couldn''t find any documentation or solution to those issues: 1) the generator rails g rspec:helper does nothing; 2) there seems to be no way to test helper methods as I used to do... for example the following spec it ''should set monday as first day of the week'' do
2010 Aug 29
0
Troll - A Rails plugin for making webservice mocking easier
Hi Folks, Troll trumps your existing ActiveResource mocking libraries like inbuilt HttpMock,Fakeweb or Webmock out of water. With Troll, ActiveResource mocking just works, some of its features: 1. Don''t need to mock calls at Net::HTTP level (which webmock,fakeweb do). Really, we don''t care what HTTP library ActiveResource uses, fakeweb and webmock bring additional complexity
2010 Sep 23
0
rspec problems mocking classes based on mongoid
I am getting errors when running my rspecs. My project uses rails 3, mongoid, factory_girl, rspec 2.0.0.beta.22, rspec-mocs, etc http://pastebin.com/raw.php?i=WkaGiFag Getting: Failure/Error: @product = assign(:product, stub_model(Product, undefined method `to_sym'' for nil:NilClass I''m pretty sure stub_model has no clue on how to handle objects based on mongoid. Any ideas?
2007 Oct 25
1
Mocking/Stubbing help with subdomain as account key
My app uses account_location to set up subdomains as account keys. In my controllers, all my model operations are scoped through the @current_person object. The question is: How do I test this with RSpec''s mocking and stubbing? Basically, I need to test that @current_person.things is getting the find message and returning @thing. I''ve tried stubbing and mocking
2007 Aug 16
3
Mocking a non-existent method
I don''t like this: i = mock(Integer) i.should_receive(:asdfasdf).and_return(''foo'') puts i.asdfasdf Shouldn''t rspec check to see that :asdfasdf is a valid message to be sending Integer? Joe
2007 Sep 18
2
rSpec / Nested Routes / Mocks
I''m having a terrible time trying to test a nested route with rSpec. I can''t seem to tell rSpec to expect the call @item.user. The following error message plagues me not matter how I try to fuss with the mock: Spec::Mocks::MockExpectationError in ''ItemsController handling POST / items should redirect to the new course on successful save'' Mock
2007 Sep 05
4
Mocking to spec a sort_by method
Hello, I have a question regarding the use of Mocha with rSpec to spec one of my methods. My spec contains the following vehical1 = mock() vehical2 = mock() vehical1.stubs(:mph).returns(150) vehical2.stubs(:mph).returns(250) comparer.add_vehical([@vehical1, @vehical2]) comparer.sort_by(:mph) The comparer is an object that has a basic "stack like" functionality, add_vehical is the
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 11
4
Using rspec and mocha
I prefer to use rspec than test::unit for developing my apps. However I''ve found its mocking library to be pretty inflexible compared to Mocha. This isn''t really a surprise since rspec isn''t intended as a mocking framework, whereas Mocha is. So I''d like to play to both of their strengths and use rspec as my testing/specification framework and Mocha do to