Thanks Myron for your tip, It is definitely the first time I see a
before(:context).
Still I believe that my main issue has to do with what Jon Rowe is pointing
out, the weirdest thing is that I originally was successful in writing a
authentication_spec.rb file using nested describe and calling the same User
class... It is just frustrating.
JFF
On Wednesday, January 17, 2018 at 1:25:15 PM UTC-5, Myron Marston wrote:
>
> If you want all examples in a particular context to share an object, the
> easiest way is to use before(:context) to initialize it and store it in
> an instance variable, and then use that instance variable from your
> examples. Here’s an example:
>
> context "my context" doi
> before(:context) { @browser = Watir::Browser.new :firefox }
>
> it "uses the browser" do
> @browser.do_something
> end
>
> it "uses the browser for something else" do
> @browser.do_something_else
> endend
>
> HTH,
> Myron
>
>
>
> On Wed, Jan 17, 2018 at 9:32 AM, Jeff Fagot <[email protected]
> <javascript:>> wrote:
>
>>
>> Thanks Jon for your time and answer.
>> Unfortunately, I have to say I am still confused. Moreover (maybe I am
>> wrong but) I have never seen anyone doing as you are suggesting and I do
>> not want a specific solution but rather a common/best practice solution.
>>
>> So let me exposed you more to what I am trying to accomplish that would
>> probably give you more insights about the "structure I am trying to
>> accomplish" (knowing that there are many things I have to improve).
>>
>> I am thinking of having a _spec file to test all my reports. I am aware
>> that I will mostly have to refactor afterwards but for the time being I
>> would have within that same _spec file 2 suites defined by their 'context'
>> : one for the Type1 and another for the Type2.
>> Each 'context' block would have 'its own set of tests defined as
>> 'describe' blocks.
>> Each 'context' could be run independently from one another and therefore
>> have its own browser instance, while within a specific 'context', I would
>> want to always refer to the same instance browser to play my test (I would
>> log onto the same site with same user once per context).
>>
>>
>> ########### FILE_SPEC.RB ###########
>> context 'Testing reports of Type = 2' do
>>
>> describe 'Given I am logging into QC as a ValidUser' do
>> .....
>> it 'The ValidUser is taken to the Dashboard page' do
>> expect...
>> end
>>
>> end
>>
>> describe 'When I access report_type1 from search' do
>> ...
>> it 'It opens the report_type1' do
>> expect...
>> end
>> end
>>
>> describe 'When I filter the report_type1' do
>> ...
>> it 'Displays the proper page of results' do
>> expect...
>> end
>> end
>>
>> end
>>
>> context ''Testing reports of Type = 1' do
>> ....very similar things as above
>> end
>> ############################################
>>
>> Any help would be much appreciated.
>> Thanks
>>
>>> --
>> 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/d3279bff-ed2c-4983-b6a6-cf7c36df7c04%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/rspec/d3279bff-ed2c-4983-b6a6-cf7c36df7c04%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/ae0e71e9-40fd-48fc-8801-362e4b2f7333%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.