Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`@' is not allowed as an instance variable name under ruby 2.0.0-rc2 #40

Open
kpolitowicz opened this issue Feb 24, 2013 · 3 comments
Open

Comments

@kpolitowicz
Copy link

     Failure/Error: it { should have_scope :expiring, :where => "date_expired IS NOT NULL" }
     `@' is not allowed as an instance variable name
     # /usr/local/opt/rbenv/versions/2.0.0-rc2/lib/ruby/gems/2.0.0/gems/remarkable-4.0.0.alpha4/lib/remarkable/core/dsl/assertions.rb:402:in `instance_variable_get'
     # /usr/local/opt/rbenv/versions/2.0.0-rc2/lib/ruby/gems/2.0.0/gems/remarkable-4.0.0.alpha4/lib/remarkable/core/dsl/assertions.rb:402:in `matches_collection_assertions?'
     # /usr/local/opt/rbenv/versions/2.0.0-rc2/lib/ruby/gems/2.0.0/gems/remarkable-4.0.0.alpha4/lib/remarkable/core/dsl/assertions.rb:291:in `matches?'
     # /usr/local/opt/rbenv/versions/2.0.0-rc2/lib/ruby/gems/2.0.0/gems/rspec-expectations-2.12.0/lib/rspec/expectations/handler.rb:23:in `handle_matcher'
     # /usr/local/var/lib/rbenv/versions/2.0.0-rc2/lib/ruby/gems/2.0.0/gems/rspec-core-2.12.1/lib/rspec/core/subject.rb:64:in `should'
     # ./spec/models/activity_file_spec.rb:20:in `block (2 levels) in <top (required)>'
@ccallebs
Copy link

ccallebs commented Jul 1, 2013

@kpolitowicz Were you ever able to pin down this issue?

@kpolitowicz
Copy link
Author

Not really. Since the project seems dead, I will be probably replacing it with something else long-term. For now, as scopes are the only thing that breaks under ruby 2.0, I'm gonna just write my own scope matcher.

@ghost
Copy link

ghost commented Jul 19, 2013

The problem is that it's trying to set an instance variable called "@". You just need this somewhere in your spec load path:

module Remarkable
  module DSL
    module Assertions
      def matches_collection_assertions? #:nodoc:
        arguments  = self.class.matcher_arguments
        assertions = self.class.matcher_collection_assertions
        collection = self.class.matcher_arguments[:collection] ? instance_variable_get("@#{self.class.matcher_arguments[:collection]}") : []

        assert_collection(nil, collection) do |value|
          instance_variable_set("@#{arguments[:as]}", value)
          send_methods_and_generate_message(assertions)
        end
      end
    end
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants