Hello, Here is my *pdf_helper.rb* => http://pastebin.com/QU1kTKXk. I want to test, if self.create method can take more than two arguments. But, when I try to run my test. It showed *PdfHelper Should have two arguments Failure/Error: create_pdf.should_receive(object,template).with(user,file) NameError: undefined local variable or method `create_pdf'' for #<RSpec::Core::ExampleGroup::Nested_1:0xabf72f0> # ./pdf_helper_spec.rb:13:in `block (2 levels) in <top (required)>'' *here is my pdf_helper_spec.rb file: * require ''pdf_helper'' describe "PdfHelper" do it "Should be in public folder" do file = File.new ("#{Rails.root}/public/pdf") File.exist?(file).should be_true end it "Should have two arguments" do file = File.new("#{Rails.root}/public/pdf/templates/chbox.pdf") user = User.create(:first_name => "mark", :last_name => "jhon", :account_number => "3442", :phone_number => "23333333") create_pdf.should_receive(object,template).with(user,file) end end* * *how can I fix that? Thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Cco_azHqoCsJ. For more options, visit https://groups.google.com/groups/opt_out.
Hi there, try: PdfHelper.should_recieve(:create_pdf).with(user, file) On Sun, Sep 16, 2012 at 1:01 AM, Adnan <adnan.ayon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > Here is my *pdf_helper.rb* => http://pastebin.com/QU1kTKXk. I want to > test, if self.create method can take more than two arguments. But, when I > try to run my test. It showed > > *PdfHelper Should have two arguments > Failure/Error: > create_pdf.should_receive(object,template).with(user,file) > NameError: > undefined local variable or method `create_pdf'' for > #<RSpec::Core::ExampleGroup::Nested_1:0xabf72f0> > # ./pdf_helper_spec.rb:13:in `block (2 levels) in <top (required)>'' > > *here is my pdf_helper_spec.rb file: > > * > require ''pdf_helper'' > > describe "PdfHelper" do > it "Should be in public folder" do > file = File.new ("#{Rails.root}/public/pdf") > File.exist?(file).should be_true > end > > it "Should have two arguments" do > file > File.new("#{Rails.root}/public/pdf/templates/chbox.pdf") > user = User.create(:first_name => "mark", :last_name => > "jhon", :account_number => "3442", :phone_number => "23333333") > create_pdf.should_receive(object,template).with(user,file) > end > end* > * > *how can I fix that? > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/Cco_azHqoCsJ. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
P.S. But still, this will probably fail because you''re not actually doing anything (at least that''s obvious) to trigger PdfHelper.create_pdf. "user" has no knowledge of "file" assuming you have a callback to create a pdf when a user is created. The first test is also weird, it''s like saying a 1; a.should == 1. On Sun, Sep 16, 2012 at 1:57 AM, Mirri Kim <mirri.kim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi there, try: > > PdfHelper.should_recieve(:create_pdf).with(user, file) > > > On Sun, Sep 16, 2012 at 1:01 AM, Adnan <adnan.ayon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hello, >> >> Here is my *pdf_helper.rb* => http://pastebin.com/QU1kTKXk. I want to >> test, if self.create method can take more than two arguments. But, when I >> try to run my test. It showed >> >> *PdfHelper Should have two arguments >> Failure/Error: >> create_pdf.should_receive(object,template).with(user,file) >> NameError: >> undefined local variable or method `create_pdf'' for >> #<RSpec::Core::ExampleGroup::Nested_1:0xabf72f0> >> # ./pdf_helper_spec.rb:13:in `block (2 levels) in <top (required)>'' >> >> *here is my pdf_helper_spec.rb file: >> >> * >> require ''pdf_helper'' >> >> describe "PdfHelper" do >> it "Should be in public folder" do >> file = File.new ("#{Rails.root}/public/pdf") >> File.exist?(file).should be_true >> end >> >> it "Should have two arguments" do >> file >> File.new("#{Rails.root}/public/pdf/templates/chbox.pdf") >> user = User.create(:first_name => "mark", :last_name => >> "jhon", :account_number => "3442", :phone_number => "23333333") >> create_pdf.should_receive(object,template).with(user,file) >> end >> end* >> * >> *how can I fix that? >> >> Thanks >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-talk/-/Cco_azHqoCsJ. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.