I am trying to run some sample RSpec examples from an ebook but it looks the book is having older version of RSpec hence some examples are referencing old RSpec API which is creating problems. I am trying to resolve them as much as I can but since I am new to Ruby & RSpec its a little challenging for me.
From the error log I can figure out that it's a scoping problem but not sure how to resolve it.
Is subject still a part of rspec 3.4.2 version?
$rspec --version
3.4.2
DOES NOT WORK
require "spec_helper"
describe Location do
describe "#initialize" do
subject { Location.new(:latitude => 38.911268, :longitude => -77.444243) }
expect(:latitude).to eq(38.911268)
expect(:longitude).to eq(-77.444243)
end
end
Error Log:
method_missing:expectis not available on an example group (e.g. adescribeorcontextblock). It is only available from within individual examples (e.g.itblocks) or from constructs that run in the scope of an example (e.g.before,let, etc). (RSpec::Core::ExampleGroup::WrongScopeError)
Aucun commentaire:
Enregistrer un commentaire