--- On Fri, 6/7/13, rspec-users-requ...@rubyforge.org 
<rspec-users-requ...@rubyforge.org> wrote:

From: rspec-users-requ...@rubyforge.org <rspec-users-requ...@rubyforge.org>
Subject: rspec-users Digest, Vol 84, Issue 1
To: rspec-users@rubyforge.org
Date: Friday, June 7, 2013, 10:08 AM

Send rspec-users mailing list submissions to
    rspec-users@rubyforge.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://rubyforge.org/mailman/listinfo/rspec-users
or, via email, send a message with subject or body 'help' to
    rspec-users-requ...@rubyforge.org

You can reach the person managing the list at
    rspec-users-ow...@rubyforge.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of rspec-users digest..."


Today's Topics:

   1. Fuzzy should_receive matching (Alexander Baronec)
   2. Re: Fuzzy should_receive matching (David Chelimsky)
   3. Re: RSpec 2, Rails 3, and SSL routes (Aashish Kiran)
   4. Re: Fuzzy should_receive matching (Alexander Baronec)
   5. Error uccored while evaluating nil.collect (Oliver Jesus)


----------------------------------------------------------------------

Message: 1
Date: Thu, 30 May 2013 11:44:19 +0400
From: Alexander Baronec <abo...@gmail.com>
To: rspec-users <rspec-users@rubyforge.org>
Subject: [rspec-users] Fuzzy should_receive matching
Message-ID:
    <CAKcJw60A1mJR3yJevHrYnsDKjoPtkuDDQr6j1fgOyYD055qQ=q...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

Hello.
I have a test problem when I should test arguments in method not by exact
matching buy with fuzzy matching.

For example I have this test:

require 'rspec'

describe do
  it do
    o = Object.new
    o.should_receive(:api_send).with mode: :say

    o.api_send mode: :say, time: Time.now + rand(1..10), bans: { login1:
{time: Time.now, expiration: Time.now + 100}}
  end
end

I want helper to test that method api_send receive mode: :say, time:
Time.now + rand(1..10), bans: { login1: {time: Time.now, expiration:
Time.now + 100}} but I do not care about what time exactly is.

I want something like

inspect_api o, mode: :say, time: Time, bans: { login:1: {time: Time,
expiration: Time}}

Best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://rubyforge.org/pipermail/rspec-users/attachments/20130530/169a96a3/attachment-0001.html>

------------------------------

Message: 2
Date: Thu, 30 May 2013 07:11:31 -0500
From: David Chelimsky <dchelim...@gmail.com>
To: rspec-users <rspec-users@rubyforge.org>
Subject: Re: [rspec-users] Fuzzy should_receive matching
Message-ID:
    <cakw-owr2puzgcd511hqoot4uhs1fujel7ebk3yduy8segpk...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

On Thu, May 30, 2013 at 2:44 AM, Alexander Baronec <abo...@gmail.com> wrote:

> Hello.
> I have a test problem when I should test arguments in method not by exact
> matching buy with fuzzy matching.
>
> For example I have this test:
>
> require 'rspec'
>
> describe do
>   it do
>     o = Object.new
>     o.should_receive(:api_send).with mode: :say
>
>     o.api_send mode: :say, time: Time.now + rand(1..10), bans: { login1:
> {time: Time.now, expiration: Time.now + 100}}
>
  end
> end
>
> I want helper to test that method api_send receive mode: :say, time:
> Time.now + rand(1..10), bans: { login1: {time: Time.now, expiration:
> Time.now + 100}} but I do not care about what time exactly is.
>
> I want something like
>
> inspect_api o, mode: :say, time: Time, bans: { login:1: {time: Time,
> expiration: Time}}
>

See docs:

http://rubydoc.info/gems/rspec-mocks/file/README.md#Argument_Matchers
http://rubydoc.info/gems/rspec-mocks/RSpec/Mocks/ArgumentMatchers#hash_including-instance_method

(the info in the 2nd link needs to be added to the first - sorry)

You could do either of:

    o.should_receive(:api_send).with hash_including(mode: :say)
    o.should_receive(:api_send).with mode: :say, time: instance_of(Time),
