On Nov 3, 2012, at 5:12 PM, Javix <[email protected]> wrote:
>
> The following code is eval'd in the context of the group, which is a class.
> Wrap these two lines in an example (it "does something" do) and it should
> work as you expect.
>>
>> I put the 2 lines as follows but still have errors:
Use "it", not "context"
>
> describe "has a generated number" do
> before { @account.save }
> its(:acc_number) { should_not be_nil }
>
> context "some description comes here" do
> last = client.accounts.last
> last.should_not be_nil
> end
> end
>>
>>> last = client.accounts.last
>>> last.should_not be_nil
>>> end
>>> #it is just to prove and show that call to 'client fails :)
>>> It fails like that:
>>>
>>> account_spec.rb:24:in `block (2 levels) in <top (required)>': undefined
>>> local variable or method `client' for #<Class:0x878c5a0> (NameError)
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in
>>> `module_eval'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in
>>> `subclass'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in
>>> `describe'
>>> from
>>> /home/serge/Development/Ruby/Rails3/jlc-invest/spec/models/account_spec.rb:23:in
>>> `block in <top (required)>'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in
>>> `module_eval'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:238:in
>>> `subclass'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:224:in
>>> `describe'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/dsl.rb:18:in
>>> `describe'
>>> from
>>> /home/serge/Development/Ruby/Rails3/jlc-invest/spec/models/account_spec.rb:3:in
>>> `<top (required)>'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in
>>> `load'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in
>>> `block in load_spec_files'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in
>>> `map'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in
>>> `load_spec_files'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in
>>> `run'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:66:in
>>> `rescue in run'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:62:in
>>> `run'
>>> from
>>> /home/serge/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in
>>> `block in autorun'
>>>
>>> What is wring here? Why previousely defined client variable is 'visible'
>>> everywhere before but the last test? Thank you.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "rspec" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/rspec/-/jfgsqqmL2BMJ.
>>> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rspec/-/0YSpdCS09mEJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.