Re: [rspec-users] need some advice on the best way to structure testable shared methods

2011-11-14 Thread Patrick J. Collins
> Use the described class: > > shared_examples "a nameable thingie" do |klass| > describe "#build_name" do > it "it adds the collection of arguments to the base components and > formats them for a form element name attribute" do > described_class.new(nil,nil).build_name(:lol, :lollers

Re: [rspec-users] Write tests for objects with lots of dependencies

2011-11-14 Thread David Chelimsky
On Nov 8, 2011, at 12:52 AM, Romain Tribes wrote: > Hello, > > I'm writing a Risk-like webgame > (https://github.com/Sephi-Chan/Conquest-on-Rails) and I want to add tests, > but it's painful since objects have a lot of dependencies each other. > > For instance, I have moved the attack logic in

Re: [rspec-users] set_fixture_class works on individual test, but test suite fails

2011-11-14 Thread David Chelimsky
On Nov 8, 2011, at 10:52 AM, Stephen Kessler wrote: > Hi all, > > I have a bug in my code that I have been unable to track down that > deals with the set_fixture_class statement. Basically, > set_fixture_class (and my tests) are working fine when I test one > controller in isolation, but they ar

Re: [rspec-users] Problem with mocking helper methods

2011-11-14 Thread David Chelimsky
On Nov 11, 2011, at 6:48 AM, Ervin wrote: > Given that I assume that rails helper image_tag works as intended, I > want to mock out call to this method in my helper. > > spec/helpers/some_helper_spec.rb: > require 'spec_helper' > describe SomeHelper do > it 'allows stub tags' do >help

Re: [rspec-users] Are there plans to introduce conf.simplecov option?

2011-11-14 Thread David Chelimsky
On Nov 8, 2011, at 4:40 PM, ipoval wrote: > Hi, > > I wanted to ask if there are plans to introduce Rspec.configure { | > conf| conf.simplecov = true } option? > I understand that it is easy to add "require 'simplecov'; > SimpleCov.start" into the spec_helper.rb, but it just doesn't look > nice t

Re: [rspec-users] need some advice on the best way to structure testable shared methods

2011-11-14 Thread David Chelimsky
On Nov 14, 2011, at 6:57 PM, Patrick J. Collins wrote: > So, I recognize that there are many different ways to accomplish what I am > trying to do, but none of them seem to be as elegant as I would like. > > I have a few classes which need to have shared functionality... > > So I could do someth

Re: [rspec-users] Wrong number of arguments (reduce, rspec/core/metadata)

2011-11-14 Thread David Chelimsky
On Nov 8, 2011, at 10:45 AM, Thibaut Barrère wrote: > Hello, > > I'm a bit puzzled on this one. > > I'm getting a wrong number of arguments on a reduce call (full stack trace > here: https://gist.github.com/1348309). > > Any idea where it could come from? (I tried with 2.7.1 and 2.8.0.rc1). >

Re: [rspec-users] How to write view specs with multiple forms

2011-11-14 Thread David Chelimsky
On Nov 8, 2011, at 12:53 AM, emadridm wrote: > Hi guys, > > I don't know how to write an spec for a view template with two or more > forms. The follow content corresponds to the file named home.html.haml > > !!! 5 > = form_for(:session, :url => sessions_path) do |f| > .field >= f.label :ema

Re: [rspec-users] need some advice on the best way to structure testable shared methods

2011-11-14 Thread Patrick J. Collins
> Having trouble following your example. Why do you have to pass > Bar.new(nil, nil) for this test? Because the shared example is testing the method #build_name from the module that is included in the various classes-- it needs the object that #build_name is attached to in order to test the funct

Re: [rspec-users] need some advice on the best way to structure testable shared methods

2011-11-14 Thread Cynthia Kiser
Quoting Patrick J. Collins : > describe Bar do > it_behaves_like "a nameable thingie", Bar.new(nil, nil) > end > > Which I don't like, mainly because Foo & Bar's initialize methods require > arguments, and I am having to do (nil, nil) which seems very uncool... Having trouble following your exa

[rspec-users] need some advice on the best way to structure testable shared methods

2011-11-14 Thread Patrick J. Collins
So, I recognize that there are many different ways to accomplish what I am trying to do, but none of them seem to be as elegant as I would like. I have a few classes which need to have shared functionality... So I could do something like this: module NameBuilder def build_name(*args) args

Re: [rspec-users] Is it possible to execute 'lets' once for all 'its'?

2011-11-14 Thread Cynthia Kiser
Quoting JDeville : > The setup for certain integration specs is a bit slow, and I'm generally > careful to make my 'it' blocks read-only. However, I also like to keep my > it blocks extremely focused on just 1 thing. This has become a performance > problem though, because the setup is executed

[rspec-users] Are there plans to introduce conf.simplecov option?

2011-11-14 Thread ipoval
Hi, I wanted to ask if there are plans to introduce Rspec.configure { | conf| conf.simplecov = true } option? I understand that it is easy to add "require 'simplecov'; SimpleCov.start" into the spec_helper.rb, but it just doesn't look nice there. -- Thanks! ___

[rspec-users] Testing Custom methods

2011-11-14 Thread Tony Spore
I am attempting to test a custom method, and totally bombing out. describe Record do describe '#save_cf_data' do before :each do @record = mock_model(Record) end it "should have a birthday" do @record.save_cf_data({"final_outputs"=>["birth_day"=>["3"]]}) @record.bir

[rspec-users] Wrong number of arguments (reduce, rspec/core/metadata)

2011-11-14 Thread Thibaut Barrère
Hello, I'm a bit puzzled on this one. I'm getting a wrong number of arguments on a reduce call (full stack trace here: https://gist.github.com/1348309). Any idea where it could come from? (I tried with 2.7.1 and 2.8.0.rc1). FWIW, it's a Rails 2.3/RSpec 1 app that I'm migrating to Rails 3.0/RSp

[rspec-users] Problem with mocking helper methods

2011-11-14 Thread Ervin
Given that I assume that rails helper image_tag works as intended, I want to mock out call to this method in my helper. spec/helpers/some_helper_spec.rb: require 'spec_helper' describe SomeHelper do it 'allows stub tags' do helper.should_receive(:image_tag).with(2).and_return(3)

[rspec-users] set_fixture_class works on individual test, but test suite fails

2011-11-14 Thread Stephen Kessler
Hi all, I have a bug in my code that I have been unable to track down that deals with the set_fixture_class statement. Basically, set_fixture_class (and my tests) are working fine when I test one controller in isolation, but they are failing when I run all my controller specs together. My projec

[rspec-users] Write tests for objects with lots of dependencies

2011-11-14 Thread Romain Tribes
Hello, I'm writing a Risk-like webgame (https://github.com/Sephi-Chan/Conquest-on-Rails) and I want to add tests, but it's painful since objects have a lot of dependencies each other. For instance, I have moved the attack logic in a dedicated class (https://github.com/Sephi-Chan/Conquest-on-Ra

[rspec-users] Is it possible to execute 'lets' once for all 'its'?

2011-11-14 Thread JDeville
The setup for certain integration specs is a bit slow, and I'm generally careful to make my 'it' blocks read-only. However, I also like to keep my it blocks extremely focused on just 1 thing. This has become a performance problem though, because the setup is executed for every 'it'. Is there

[rspec-users] How to write view specs with multiple forms

2011-11-14 Thread emadridm
Hi guys, I don't know how to write an spec for a view template with two or more forms. The follow content corresponds to the file named home.html.haml !!! 5 = form_for(:session, :url => sessions_path) do |f| .field = f.label :email = f.text_field :email .field = f.label :password