:bans { login1: {time: instance_of(Time), expiration: instance_of(Time) }

HTH,
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://rubyforge.org/pipermail/rspec-users/attachments/20130530/3d4f29ef/attachment-0001.html>

------------------------------

Message: 3
Date: Tue, 04 Jun 2013 13:01:48 +0200
From: Aashish Kiran <li...@ruby-forum.com>
To: rspec-users@rubyforge.org
Subject: Re: [rspec-users] RSpec 2, Rails 3, and SSL routes
Message-ID: <4b829209b1aacb393c24eef1f356f...@ruby-forum.com>
Content-Type: text/plain; charset=UTF-8

I too came across same situation (i.e., testing ssl request in rails 
with specs).
Thinking there should be a solution.

Thanks,
Aashish

-- 
Posted via http://www.ruby-forum.com/.


------------------------------

Message: 4
Date: Wed, 5 Jun 2013 13:20:28 +0400
From: Alexander Baronec <abo...@gmail.com>
To: rspec-users <rspec-users@rubyforge.org>
Subject: Re: [rspec-users] Fuzzy should_receive matching
Message-ID:
    <cakcjw61-stl8ixald_v77hxbo4qqrfzie5wfbkkcfcmjpsb...@mail.gmail.com>
Content-Type: text/plain; charset="koi8-r"

Thx. It's exactly what I searched.


On Thu, May 30, 2013 at 4:11 PM, David Chelimsky <dchelim...@gmail.com>wrote:

> On Thu, May 30, 2013 at 2:44 AM, Alexander Baronec <abo...@gmail.com>wrote:
>
>> Hello.
>> I have a test problem when I should test arguments in method not by exact
>> matching buy with fuzzy matching.
>>
>> For example I have this test:
>>
>> require 'rspec'
>>
>> describe do
>>   it do
>>     o = Object.new
>>     o.should_receive(:api_send).with mode: :say
>>
>>     o.api_send mode: :say, time: Time.now + rand(1..10), bans: { login1:
>> {time: Time.now, expiration: Time.now + 100}}
>>
>   end
>> end
>>
>> I want helper to test that method api_send receive mode: :say, time:
>> Time.now + rand(1..10), bans: { login1: {time: Time.now, expiration:
>> Time.now + 100}} but I do not care about what time exactly is.
>>
>> I want something like
>>
>> inspect_api o, mode: :say, time: Time, bans: { login:1: {time: Time,
>> expiration: Time}}
>>
>
> See docs:
>
> http://rubydoc.info/gems/rspec-mocks/file/README.md#Argument_Matchers
>
> http://rubydoc.info/gems/rspec-mocks/RSpec/Mocks/ArgumentMatchers#hash_including-instance_method
>
> (the info in the 2nd link needs to be added to the first - sorry)
>
> You could do either of:
>
>     o.should_receive(:api_send).with hash_including(mode: :say)
>     o.should_receive(:api_send).with mode: :say, time: instance_of(Time),
> :bans { login1: {time: instance_of(Time), expiration: instance_of(Time) }
>
> HTH,
> David
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
? ?????????? ???????????,
?????????
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://rubyforge.org/pipermail/rspec-users/attachments/20130605/6c1781c5/attachment-0001.html>

------------------------------

Message: 5
Date: Fri, 7 Jun 2013 03:02:43 -0700 (PDT)
From: Oliver Jesus <oliverjesus2...@yahoo.com>
To: rspec-users@rubyforge.org
Subject: [rspec-users] Error uccored while evaluating nil.collect
Message-ID:
    <1370599363.73231.yahoomailclas...@web162004.mail.bf1.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"

Hello, I am new to RSpec and I've got error something like this:?
You have a nil object when you didn't expect it!?
You might have expected an instance of Array.?
The error occurred while evaluating nil.collect?

In my controller:?

def new?
? ? @employee_mst = EmployeeMst.new?
? ? @branch_mst = BranchMst.all(:group => "branch_code")?
? ? @department_mst = DepartmentMst.all?

? ? respond_to do |format|?
? ? ? format.html # new.html.erb?
? ? ? format.xml ?{ render :xml => @employee_mst }?
? ? ? format.xml ?{ render :xml => @branch_mst }?
? ? ? format.xml ?{ render :xml => @department_mst } ? ? ??
? ? end?
? end?

In my RSpec controller:?

? describe "GET new" do?
? ? it "assigns a new employee_mst as @employee_mst" do?
? ? ? get :new?
? ? ? assigns(:employee_mst).should be_a_new(EmployeeMst)?
? ? end?
? end?


I think something is missing in RSpec controller, because I've add 4 lines of 
codes:?
? ? ?@branch_mst = BranchMst.all(:group => "branch_code")?
? ? ?@department_mst = DepartmentMst.all?
? ? ? format.xml ?{ render :xml => @branch_mst }?
? ? ? format.xml ?{ render :xml => @department_mst } ??

Please help me regarding this error. I greatly appreciated all those answers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://rubyforge.org/pipermail/rspec-users/attachments/20130607/833281b3/attachment.html>

------------------------------

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

End of rspec-users Digest, Vol 84, Issue 1
******************************************

I've seen the error. It's not in the rspec, it's on my model. Thank you for you 
help.
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to