require 'rack/test'
module ExpenseTracker
describe 'API draft' do
include Rack::Test::Methods
it 'records submitted expenses'
end
endAn error occurred while loading ./spec/unit/draft_spec.rb.
Failure/Error:
describe 'API draft' do
include Rack::Test::Methods
it 'records submitted expenses'
end
NoMethodError:
undefined method `describe' for ExpenseTracker:Module
# ./spec/unit/draft_spec.rb:4:in `<module:ExpenseTracker>'
# ./spec/unit/draft_spec.rb:3:in `<top (required)>'
No examples found.
Finished in 0.0003 seconds (files took 0.12244 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
module ExpenseTracker
RSpec.describe 'API draft' do
include Rack::Test::Methods
it 'records submitted expenses'
end
endexpense_tracker git:(unit_tests) ✗ rspec spec/unit/draft_spec.rb
API draft
records submitted expenses (PENDING: Not yet implemented)
Pending: (Failures listed here are expected and do not affect your suite's status)
1) API draft records submitted expenses
# Not yet implemented
# ./spec/unit/draft_spec.rb:7
Finished in 0.00194 seconds (files took 0.12484 seconds to load)
1 example, 0 failures, 1 pending
For a bare top-level describe to work, RSpec has to monkey patch some objects it does not own (specifically, the main object, and the Module class). The config.disable_monkey_patching! option turns off all of RSpec’s monkey patching, including the describe monkey patched onto main and Module. Thus, when you use that option, you get a NoMethodError when you try to call Module#describe or main.describe as you are in your example.
For more info, check out our original discussion of the option. Also, if you’re going through the new Effective Testing with RSpec 3: Build Ruby Apps with Confidence book (as I suspect you are, given the book builds an app called ExpenseTracker and it looks like that’s what you’re working on!), there’s an explanation of this at the bottom of page 163 and top of page 164.
HTH,
Myron
--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+unsubscribe@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/05b92135-d300-4f40-98ea-e7725d6e9fba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
For a bare top-level
describeto work, RSpec has to monkey patch some objects it does not own (specifically, themainobject, and theModuleclass). Theconfig.disable_monkey_patching!option turns off all of RSpec’s monkey patching, including thedescribemonkey patched ontomainandModule. Thus, when you use that option, you get aNoMethodErrorwhen you try to callModule#describeormain.describeas you are in your example.For more info, check out our original discussion of the option. Also, if you’re going through the new Effective Testing with RSpec 3: Build Ruby Apps with Confidence book (as I suspect you are, given the book builds an app called
ExpenseTrackerand it looks like that’s what you’re working on!), there’s an explanation of this at the bottom of page 163 and top of page 164.HTH,
Myron
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.