On Thursday, 21 September 2017 17:21:27 UTC+2, Myron Marston wrote:
>
> 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 
> <http://rspec.info/blog/2013/07/the-plan-for-rspec-3/#zero-monkey-patching-mode>
>  
> 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
>

Thanks a lot, Myron !
Yes, you are absolutely right, I am going through the latest Spec book you 
mentioned and like it very much as the previous one by the way :).
Sure, I'll take a look the original discussion and the explanation on the 
page you mentioned.

All the best,

Serguei
 

> ​
>
> On Thu, Sep 21, 2017 at 7:44 AM, Javix <[email protected] <javascript:>> 
> wrote:
>
>> I discovered that when I uncomment *begin /end* block in the generated 
>> *spec_helper.rb* file my simple spec fails if I do not use RSpec prefix 
>> for describe blocks as follows:
>>
>> require 'rack/test' 
>>
>>
>> module ExpenseTracker
>>   describe 'API draft' do
>>     include Rack::Test::Methods
>>     
>>     it 'records submitted expenses'
>>   end
>> end
>>
>>
>> Error:
>>
>> An 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
>>
>> If I change the same spec by prefixing describe with RSpec, it works:
>>
>> module ExpenseTracker
>>   RSpec.describe 'API draft' do
>>     include Rack::Test::Methods
>>     
>>     it 'records submitted expenses'
>>   end
>> end
>>
>> *expense_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
>>
>> Any ideas why ? Thank you.
>>
>> -- 
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] <javascript:>
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rspec/05b92135-d300-4f40-98ea-e7725d6e9fba%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/rspec/05b92135-d300-4f40-98ea-e7725d6e9fba%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/91a6300b-74bf-4a52-9ad8-7ca87acc1625%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to