ruby-mocha Questions

1

This question may seem like a duplicate of this one but the accepted answer does not help with my problem. Context Since Rails 5 no longer supports directly manipulating sessions in controller te...
Systematism asked 30/3, 2017 at 8:35

6

Solved

I am currently trying to run some tests made with webdriverjs and chromedriver but they need microphone permissions. This is the popup that shows up: I have tried: chromedriver.start(['--disa...

3

Solved

I have a Rails controller action to test. In that action, a method User.can? is invoked several times with different parameters. In one of the test case for it, I want to make sure that User.can?('...
Gader asked 28/3, 2012 at 0:29

4

Solved

I need to make sure a method is not called giving a specific set of conditions, and I'm looking for the opposite of the mocha expects.
Aluminize asked 3/2, 2011 at 1:5

3

Solved

I am testing some scripts that interface with system commands. Their logic depends on the return code of the system commands, i.e. the value of $?. So, as a simplified example, the script might say...
Ludwig asked 3/1, 2011 at 23:46

3

I have an object MyObject: class MyObject def initialize(options = {}) @stat_to_load = options[:stat_to_load] || 'test' end def results [] end end I want to stub the results method only...
Byelostok asked 29/5, 2013 at 14:1

3

Solved

Given a parent class Fruit and its subclasses Apple and Banana, is it possible to stub the method foo defined in Fruit, so that any calls to method foo on any instances of Apple and Banana are stub...
Bulb asked 24/9, 2011 at 13:20

3

Solved

Much like this question, I too am using Ryan Bates's nifty_scaffold. It has the desirable aspect of using Mocha's any_instance method to force an "invalid" state in model objects buried behind the ...
Somniferous asked 24/5, 2010 at 1:37

4

The gist of my problem is as follows:- I'm writing a Mocha mock in Ruby for the method represented as "post_to_embassy" below. It is not really our concern, for the purpose of describing the probl...
Echols asked 30/4, 2010 at 5:56

5

Solved

I have been following the 15 TDD steps to create a Rails application guide - but have run into an issue I cannot seem to resolve. For the functional test of the WordsController, I have the followin...
Philipp asked 25/6, 2010 at 14:37

1

Solved

I have a repo that contains multiple components, most of them in JavaScript (Node.js) and one written in Ruby (Ruby on Rails). I'd like to have one .travis.yml file that triggers one build that run...
Goddaughter asked 5/7, 2015 at 21:26

3

I have a scenario more or less like this class A def initialize(&block) b = B.new(&block) end end I am unit testing class A and I want to know if B#new is receiving the block passed t...
Curtis asked 15/7, 2010 at 2:17

1

Rspec-mocks has expect(some_object).to receive(:some_method).and_call_original. Can I do this with Mocha, and if so, how? some_object.expects(:some_method).... ...what?
Carnay asked 11/2, 2014 at 23:10

1

It appears as though setting any method-call expectation with Mocha prevent the original implementation from being called. This seems to cover calling the original method with rspec. Is th...
Draftee asked 1/12, 2011 at 19:12

2

Solved

I have a module: module MyModule def do_something # ... end end used by a class as follows: class MyCommand extend MyModule def self.execute # ... do_something end end How do I verif...
Terr asked 15/5, 2013 at 21:44

2

Solved

I've been programming for years in plenty of languages and like to think I'm generally pretty good at it. However, I haven't ever written any automated testing: no unit tests, no TDD, no BDD,...
Socle asked 14/2, 2013 at 9:9

1

Solved

I'm developing a gem for Rails 3 and came across an error in my test suit when running it under Ruby 1.8.7 at travis-ci.org: /home/travis/.rvm/gems/ruby-1.8.7-p370/gems/minitest-3.5.0/lib/minitest...
Denomination asked 7/10, 2012 at 20:0

1

Solved

Let's assume that i have this class class Foo def bar(param1=nil, param2=nil, param3=nil) :bar1 if param1 :bar2 if param2 :bar3 if param3 end end I can stub whole bar method using: Foo.any...
Gendarmerie asked 9/3, 2012 at 17:48

2

Solved

I call a third party web service right now as part of my application. I am using the RestClient gem in order to do this. There are a ton of tools available to do the same thing, so that should not ...
Marquise asked 24/10, 2011 at 22:51

1

Solved

I'm trying to use mocha in my Rails 3 project but keep getting the following exception: NoMethodError: undefined method `mock' for #<MochaTest:0x00000101f434e8> /Users/John/.rvm/gems/ruby-1...
Tilden asked 30/9, 2011 at 10:46

1

I've followed all of the steps that I've been able to find online for configuring Rails 3 with Rspec 2 and Mocha. In my Gemfile: group :development do gem 'rails3-generators' gem "rspec", '>=...
Melindamelinde asked 2/8, 2010 at 20:19

1

Foo.expects(:bar) Foo.bar(:abc => 123, :xyz => 987) # assert Foo.bar was called with a hash that has a key of :abc == 123 Basically I want to examine the object passed as an argument to a ...
Croesus asked 24/2, 2011 at 20:40

3

Solved

Within my controller specs I am stubbing out valid? for some routing tests, (based on Ryan Bates nifty_scaffold) as follows :- it "create action should render new template when model is invalid" d...
Janejanean asked 23/4, 2010 at 8:31

1

Is there a Mocha equivalent of Rspec’s “mock().as_null_object”?
Poppy asked 19/12, 2010 at 6:58

2

Solved

I need to mock the following: Class User def facebook #returns an instance of a facebook gem end end So in my User tests, to access the User's facebook info I need to call user.facebook.me.in...
Verbify asked 24/10, 2010 at 14:33

© 2022 - 2024 — McMap. All rights reserved.