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

  • SEARCH
  • Home
  • 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 8052733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:37:32+00:00 2026-06-05T07:37:32+00:00

I’m working on a text game engine, and have run into a snag while

  • 0

I’m working on a text game engine, and have run into a snag while developing the exploration module. When I try and instantiate my Location class with a block argument from a fixture, I’m getting this error:

ArgumentError, “wrong number of arguments (3 for 2)

for this code:

# in lib/explore/models/location.rb, line 15
class Location < RoundTable::Controllers::ActionDelegate
  # ... code omitted for brevity

  def initialize(slug, params = nil, &block)
    # ... code omitted for brevity

    if block_given?
      parser = Explore::Parsers::LocationParser.new(self)
      parser.instance_eval &block
    end # if
  end # constructor

  # ... code omitted for brevity
end # class Location

# in spec/fixtures/models/locations.rb, line 38
location :mushroom_kingdom, :name => "Mushroom Kingdom" do
  edges = Explore::Fixtures[:edges]
  edges.each do |key, value|
    go value.location, *value.params
  end # each
end # location

# in spec/models/location_spec.rb, line 193
context "initialized with block" do
  let :fixture do fixtures[:mushroom_kingdom] end

  subject { described_class.new fixture.slug, fixture.params, &fixture.block }

  it { puts subject.inspect }
end # context initialized with block

It’s pretty obviously a syntax error somewhere, where a block isn’t getting converted to a proc or vice versa, but I’ve been over the code a dozen times and can’t find it. If any eagle-eyed readers can help me out, I would be eternally grateful.

Source Files:

  • location.rb (Github)
  • location_spec.rb (Github)
  • (fixtures) locations.rb (Github)

The full source is available on Github, but is split between two repositories:

  • the engine (Github)
  • the plugin (Github)

To run code or specs, the plugin code needs to be placed inside the engine directory in vendor/modules/plugins/explore.

Backtrace:

1) RoundTable::Vendor::Plugins::Explore::Models::Location initialization with block 
     Failure/Error: it { expect { described_class.new fixture.slug, fixture.params, &fixture.block }.not_to raise_error ArgumentError }
       expected no ArgumentError, got #<ArgumentError: wrong number of arguments (3 for 2)>
     # ./spec/models/location_spec.rb:33:in `block (4 levels) in <top (required)>'

2) RoundTable::Vendor::Plugins::Explore::Models::Location initialized with block 
     Failure/Error: subject { described_class.new fixture.slug, fixture.params, &fixture.block }
     ArgumentError:
       wrong number of arguments (3 for 2)
     # ./lib/explore/parsers/location_parser.rb:39:in `go'
     # ./spec/fixtures/models/locations.rb:41:in `block (2 levels) in <module:Models>'
     # ./spec/fixtures/models/locations.rb:40:in `each'
     # ./spec/fixtures/models/locations.rb:40:in `block in <module:Models>'
     # ./lib/explore/models/location.rb:49:in `instance_eval'
     # ./lib/explore/models/location.rb:49:in `initialize'
     # ./spec/models/location_spec.rb:196:in `new'
     # ./spec/models/location_spec.rb:196:in `block (3 levels) in <top (required)>'
     # ./spec/models/location_spec.rb:198:in `block (3 levels) in <top (required)>'

Edit 2012年06月06日:

  • Replaced sample code with actual, non-conforming code
  • Added links to full project
  • 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-05T07:37:33+00:00Added an answer on June 5, 2026 at 7:37 am

    rspec sometimes swallows backtraces in ways that aren’t completely helpful (i think you can use the -b option to suppress this ) – the error is (I think) elsewhere.

    From my reading of the code, mushroom kingdom’s block is instance_evaled on an instance of Explore::Parsers::LocationParser

    This class defines a go method like so

    def go(location, params = {})
    

    but mushroom kingdom does

    go value.location, *value.params
    

    where value.params is the hash of options used to create an edge at the bottom of your edges fixtures file. In at least one case, that hash has 2 objects in it, so when you splat that you end up calling go with 3 arguments. Given that go appears to take a hash as its second argument, was that splat really intentional?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.