[rspec-users] problems with javascript testing

2011-11-22 Thread Chad
Hi all,

I may be missing something simple here, but I'm having problems with
attempting to get a javascript request test going. I'm not sure if
this is the correct place to ask but perhaps someone will be able to
direct me to the right place if not.

The problem I'm having is that in my before(:each) block in the test I
create about 60 records (using FactoryGirl) so that I can test
filtering/searching data. Here's my code for that:

  before(:each) do
# create records for pagination and filtering
@consumers = FactoryGirl.create_list(:user, 50)
@providers = FactoryGirl.create_list(:provider, 10)

# create and log in with an admin user
@user = Factory(:admin)

visit log_in_path
fill_in "email", :with => @user.EmailAddress
fill_in "password", :with => "foobar"
click_button "Log in"
  end

So in effect that just populates some data and logs in with an admin
user.

The problem is, when I run a test with :js => true, I do not see any
users in the list. Take the following two tests:

it "should show users", :focus => true, :solr => true do
  visit users_path
  save_and_open_page
  page.should have_css('.row')
end

it "should show users with javascript", :focus => true, :js =>
true, :solr => true do
  visit users_path
  save_and_open_page
  page.should have_css('.row')
end

The first one passes, and opens up a saved page showing a nice list of
users. The second one fails, and opens up an empty user listing. I've
tried with both selenium and capybara-webkit and both exhibit the same
result.

Any idea why this may be?
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] problems with javascript testing

2011-11-22 Thread Evgeni Dzhelyov
If your tests run in db transaction, you will not see the records when
using javascript test adapter, like selenium. Refer to the capybara's
README how to solve that, if this is the problem.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] How do we test a Rails Model which does not have an equivalent table in the backend using RSpec

