RubyGems Navigation menu

at 0.1.3

# At `At` is a small library that allows you to access instance variables on an object as if they were `attr_accessor`s for testing purposes. Basically, `at` directly translates this: ```ruby value = object.instance_eval { @instance_variable } object.instance_eval { @instance_variable = "#{value}!" } ``` into this: ```ruby value = = "#{value}!" ``` ## Install ### Bundler: `gem 'at'` ### RubyGems: `gem install at` ## Usage If I want to test the output of the `full_name` method in my `User` class below, I would normally have three options for testing all possible outcomes; initialize a `User` object for each test case, initialize one `User` object and use `instance_eval` to set the instance variables individually, or create `attr_accessor`s for each instance variable I would like to test. In Rspec, I can use `assigns` to test the value of the instance variable, but I can't _get_ the value of the instance variable. `At` solves these problems. ```ruby require 'at' class User def initialize(first_name=nil, last_name=nil) @first_name, @last_name = first_name, last_name end def full_name [@first_name, @last_name].compact.join(" ") end end describe User, '#full_name' do it 'should output the full name correctly' do = 'John' = 'Doe' subject.full_name.should == 'John Doe' end end ``` Check out the specs for a better usage example. ## Contributing * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it * Fork the project * Start a feature/bugfix branch * Commit and push until you are happy with your contribution * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it. ## Copyright Copyright © 2012 Ryan Scott Lewis . The MIT License (MIT) - See LICENSE for further details.


  1. 0.2.0 - February 16, 2013 (9 KB)
  2. 0.1.4 - December 11, 2012 (9.5 KB)
  3. 0.1.3 - November 24, 2012 (11 KB)
  4. 0.1.2 - October 07, 2011 (5.5 KB)
  5. 0.1.1 - October 07, 2011 (5 KB)
Show all versions (6 total)

Runtime Dependencies (1):

  • version ~> 1.0.0
  • Development Dependencies (6):



    • Ryan Scott Lewis

    SHA 256 checksum:


    Total downloads 21,354

    For this version 3,144

    = Copy to clipboard Copied!




    Required Ruby Version: None