Re: [rspec-users] Problem with RSpec, Rails or Me? (I know the answer is me!!)
On 19 December 2011 21:32, Ants Pants wrote: > > > On 19 December 2011 20:45, Pat Maddox wrote: > >> On Dec 19, 2011, at 11:00 AM, Ants Pants wrote: >> >> > This could just be my lack of knowledge of how Rails works but from the >> following code in my RSpec test >> > >> > $stderr.puts "BEFORE: >> #{@invitation.meeting.event.event_type.event_type_time_units.inspect}" >> >> Can you please share your RSpec code that doesn't do what you expect it >> to? >> >> Pat >> ___ >> rspec-users mailing list >> rspec-users@rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > I've added the necessary code. I've shown that before the save! the > event_type.event_type_time_units association returns data (from a Factory > build). After the save!, EventTypeTimeUnit.all shows that the data is in > the DB and all keys look okay, I've then whacked in two puts; the first > showing that event_type returns the correct id; and the second puts returns > an empty list. > > This is simply in an it block with nothing special going on. The code is > in the order as it's in the block. Nothing going on in between. > > It's not an RSpec problem (I don't think) It's just running in that > environment. > > Thanks for taking an interest but to be honest, dont waste any time on it, > I'll sort it out. But to me, it's a strange one!! > > -ants > > > In the end, I just used #reload to reload the attributes from the DB and it works. Should I have to do this, I don't know, but my test is now passing. -ants ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Matcher for testing file content.
Hi. Is there any matcher for test file content, anything like file("/path/to/file.txt").should contain("File content") or file("/path/to/file.txt").content.should == "File content" or file_content("/path/to/file.txt").should == "File content" or something else? Jarl ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Matcher for testing file content.
On Tue, Dec 20, 2011 at 5:51 AM, Jarl Friis wrote: > Hi. > > Is there any matcher for test file content, anything like > > file("/path/to/file.txt").should contain("File content") > or > file("/path/to/file.txt").content.should == "File content" > or > file_content("/path/to/file.txt").should == "File content" > > or something else? > File.read("/path/to/file") will give you a string of the entire contents of the file. File.read("/path/to/file").should match "content" File.read("/path/to/file").should include "content" etc. Does that help? Best, Michael Guterl ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Matcher for testing file content.
Yes, that certainly did the trick... I use File.read("/path/to/file").should == "content" Thanks. 2011/12/20 Michael Guterl : > On Tue, Dec 20, 2011 at 5:51 AM, Jarl Friis wrote: >> Hi. >> >> Is there any matcher for test file content, anything like >> >> file("/path/to/file.txt").should contain("File content") >> or >> file("/path/to/file.txt").content.should == "File content" >> or >> file_content("/path/to/file.txt").should == "File content" >> >> or something else? >> > File.read("/path/to/file") will give you a string of the entire > contents of the file. > > File.read("/path/to/file").should match "content" > File.read("/path/to/file").should include "content" > > etc. > > Does that help? > > Best, > Michael Guterl > ___ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -- Jarl Friis Softace ApS RÄdhustorvet 7, 2. 3520 Farum LinkedIn: http://dk.linkedin.com/in/jarlfriis ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users