2011-11-22 Thread Mohnish J.
Mohnish J. wrote in post #1033006:
> Sidu Ponnappa wrote in post #1032900:
>>> I'm getting a common error for all such defined methods saying that>
>> `database_name.table_name does not exist`. Well , this is true but how>
>> should is
>> it really making a difference?, and how to get a work around> for this
>> to just
>> test a simple use case of calling a method successfully> in the above
>> context.
>> I don't believe this issue has anything to do with RSpec (you'd see
>> the same if you used MiniTest or any other tool).
>>
>> You want to have Moderator be a simple Ruby object, or possibly have
>> it inherit from ActiveModel rather than ActiveRecord.
>>
>> Best,
>> Sidu.
>> http://c42.in
>> http://rubymonk.com
>
> Thanks for your inputs Sidu,I tried replacing ActiveRecord with
> ActiveModel got the following error:-
>
>
> 
/home/mohnish/.rvm/gems/ruby-1.9.2-p180/gems/restfulie-1.0.3/lib/restfulie/server/action_controller/patch.rb:2:
> warning: already initialized constant HTTP_METHODS
> /home/mohnish/Cognizant/socialtango/app/models/admin_stats.rb:1:in ` (required)>': uninitialized constant ActiveModel::Base (NameError)
>
>
> Seems like, I will have to look for another workaround..

Well,

The below line code did work for me:-

Model_name.method_name.should_not be_nil

-- 
Posted via http://www.ruby-forum.com/.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] Rails code reloading in RSpec test environment?

2011-11-22 Thread Ash Moran
Hi

I've worked on a couple of Rails 3 apps recently and the test feedback loop is 
killing me. With no modifications, it takes 15-25 seconds to run a single 
example. I've avoided Spork so far, but I've tried Spin[1]. Spin shaves a few 
seconds off but it's still agonising. I've also experimented with multiple 
Guard groups and other hacks to run isolated code in lib/, but a lot of the 
code can't be isolated (all the controllers, for example).

My last resort is to try and run Rails against an environment with 
`config.cache_classes = false`. Has anyone tried this (and got it working)? I 
imagine it would have to run tests over DRb, which I've only used with Spork 
before. The last mention of "cache_classes" on this list was in 2009, so I 
thought I'd check before I invested time in it in case there any major 
obstacles.

Any help appreciated

Cheers
Ash


[1] http://jstorimer.github.com/spin/

-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashmoran

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


Re: [rspec-users] Rails code reloading in RSpec test environment?

2011-11-22 Thread Andrew Premdas
On 22 November 2011 20:31, Ash Moran  wrote:
> Hi
>
> I've worked on a couple of Rails 3 apps recently and the test feedback loop 
> is killing me. With no modifications, it takes 15-25 seconds to run a single 
> example. I've avoided Spork so far, but I've tried Spin[1]. Spin shaves a few 
> seconds off but it's still agonising. I've also experimented with multiple 
> Guard groups and other hacks to run isolated code in lib/, but a lot of the 
> code can't be isolated (all the controllers, for example).
>
> My last resort is to try and run Rails against an environment with 
> `config.cache_classes = false`. Has anyone tried this (and got it working)? I 
> imagine it would have to run tests over DRb, which I've only used with Spork 
> before. The last mention of "cache_classes" on this list was in 2009, so I 
> thought I'd check before I invested time in it in case there any major 
> obstacles.
>
> Any help appreciated
>
> Cheers
> Ash
>
Use Ruby 1.8.7 its much faster. There is a very good screencast on
Destroy All Software that might help also - the one about extracting
domain objects (or something like that).

HTH

Andrew

ps


>
> [1] http://jstorimer.github.com/spin/
>
> --
> http://www.patchspace.co.uk/
> http://www.linkedin.com/in/ashmoran
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 

Andrew Premdas
blog.andrew.premdas.org
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Rails code reloading in RSpec test environment?

2011-11-22 Thread Justin Ko

On Nov 22, 2011, at 4:52 PM, Andrew Premdas wrote:

> On 22 November 2011 20:31, Ash Moran  wrote:
>> Hi
>> 
>> I've worked on a couple of Rails 3 apps recently and the test feedback loop 
>> is killing me. With no modifications, it takes 15-25 seconds to run a single 
>> example. I've avoided Spork so far, but I've tried Spin[1]. Spin shaves a 
>> few seconds off but it's still agonising. I've also experimented with 
>> multiple Guard groups and other hacks to run isolated code in lib/, but a 
>> lot of the code can't be isolated (all the controllers, for example).
>> 
>> My last resort is to try and run Rails against an environment with 
>> `config.cache_classes = false`. Has anyone tried this (and got it working)? 
>> I imagine it would have to run tests over DRb, which I've only used with 
>> Spork before. The last mention of "cache_classes" on this list was in 2009, 
>> so I thought I'd check before I invested time in it in case there any major 
>> obstacles.
>> 
>> Any help appreciated
>> 
>> Cheers
>> Ash
>> 
> Use Ruby 1.8.7 its much faster. There is a very good screencast on
> Destroy All Software that might help also - the one about extracting
> domain objects (or something like that).

Anytime someone suggests using 1.8, a Chinchilla explodes. 1.9.3 has the "slow 
require" fix - please use that if it is your concern.

> 
> HTH
> 
> Andrew
> 
> ps
> 
> 
>> 
>> [1] http://jstorimer.github.com/spin/
>> 
>> --
>> http://www.patchspace.co.uk/
>> http://www.linkedin.com/in/ashmoran
>> 
>> ___
>> rspec-users mailing list
>> rspec-users@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>> 
> 
> 
> 
> -- 
> 
> Andrew Premdas
> blog.andrew.premdas.org
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

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


Re: [rspec-users] Rails code reloading in RSpec test environment?

2011-11-22 Thread Andrew Premdas
On 23 November 2011 00:57, Justin Ko  wrote:
>
> On Nov 22, 2011, at 4:52 PM, Andrew Premdas wrote:
>
>> On 22 November 2011 20:31, Ash Moran  wrote:
>>> Hi
>>>
>>> I've worked on a couple of Rails 3 apps recently and the test feedback loop 
>>> is killing me. With no modifications, it takes 15-25 seconds to run a 
>>> single example. I've avoided Spork so far, but I've tried Spin[1]. Spin 
>>> shaves a few seconds off but it's still agonising. I've also experimented 
>>> with multiple Guard groups and other hacks to run isolated code in lib/, 
>>> but a lot of the code can't be isolated (all the controllers, for example).
>>>
>>> My last resort is to try and run Rails against an environment with 
>>> `config.cache_classes = false`. Has anyone tried this (and got it working)? 
>>> I imagine it would have to run tests over DRb, which I've only used with 
>>> Spork before. The last mention of "cache_classes" on this list was in 2009, 
>>> so I thought I'd check before I invested time in it in case there any major 
>>> obstacles.
>>>
>>> Any help appreciated
>>>
>>> Cheers
>>> Ash
>>>
>> Use Ruby 1.8.7 its much faster. There is a very good screencast on
>> Destroy All Software that might help also - the one about extracting
>> domain objects (or something like that).
>
> Anytime someone suggests using 1.8, a Chinchilla explodes. 1.9.3 has the 
> "slow require" fix - please use that if it is your concern.
>

Yeh I know, but have you actually tried it out and got benchmarks to
prove that 1.9.3 is fast enough? I've been trying for the last few
weeks to get the rails test cycle going as quickly as possible. I'd
like to be using 1.9.x but its just been to slow. I've tried
fast_require patches, done lots of googling, used rvm to try different
versions etc. etc.. Currently the Rails test cycle is much faster in
1.8.7 - and for me the speed of the test cycle is the most important
thing. Using rvm I can always run the app on 1.9.x in CI and
production (so long as I create it using 1.8.x). Even using 1.8.7 the
time to run a model spec is a couple of seconds, which really is still
to slow, but its bearable. As soon as this becomes 4 or 5 seconds then
my style of programming has to change, and I don't want that.

If you have some uber fast version of 1.9.3 working reliably with
Rails 3.1.x and RVM running a single spec on an empty rails project in
less than 2 seconds - please point me in that direction with a link to
the particular patch/article/whatever.

All best

Andrew

>>
>> HTH
>>
>> Andrew
>>
>> ps
>>
>>
>>>
>>> [1] http://jstorimer.github.com/spin/
>>>
>>> --
>>> http://www.patchspace.co.uk/
>>> http://www.linkedin.com/in/ashmoran
>>>
>>> ___
>>> rspec-users mailing list
>>> rspec-users@rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>
>>
>>
>>
>> --
>> 
>> Andrew Premdas
>> blog.andrew.premdas.org
>> ___
>> rspec-users mailing list
>> rspec-users@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
> ___
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 

Andrew Premdas
blog.andrew.premdas.org
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users