[rspec-users] attributes method not working?
This is probably basic but I'm not seeing it. I'm using rspec & rspec-rails 1.1.11 on Ubuntu, & rails 2.1.0. Here's (the relevant parts of) my class I'm testing:
class Adtag < ActiveRecord::Base
# snip
validates_inclusion_of :size, :in => IAB_SIZES
validates_presence_of :code
validates_presence_of :client_id
validates_presence_of :campaign_id
# snip
end
And here's the spec:
module AdtagSpecHelper
def valid_adtag_attributes
{
:category => "shopping",
:code => "goes",
:client_id => 1,
:campaign_id => 1,
:size => "300x250"
}
end
end
describe Adtag do
include AdtagSpecHelper
before(:each) do
@adtag = Adtag.create( valid_adtag_attributes )
@adtag.should be_valid
end
it "should be invalid without an approved size" do
@adtag.attributes = valid_adtag_attributes.except(:size) # ONE
@adtag.errors.on(:size).should eql("is not included in the list") # TWO
@adtag.should have(1).error_on(:size) # THREE
@adtag.should_not be_valid
@adtag.size = "300x250"
@adtag.should be_valid
end
end
When I run this, the line with # ONE isn't getting executed. the attributes= method doesn't change the attributes of the @adtag object and I don't know why - there is no update SQL command in the test log. I can get around this by changing that line to this:
@adtag.update_attribute( :size, nil )
...which works but then at the line with # THREE, another error appears:
1)
'Adtag should be invalid without an approved size' FAILED
expected "is not included in the list", got nil (using .eql?)
...and that is weird because the "validates_inclusion_of :size, :in => IAB_SIZES" in the model should complain, not give nil.
All of this adds up to some general strangeness that seems pretty un-rspec-like. Any ideas or help is most welcome.
-Jason
___
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] "once" not honored?
I'm trying this:
firmware.should_receive(:execute).with("ATZ").once.ordered.and_return(AT_OK)
firmware.should_receive(:execute).with("ATE0V1").once.ordered.and_return(AT_OK)
firmware.should_receive(:execute).with("AT+CNUM").once.and_return(AT_OK)
But rspec does not complain that "AT+CNUM" is never passed as argument.
Bug? Or did I misinterpret the feature "once" ?
NB: I'd love to be able to write firmware.should_receive("AT+CNUM") but
that seems to fail on the way the method :"AT+CNUM" is being defined;
which in turn seems something I can only change (quickly) for Ruby 1.9,
namely blocks not accepting implicit blocks as parameter. Any chance of
fixing that?
Bye,
Kero.
___
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Generated rspec video
> > Stuff for off-list: > > - created with mencoder, I can play with mplayer. > >Reports on success or failure of other players welcome. > > weird codec combo... you should have used thedora or xvid at least :-P > (cannot play or even recognize the .avi codec signature). > > Anyway, will look at it when switch to linux. Hmf, mencoder will not produce xvid or theora just like that. Will try more tomorrow. I installed xine to verify playback; it plays video on the url I posted but does not playback the audio :( Bye, Kero. PS: a slightly hacked rspec gives very nice results with "-f p -c" now :) Fails rspec tests themselves, of course. For now. ___________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Generated rspec video
In reply to "Andrew WC Brown" <[EMAIL PROTECTED]> on Tue Feb 12 05:18:49 2008: > Load Failed > > Reason : Operation could not be completed. (WebKitErrorDomain error 204.) > > http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi > > (2MB video) No idea what makes webkit (or connection, or ...) fail for you. md5sum is correct for me, too. (then again, I fear the proxy here cached this download. The upload of my server at home is nice, but not 600kB/s). $ wget http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi --23:19:26-- http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi => `R-Spec Demo.avi' Connecting to 130.140.55.5:80... connected. Proxy request sent, awaiting response... 200 OK Length: 2,100,752 (2.0M) [video/avi] 100%[>] 2,100,752672.52K/s ETA 00:00 23:19:29 (670.15 KB/s) - `R-Spec Demo.avi' saved [2100752/2100752] _______ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Generated rspec video
Hi all! A sneak preview of what I've been doing with my patch that made it into rspec 1.1.3: http://chmeee.dyndns.org/ruby/R-Spec%20Demo.avi (2MB video) Remarks: - this is a (not-too-comfortable) test of my program itself; that's what causes the double-lines in some places - I can not use "-f p -c" since it outputs a step later than you'd expect! (that's how it can get the color right, I assume) I'm going to wrestle this a bit tonight. Stuff for off-list: - created with mencoder, I can play with mplayer. Reports on success or failure of other players welcome. - I do not have the timings of espeak and mencoder right, yet. If you know tools that can concatenate (malformed espeak) wav-files and images besides mencoder, I'd like to know. If you know how to let mencoder stick to the 25fps I tell it to, I'd like to know. (my mencoder line is echo'ed in the video) Experience with festival, anyone? I'm on linux, but I suppose that's obvious from the tools I used. Bye, Kero. _______ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
[rspec-users] Tests Not Detected, Says 0 Examples
Hi, I'm trying to get tests running on a gem I forked on github. When I try to run tests, it says "0 examples", despite lots of tests in the /spec directory. Here is some pertinent information: Code at: http://github.com/dissolved/yahoo_stock RSpec version 2.0.1 Some examples: 01:05:43 [xenon:~/Development/ruby/yahoo_stock] [[email protected]] master $ rspec spec Finished in 0.5 seconds 0 examples, 0 failures 01:09:03 [xenon:~/Development/ruby/yahoo_stock] [[email protected]] master $ rspec spec/yahoo_stock/history_spec.rb Finished in 0.4 seconds 0 examples, 0 failures I've got an email out to the primary developer of the original gem, but think I may be having a more general problem. The readme for the project does say to use 'rake spec' using RSpec 1.2.2, but that yields a "No Rakefile found" error. What am I missing here? Thanks for any help! Ryan ___________ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
Re: [rspec-users] Autotest with rspec HTML output
I've always secretly thought that Adobe Air might be a good candidate for something like this, I just never got around to actually trying to do something about it. Air runs on Windows/Linux/OSX, can render HTML just fine, and can interact with the local filesystem to an extent. Last time I checked it's not able to run any commands on the target system, so you can't have it trigger tests... but if Autotest was running and writing results to a file, you should be able to rig something together. Don On 11/11/07, Ben Mabey <[EMAIL PROTECTED]> wrote: > > > I was thinking that a little window(cocoa) or maybe just a browser > window could display the summary of the test run like autotest does and > then the failed specs in HTML format. Not the entire HTML report would > be generated/displayed- only the failing ones would be so it would be > manageable on projects with large test suites. So, instead of having a > terminal window open with autotest it would just be a stand alone window. > > aslak hellesoy wrote: > > Where would the HTML report be displayed? > > > > On Nov 11, 2007 6:38 AM, Ben Mabey <[EMAIL PROTECTED]> wrote: > > > >> Hey all, > >> I was just wondering if any one has played around with getting > >> autotest's rspec integration working with rspec's HTML output. I > really > >> like how in the rspec textmate bundle the context of the failing code > >> is inlined with the failing spec along with the exact line highlighted > >> and a link to the exact spot in reference. However, I rarely use this > >> nice output since autotest is so convenient... So, I was thinking > >> wouldn't it be great to have the best of both worlds? What do you > >> think? And before I try and do this, has anyone else already done it? > >> > >> > >> -Ben > >> > >> > >> ___________ > >> rspec-users mailing list > >> [email protected] > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> > > _______ > > rspec-users mailing list > > [email protected] > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > ___ > rspec-users mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/rspec-users > ___ rspec-users mailing list [email protected] http://rubyforge.org/mailman/listinfo/rspec-users
