Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8486717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:01:42+00:00 2026-06-10T21:01:42+00:00

In the code below, I am getting an error on the line marked with

  • 0

In the code below, I am getting an error on the line marked with a comment (near the bottom of the snippet): undefined methodmock_transaction_input’`

I don’t understand why, since the method mock_transaction_input is defined above. I can’t find the difference between what I’m doing and the first example in this article..

Any help is much appreciated!

require 'spec_helper'

describe Transaction do

    def mock_transaction_input input
        ret = double "TransactionInput"
        input.each do |method, mock_return| 
            ret.stub(method).and_return(mock_return)
        end
        ret
    end

    describe "basic calculations" do

        examples = {
            :example_one => {
                :in => {:amount => 10, :alcohol => 5, :tip => 2, :anywhere_credit => 3, :merchant_credit => 1, :initial_subsidy => 0.25, :initial_subsidy_per => 1, :repeat_subsidy => 0, :repeat_subsidy_per => 0, :deal_subsidy => 0, :our_cut => 0.2, :tax_rate => 0.0825, :cc_fee_waived? => false, :cut_on_tax? => true, :cut_on_tip? => true, :deal_redeemed? => false},
                :out => { :our_cut => -0.11 , :merchant_cut => 12.58, :gross_sale => 17, :net_sale => 16.25, :merchant_cc_fee => 0.42}
            },

        }

        examples.each do |name, input_output| 

            input = input_output[:in]
            output = input_output[:out]

            # ERROR HERE
            transaction = Transaction.new(mock_transaction_input input)

            output.each do |method, expected_return|
                it "should return #{expected_return} when #{method} is called" do
                    transaction.send(method).should == expected_return
                end
            end
        end
    end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:01:43+00:00Added an answer on June 10, 2026 at 9:01 pm

    The quick answer – you can use mock_transaction_input method only in it or specify context. In order to user this method in the example group you have to define this method as a class method def self.mock_transaction_input.

    Check the docs: https://www.relishapp.com/rspec/rspec-core/docs/helper-methods/define-helper-methods-in-a-module

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting JQUERY undefined error. Do you have any idea (code below). <%@
In the below code I am getting the following error on line If (Not
For the code below, i am getting the error in title for line while((*(It2
I'm getting the following error on the line of code below: Syntax error (missing
I am getting abpve error at line str.append(ch); in below code. I basically want
I’m getting system error when I try to compile the code below on Visual
I'm getting this error message with the code below: class Money { public: Money(float
When i run the below code I am getting error like ex = {The
A user is getting an error on their phone when executing the code below,
Im getting the following error for the piece of code below : expression list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.