jimweirich / rspec-given

Given/When/Then keywords for RSpec Specifications
https://github.com/jimweirich/rspec-given
MIT License
653 stars 61 forks source link

Incorrect errors when nested in Modules #19

Closed jimweirich closed 11 years ago

jimweirich commented 11 years ago

If a spec is nested inside of a module, constant names are not correctly evaluated when errors occur.

For example:

RSpec::Given.use_natural_assertions

module Argus
  describe Drone do
    Given(:drone) { Drone.new }
    Then { drone.name == Drone::NAME }
  end
end

will produce the following error message:

  1) Argus::Drone 
     Failure/Error: Then { drone.name == Drone::NAME }
       Then expression failed at /Users/jim/working/git/argus/examples/xx_spec.rb:17
       expected: "Amelia"
       to equal: NameError: uninitialized constant RSpec::Given::InstanceExtensions::Drone
         NameError: uninitialized constant RSpec::Given::InstanceExtensions::Drone
                    <- drone.name == Drone::NAME
         "Amelia"   <- drone.name
         #<Argus::Drone:0x007fef24953f88>
                    <- drone
         NameError: uninitialized constant RSpec::Given::InstanceExtensions::Drone
                    <- Drone::NAME
         NameError: uninitialized constant RSpec::Given::InstanceExtensions::Drone
                    <- Drone
     # ./examples/xx_spec.rb:17:in `block in Then'
jimweirich commented 11 years ago

Fixed in 2.4.1.