RR (Double Ruby) is a test double framework that features a rich selection of double techniques and a terse syntax.
Questions tagged [rr]
32 questions
0
votes
1 answer
How to use grepl with a character vector length greater than one?
Trying to create a conditional dummy variable (c) which converts b >= x to c = 1 and b < x to c = 0.
An example output when x = 3:
a b c
1 1 0
2 3 1
3 4 1
4 2 0
df$c<-ifelse(grepl(b[b <= 3], df$b), as.numeric(1), as.numeric(0))
I've tried using…

Wai Lau
- 25
- 5
0
votes
0 answers
Prevent mysqldump produces intermediate files
Mysqldump produces intermediate files. How do I prevent these files?
- my code:
mysqldump -v --single-transaction --quick mydb > dump.sql
- result:
7.7G 13:49 dump-rr-rr-rr-rr.sql
6.7G 13:42 dump-rr-rr-rr.sql
3.4G 13:20 dump-rr-rr.sql
1.7G…

Daniel Cho
- 9
- 2
0
votes
1 answer
ns_parserr: Message to long; error message when using BIND resolver library function ns_parserr()
The code below is suppose to print out the TXT Resource Records i have in my zone file.
When i execute the code only with BLOCK 1 (BLOCK 2 not present) i get the name, Type, Class,TTL and Data Length for each of the 3 TXT RRs i have.
But when i…

user619656
- 799
- 2
- 10
- 18
0
votes
1 answer
Watson retrieve and rank: document relevance score
How do I call Solr to return relevance scores in the result? I want to have a Solr document that includes the confidence that Solr uses internally for ranking, but I don't want to have to make a separate call to the ranker?
I tried to add the…

Alelou
- 1
- 1
0
votes
1 answer
Nomethod error when trying to make rr mock stubs work
I am setting up a project and have been trying to make rr mocks work but I am getting nomethod error. I have tried moving the required method as well but nothing works. This is my repo
$ rspec spec/views
F
Failures:
1) home/show.html.haml
…

Saad
- 1,856
- 1
- 22
- 28
0
votes
1 answer
mocha gem stub method and assign response
In this example I use rr gem, and stub an object method which is obj.project here, and assign returned value to any variable(in this case that is project_data ) when the method is called from any other method or class.
obj = Object.new
…

Johnny Cash
- 4,867
- 5
- 21
- 37
0
votes
1 answer
rr gem assert_received equivalent in mocha gem
Now I use rr gem to stub Project model count method, and then I replicate index action to check the count method is called or not. I'm planning to use mocha gem but I don't figure out what is the equivalent of assert_received method in mocha gem.…

Johnny Cash
- 4,867
- 5
- 21
- 37
0
votes
2 answers
DNS Resource Record Type Field (MB, MG, MR)
What is usage of MB, MG, MR types in a Resource Record?
Some information in Here, but I can't understand their usage in real world!

Jessica
- 685
- 1
- 9
- 23
0
votes
0 answers
Running CeWL with Ruby
I'm trying to run a Ruby program called CeWL.
I've added all of the required gems. When I try and open the .rb using ruby.exe it displays the message missing url agrument (try --help) and when I try to run it on start cmd with ruby or start cmd with…
0
votes
1 answer
How to call original method in btakita/rr ?
I need to check that particular method is called. Is it possible in btakita/rr?
rspec example from:
https://www.relishapp.com/rspec/rspec-mocks/v/2-13/docs/message-expectations/calling-the-original-method!
…

gayavat
- 18,910
- 11
- 45
- 55
0
votes
2 answers
Unit Testing updating a mongoid field using rr
I am trying to unit test the following code:
require 'mongoid'
class Seller
include Mongoid::Document
field :updated_at, type: Time
def update_updated_at
updated_at = Time.now
save
end
end
Here is my attempt
describe Seller do
…

zhon
- 1,610
- 1
- 22
- 31
0
votes
2 answers
Unit Testing Ruby Blocks by Mocking with rr (was flexmock)
How do I unit test the following:
def update_config
store = YAML::Store.new('config.yaml')
store.transaction do
store['A'] = 'a'
end
end
Here is my start:
def test_yaml_store
mock_store = flexmock('store')
…

zhon
- 1,610
- 1
- 22
- 31
0
votes
1 answer
How to use custom RR wildcard matcher?
I have created a wildcard matcher for RR that matches JSON strings by parsing them into hashes. This is because JSON (de)serialization doesn't preserve order; if we have:
{ 'foo': 42, 'bar': 123 }
... then after (de)serialization, we might find…

Duncan Bayne
- 3,870
- 4
- 39
- 64
0
votes
1 answer
RR Mock method called, but spec still fails
Stack: Rails 3.0.7, Mongoid 2.2.5, RSpec 2.11.0, RR 1.0.4
I have a Subscription model that looks like this:
class Subscription
include Mongoid::Document
embeds_many :addons
after_save :update_feature_policy!
def update_feature_policy!
…

Raphael
- 1,701
- 15
- 26
0
votes
1 answer
Mocking Validates Uniqueness Callback
How do you mock out the validates :name, uniqueness: true callback for an attribute?
I imagine it would work something like this:
describe "with duplicate name" do
before { mock(subject.name).unique? { false } }
it "should be invalid" do
…

vladiim
- 1,862
- 2
- 20
- 27