Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix a test that failed when rspec 2 was used #118

merged 1 commit into from

4 participants


RSpec1: spec spec => Everything OK
RSpec2: rspec spec =>

  1) Virtus::InstanceMethods#initialize with an argument that responds to #to_hash sets attributes
     Failure/Error: be(name)

       expected #<RSpec::Mocks::Mock:18872480> => #<RSpec::Mocks::Mock:0x11ff8a0 @name="name">
            got #<String:18867120> => "#[RSpec::Mocks::Mock:0x11ff8a0 @name=\"name\"]"

       Compared using equal?, which compares object identity,
       but expected and actual are not the same object. Use
       'actual.should eq(expected)' if you don't care about
       object identity in this example.

       @@ -1,2 +1,2 @@
       -#<RSpec::Mocks::Mock:0x11ff8a0 @name="name">
       +"#[RSpec::Mocks::Mock:0x11ff8a0 @name=\"name\"]"

I wasn't 100% sure what was exactly tested here. I tried to change it to as close to the test name as possible. Now it passes with both rspec versions.


Looks similar: #110
Guys do not use Rspec2 since they rely on mutant.


Small correction - we rely on heckle which requires rspec1 :) Mutant will work with rspec2 so when it's ready we'll upgrade to rspec2.


I think this pull request has a sense since it doesn't break anything (unlike my one) and make spec easier to understand.

mbj commented

@solnic Mutant will work with any test framework as long as a framework specific killer can be written. See the current rspec2 killer.

@solnic solnic merged commit 0bd923a into solnic:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 1, 2012
  1. @indrekj
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 5 deletions.
  1. +11 −5 spec/unit/virtus/instance_methods/initialize_spec.rb
16 spec/unit/virtus/instance_methods/initialize_spec.rb
@@ -25,16 +25,22 @@
context 'with an argument that responds to #to_hash' do
- subject { => name) }
- let(:name) { stub('name') }
+ subject { }
+ let(:attributes) do
+ do
+ def to_hash
+ {:name => 'John'}
+ end
+ end
it 'sets attributes' do
- be(name)
+ == 'John'
- context' with an argument that does not respond to #to_hash' do
+ context 'with an argument that does not respond to #to_hash' do
subject { }
specify { expect { subject }.to raise_error(NoMethodError) }
Something went wrong with that request. Please try again.