From lists at ruby-forum.com Fri Jun 1 15:46:39 2012 From: lists at ruby-forum.com (Ben Densmore) Date: Fri, 01 Jun 2012 17:46:39 +0200 Subject: [rspec-users] Newbie testing questions Message-ID: <116e33fa2c1a6388da420b253881b536@ruby-forum.com> I recently wrote my first gem and am now in the process of learning how to write tests for it before I release. My gem is pretty basic and really just has a few class files with some methods for using GET to an API that returns some JSON data. I'm trying to come up with what I should be testing for, but to be honest this is where testing has always stumped me. If I have a class file that looks like the following: module MyModule class MyClass < MyParentClass def search(keyword) MyModule.get("/someurl/#{keyword}") end end end The method in this class uses the HTTParty gem and just does a get on this URL which returns JSON. Is it a valid use case to test for the keyword argument? I am not sure if there is any benefit to testing this since it's so very basic. It's a good experiment for me since I am so new to testing but I really want to understand what specifically I should be testing. Any guidance would be greatly appreicated. Thanks, Ben -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Fri Jun 1 16:07:37 2012 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 1 Jun 2012 17:07:37 +0100 Subject: [rspec-users] Newbie testing questions In-Reply-To: <116e33fa2c1a6388da420b253881b536@ruby-forum.com> References: <116e33fa2c1a6388da420b253881b536@ruby-forum.com> Message-ID: Hi Ben, On 1 Jun 2012, at 16:46, Ben Densmore wrote: > I recently wrote my first gem and am now in the process of learning how > to write tests for it before I release. > > My gem is pretty basic and really just has a few class files with some > methods for using GET to an API that returns some JSON data. > > I'm trying to come up with what I should be testing for, but to be > honest this is where testing has always stumped me. > > If I have a class file that looks like the following: > > module MyModule > > class MyClass < MyParentClass > > def search(keyword) > MyModule.get("/someurl/#{keyword}") > end > > end > > end > > The method in this class uses the HTTParty gem and just does a get on > this URL which returns JSON. > > Is it a valid use case to test for the keyword argument? I am not sure > if there is any benefit to testing this since it's so very basic. It's a > good experiment for me since I am so new to testing but I really want to > understand what specifically I should be testing. > > Any guidance would be greatly appreicated. > > Thanks, > Ben You want to aim to test logic, or behaviour. Think about each test as a warning light that you're fitting to your system; if someone comes along later and inadvertently changes the behaviour, the warning light will go off and alert them to their mistake. In this example, the only behaviour you have is mapping the keyword into a URL, so your warning light could check something like describe MyClass context "searching" do it "calls the web service with the correct URL" do MyModule.should_receive(:get).with("/someurl/example-keyword") MyClass.new.search('example-keyword') end end end Because there's so little actual behaviour in the example you've given above, this test looks a bit pointless. If you have some more examples of code where there's more risk that something could get broken in the future, let us see that and we can probably give you more useful advice. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users cheers, Matt -- Freelance programmer & coach Author, http://pragprog.com/book/hwcuc/the-cucumber-book Founder, http://www.relishapp.com/ Twitter, https://twitter.com/mattwynne -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick at collinatorstudios.com Fri Jun 1 20:31:43 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Fri, 1 Jun 2012 13:31:43 -0700 (PDT) Subject: [rspec-users] using chrome for integration tests? Message-ID: Hi everyone, I am trying to figure out how to my integration tests in Chrome... Doing some googling all I could find was this: # spec_helper.rb Capybara.register_driver :selenium do |app| Capybara::Selenium::Driver.new(app, :browser => :chrome) end However, firefox still launches.. Is there something else I need to do? Patrick J. Collins http://collinatorstudios.com From lbocseg at yahoo.com.br Sun Jun 3 23:05:53 2012 From: lbocseg at yahoo.com.br (Rodrigo Rosenfeld Rosas) Date: Sun, 03 Jun 2012 20:05:53 -0300 Subject: [rspec-users] oojs - modular object-oriented Client-side specs Message-ID: <4FCBEDD1.8060403@yahoo.com.br> I've just published an article on testing client-side code with my newly released oojs gem, mostly useful for integration tests. They're not full integration tests since all AJAX calls are stubbed with SinonJS. I thought that maybe some of you might be interested on it: http://rosenfeld.herokuapp.com/en/articles/programming/2012-06-03-client-side-object-oriented-programming-and-testing Any feedback is appreciated. Cheers, Rodrigo. From robbie at onthecity.org Tue Jun 5 20:47:29 2012 From: robbie at onthecity.org (Robbie Leib) Date: Tue, 5 Jun 2012 13:47:29 -0700 Subject: [rspec-users] "it" blocks not executing Message-ID: <42115B02-AD09-44C6-B767-1818CE481EEC@gmail.com> Rails 2.3.14 app rspec (1.3.2) rspec-rails (1.3.4) When I run bundle exec rake spec, not matter what, I get: 0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 0% passed I have one spec file, and I hit the first debug statement, and not the 2nd: require 'spec_helper' describe Api::Admin::V1::UsersController do describe "/api/admin/v1/users" do describe "GET index" do debugger it "should return first 20 users" do debugger assert_equal false, true end it "should return page 2" do end it "should filter on last name" do end end end end What could be causing this? Thanks, -- Robbie From rainer at incutio.com Wed Jun 6 10:14:34 2012 From: rainer at incutio.com (Rainer Kuhn) Date: Wed, 6 Jun 2012 11:14:34 +0100 Subject: [rspec-users] Slow Focus tags Message-ID: [This is my third and final attempt to post to this group, first 2 were with google groups] I noticed that focusing a single spec takes ages to run. We commonly use that, often in combination with guard to speed up our spec runs. I admit that the overall performance of our specs is bad, since we ditched mocking entirely and went with semi-integration specs on all levels. But this practice has served us very well on picking up failures. All runs on a single spec with focus: true that only tests (2 + 2).should == 4, among 700 other specs. Any ideas how to profile or even fix that? # What I want to get: $ time rspec spec/models/user_spec.rb:5 Finished in 1.41 seconds 1 example, 0 failures real 0m13.768s user 0m11.269s sys 0m1.692s # What I get using the focus tag: $ time rake spec Finished in 2.1 seconds 1 example, 0 failures real 1m5.502s user 0m46.467s sys 0m14.455s $time rspec spec Finished in 1.39 seconds 1 example, 0 failures real 0m51.350s user 0m36.069s sys 0m12.842s Thank you Ray -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 6 11:24:10 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 6 Jun 2012 06:24:10 -0500 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: On Wed, Jun 6, 2012 at 5:14 AM, Rainer Kuhn wrote: > [This is my third and final attempt to post to this group, first 2 were with > google groups] The google group is a mirror of the rspec-users list, but for that to work you actually have to post to the rspec-users list, not the google group. We're considering retiring that list and only using the google group, at which point you'd be able to post directly to the google group. > I noticed that focusing a single spec takes ages to run. We commonly use > that, often in combination with guard to speed up our spec runs. I admit > that the overall performance of our specs is bad, since we ditched mocking > entirely and went with semi-integration specs on all levels. But this > practice has served us very well on picking up failures. > > All runs on a single spec with focus: true that only tests (2 + 2).should == > 4, among 700 other specs. > Any ideas how to profile or even fix that? > > # What I want to get: > $ time rspec spec/models/user_spec.rb:5 > Finished in 1.41 seconds?1 example, 0 failures > real 0m13.768s > user 0m11.269s > sys 0m1.692s Wow. This is _not_ what I'd want to get. Nearly 14 secs to run a single example sounds like you're suffering some serious startup time. What version of rspec, ruby, rails, etc are you running? > # What I get using the focus tag: > $ time rake spec > Finished in 2.1 seconds?1 example, 0 failures > real 1m5.502s > user 0m46.467s > sys 0m14.455s When you run `rake spec` it loads up the Rails development environment (because that's the environment you're running rake in) and then shells out the `rspec spec` command with the Rails test environment. That's why `rake spec` will always take longer than running `rspec spec`. > $time rspec spec > Finished in 1.39 seconds?1 example, 0 failures > real 0m51.350s > user 0m36.069s > sys 0m12.842s When you run with `--tag focus` on the command line, or `config.filter_run_including :focus`, rspec evaluates the metadata for every example in the suite in order to find the one(s) that match(es) the tag. It's possible that you've got a filter in your config or in a spec that takes a long time to evaluate. What's in RSpec.configure in spec/spec_helper.rb? David From dchelimsky at gmail.com Wed Jun 6 11:25:51 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 6 Jun 2012 06:25:51 -0500 Subject: [rspec-users] "it" blocks not executing In-Reply-To: <42115B02-AD09-44C6-B767-1818CE481EEC@gmail.com> References: <42115B02-AD09-44C6-B767-1818CE481EEC@gmail.com> Message-ID: On Tue, Jun 5, 2012 at 3:47 PM, Robbie Leib wrote: > Rails 2.3.14 app > > rspec (1.3.2) > rspec-rails (1.3.4) > > When I run bundle exec rake spec, not matter what, I get: > > 0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications This is not rspec's output, so something else is not configured correctly. Would you mind posting the Rakefile and spec/spec_helper.rb? > 0% passed > > I have one spec file, and I hit the first debug statement, and not the 2nd: > > require 'spec_helper' > > describe Api::Admin::V1::UsersController do > ? ? ? ?describe "/api/admin/v1/users" do > ? ? ? ? ? ? ? ?describe "GET index" do > ? ? ? ? ? ? ? ? ? ? ? ?debugger > ? ? ? ? ? ? ? ? ? ? ? ?it "should return first 20 users" do > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?debugger > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?assert_equal false, true > ? ? ? ? ? ? ? ? ? ? ? ?end > ? ? ? ? ? ? ? ? ? ? ? ?it "should return page 2" do > ? ? ? ? ? ? ? ? ? ? ? ?end > ? ? ? ? ? ? ? ? ? ? ? ?it "should filter on last name" do > ? ? ? ? ? ? ? ? ? ? ? ?end > ? ? ? ? ? ? ? ?end > ? ? ? ?end > end > > What could be causing this? > > Thanks, > > > > -- > > Robbie > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rainer at incutio.com Wed Jun 6 11:38:58 2012 From: rainer at incutio.com (Rainer Kuhn) Date: Wed, 6 Jun 2012 12:38:58 +0100 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: I have started with a blank spec_helper and I'm seeing lots of improvements regarding the focus tag. Not the 12sec load time however. Let me do some legwork first and I present you with the results in a couple of hours. Tomorrow perhaps since I have a couple of hours of urgent dev work my list. My current spec_helper is a huge mess copy pasted from multiple sources over a period of 4 months. I'm really not proud of it especially since I'm using spec since 2008. Read it and weep: https://gist.github.com/2881400 On Wed, Jun 6, 2012 at 12:24 PM, David Chelimsky wrote: > On Wed, Jun 6, 2012 at 5:14 AM, Rainer Kuhn wrote: > > [This is my third and final attempt to post to this group, first 2 were > with > > google groups] > > The google group is a mirror of the rspec-users list, but for that to > work you actually have to post to the rspec-users list, not the google > group. We're considering retiring that list and only using the google > group, at which point you'd be able to post directly to the google > group. > > > I noticed that focusing a single spec takes ages to run. We commonly use > > that, often in combination with guard to speed up our spec runs. I admit > > that the overall performance of our specs is bad, since we ditched > mocking > > entirely and went with semi-integration specs on all levels. But this > > practice has served us very well on picking up failures. > > > > All runs on a single spec with focus: true that only tests (2 + > 2).should == > > 4, among 700 other specs. > > Any ideas how to profile or even fix that? > > > > # What I want to get: > > $ time rspec spec/models/user_spec.rb:5 > > Finished in 1.41 seconds 1 example, 0 failures > > real 0m13.768s > > user 0m11.269s > > sys 0m1.692s > > Wow. This is _not_ what I'd want to get. Nearly 14 secs to run a > single example sounds like you're suffering some serious startup time. > What version of rspec, ruby, rails, etc are you running? > > > # What I get using the focus tag: > > $ time rake spec > > Finished in 2.1 seconds 1 example, 0 failures > > real 1m5.502s > > user 0m46.467s > > sys 0m14.455s > > When you run `rake spec` it loads up the Rails development environment > (because that's the environment you're running rake in) and then > shells out the `rspec spec` command with the Rails test environment. > That's why `rake spec` will always take longer than running `rspec > spec`. > > > $time rspec spec > > Finished in 1.39 seconds 1 example, 0 failures > > real 0m51.350s > > user 0m36.069s > > sys 0m12.842s > > When you run with `--tag focus` on the command line, or > `config.filter_run_including :focus`, rspec evaluates the metadata for > every example in the suite in order to find the one(s) that match(es) > the tag. It's possible that you've got a filter in your config or in a > spec that takes a long time to evaluate. What's in RSpec.configure in > spec/spec_helper.rb? > > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Rainer Kuhn Rails Developer Incutio :: www.incutio.com http://www.facebook.com/Incutio https://twitter.com/incutio UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham, LL13 9UG. US Head Office: 33 South Commercial Street, Manchester, NH 03101 T: +44 (0) 1978 661 666 F: +44 (0)7092 181 581 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Jun 6 11:50:13 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 6 Jun 2012 06:50:13 -0500 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: On Wed, Jun 6, 2012 at 6:38 AM, Rainer Kuhn wrote: > I have started with a blank spec_helper and I'm seeing lots of improvements > regarding the focus tag. Not the 12sec load time however. Let me do some > legwork first and I present you with the results in a couple of hours. > Tomorrow perhaps since I have a couple of hours of urgent dev work my list. > > My current spec_helper is a huge mess copy pasted from multiple sources over > a period of 4 months. I'm really not proud of it especially since I'm using > spec since 2008. Read it and weep: > https://gist.github.com/2881400 There's a lot there. Redis, fog, all the macros modules. Any of them could be contributing. > On Wed, Jun 6, 2012 at 12:24 PM, David Chelimsky > wrote: >> >> On Wed, Jun 6, 2012 at 5:14 AM, Rainer Kuhn wrote: >> > [This is my third and final attempt to post to this group, first 2 were >> > with >> > google groups] >> >> The google group is a mirror of the rspec-users list, but for that to >> work you actually have to post to the rspec-users list, not the google >> group. We're considering retiring that list and only using the google >> group, at which point you'd be able to post directly to the google >> group. >> >> > I noticed that focusing a single spec takes ages to run. We commonly use >> > that, often in combination with guard to speed up our spec runs. I admit >> > that the overall performance of our specs is bad, since we ditched >> > mocking >> > entirely and went with semi-integration specs on all levels. But this >> > practice has served us very well on picking up failures. >> > >> > All runs on a single spec with focus: true that only tests (2 + >> > 2).should == >> > 4, among 700 other specs. >> > Any ideas how to profile or even fix that? >> > >> > # What I want to get: >> > $ time rspec spec/models/user_spec.rb:5 >> > Finished in 1.41 seconds?1 example, 0 failures >> > real 0m13.768s >> > user 0m11.269s >> > sys 0m1.692s >> >> Wow. This is _not_ what I'd want to get. Nearly 14 secs to run a >> single example sounds like you're suffering some serious startup time. >> What version of rspec, ruby, rails, etc are you running? >> >> > # What I get using the focus tag: >> > $ time rake spec >> > Finished in 2.1 seconds?1 example, 0 failures >> > real 1m5.502s >> > user 0m46.467s >> > sys 0m14.455s >> >> When you run `rake spec` it loads up the Rails development environment >> (because that's the environment you're running rake in) and then >> shells out the `rspec spec` command with the Rails test environment. >> That's why `rake spec` will always take longer than running `rspec >> spec`. >> >> > $time rspec spec >> > Finished in 1.39 seconds?1 example, 0 failures >> > real 0m51.350s >> > user 0m36.069s >> > sys 0m12.842s >> >> When you run with `--tag focus` on the command line, or >> `config.filter_run_including :focus`, rspec evaluates the metadata for >> every example in the suite in order to find the one(s) that match(es) >> the tag. It's possible that you've got a filter in your config or in a >> spec that takes a long time to evaluate. What's in RSpec.configure in >> spec/spec_helper.rb? >> >> David >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > Rainer Kuhn > > Rails Developer > Incutio ::?www.incutio.com > http://www.facebook.com/Incutio > https://twitter.com/incutio > > UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham, > LL13 9UG. > > US Head Office:?33 South Commercial Street,?Manchester,?NH 03101 > > T:?+44 (0)?1978 661 666 > F:?+44 (0)7092 181 581 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rainer at incutio.com Thu Jun 7 09:00:44 2012 From: rainer at incutio.com (Rainer Kuhn) Date: Thu, 7 Jun 2012 10:00:44 +0100 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: I narrowed it down to three things, the first one might be interesting to you, the other ones are my problem, although probably common among lots of projects: Since we don't mock we usually need a bit of test data prepared for each test. At first we used factories, but setting things up every time took way to long. So I went for fixture builder instead. ( http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance) It was an immediate improvement, although not a great one, since we have a generic setup_test_data method that runs before most tests and loads from the database into instance variables. 1) config.global_fixtures = :all With this line in, the execution of a single focused spec jumps up to a minute. My unresearched guess is that it might load the fixtures for each spec, although it won't even be executed. 2) They way I handle fixtures I am about to change fixture loading to lazy evaluation instead require 'rspec/core/shared_context' module LazyFixtures extend RSpec::Core::SharedContext let(:admin) { User.first } end 3) My Rails Env doesn't exactly load fast time rails runner "3 + 4" real 0m11.521s user 0m8.531s sys 0m1.404s (4) Not really relevant, but a Macbook Air runs out of it's 4GB memory so fast and starts swapping, next time, I want an iMac! On Wed, Jun 6, 2012 at 12:50 PM, David Chelimsky wrote: > On Wed, Jun 6, 2012 at 6:38 AM, Rainer Kuhn wrote: > > I have started with a blank spec_helper and I'm seeing lots of > improvements > > regarding the focus tag. Not the 12sec load time however. Let me do some > > legwork first and I present you with the results in a couple of hours. > > Tomorrow perhaps since I have a couple of hours of urgent dev work my > list. > > > > My current spec_helper is a huge mess copy pasted from multiple sources > over > > a period of 4 months. I'm really not proud of it especially since I'm > using > > spec since 2008. Read it and weep: > > https://gist.github.com/2881400 > > There's a lot there. Redis, fog, all the macros modules. Any of them > could be contributing. > > > On Wed, Jun 6, 2012 at 12:24 PM, David Chelimsky > > wrote: > >> > >> On Wed, Jun 6, 2012 at 5:14 AM, Rainer Kuhn wrote: > >> > [This is my third and final attempt to post to this group, first 2 > were > >> > with > >> > google groups] > >> > >> The google group is a mirror of the rspec-users list, but for that to > >> work you actually have to post to the rspec-users list, not the google > >> group. We're considering retiring that list and only using the google > >> group, at which point you'd be able to post directly to the google > >> group. > >> > >> > I noticed that focusing a single spec takes ages to run. We commonly > use > >> > that, often in combination with guard to speed up our spec runs. I > admit > >> > that the overall performance of our specs is bad, since we ditched > >> > mocking > >> > entirely and went with semi-integration specs on all levels. But this > >> > practice has served us very well on picking up failures. > >> > > >> > All runs on a single spec with focus: true that only tests (2 + > >> > 2).should == > >> > 4, among 700 other specs. > >> > Any ideas how to profile or even fix that? > >> > > >> > # What I want to get: > >> > $ time rspec spec/models/user_spec.rb:5 > >> > Finished in 1.41 seconds 1 example, 0 failures > >> > real 0m13.768s > >> > user 0m11.269s > >> > sys 0m1.692s > >> > >> Wow. This is _not_ what I'd want to get. Nearly 14 secs to run a > >> single example sounds like you're suffering some serious startup time. > >> What version of rspec, ruby, rails, etc are you running? > >> > >> > # What I get using the focus tag: > >> > $ time rake spec > >> > Finished in 2.1 seconds 1 example, 0 failures > >> > real 1m5.502s > >> > user 0m46.467s > >> > sys 0m14.455s > >> > >> When you run `rake spec` it loads up the Rails development environment > >> (because that's the environment you're running rake in) and then > >> shells out the `rspec spec` command with the Rails test environment. > >> That's why `rake spec` will always take longer than running `rspec > >> spec`. > >> > >> > $time rspec spec > >> > Finished in 1.39 seconds 1 example, 0 failures > >> > real 0m51.350s > >> > user 0m36.069s > >> > sys 0m12.842s > >> > >> When you run with `--tag focus` on the command line, or > >> `config.filter_run_including :focus`, rspec evaluates the metadata for > >> every example in the suite in order to find the one(s) that match(es) > >> the tag. It's possible that you've got a filter in your config or in a > >> spec that takes a long time to evaluate. What's in RSpec.configure in > >> spec/spec_helper.rb? > >> > >> David > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > > > -- > > Rainer Kuhn > > > > Rails Developer > > Incutio :: www.incutio.com > > http://www.facebook.com/Incutio > > https://twitter.com/incutio > > > > UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, > Wrexham, > > LL13 9UG. > > > > US Head Office: 33 South Commercial Street, Manchester, NH 03101 > > > > T: +44 (0) 1978 661 666 > > F: +44 (0)7092 181 581 > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Rainer Kuhn Rails Developer Incutio :: www.incutio.com http://www.facebook.com/Incutio https://twitter.com/incutio UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham, LL13 9UG. US Head Office: 33 South Commercial Street, Manchester, NH 03101 T: +44 (0) 1978 661 666 F: +44 (0)7092 181 581 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Jun 7 10:54:49 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 Jun 2012 05:54:49 -0500 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: On Thu, Jun 7, 2012 at 4:00 AM, Rainer Kuhn wrote: > I narrowed it down to three things, the first one might be interesting to > you, the other ones are my problem, although probably common among lots of > projects: > > Since we don't mock we usually need a bit of test data prepared for each > test. At first we used factories, but setting things up every time took way > to long. So I went for fixture builder instead. > (http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance) > It was an immediate improvement, although not a great one, since we have a > generic setup_test_data method that runs before most tests and loads from > the database into instance variables. > > 1)?config.global_fixtures = :all > With this line in, the execution of a single focused spec jumps up to a > minute. My unresearched guess is that it might load the fixtures for each > spec, although it won't even be executed. Would you please check log/test.log to verify this? From dchelimsky at gmail.com Thu Jun 7 11:15:04 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 Jun 2012 06:15:04 -0500 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: On Thu, Jun 7, 2012 at 5:54 AM, David Chelimsky wrote: > On Thu, Jun 7, 2012 at 4:00 AM, Rainer Kuhn wrote: >> I narrowed it down to three things, the first one might be interesting to >> you, the other ones are my problem, although probably common among lots of >> projects: >> >> Since we don't mock we usually need a bit of test data prepared for each >> test. At first we used factories, but setting things up every time took way >> to long. So I went for fixture builder instead. >> (http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance) >> It was an immediate improvement, although not a great one, since we have a >> generic setup_test_data method that runs before most tests and loads from >> the database into instance variables. >> >> 1)?config.global_fixtures = :all >> With this line in, the execution of a single focused spec jumps up to a >> minute. My unresearched guess is that it might load the fixtures for each >> spec, although it won't even be executed. > > Would you please check log/test.log to verify this? Actually I went ahead and checked this myself and what I see is that it only creates fixtures before each spec that is run. If you run one, it happens once ... 2, twice, etc. From rainer at incutio.com Thu Jun 7 11:17:35 2012 From: rainer at incutio.com (Rainer Kuhn) Date: Thu, 7 Jun 2012 12:17:35 +0100 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: My guess was wrong, it can't seem to handle empty fixtures yml files. The gist contains only a brief snippets of the actual log, but you can see that it's trying to load fixtures from multiple specs https://gist.github.com/2888253 cat event_critical_errors.yml --- {} Users/rainer/work/app_path/spec/controllers/accounts_controller_spec.rb:3:in `' Unable to load event_critical_error, underlying cause No such file to load -- event_critical_error /Users/rainer/work/carrier-pigeon/spec/requests/suppressed_emails_spec.rb:3:in `' Unable to load event_critical_error, underlying cause No such file to load -- event_critical_error If you need more data, let me know. On Thu, Jun 7, 2012 at 11:54 AM, David Chelimsky wrote: > On Thu, Jun 7, 2012 at 4:00 AM, Rainer Kuhn wrote: > > I narrowed it down to three things, the first one might be interesting to > > you, the other ones are my problem, although probably common among lots > of > > projects: > > > > Since we don't mock we usually need a bit of test data prepared for each > > test. At first we used factories, but setting things up every time took > way > > to long. So I went for fixture builder instead. > > ( > http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance > ) > > It was an immediate improvement, although not a great one, since we have > a > > generic setup_test_data method that runs before most tests and loads from > > the database into instance variables. > > > > 1) config.global_fixtures = :all > > With this line in, the execution of a single focused spec jumps up to a > > minute. My unresearched guess is that it might load the fixtures for each > > spec, although it won't even be executed. > > Would you please check log/test.log to verify this? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Rainer Kuhn Rails Developer Incutio :: www.incutio.com http://www.facebook.com/Incutio https://twitter.com/incutio UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham, LL13 9UG. US Head Office: 33 South Commercial Street, Manchester, NH 03101 T: +44 (0) 1978 661 666 F: +44 (0)7092 181 581 -------------- next part -------------- An HTML attachment was scrubbed... URL: From rainer at incutio.com Thu Jun 7 11:26:12 2012 From: rainer at incutio.com (Rainer Kuhn) Date: Thu, 7 Jun 2012 12:26:12 +0100 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: I guess I can forward this issue to fixture builder, It only happens for fixtures that are in a module, like Event::Confirm Event::CriticalError Those fixtures propably need to either be named differently or to live in a module subfolder. So, nothing wrong with RSpec, I am very sorry that I put this one on you, so many times you have already proven to people that the error lies elsewhere and rspec is running perfectly fine. But for many users like me it's where we see the error/problem we suspect it's origin. And integration between all the testing tools is tricky to balance for devs. On Thu, Jun 7, 2012 at 12:15 PM, David Chelimsky wrote: > On Thu, Jun 7, 2012 at 5:54 AM, David Chelimsky > wrote: > > On Thu, Jun 7, 2012 at 4:00 AM, Rainer Kuhn wrote: > >> I narrowed it down to three things, the first one might be interesting > to > >> you, the other ones are my problem, although probably common among lots > of > >> projects: > >> > >> Since we don't mock we usually need a bit of test data prepared for each > >> test. At first we used factories, but setting things up every time took > way > >> to long. So I went for fixture builder instead. > >> ( > http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance > ) > >> It was an immediate improvement, although not a great one, since we > have a > >> generic setup_test_data method that runs before most tests and loads > from > >> the database into instance variables. > >> > >> 1) config.global_fixtures = :all > >> With this line in, the execution of a single focused spec jumps up to a > >> minute. My unresearched guess is that it might load the fixtures for > each > >> spec, although it won't even be executed. > > > > Would you please check log/test.log to verify this? > > Actually I went ahead and checked this myself and what I see is that > it only creates fixtures before each spec that is run. If you run one, > it happens once ... 2, twice, etc. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Rainer Kuhn Rails Developer Incutio :: www.incutio.com http://www.facebook.com/Incutio https://twitter.com/incutio UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham, LL13 9UG. US Head Office: 33 South Commercial Street, Manchester, NH 03101 T: +44 (0) 1978 661 666 F: +44 (0)7092 181 581 -------------- next part -------------- An HTML attachment was scrubbed... URL: From rainer at incutio.com Thu Jun 7 11:29:55 2012 From: rainer at incutio.com (Rainer Kuhn) Date: Thu, 7 Jun 2012 12:29:55 +0100 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: Follow up: is there a way to set RSpec to be less forgiving on errors. If my specs would have failed because of that error I would have fixed it months ago. (Or at least reported it) On Thu, Jun 7, 2012 at 12:26 PM, Rainer Kuhn wrote: > I guess I can forward this issue to fixture builder, It only happens for > fixtures that are in a module, like > Event::Confirm > Event::CriticalError > Those fixtures propably need to either be named differently or to live in > a module subfolder. > > So, nothing wrong with RSpec, I am very sorry that I put this one on you, > so many times you have already proven to people that the error lies > elsewhere and rspec is running perfectly fine. But for many users like me > it's where we see the error/problem we suspect it's origin. > And integration between all the testing tools is tricky to balance for > devs. > > On Thu, Jun 7, 2012 at 12:15 PM, David Chelimsky wrote: > >> On Thu, Jun 7, 2012 at 5:54 AM, David Chelimsky >> wrote: >> > On Thu, Jun 7, 2012 at 4:00 AM, Rainer Kuhn wrote: >> >> I narrowed it down to three things, the first one might be interesting >> to >> >> you, the other ones are my problem, although probably common among >> lots of >> >> projects: >> >> >> >> Since we don't mock we usually need a bit of test data prepared for >> each >> >> test. At first we used factories, but setting things up every time >> took way >> >> to long. So I went for fixture builder instead. >> >> ( >> http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance >> ) >> >> It was an immediate improvement, although not a great one, since we >> have a >> >> generic setup_test_data method that runs before most tests and loads >> from >> >> the database into instance variables. >> >> >> >> 1) config.global_fixtures = :all >> >> With this line in, the execution of a single focused spec jumps up to a >> >> minute. My unresearched guess is that it might load the fixtures for >> each >> >> spec, although it won't even be executed. >> > >> > Would you please check log/test.log to verify this? >> >> Actually I went ahead and checked this myself and what I see is that >> it only creates fixtures before each spec that is run. If you run one, >> it happens once ... 2, twice, etc. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Rainer Kuhn > > Rails Developer > Incutio :: www.incutio.com > http://www.facebook.com/Incutio > https://twitter.com/incutio > > UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, > Wrexham, LL13 9UG. > > US Head Office: 33 South Commercial Street, Manchester, NH 03101 > > T: +44 (0) 1978 661 666 > F: +44 (0)7092 181 581 > > -- Rainer Kuhn Rails Developer Incutio :: www.incutio.com http://www.facebook.com/Incutio https://twitter.com/incutio UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham, LL13 9UG. US Head Office: 33 South Commercial Street, Manchester, NH 03101 T: +44 (0) 1978 661 666 F: +44 (0)7092 181 581 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Jun 7 11:43:12 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 Jun 2012 06:43:12 -0500 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: On Thu, Jun 7, 2012 at 6:17 AM, Rainer Kuhn wrote: > My guess was wrong, it can't seem to handle empty fixtures yml files. The > gist contains only a brief snippets of the actual log, but you can see that > it's trying to load fixtures from multiple specs > > https://gist.github.com/2888253 > > cat event_critical_errors.yml > --- {} > > Users/rainer/work/app_path/spec/controllers/accounts_controller_spec.rb:3:in > `' > Unable to load event_critical_error, underlying cause No such file to load > -- event_critical_error > > /Users/rainer/work/carrier-pigeon/spec/requests/suppressed_emails_spec.rb:3:in > `' > Unable to load event_critical_error, underlying cause No such file to load > -- event_critical_error That's happening in Rails. Would you please report this to http://github.com/rails/rails/issues? From dchelimsky at gmail.com Thu Jun 7 11:46:55 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 Jun 2012 06:46:55 -0500 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: On Thu, Jun 7, 2012 at 6:26 AM, Rainer Kuhn wrote: > I guess I can forward this issue to fixture builder, It only happens for > fixtures that are in a module, like > Event::Confirm > Event::CriticalError > Those fixtures propably need to either be named differently or to live in a > module subfolder. > > So, nothing wrong with RSpec, I am very sorry that I put this one on you, so > many times you have already proven to people that the error lies elsewhere > and rspec is running perfectly fine. But for many users like me it's where > we see the error/problem we suspect it's origin. Don't worry about blame, as long as you're not spewing hate in the process. RSpec is far from perfect, and it's fine for you to report problems here even if they end up being further down the stack. It's useful for other RSpec users who might encounter the same problem, and once we identify what the problem really is then it can be reported to the proper place with more accuracy. > And integration between all the testing tools is tricky to balance for devs. This is true of non-testing tools as well :) Thanks for doing the research. Cheers, David > > On Thu, Jun 7, 2012 at 12:15 PM, David Chelimsky > wrote: >> >> On Thu, Jun 7, 2012 at 5:54 AM, David Chelimsky >> wrote: >> > On Thu, Jun 7, 2012 at 4:00 AM, Rainer Kuhn wrote: >> >> I narrowed it down to three things, the first one might be interesting >> >> to >> >> you, the other ones are my problem, although probably common among lots >> >> of >> >> projects: >> >> >> >> Since we don't mock we usually need a bit of test data prepared for >> >> each >> >> test. At first we used factories, but setting things up every time took >> >> way >> >> to long. So I went for fixture builder instead. >> >> >> >> (http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance) >> >> It was an immediate improvement, although not a great one, since we >> >> have a >> >> generic setup_test_data method that runs before most tests and loads >> >> from >> >> the database into instance variables. >> >> >> >> 1)?config.global_fixtures = :all >> >> With this line in, the execution of a single focused spec jumps up to a >> >> minute. My unresearched guess is that it might load the fixtures for >> >> each >> >> spec, although it won't even be executed. >> > >> > Would you please check log/test.log to verify this? >> >> Actually I went ahead and checked this myself and what I see is that >> it only creates fixtures before each spec that is run. If you run one, >> it happens once ... 2, twice, etc. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > > > > -- > Rainer Kuhn > > Rails Developer > Incutio ::?www.incutio.com > http://www.facebook.com/Incutio > https://twitter.com/incutio > > UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham, > LL13 9UG. > > US Head Office:?33 South Commercial Street,?Manchester,?NH 03101 > > T:?+44 (0)?1978 661 666 > F:?+44 (0)7092 181 581 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Thu Jun 7 11:57:39 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 7 Jun 2012 06:57:39 -0500 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: On Thu, Jun 7, 2012 at 6:29 AM, Rainer Kuhn wrote: > Follow up: is there a way to set RSpec to be less forgiving on errors. If my > specs would have failed because of that error I would have fixed it months > ago. (Or at least reported it) I can't duplicate this behavior myself, but from what I can see in the gist, it happens when rspec calls Rails `fixtures` method and does not bubble back up to RSpec. If you see a place that RSpec is actively hiding this please submit an issue to http://github.com/rspec/rspec-rails/issues. Cheers, David > > > On Thu, Jun 7, 2012 at 12:26 PM, Rainer Kuhn wrote: >> >> I guess I can forward this issue to fixture builder, It only happens for >> fixtures that are in a module, like >> Event::Confirm >> Event::CriticalError >> Those fixtures propably need to either be named differently or to live in >> a module subfolder. >> >> So, nothing wrong with RSpec, I am very sorry that I put this one on you, >> so many times you have already proven to people that the error lies >> elsewhere and rspec is running perfectly fine. But for many users like me >> it's where we see the error/problem we suspect it's origin. >> And integration between all the testing tools is tricky to balance for >> devs. >> >> On Thu, Jun 7, 2012 at 12:15 PM, David Chelimsky >> wrote: >>> >>> On Thu, Jun 7, 2012 at 5:54 AM, David Chelimsky >>> wrote: >>> > On Thu, Jun 7, 2012 at 4:00 AM, Rainer Kuhn wrote: >>> >> I narrowed it down to three things, the first one might be interesting >>> >> to >>> >> you, the other ones are my problem, although probably common among >>> >> lots of >>> >> projects: >>> >> >>> >> Since we don't mock we usually need a bit of test data prepared for >>> >> each >>> >> test. At first we used factories, but setting things up every time >>> >> took way >>> >> to long. So I went for fixture builder instead. >>> >> >>> >> (http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance) >>> >> It was an immediate improvement, although not a great one, since we >>> >> have a >>> >> generic setup_test_data method that runs before most tests and loads >>> >> from >>> >> the database into instance variables. >>> >> >>> >> 1)?config.global_fixtures = :all >>> >> With this line in, the execution of a single focused spec jumps up to >>> >> a >>> >> minute. My unresearched guess is that it might load the fixtures for >>> >> each >>> >> spec, although it won't even be executed. >>> > >>> > Would you please check log/test.log to verify this? >>> >>> Actually I went ahead and checked this myself and what I see is that >>> it only creates fixtures before each spec that is run. If you run one, >>> it happens once ... 2, twice, etc. >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> >> >> -- >> Rainer Kuhn >> >> Rails Developer >> Incutio ::?www.incutio.com >> http://www.facebook.com/Incutio >> https://twitter.com/incutio >> >> UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, >> Wrexham, LL13 9UG. >> >> US Head Office:?33 South Commercial Street,?Manchester,?NH 03101 >> >> T:?+44 (0)?1978 661 666 >> F:?+44 (0)7092 181 581 >> > > > > -- > Rainer Kuhn > > Rails Developer > Incutio ::?www.incutio.com > http://www.facebook.com/Incutio > https://twitter.com/incutio > > UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham, > LL13 9UG. > > US Head Office:?33 South Commercial Street,?Manchester,?NH 03101 > > T:?+44 (0)?1978 661 666 > F:?+44 (0)7092 181 581 > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From rainer at incutio.com Thu Jun 7 12:18:02 2012 From: rainer at incutio.com (Rainer Kuhn) Date: Thu, 7 Jun 2012 13:18:02 +0100 Subject: [rspec-users] Slow Focus tags In-Reply-To: References: Message-ID: I tried putting the fixtures into a subfolder, next I'm trying to replicate the behaviour in a blank project. Then you and the rails devs have a bit more to play with. On Thu, Jun 7, 2012 at 12:57 PM, David Chelimsky wrote: > On Thu, Jun 7, 2012 at 6:29 AM, Rainer Kuhn wrote: > > Follow up: is there a way to set RSpec to be less forgiving on errors. > If my > > specs would have failed because of that error I would have fixed it > months > > ago. (Or at least reported it) > > I can't duplicate this behavior myself, but from what I can see in the > gist, it happens when rspec calls Rails `fixtures` method and does not > bubble back up to RSpec. If you see a place that RSpec is actively > hiding this please submit an issue to > http://github.com/rspec/rspec-rails/issues. > > Cheers, > David > > > > > > > On Thu, Jun 7, 2012 at 12:26 PM, Rainer Kuhn wrote: > >> > >> I guess I can forward this issue to fixture builder, It only happens for > >> fixtures that are in a module, like > >> Event::Confirm > >> Event::CriticalError > >> Those fixtures propably need to either be named differently or to live > in > >> a module subfolder. > >> > >> So, nothing wrong with RSpec, I am very sorry that I put this one on > you, > >> so many times you have already proven to people that the error lies > >> elsewhere and rspec is running perfectly fine. But for many users like > me > >> it's where we see the error/problem we suspect it's origin. > >> And integration between all the testing tools is tricky to balance for > >> devs. > >> > >> On Thu, Jun 7, 2012 at 12:15 PM, David Chelimsky > >> wrote: > >>> > >>> On Thu, Jun 7, 2012 at 5:54 AM, David Chelimsky > >>> wrote: > >>> > On Thu, Jun 7, 2012 at 4:00 AM, Rainer Kuhn > wrote: > >>> >> I narrowed it down to three things, the first one might be > interesting > >>> >> to > >>> >> you, the other ones are my problem, although probably common among > >>> >> lots of > >>> >> projects: > >>> >> > >>> >> Since we don't mock we usually need a bit of test data prepared for > >>> >> each > >>> >> test. At first we used factories, but setting things up every time > >>> >> took way > >>> >> to long. So I went for fixture builder instead. > >>> >> > >>> >> ( > http://pivotallabs.com/users/georg/blog/articles/1864-fixture-builder-and-rspec-acceptance > ) > >>> >> It was an immediate improvement, although not a great one, since we > >>> >> have a > >>> >> generic setup_test_data method that runs before most tests and loads > >>> >> from > >>> >> the database into instance variables. > >>> >> > >>> >> 1) config.global_fixtures = :all > >>> >> With this line in, the execution of a single focused spec jumps up > to > >>> >> a > >>> >> minute. My unresearched guess is that it might load the fixtures for > >>> >> each > >>> >> spec, although it won't even be executed. > >>> > > >>> > Would you please check log/test.log to verify this? > >>> > >>> Actually I went ahead and checked this myself and what I see is that > >>> it only creates fixtures before each spec that is run. If you run one, > >>> it happens once ... 2, twice, etc. > >>> _______________________________________________ > >>> rspec-users mailing list > >>> rspec-users at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> > >> > >> > >> -- > >> Rainer Kuhn > >> > >> Rails Developer > >> Incutio :: www.incutio.com > >> http://www.facebook.com/Incutio > >> https://twitter.com/incutio > >> > >> UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, > >> Wrexham, LL13 9UG. > >> > >> US Head Office: 33 South Commercial Street, Manchester, NH 03101 > >> > >> T: +44 (0) 1978 661 666 > >> F: +44 (0)7092 181 581 > >> > > > > > > > > -- > > Rainer Kuhn > > > > Rails Developer > > Incutio :: www.incutio.com > > http://www.facebook.com/Incutio > > https://twitter.com/incutio > > > > UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, > Wrexham, > > LL13 9UG. > > > > US Head Office: 33 South Commercial Street, Manchester, NH 03101 > > > > T: +44 (0) 1978 661 666 > > F: +44 (0)7092 181 581 > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Rainer Kuhn Rails Developer Incutio :: www.incutio.com http://www.facebook.com/Incutio https://twitter.com/incutio UK Head Office: Unit 4, The Bridge Business Centre, Ash Road South, Wrexham, LL13 9UG. US Head Office: 33 South Commercial Street, Manchester, NH 03101 T: +44 (0) 1978 661 666 F: +44 (0)7092 181 581 -------------- next part -------------- An HTML attachment was scrubbed... URL: From robbie at onthecity.org Thu Jun 7 16:51:05 2012 From: robbie at onthecity.org (Robbie Leib) Date: Thu, 7 Jun 2012 09:51:05 -0700 Subject: [rspec-users] "it" blocks not executing In-Reply-To: References: Message-ID: <489B7349-385D-4952-9B9D-030344DF726D@gmail.com> ************************************* ************************************* Rakefile ************************************* ************************************* require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails' # Load the resque gem rake tasks into our namespace # http://stackoverflow.com/questions/1878640/including-rake-tasks-in-gems Dir["#{Gem.searcher.find('resque').full_gem_path}/lib/tasks/*.rake"].each { |ext| load ext } ************************************* ************************************* rspec.rake ************************************* ************************************* gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 rspec_gem_dir = nil Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir| rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb") end rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec') if rspec_gem_dir && (test ?d, rspec_plugin_dir) raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n" end if rspec_gem_dir $LOAD_PATH.unshift("#{rspec_gem_dir}/lib") elsif File.exist?(rspec_plugin_dir) $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib") end # Don't load rspec if running "rake gems:*" unless ARGV.any? {|a| a =~ /^gems/} begin require 'spec/rake/spectask' rescue MissingSourceFile module Spec module Rake class SpecTask include ::Rake::DSL if defined?(::Rake::DSL) def initialize(name) task name do # if rspec-rails is a configured gem, this will output helpful material and exit ... require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment")) # ... otherwise, do this: raise <<-MSG #{"*" * 80} * You are trying to run an rspec rake task defined in * #{__FILE__}, * but rspec can not be found in vendor/gems, vendor/plugins or system gems. #{"*" * 80} MSG end end end end end end Rake.application.instance_variable_get('@tasks').delete('default') spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop task :noop do end task :default => :spec task :stats => "spec:statsetup" desc "Run all specs in spec directory (excluding plugin specs)" Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['spec/**/*_spec.rb'] end namespace :spec do desc "Run all specs in spec directory with RCov (excluding plugin specs)" Spec::Rake::SpecTask.new(:rcov) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['spec/**/*_spec.rb'] t.rcov = true t.rcov_opts = lambda do IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten end end desc "Print Specdoc for all specs (excluding plugin specs)" Spec::Rake::SpecTask.new(:doc) do |t| t.spec_opts = ["--format", "specdoc", "--dry-run"] t.spec_files = FileList['spec/**/*_spec.rb'] end desc "Print Specdoc for all plugin examples" Spec::Rake::SpecTask.new(:plugin_doc) do |t| t.spec_opts = ["--format", "specdoc", "--dry-run"] t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*') end [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub| desc "Run the code examples in spec/#{sub}" Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] end end desc "Run the code examples in vendor/plugins (except RSpec's own)" Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*") end namespace :plugins do desc "Runs the examples for rspec_on_rails" Spec::Rake::SpecTask.new(:rspec_on_rails) do |t| t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb'] end end # Setup specs for stats task :statsetup do require 'code_statistics' ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models') ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views') ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers') ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers') ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib') ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing') ::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration') ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models') ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views') ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers') ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers') ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib') ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing') ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration') end namespace :db do namespace :fixtures do desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z." task :load => :environment do ActiveRecord::Base.establish_connection(Rails.env) base_dir = File.join(Rails.root, 'spec', 'fixtures') fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir require 'active_record/fixtures' (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file| Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*')) end end end end end end ************************************* ************************************* spec_helper.rb ************************************* ************************************* # This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] ||= 'test' require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) require 'spec/autorun' require 'spec/rails' # Uncomment the next line to use webrat's matchers #require 'webrat/integrations/rspec-rails' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} Spec::Runner.configure do |config| # If you're not using ActiveRecord you should remove these # lines, delete config/database.yml and disable :active_record # in your config/boot.rb config.use_transactional_fixtures = true config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/test/fixtures/' # == Fixtures # # You can declare fixtures for each example_group like this: # describe "...." do # fixtures :table_a, :table_b # # Alternatively, if you prefer to declare them only once, you can # do so right here. Just uncomment the next line and replace the fixture # names with your fixtures. # # config.global_fixtures = :table_a, :table_b # # If you declare global fixtures, be aware that they will be declared # for all of your examples, even those that don't use them. # # You can also declare which fixtures to use (for example fixtures for test/fixtures): # # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' # # == Mock Framework # # RSpec uses its own mocking framework by default. If you prefer to # use mocha, flexmock or RR, uncomment the appropriate line: # config.mock_with :mocha # config.mock_with :flexmock # config.mock_with :rr # # == Notes # # For more information take a look at Spec::Runner::Configuration and Spec::Runner end From lists at ruby-forum.com Fri Jun 8 21:03:08 2012 From: lists at ruby-forum.com (Michael Madrid) Date: Fri, 08 Jun 2012 23:03:08 +0200 Subject: [rspec-users] Rspec include paths Message-ID: <3393774b8fa1ea9e250b895150083d80@ruby-forum.com> 'm using rspec 2.10 with Rails 3.2.1 and have problems with classes not being found. I have put a class called DbTasks under a dir app/util. Under spec, i've created file util/db_tasks_spec.rb which runs afer i included the line: require File.join(File.dirname(FILE), '../../app/util/db_tasks') However, rspec now isn't able to find my models. I don't want to have to include these manually. Is there a way to config rspecs paths so everything gets found? -- Posted via http://www.ruby-forum.com/. From jared at yourelevation.com Fri Jun 8 21:21:16 2012 From: jared at yourelevation.com (jared) Date: Fri, 8 Jun 2012 14:21:16 -0700 (PDT) Subject: [rspec-users] RSpec 2/Rails 3 - content_for in view specs In-Reply-To: <201008290112.54287.michael@schuerig.de> References: <201008290112.54287.michael@schuerig.de> Message-ID: <95c7c556-c8f1-418f-a9b4-4f13c2a65035@googlegroups.com> This worked in Rails 3.1 but view.instance_variable_get(:@_content_for) is nil in Rails 3.2 Anybody have a solution for this in Rails 3.2? Thanks! Jared On Saturday, August 28, 2010 4:12:53 PM UTC-7, Michael Schuerig wrote: > > On Thursday 19 August 2010, Dylan Markow wrote: > > Is there a way to get to the content captured in a "content_for" > > block through my view specs, or at the very least get my "render" > > call to use the full layout? > > Try defining a method like this in your spec > > def content_for(name) > view.instance_variable_get(:@_content_for)[name] > end > > and then > > content_for(:sidebar).should ... > > > Michael > > -- > Michael Schuerig > mailto:michael at schuerig.de > http://www.schuerig.de/michael/ > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Sat Jun 9 03:54:39 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 8 Jun 2012 22:54:39 -0500 Subject: [rspec-users] Rspec include paths In-Reply-To: <3393774b8fa1ea9e250b895150083d80@ruby-forum.com> References: <3393774b8fa1ea9e250b895150083d80@ruby-forum.com> Message-ID: On Fri, Jun 8, 2012 at 4:03 PM, Michael Madrid wrote: > 'm using rspec 2.10 with Rails 3.2.1 and have problems with classes not > being found. > > I have put a class called DbTasks under a dir app/util. Under spec, i've > created file util/db_tasks_spec.rb which runs afer i included the line: > > require File.join(File.dirname(FILE), '../../app/util/db_tasks') > > However, rspec now isn't able to find my models. I don't want to have to > include these manually. Is there a way to config rspecs paths so > everything gets found? Add 'app/util' to config.autoload_paths in config/application.rb. That's where it belongs (not in your rspec config). From dchelimsky at gmail.com Sat Jun 9 13:14:49 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Sat, 9 Jun 2012 08:14:49 -0500 Subject: [rspec-users] "it" blocks not executing In-Reply-To: <489B7349-385D-4952-9B9D-030344DF726D@gmail.com> References: <489B7349-385D-4952-9B9D-030344DF726D@gmail.com> Message-ID: On Thu, Jun 7, 2012 at 11:51 AM, Robbie Leib wrote: > ************************************* > ************************************* > rspec.rake > ************************************* > ************************************* > > gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 This might be the problem right here. Are you running in Ruby 1.9 and do you have test-unit-1.2.3 installed? From robert.leib at gmail.com Mon Jun 11 16:29:53 2012 From: robert.leib at gmail.com (Robbie Leib) Date: Mon, 11 Jun 2012 09:29:53 -0700 Subject: [rspec-users] "it" blocks not executing In-Reply-To: <489B7349-385D-4952-9B9D-030344DF726D@gmail.com> References: <489B7349-385D-4952-9B9D-030344DF726D@gmail.com> Message-ID: <225D133F-763C-4911-BE1A-E55110AB15C1@gmail.com> Did this help at all? On Jun 7, 2012, at 9:51 AM, Robbie Leib wrote: > ************************************* > ************************************* > Rakefile > ************************************* > ************************************* > > require(File.join(File.dirname(__FILE__), 'config', 'boot')) > > require 'rake' > require 'rake/testtask' > require 'rake/rdoctask' > > require 'tasks/rails' > > # Load the resque gem rake tasks into our namespace > # http://stackoverflow.com/questions/1878640/including-rake-tasks-in-gems > Dir["#{Gem.searcher.find('resque').full_gem_path}/lib/tasks/*.rake"].each { |ext| load ext } > > > ************************************* > ************************************* > rspec.rake > ************************************* > ************************************* > > gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9 > rspec_gem_dir = nil > Dir["#{RAILS_ROOT}/vendor/gems/*"].each do |subdir| > rspec_gem_dir = subdir if subdir.gsub("#{RAILS_ROOT}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb") > end > rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec') > > if rspec_gem_dir && (test ?d, rspec_plugin_dir) > raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n" > end > > if rspec_gem_dir > $LOAD_PATH.unshift("#{rspec_gem_dir}/lib") > elsif File.exist?(rspec_plugin_dir) > $LOAD_PATH.unshift("#{rspec_plugin_dir}/lib") > end > > # Don't load rspec if running "rake gems:*" > unless ARGV.any? {|a| a =~ /^gems/} > > begin > require 'spec/rake/spectask' > rescue MissingSourceFile > module Spec > module Rake > class SpecTask > include ::Rake::DSL if defined?(::Rake::DSL) > > def initialize(name) > task name do > # if rspec-rails is a configured gem, this will output helpful material and exit ... > require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment")) > > # ... otherwise, do this: > raise <<-MSG > > #{"*" * 80} > * You are trying to run an rspec rake task defined in > * #{__FILE__}, > * but rspec can not be found in vendor/gems, vendor/plugins or system gems. > #{"*" * 80} > MSG > end > end > end > end > end > end > > Rake.application.instance_variable_get('@tasks').delete('default') > > spec_prereq = File.exist?(File.join(RAILS_ROOT, 'config', 'database.yml')) ? "db:test:prepare" : :noop > task :noop do > end > > task :default => :spec > task :stats => "spec:statsetup" > > desc "Run all specs in spec directory (excluding plugin specs)" > Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t| > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > t.spec_files = FileList['spec/**/*_spec.rb'] > end > > namespace :spec do > desc "Run all specs in spec directory with RCov (excluding plugin specs)" > Spec::Rake::SpecTask.new(:rcov) do |t| > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > t.spec_files = FileList['spec/**/*_spec.rb'] > t.rcov = true > t.rcov_opts = lambda do > IO.readlines("#{RAILS_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten > end > end > > desc "Print Specdoc for all specs (excluding plugin specs)" > Spec::Rake::SpecTask.new(:doc) do |t| > t.spec_opts = ["--format", "specdoc", "--dry-run"] > t.spec_files = FileList['spec/**/*_spec.rb'] > end > > desc "Print Specdoc for all plugin examples" > Spec::Rake::SpecTask.new(:plugin_doc) do |t| > t.spec_opts = ["--format", "specdoc", "--dry-run"] > t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*') > end > > [:models, :controllers, :views, :helpers, :lib, :integration].each do |sub| > desc "Run the code examples in spec/#{sub}" > Spec::Rake::SpecTask.new(sub => spec_prereq) do |t| > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"] > end > end > > desc "Run the code examples in vendor/plugins (except RSpec's own)" > Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t| > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*") > end > > namespace :plugins do > desc "Runs the examples for rspec_on_rails" > Spec::Rake::SpecTask.new(:rspec_on_rails) do |t| > t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""] > t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb'] > end > end > > # Setup specs for stats > task :statsetup do > require 'code_statistics' > ::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models') > ::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views') > ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers') > ::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers') > ::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib') > ::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing') > ::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration') > ::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models') > ::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views') > ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers') > ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers') > ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib') > ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing') > ::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration') > end > > namespace :db do > namespace :fixtures do > desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z." > task :load => :environment do > ActiveRecord::Base.establish_connection(Rails.env) > base_dir = File.join(Rails.root, 'spec', 'fixtures') > fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir > > require 'active_record/fixtures' > (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file| > Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*')) > end > end > end > end > end > > end > > > > ************************************* > ************************************* > spec_helper.rb > ************************************* > ************************************* > > > # This file is copied to ~/spec when you run 'ruby script/generate rspec' > # from the project root directory. > ENV["RAILS_ENV"] ||= 'test' > require File.expand_path(File.join(File.dirname(__FILE__),'..','config','environment')) > require 'spec/autorun' > require 'spec/rails' > > # Uncomment the next line to use webrat's matchers > #require 'webrat/integrations/rspec-rails' > > # Requires supporting files with custom matchers and macros, etc, > # in ./support/ and its subdirectories. > Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f} > > Spec::Runner.configure do |config| > # If you're not using ActiveRecord you should remove these > # lines, delete config/database.yml and disable :active_record > # in your config/boot.rb > config.use_transactional_fixtures = true > config.use_instantiated_fixtures = false > config.fixture_path = RAILS_ROOT + '/test/fixtures/' > > # == Fixtures > # > # You can declare fixtures for each example_group like this: > # describe "...." do > # fixtures :table_a, :table_b > # > # Alternatively, if you prefer to declare them only once, you can > # do so right here. Just uncomment the next line and replace the fixture > # names with your fixtures. > # > # config.global_fixtures = :table_a, :table_b > # > # If you declare global fixtures, be aware that they will be declared > # for all of your examples, even those that don't use them. > # > # You can also declare which fixtures to use (for example fixtures for test/fixtures): > # > # config.fixture_path = RAILS_ROOT + '/spec/fixtures/' > # > # == Mock Framework > # > # RSpec uses its own mocking framework by default. If you prefer to > # use mocha, flexmock or RR, uncomment the appropriate line: > # > config.mock_with :mocha > # config.mock_with :flexmock > # config.mock_with :rr > # > # == Notes > # > # For more information take a look at Spec::Runner::Configuration and Spec::Runner > end > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robbie at onthecity.org Mon Jun 11 18:02:24 2012 From: robbie at onthecity.org (Robbie Leib) Date: Mon, 11 Jun 2012 11:02:24 -0700 Subject: [rspec-users] "it" blocks not executing In-Reply-To: References: Message-ID: <1E827CD5-1245-4A22-A8CD-ACB1D96D297C@gmail.com> ruby -v: ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [i686-darwin11.4.0], MBARI 0x6770, Ruby Enterprise Edition 2012.02 bundle list: * Ascii85 (1.0.1) * POpen4 (0.1.4) * Platform (0.4.0) * RedCloth (4.1.9) * RubyInline (3.11.2) * SystemTimer (1.2.3) * ZenTest (4.8.1) * actionmailer (2.3.14) * actionpack (2.3.14) * activerecord (2.3.14) * activeresource (2.3.14) * activesupport (2.3.14) * addressable (2.2.8) * after_commit (1.0.8) * airbrake (3.1.0) * amazon-ecs (0.5.7) * ancestry (1.3.0) * annotate (2.4.0) * archive-tar-minitar (0.5.2) * barby (0.3.2) * bitly (0.6.1) * builder (3.0.0) * bundler (1.1.4) * capistrano (2.12.0) * capybara (1.1.1) * cgi_multipart_eof_fix (2.5.0) * childprocess (0.3.2) * chronic (0.3.0) * color (1.4.0) * columnize (0.3.6) * crack (0.1.6) * cucumber (1.1.0) * cucumber-rails (0.3.2) * daemons (1.0.10) * dalli (1.0.5) * database_cleaner (0.8.0) * date-performance (0.4.8) * diff-lcs (1.1.3) * domain_name (0.5.3) * excon (0.6.6) * factory_girl (2.6.4) * faraday (0.7.6) * fastercsv (1.5.3) * fastthread (1.0.7) * ffi (1.0.11) * fog (0.10.0) * foreman (0.46.0) * forgery (0.3.0) * formatador (0.2.3) * gem_plugin (0.2.3) * geokit (1.6.5 98b758b) * gherkin (2.5.4) * git_remote_branch (0.3.3) * google4r-checkout (1.0.6 c6f7c0a) * grit (2.5.0) * growl (1.0.3) * guard (1.1.1) * guard-cucumber (0.7.5) * guard-rspec (1.0.0) * guard-test (0.5.0) * hashie (0.2.2) * heroku (2.25.0) * highline (1.6.12) * hiredis (0.4.5) * hoe (2.8.0) * hpricot (0.8.6) * httparty (0.5.2) * httpauth (0.1) * icalendar (1.0.2) * image_science (1.1.3) * jammit (0.6.5) * json (1.4.6) * json_pure (1.7.3) * kgio (2.7.4) * koala (1.3.0) * launchy (2.1.0) * libwebsocket (0.1.3) * libxml-ruby (1.1.3) * linecache (0.46) * listen (0.4.2) * mail (2.2.5) * mechanize (2.1.1) * metaclass (0.0.1) * mime-types (1.16) * mocha (0.11.4) * money (3.0.5) * mongrel (1.1.5) * multi_json (1.0.4) * multipart-post (1.1.5) * mysql2 (0.2.18) * net-http-digest_auth (1.2.1) * net-http-persistent (2.6) * net-scp (1.0.4) * net-sftp (2.0.5) * net-ssh (2.1.4) * net-ssh-gateway (1.1.0) * netrc (0.7.4) * newrelic_rpm (3.3.5) * nokogiri (1.5.3) * ntlm-http (0.1.1) * oauth (0.4.1) * oauth2 (0.6.0) * open4 (1.3.0) * pdf-reader (1.1.1) * png (1.2.0) * polyglot (0.3.1) * posix-spawn (0.3.6) * prawn (0.12.0) * rabl (0.3.0) * rack (1.1.3) * rack-test (0.6.1) * rails (2.3.14) * rainbow (1.1.4) * rake (0.9.2.2) * rb-fchange (0.0.5) * rb-fsevent (0.9.1) * rb-inotify (0.8.8) * rbx-require-relative (0.0.9) * rcov (1.0.0) * redis (2.2.2) * redis-namespace (1.0.3) * resque (1.19.0 361879d) * resque-retry (0.1.0 d3fe417) * resque-scheduler (1.9.9 f57e393) * rest-client (1.6.1) * right_aws (3.0.4) * right_http_connection (1.3.0) * rmagick (2.5.2) * rpm_contrib (2.1.11) * rspec (1.3.2) * rspec-rails (1.3.4 dcabc8b) * ruby-debug (0.10.4) * ruby-debug-base (0.10.4) * ruby-hmac (0.3.2) * ruby-rc4 (0.1.5) * rubyzip (0.9.4) * rufus-scheduler (2.0.7) * rvideo (0.9.3) * sanitize (2.0.3) * sanitize_email (0.3.7) * sass (3.1.19) * selenium-webdriver (2.22.2) * shoulda (3.0.1) * shoulda-context (1.0.0) * shoulda-matchers (1.0.0) * showoff-io (0.3.1) * simple-navigation (3.7.0) * sinatra (1.1.0) * spork (0.8.5) * spork-testunit (0.0.8) * subcontractor (0.3.2) * term-ansicolor (1.0.7) * termios (0.9.4) * test-unit (2.2.0) * thor (0.15.2) * tilt (1.1) * timecop (0.3.5) * transaction-simple (1.4.0) * treetop (1.4.10) * ttfunk (1.0.3) * twitter (0.9.8) * typhoeus (0.2.4) * tzinfo (0.3.33) * unf (0.0.5) * unf_ext (0.0.5) * vegas (0.1.11) * webrobots (0.0.13) * wice_grid (0.6.0 fdcff0e) * will_paginate (2.3.16) * xpath (0.1.4) * yajl-ruby (0.7.5) * yui-compressor (0.9.6) From lists at ruby-forum.com Thu Jun 14 07:40:14 2012 From: lists at ruby-forum.com (Joshua Muheim) Date: Thu, 14 Jun 2012 09:40:14 +0200 Subject: [rspec-users] response.should have_content("1 movie") does not seem to work for me Message-ID: Hey everybody I have worked quite to near the end of The RSpec Book, but now I'm having some troubles. I'm trying to get the last few Cucumber steps to work, which are: Then /^Caddyshack should be in the Comedy genre$/ do visit genres_path click_link "Comedy" save_and_open_page response.should have_content("1 movie") response.should have_content("Caddyshack") end So far everything's working, but the have_content("1 movie") doesn't, although I have hard-coded the string into the view, and when displaying what Webrat sees using save_and_open_page, the string definitely is there! Name: Comedy Contains 1 movie Edit | Back This is what Cucumber tells me: Scenario: Create movie in genre # features/create_movie.feature:7 Given a genre named Comedy # features/step_definitions/genre_steps.rb:1 When I create a movie Caddyshack in the Comedy genre # features/step_definitions/movie_steps.rb:1 Then Caddyshack should be in the Comedy genre # features/step_definitions/movie_steps.rb:10 expected there to be content "1 movie" in "" (RSpec::Expectations::ExpectationNotMetError) ./features/step_definitions/movie_steps.rb:14:in `/^Caddyshack should be in the Comedy genre$/' features/create_movie.feature:10:in `Then Caddyshack should be in the Comedy genre' I'm sort of confused anyway, because in the RSpec book I'm told to use contains("1 movie"), but this method is not found! undefined method `contains' for # (NoMethodError) After some searching on Google I got the hint to use should_contain("1 movie"), and this method seems to be available, but it doesn't seem to work. Anyways, I'm a bit confused now, because should_contain() was claimed to be a Capybara thing, and not a Webrat thing, but I never read something about Capybara in the book, only about Webrat. So what am I using now, and why?? Is it because the book is a bit old already, and nowadays Rails uses Capybara by default? Because when removing gem "webrat" from my Gemfile, Cucumber doesn't complain! Please also see my other post about this question (I'm sorry for having two posts, I didn't realize they both would be about the same thing): http://www.ruby-forum.com/topic/4402795 Thanks a lot for help, Josh -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Thu Jun 14 18:11:22 2012 From: lists at ruby-forum.com (Joshua Muheim) Date: Thu, 14 Jun 2012 20:11:22 +0200 Subject: [rspec-users] Selenium+Autotest: how to run browser in background? Message-ID: Hey guys After hours of hard work I finally managed to set up my development environment to run cucumber scenarios using autotest and selenium. What's a bit bugging is the fact that Firefox always jumps to the foreground when Autotest does its job. How can I keep Firefox in the background so that I can continue with my work without being interrupted? Thanks! -- Posted via http://www.ruby-forum.com/. From jko170 at gmail.com Fri Jun 15 15:13:24 2012 From: jko170 at gmail.com (Justin Ko) Date: Fri, 15 Jun 2012 09:13:24 -0600 Subject: [rspec-users] response.should have_content("1 movie") does not seem to work for me In-Reply-To: References: Message-ID: <0DD24FB9-D272-4704-AD52-63AF61787793@gmail.com> On Jun 14, 2012, at 1:40 AM, Joshua Muheim wrote: > Hey everybody > > I have worked quite to near the end of The RSpec Book, but now I'm > having some troubles. > > I'm trying to get the last few Cucumber steps to work, which are: > > Then /^Caddyshack should be in the Comedy genre$/ do > visit genres_path > click_link "Comedy" > save_and_open_page > response.should have_content("1 movie") > response.should have_content("Caddyshack") > end > > So far everything's working, but the have_content("1 movie") doesn't, > although I have hard-coded the string into the view, and when displaying > what Webrat sees using save_and_open_page, the string definitely is > there! > > Name: Comedy > > Contains 1 movie > Edit | Back > > This is what Cucumber tells me: > > Scenario: Create movie in genre # > features/create_movie.feature:7 > Given a genre named Comedy # > features/step_definitions/genre_steps.rb:1 > When I create a movie Caddyshack in the Comedy genre # > features/step_definitions/movie_steps.rb:1 > Then Caddyshack should be in the Comedy genre # > features/step_definitions/movie_steps.rb:10 > expected there to be content "1 movie" in "" > (RSpec::Expectations::ExpectationNotMetError) > ./features/step_definitions/movie_steps.rb:14:in `/^Caddyshack > should be in the Comedy genre$/' > features/create_movie.feature:10:in `Then Caddyshack should be in > the Comedy genre' > > I'm sort of confused anyway, because in the RSpec book I'm told to use > contains("1 movie"), but this method is not found! > > undefined method `contains' for > # (NoMethodError) > > After some searching on Google I got the hint to use should_contain("1 > movie"), and this method seems to be available, but it doesn't seem to > work. Anyways, I'm a bit confused now, because should_contain() was > claimed to be a Capybara thing, and not a Webrat thing, but I never read > something about Capybara in the book, only about Webrat. So what am I > using now, and why?? Is it because the book is a bit old already, and > nowadays Rails uses Capybara by default? Because when removing > > gem "webrat" > > from my Gemfile, Cucumber doesn't complain! > > Please also see my other post about this question (I'm sorry for having > two posts, I didn't realize they both would be about the same thing): > > http://www.ruby-forum.com/topic/4402795 > > Thanks a lot for help, > Josh > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users For Capybara, you want: page.should have_content For Webrat, I _think_ you want: response.should have_text From lists at ruby-forum.com Sat Jun 16 21:38:26 2012 From: lists at ruby-forum.com (Tyrel R.) Date: Sat, 16 Jun 2012 23:38:26 +0200 Subject: [rspec-users] 2 almost identical tests need different assertions to work and I can't figure out why Message-ID: Hey everyone, I am learning bdd and do deffently like it on the whole. I ran into a strange situation I got around it but it left a question in my mind and I would appreciate help in removing it ;) So hear is what happened test for one model: it "Should protect id from mass assignment" do attributes = @user.attributes attributes['id'] = 42 lambda do User.create(attributes).id.should_not equal 42 end.should raise_error ActiveModel::MassAssignmentSecurity::Error end passes test for another model it "Should not allow ID to be mass assigned" do attributes = @dispensary.attributes attributes['id'] = 42 disp = Dispensary.create( attributes ) disp.id.should_not equal 42 end also passes if I write a similar test for the first one instead of checking the exception like [code] it "Should not allow ID to be mass assigned" do attributes = @dispensary.attributes attributes['id'] = 42 disp = Dispensary.create( attributes ) disp.id.should_not equal 42 end Rspec stops because an error was raised. I am confused what variable am I missing thank you -- Posted via http://www.ruby-forum.com/. From jko170 at gmail.com Mon Jun 18 14:45:09 2012 From: jko170 at gmail.com (Justin Ko) Date: Mon, 18 Jun 2012 08:45:09 -0600 Subject: [rspec-users] 2 almost identical tests need different assertions to work and I can't figure out why In-Reply-To: References: Message-ID: <9A68649D-47BC-433F-8036-CB471C5E3F50@gmail.com> On Jun 16, 2012, at 3:38 PM, Tyrel R. wrote: > Hey everyone, I am learning bdd and do deffently like it on the whole. I > ran into a strange situation I got around it but it left a question in > my mind and I would appreciate help in removing it ;) > > So hear is what happened > > test for one model: > > it "Should protect id from mass assignment" do > attributes = @user.attributes > attributes['id'] = 42 > lambda do > User.create(attributes).id.should_not equal 42 > end.should raise_error ActiveModel::MassAssignmentSecurity::Error > end > > passes > > test for another model > > it "Should not allow ID to be mass assigned" do > attributes = @dispensary.attributes > attributes['id'] = 42 > disp = Dispensary.create( attributes ) > disp.id.should_not equal 42 > end > > also passes > > if I write a similar test for the first one instead of checking the > exception like > [code] > it "Should not allow ID to be mass assigned" do > attributes = @dispensary.attributes > attributes['id'] = 42 > disp = Dispensary.create( attributes ) > disp.id.should_not equal 42 > end > > Rspec stops because an error was raised. I am confused what variable am > I missing thank you > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users What is the error message?.... From jko170 at gmail.com Mon Jun 18 15:43:08 2012 From: jko170 at gmail.com (Justin Ko) Date: Mon, 18 Jun 2012 09:43:08 -0600 Subject: [rspec-users] Selenium+Autotest: how to run browser in background? In-Reply-To: References: Message-ID: <4DC61D37-093E-412A-B2B3-DD6B66C70A82@gmail.com> On Jun 14, 2012, at 12:11 PM, Joshua Muheim wrote: > Hey guys > > After hours of hard work I finally managed to set up my development > environment to run cucumber scenarios using autotest and selenium. > > What's a bit bugging is the fact that Firefox always jumps to the > foreground when Autotest does its job. How can I keep Firefox in the > background so that I can continue with my work without being > interrupted? > > Thanks! > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users That is how selenium works - it needs to fire up a browser (firefox). Take a look at the capybara-webkit gem. From patrick at collinatorstudios.com Tue Jun 19 05:16:44 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Mon, 18 Jun 2012 22:16:44 -0700 (PDT) Subject: [rspec-users] shared examples with controllers + included modules? Message-ID: Hi everyone, I ran into a little problem this evening and couldn't quite figure out how to solve it... So I have this sort of thing: class FooController < ApplicationController include Omg end module Omg def self.included(base) base.before_filter :set_something, :only => :show base.class_eval do attr_reader :something end end def set_something @something ||= Something.new(current_user) end end .... So, then I had a controller test like: describe FooController do it_behaves_like "omg", subject end ... shared_example "omg" do |obj| it "sets something" do Something.expects(:new).once get :show end it "gets something" do Something.stubs(:new).returns "lol" get :show obj.something.should == "lol" end end ......... So this failed, and I saw-- ok-- subject apparently isn't a real instance of the controller outside of an "it" block...... It's a proc of some kind, and I didn't know what to do with it-- so I changed my test code slightly: describe FooController do it_behaves_like "omg", FooController.new end ... and I got a failure, and upon inspecting, I found that in side the context of the shared examples, the "obj" variable was not the same controller instance as the one performing the get :show... So obj.something never equalled "lol", because it never got its setter method called.. So I said to mself: "????????" and thought I'd ask here: How can I refernence the real subject link this inside a shared example? Patrick J. Collins http://collinatorstudios.com From dchelimsky at gmail.com Tue Jun 19 10:16:29 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 19 Jun 2012 05:16:29 -0500 Subject: [rspec-users] shared examples with controllers + included modules? In-Reply-To: References: Message-ID: On Tue, Jun 19, 2012 at 12:16 AM, Patrick J. Collins wrote: > Hi everyone, > > I ran into a little problem this evening and couldn't quite figure out > how to solve it... > > So, then I had a controller test like: > > describe FooController do > ?it_behaves_like "omg", subject > end > > ... > > shared_example "omg" do |obj| > > ?it "gets something" do > ? ?Something.stubs(:new).returns "lol" > ? ?get :show > ? ?obj.something.should == "lol" > ?end > end > > ......... > > So this failed, and I saw-- ok-- subject apparently isn't a real > instance of the controller outside of an "it" block...... ?It's a proc > of some kind, and I didn't know what to do with it-- so I changed my > test code slightly: > > describe FooController do > ?it_behaves_like "omg", FooController.new > end > > ... and I got a failure, and upon inspecting, I found that in side the > context of the shared examples, the "obj" variable was not the same > controller instance as the one performing the get :show... ?So > obj.something never equalled "lol", because it never got its setter > method called.. > > So I said to mself: "????????" > > and thought I'd ask here: > > How can I refernence the real subject link this inside a shared example? Assuming this is a controller spec, you can reference the controller via the `controller` method (courtesy of ActionController::TestCase::Behavior [1][2][3]): shared_examples "omg" do it "gets something" do Something.stubs(:new).returns "lol" get :show controller.something.should == "lol" end end describe FooController do it_behaves_like "omg" end HTH, David [1] https://github.com/rspec/rspec-rails/blob/9abdc0a588a78d3cd50bb58ce719ce72f9af34e1/lib/rspec/rails/example/controller_example_group.rb#L9 [2] https://github.com/rspec/rspec-rails/blob/9abdc0a588a78d3cd50bb58ce719ce72f9af34e1/lib/rspec/rails/example/controller_example_group.rb#L77 [3] https://github.com/rails/rails/blob/c1b1956a15d3d38d0a4504e168bb69638d71e536/actionpack/lib/action_controller/test_case.rb#L508 From david.piegza at web.de Wed Jun 20 10:18:28 2012 From: david.piegza at web.de (David Piegza) Date: Wed, 20 Jun 2012 12:18:28 +0200 Subject: [rspec-users] Mock UploadedFile object in controller params Message-ID: <4C7FCA41-3A6C-448E-8016-7A7923823AE7@web.de> Hi, I'm trying to mock an UploadedFile object and pass it to a controller action. Unfortunately, the mocked object gets stringified in the params hash, so I'm not able to use the mock object in a test. Is there any way to avoid this stringification for UploadedFile objects? This has been discussed already on github: https://github.com/rails/rails/pull/1203 As described, the params are stringified, but it should exclude Rack::Test::UploadedFile: https://github.com/rails/rails/pull/1203#issuecomment-1217081 Here is a small example: let(:file) { mock('UploadedFile') } it "tests something" do file.stub(:content_type).and_return 'text/plain' # this won't work post :upload, { file: file } # params in controller will be "file" => "#[RSpec::Mock ... ]" end I get a NoMethodError: undefined method `content_type' for "#[RSpec::Mocks::Mock:0x3fe4723a81bc @name=\"file\"]":String So, how can I test this? Thanks, David -------------- next part -------------- An HTML attachment was scrubbed... URL: From farheen at deeproot.co.in Wed Jun 20 09:58:31 2012 From: farheen at deeproot.co.in (farheen at deeproot.co.in) Date: Wed, 20 Jun 2012 15:28:31 +0530 Subject: [rspec-users] New to rspec Message-ID: <6f4e5d528df92bf5b655180ecde0896e.squirrel@anubhav.deeproot.co.in> Hi all, As I am new to rspec, would like to know how to go about learning to write tests in rspec. Regards, Farheen Zahara From basv at odd-e.com Wed Jun 20 11:22:33 2012 From: basv at odd-e.com (Bas Vodde) Date: Wed, 20 Jun 2012 19:22:33 +0800 Subject: [rspec-users] New to rspec In-Reply-To: <6f4e5d528df92bf5b655180ecde0896e.squirrel@anubhav.deeproot.co.in> References: <6f4e5d528df92bf5b655180ecde0896e.squirrel@anubhav.deeproot.co.in> Message-ID: <3B657679-EAA1-4F6D-A00F-A093F37C6634@odd-e.com> How about writing a spec instead of an email :) Bas On 20-Jun-2012, at 5:58 PM, farheen at deeproot.co.in wrote: > Hi all, > > As I am new to rspec, would like to know how to go about learning to write > tests in rspec. > > Regards, > Farheen Zahara > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From katrina.owen at gmail.com Wed Jun 20 13:35:24 2012 From: katrina.owen at gmail.com (Katrina Owen) Date: Wed, 20 Jun 2012 15:35:24 +0200 Subject: [rspec-users] New to rspec In-Reply-To: <6f4e5d528df92bf5b655180ecde0896e.squirrel@anubhav.deeproot.co.in> References: <6f4e5d528df92bf5b655180ecde0896e.squirrel@anubhav.deeproot.co.in> Message-ID: On Wed, Jun 20, 2012 at 11:58 AM, wrote: > As I am new to rspec, would like to know how to go about learning to write > tests in rspec. The most comprehensive resource that I have used is The RSpec Book from the Pragmatic Bookshelf. I found it to be extremely helpful when getting started. http://pragprog.com/book/achbd/the-rspec-book /katrina From lists at ruby-forum.com Wed Jun 20 22:43:14 2012 From: lists at ruby-forum.com (Kathie Esteptvxw) Date: Thu, 21 Jun 2012 00:43:14 +0200 Subject: [rspec-users] Watch NFL Preseason 2012 Live Stream Online NFL Football ESPN HDQ FREE Message-ID: Watch NFL Preseason 2012 Live Stream Online NFL Football ESPN HDQ FREE. Watch NFL Preseason 2012 Live Stream NFL Football Online Games FREE Broadcast TV. The National Football League (NFL) is the largest professional American football league in the world. It was formed by eleven teams in 1920 as the American Professional Football Association (the league changed the name to the National Football League in 1922). The league currently consists of thirty-two teams from the United States. http://footballtv247.com/ The league is divided evenly into two conferences ? the American Football Conference (AFC) and National Football Conference (NFC), and each conference has four divisions that have 4 teams each. The season currently starts on the Thursday night in the first full week of September (the Thursday after Labor Day) and runs weekly to late December or early January. http://footballtv247.com/ At the end of each regular season, six teams from each conference play in the NFL playoffs, a twelve-team single-elimination tournament that culminates with the championship game, known as the Super Bowl. This game is held at a pre-selected site which is usually a city that hosts an NFL team. If you are in office or if your TV is broken or if you do not have cable, you can still watch NFL football 2011 matches online for Free! Most of the links given below are Live streaming links, while others are online video links which let you watch the highlights of NFL matches. -- Posted via http://www.ruby-forum.com/. From jko170 at gmail.com Thu Jun 21 11:14:52 2012 From: jko170 at gmail.com (Justin Ko) Date: Thu, 21 Jun 2012 05:14:52 -0600 Subject: [rspec-users] Mock UploadedFile object in controller params In-Reply-To: <4C7FCA41-3A6C-448E-8016-7A7923823AE7@web.de> References: <4C7FCA41-3A6C-448E-8016-7A7923823AE7@web.de> Message-ID: <6B77C23B-541D-4393-989D-A8DD87F4D6C6@gmail.com> On Jun 20, 2012, at 4:18 AM, David Piegza wrote: > Hi, > > I'm trying to mock an UploadedFile object and pass it to a controller action. Unfortunately, the mocked object gets stringified in the params hash, so I'm not able to use the mock object in a test. > > Is there any way to avoid this stringification for UploadedFile objects? > > This has been discussed already on github: https://github.com/rails/rails/pull/1203 > > As described, the params are stringified, but it should exclude Rack::Test::UploadedFile: https://github.com/rails/rails/pull/1203#issuecomment-1217081 > > Here is a small example: > > let(:file) { mock('UploadedFile') } > > it "tests something" do > file.stub(:content_type).and_return 'text/plain' # this won't work > post :upload, { file: file } # params in controller will be "file" => "#[RSpec::Mock ... ]" > end > > I get a NoMethodError: undefined method `content_type' for "#[RSpec::Mocks::Mock:0x3fe4723a81bc @name=\"file\"]":String > > So, how can I test this? > > Thanks, > David > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Rails has a built-in helper method for this: http://api.rubyonrails.org/classes/ActionDispatch/TestProcess.html#method-i-fixture_file_upload -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.piegza at web.de Thu Jun 21 14:45:33 2012 From: david.piegza at web.de (David Piegza) Date: Thu, 21 Jun 2012 16:45:33 +0200 Subject: [rspec-users] Mock UploadedFile object in controller params In-Reply-To: <6B77C23B-541D-4393-989D-A8DD87F4D6C6@gmail.com> References: <4C7FCA41-3A6C-448E-8016-7A7923823AE7@web.de> <6B77C23B-541D-4393-989D-A8DD87F4D6C6@gmail.com> Message-ID: <03DC4E98-4374-436A-B55A-3663BFC808FD@web.de> Thanks for the hint. But I would like to mock the UploadedFile object (I don't want to load a file..). My current workaround is to stub the params hash: controller.stub(:params).and_return { file: file } Would be nice if I could just pass in the mocked UploadedFile object... On 21.06.2012, at 13:14, Justin Ko wrote: > > On Jun 20, 2012, at 4:18 AM, David Piegza wrote: > >> Hi, >> >> I'm trying to mock an UploadedFile object and pass it to a controller action. Unfortunately, the mocked object gets stringified in the params hash, so I'm not able to use the mock object in a test. >> >> Is there any way to avoid this stringification for UploadedFile objects? >> >> This has been discussed already on github: https://github.com/rails/rails/pull/1203 >> >> As described, the params are stringified, but it should exclude Rack::Test::UploadedFile: https://github.com/rails/rails/pull/1203#issuecomment-1217081 >> >> Here is a small example: >> >> let(:file) { mock('UploadedFile') } >> >> it "tests something" do >> file.stub(:content_type).and_return 'text/plain' # this won't work >> post :upload, { file: file } # params in controller will be "file" => "#[RSpec::Mock ... ]" >> end >> >> I get a NoMethodError: undefined method `content_type' for "#[RSpec::Mocks::Mock:0x3fe4723a81bc @name=\"file\"]":String >> >> So, how can I test this? >> >> Thanks, >> David >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > Rails has a built-in helper method for this: > http://api.rubyonrails.org/classes/ActionDispatch/TestProcess.html#method-i-fixture_file_upload > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Thu Jun 21 17:12:33 2012 From: lists at ruby-forum.com (n/a n/a) Date: Thu, 21 Jun 2012 19:12:33 +0200 Subject: [rspec-users] File not found Message-ID: <347692d40f90741068b9e6ec97639bc2@ruby-forum.com> I've been trying to learn RSpec using the book The RSpec Book by David Chelimsky but I've been having a problem in Chapter 5 around page 50. I tried running "rspec spec/codebreaker/game_spec.rb --format doc" but it said that codebreaker could not be found. The file spec/codebreaker/game_spec.rb requires spec/spec_helper and spec_helper requires spec/codebreaker. In fact, the whole contents of spec/spec_helper.rb is "require 'codebreaker'". However, spec/codebreaker is a directory not a file and I wonder if this is causing the problem. It seems to me that "require 'codebreaker'" would look for spec/codebreaker.rb, but I can't find anywhere where the book says to define a file called spec/codebreaker.rb. Does anyone know what the problem might be? Can "require 'codebreaker'" make sense if codebreaker is a directory but there is no codebreaker.rb file? -- Posted via http://www.ruby-forum.com/. From jko170 at gmail.com Thu Jun 21 19:03:25 2012 From: jko170 at gmail.com (Justin Ko) Date: Thu, 21 Jun 2012 13:03:25 -0600 Subject: [rspec-users] File not found In-Reply-To: <347692d40f90741068b9e6ec97639bc2@ruby-forum.com> References: <347692d40f90741068b9e6ec97639bc2@ruby-forum.com> Message-ID: <2F0AAB20-6EC8-4E9B-BA20-40897C12320B@gmail.com> On Jun 21, 2012, at 11:12 AM, n/a n/a wrote: > I've been trying to learn RSpec using the book The RSpec Book by David > Chelimsky but I've been having a problem in Chapter 5 around page 50. I > tried running "rspec spec/codebreaker/game_spec.rb --format doc" but it > said that codebreaker could not be found. > > The file spec/codebreaker/game_spec.rb requires spec/spec_helper and > spec_helper requires spec/codebreaker. In fact, the whole contents of > spec/spec_helper.rb is "require 'codebreaker'". However, > spec/codebreaker is a directory not a file and I wonder if this is > causing the problem. It seems to me that "require 'codebreaker'" would > look for spec/codebreaker.rb, but I can't find anywhere where the book > says to define a file called spec/codebreaker.rb. > > Does anyone know what the problem might be? Can "require 'codebreaker'" > make sense if codebreaker is a directory but there is no codebreaker.rb > file? No. `require` is for requiring files. If Ruby cannot find the file, it will raise an error. Can you push your code to Github so we can take a look? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Jun 22 09:34:51 2012 From: lists at ruby-forum.com (Joshua Muheim) Date: Fri, 22 Jun 2012 11:34:51 +0200 Subject: [rspec-users] An open source project with very good use of Cucumber? Message-ID: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> Hey everybody I came here through the RSpec Book, so I grant myself to ask something about Cucumber here. ;) I'm still very new to the topic and read a lot of different opinions about how to do great Cucumber scenarios. Still, I'm a bit unsure as I don't have any experience in using it. So I hoped to be able to look into a few open source projects that use Cucumber the way it was meant to be (without relying on the web_steps.rb etc.)? Thanks a lot for hints. Josh -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jun 22 09:36:52 2012 From: lists at ruby-forum.com (Joshua Muheim) Date: Fri, 22 Jun 2012 11:36:52 +0200 Subject: [rspec-users] response.should have_content("1 movie") does not seem to work for me In-Reply-To: References: Message-ID: It seems I have to use page.should have_content("...") instead of response.should have_content("...") Maybe that's because Capybara is the default engine now and not Webrat? -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jun 22 09:38:28 2012 From: lists at ruby-forum.com (Joshua Muheim) Date: Fri, 22 Jun 2012 11:38:28 +0200 Subject: [rspec-users] Selenium+Autotest: how to run browser in background? In-Reply-To: References: Message-ID: <0b345acb4d606b41648764b5effa7520@ruby-forum.com> Well, didn't find a solution, but using the :chrome driver lets Chrome be activated in the background... See http://collectiveidea.com/blog/archives/2011/09/27/use-chrome-with-cucumber-capybara/ -- Posted via http://www.ruby-forum.com/. From ckponnappa at gmail.com Fri Jun 22 10:46:31 2012 From: ckponnappa at gmail.com (Sidu Ponnappa) Date: Fri, 22 Jun 2012 16:16:31 +0530 Subject: [rspec-users] An open source project with very good use of Cucumber? In-Reply-To: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> References: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> Message-ID: The Rspec codebase is itself a great example of how to use Cucumber correctly, IMO. Are you new to TDD entirely? If yes, then I'd suggest you come up to speed on that first. In my experience, many codebases substitute cucumber specs for TDD which is a bad idea. Best, Sidu. http://c42.in http://twitter.com/ponnappa On 22 June 2012 15:04, Joshua Muheim wrote: > Hey everybody > > I came here through the RSpec Book, so I grant myself to ask something > about Cucumber here. ;) > > I'm still very new to the topic and read a lot of different opinions > about how to do great Cucumber scenarios. Still, I'm a bit unsure as I > don't have any experience in using it. So I hoped to be able to look > into a few open source projects that use Cucumber the way it was meant > to be (without relying on the web_steps.rb etc.)? > > Thanks a lot for hints. > Josh > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lists at ruby-forum.com Fri Jun 22 12:39:18 2012 From: lists at ruby-forum.com (Roger Pack) Date: Fri, 22 Jun 2012 14:39:18 +0200 Subject: [rspec-users] An open source project with very good use of Cucumber? In-Reply-To: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> References: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> Message-ID: redcar uses it, or at least used to, with good results. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Fri Jun 22 12:42:13 2012 From: lists at ruby-forum.com (Joshua Muheim) Date: Fri, 22 Jun 2012 14:42:13 +0200 Subject: [rspec-users] An open source project with very good use of Cucumber? In-Reply-To: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> References: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> Message-ID: You mean this? https://github.com/danlucraft/redcar Having troubles to find the .feature files, though. By the way, a Rails project would be best... :) -- Posted via http://www.ruby-forum.com/. From dchelimsky at gmail.com Fri Jun 22 13:18:02 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 Jun 2012 08:18:02 -0500 Subject: [rspec-users] response.should have_content("1 movie") does not seem to work for me In-Reply-To: References: Message-ID: On Fri, Jun 22, 2012 at 4:36 AM, Joshua Muheim wrote: > It seems I have to use > > page.should have_content("...") > > instead of > > response.should have_content("...") > > Maybe that's because Capybara is the default engine now and not Webrat? While Capybara seems to have become the de facto standard, there is no default (you have to configure one or the other in your app). > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Fri Jun 22 13:21:07 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Fri, 22 Jun 2012 08:21:07 -0500 Subject: [rspec-users] An open source project with very good use of Cucumber? In-Reply-To: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> References: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> Message-ID: On Fri, Jun 22, 2012 at 4:34 AM, Joshua Muheim wrote: > Hey everybody > > I came here through the RSpec Book, so I grant myself to ask something > about Cucumber here. ;) You can ask, but you'll probably have a more well versed Cucumber-using audience on the Cucumber list: https://groups.google.com/forum/?fromgroups#!forum/cukes Cheers, David From pat.maddox at gmail.com Sun Jun 24 17:08:59 2012 From: pat.maddox at gmail.com (Pat Maddox) Date: Sun, 24 Jun 2012 10:08:59 -0700 (PDT) Subject: [rspec-users] An open source project with very good use of Cucumber? In-Reply-To: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> References: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> Message-ID: <71601bd2-f9cd-4183-880f-f81d27b3c901@googlegroups.com> On Friday, June 22, 2012 3:34:51 AM UTC-6, Joshua Muheim wrote: > > Hey everybody > > I came here through the RSpec Book, so I grant myself to ask something > about Cucumber here. ;) > > I'm still very new to the topic and read a lot of different opinions > about how to do great Cucumber scenarios. Still, I'm a bit unsure as I > don't have any experience in using it. So I hoped to be able to look > into a few open source projects that use Cucumber the way it was meant > to be (without relying on the web_steps.rb etc.)? > > Thanks a lot for hints. > Josh > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > As others have pointed out, RSpec has some good cucumber scenarios. Cucumber itself has awesome scenarios. For API-based stuff, Chargify.com has their API described through scenarios (http://docs.chargify.com/api-adjustments). And check out https://www.relishapp.com/ to see a ton of open source projects that use Cucumber for documentation. Pat -------------- next part -------------- An HTML attachment was scrubbed... URL: From kashyap.kmbc at gmail.com Mon Jun 25 07:44:51 2012 From: kashyap.kmbc at gmail.com (Kashyap KMBC) Date: Mon, 25 Jun 2012 13:14:51 +0530 Subject: [rspec-users] An open source project with very good use of Cucumber? In-Reply-To: References: <2e29dfec7d77525c69aff6eafbe7ae14@ruby-forum.com> Message-ID: <8705CF8370F343DF8B2C42B495828269@gmail.com> This: https://github.com/rspec/rspec-core -- Kashyap KMBC On Friday 22 June 2012 at 6:12 PM, Joshua Muheim wrote: > You mean this? > > https://github.com/danlucraft/redcar > > Having troubles to find the .feature files, though. > > By the way, a Rails project would be best... :) > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org (mailto:rspec-users at rubyforge.org) > http://rubyforge.org/mailman/listinfo/rspec-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From avi at kensodev.com Mon Jun 25 22:07:05 2012 From: avi at kensodev.com (Avi Tzurel) Date: Tue, 26 Jun 2012 01:07:05 +0300 Subject: [rspec-users] Rails 3.2 initializers not running when running Rspec without Spork Message-ID: <088E041A338F4510BF47208A01F80471@kensodev.com> Hi, We upgraded our app from 3.0.9 to 3.2.5. Latest Rspec version running of course. When I run rspec command, I get uninitialized constant error. The constant that Rspec is alerting on is in the initializers class. it seems that Rspec is not running the Rails initializers. Anyone else had/know this problem? Any info I can give to better pin point the problem? my spec_helper file is just a regular spec_helper out of the box with some config additions, I removed the entire spork section from there. Thanks you in advance for any assistance. -- Sincerely, Avi Tzurel English blog: http://www.kensodev.com Hebrew Blog: http://he.kensodev.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Mon Jun 25 22:25:04 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Jun 2012 18:25:04 -0400 Subject: [rspec-users] Rails 3.2 initializers not running when running Rspec without Spork In-Reply-To: <088E041A338F4510BF47208A01F80471@kensodev.com> References: <088E041A338F4510BF47208A01F80471@kensodev.com> Message-ID: On Mon, Jun 25, 2012 at 6:07 PM, Avi Tzurel wrote: > Hi, > > We upgraded our app from 3.0.9 to 3.2.5. > Latest Rspec version running of course. > > When I run rspec command, I get uninitialized constant error. > The constant that Rspec is alerting on is in the initializers class. > > it seems that Rspec is not running the Rails initializers. > Anyone else had/know this problem? > > Any info I can give to better pin point the problem? > > my spec_helper file is just a regular spec_helper out of the box with some > config additions, I removed the entire spork section from there. Please make helping you easier by posting actual code and actual error messages. Cheers, David From avi at kensodev.com Mon Jun 25 22:30:30 2012 From: avi at kensodev.com (Avi Tzurel) Date: Tue, 26 Jun 2012 01:30:30 +0300 Subject: [rspec-users] Rails 3.2 initializers not running when running Rspec without Spork In-Reply-To: References: <088E041A338F4510BF47208A01F80471@kensodev.com> Message-ID: <4ACBD38268D94ACDA21E71B015D6DC78@kensodev.com> Sure, no problem here's the error message https://gist.github.com/2991793 This is my spec_helper file https://gist.github.com/2991803 The class that is missing is Web which actually does exist in initializers https://gist.github.com/2991809 -- Sincerely, Avi Tzurel English blog: http://www.kensodev.com Hebrew Blog: http://he.kensodev.com On Tuesday, June 26, 2012 at 1:25 AM, David Chelimsky wrote: > On Mon, Jun 25, 2012 at 6:07 PM, Avi Tzurel wrote: > > Hi, > > > > We upgraded our app from 3.0.9 to 3.2.5. > > Latest Rspec version running of course. > > > > When I run rspec command, I get uninitialized constant error. > > The constant that Rspec is alerting on is in the initializers class. > > > > it seems that Rspec is not running the Rails initializers. > > Anyone else had/know this problem? > > > > Any info I can give to better pin point the problem? > > > > my spec_helper file is just a regular spec_helper out of the box with some > > config additions, I removed the entire spork section from there. > > > > > Please make helping you easier by posting actual code and actual error messages. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org (mailto:rspec-users at rubyforge.org) > http://rubyforge.org/mailman/listinfo/rspec-users > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From avi at kensodev.com Mon Jun 25 22:49:39 2012 From: avi at kensodev.com (Avi Tzurel) Date: Tue, 26 Jun 2012 01:49:39 +0300 Subject: [rspec-users] Rails 3.2 initializers not running when running Rspec without Spork In-Reply-To: <4ACBD38268D94ACDA21E71B015D6DC78@kensodev.com> References: <088E041A338F4510BF47208A01F80471@kensodev.com> <4ACBD38268D94ACDA21E71B015D6DC78@kensodev.com> Message-ID: Problem solved (although I am not sure where the bug is and if it's a bug). the initializers folder had modules defined in it (Facebook, Web). Those modules were not loading with Rails when Rspec was loading the environment and were not defined as modules in the constants. When I moved those modules to the lib folder (where they should have been in the first place), rspec ran with no problem at all. -- Sincerely, Avi Tzurel English blog: http://www.kensodev.com Hebrew Blog: http://he.kensodev.com On Tuesday, June 26, 2012 at 1:30 AM, Avi Tzurel wrote: > Sure, no problem > > here's the error message > https://gist.github.com/2991793 > > This is my spec_helper file > https://gist.github.com/2991803 > > The class that is missing is Web which actually does exist in initializers > https://gist.github.com/2991809 > > -- > Sincerely, > Avi Tzurel > > English blog: http://www.kensodev.com > Hebrew Blog: http://he.kensodev.com > > > > On Tuesday, June 26, 2012 at 1:25 AM, David Chelimsky wrote: > > > On Mon, Jun 25, 2012 at 6:07 PM, Avi Tzurel wrote: > > > Hi, > > > > > > We upgraded our app from 3.0.9 to 3.2.5. > > > Latest Rspec version running of course. > > > > > > When I run rspec command, I get uninitialized constant error. > > > The constant that Rspec is alerting on is in the initializers class. > > > > > > it seems that Rspec is not running the Rails initializers. > > > Anyone else had/know this problem? > > > > > > Any info I can give to better pin point the problem? > > > > > > my spec_helper file is just a regular spec_helper out of the box with some > > > config additions, I removed the entire spork section from there. > > > > > > > > > Please make helping you easier by posting actual code and actual error messages. > > > > Cheers, > > David > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org (mailto:rspec-users at rubyforge.org) > > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Jun 26 00:33:21 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 25 Jun 2012 20:33:21 -0400 Subject: [rspec-users] Rails 3.2 initializers not running when running Rspec without Spork In-Reply-To: References: <088E041A338F4510BF47208A01F80471@kensodev.com> <4ACBD38268D94ACDA21E71B015D6DC78@kensodev.com> Message-ID: On Mon, Jun 25, 2012 at 6:49 PM, Avi Tzurel wrote: > Problem solved (although I am not sure where the bug is and if it's a bug). > > the initializers folder had modules defined in it (Facebook, Web). > Those modules were not loading with Rails when Rspec was loading the > environment and were not defined as modules in the constants. > > When I moved those modules to the lib folder (where they should have been in > the first place), rspec ran with no problem at all. Glad you fixed the problem. In terms of the diff behavior, this is just a guess, but it sounds like between 3.0.9 and 3.2.5 Rails stopped including config/initializers in the autoload paths in the test environment. If that's the case, and you want them loaded, you can always do it yourself in config/environments/test.rb. Cheers, David > > > > -- > Sincerely, > Avi Tzurel > > > English blog: http://www.kensodev.com > Hebrew Blog: http://he.kensodev.com > > On Tuesday, June 26, 2012 at 1:30 AM, Avi Tzurel wrote: > > Sure, no problem > > here's the error message > https://gist.github.com/2991793 > > This is my spec_helper file > https://gist.github.com/2991803 > > The class that is missing is Web which actually does exist in initializers > https://gist.github.com/2991809 > > -- > Sincerely, > Avi Tzurel > > English blog: http://www.kensodev.com > Hebrew Blog: http://he.kensodev.com > > On Tuesday, June 26, 2012 at 1:25 AM, David Chelimsky wrote: > > On Mon, Jun 25, 2012 at 6:07 PM, Avi Tzurel wrote: > > Hi, > > We upgraded our app from 3.0.9 to 3.2.5. > Latest Rspec version running of course. > > When I run rspec command, I get uninitialized constant error. > The constant that Rspec is alerting on is in the initializers class. > > it seems that Rspec is not running the Rails initializers. > Anyone else had/know this problem? > > Any info I can give to better pin point the problem? > > my spec_helper file is just a regular spec_helper out of the box with some > config additions, I removed the entire spork section from there. > > > Please make helping you easier by posting actual code and actual error > messages. > > Cheers, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From farheen at deeproot.co.in Tue Jun 26 11:40:40 2012 From: farheen at deeproot.co.in (farheen at deeproot.co.in) Date: Tue, 26 Jun 2012 17:10:40 +0530 Subject: [rspec-users] search controller Message-ID: <33d0c8514c26b0370f46a9dcf18e7e90.squirrel@anubhav.deeproot.co.in> Hi all, having problems to mock params for the following controller, need help def index if params[:q].present? @q = params[:q] @field = params[:field] case @field when "filenames" @attachments = Attachment.where( :file_name => /#{@q}/i ) @documents = Array.new @attachments.each do |a| @documents << a.document end @documents.uniq! when "vendor_code", "document_number", "batch_number", "cheque_number" @documents = Document.where( @field => @q ) end puts "@documents = #{@documents.inspect}" end end Regards, Farheen Zahara From lists at ruby-forum.com Wed Jun 27 16:59:37 2012 From: lists at ruby-forum.com (Jaques Marinis) Date: Wed, 27 Jun 2012 18:59:37 +0200 Subject: [rspec-users] Watch NFL Live Games 2012 Season - NFL Football Online Message-ID: This package has a quickly download method which takes under Two min's to complete. The fast download is really because the actual package will be mild and adequate because it doesn't have virtually just about almost every undesirable data data attached with this at all. This bundle is created so that no allow every other data data apart from the ones from television upabout computer just. The majority of the additional comparable computer tv set bundles may contain adware and adware and spyware which could damage your pc. Watch NFL Games Online: http://www.watchnflgamesonlinehd.com The application can also be user friendly given that all the channels are arranged in line with the countries they're broadcast from after which based on the encoding that they generally provide. This will make it quite simple for you to find any kind of channel that you would like to look at in seconds among the over 3500 of them. This can be a really risk-free bundle for a similar reasons what has very light and doesn't contain any extra documents besides those of personal computer tv. The program is made such that it could be streamed on the internet and is extremely rigid around the files in their content material that there is no way it'll permit the bug presently right now generally at this time now certainly , truth be told furthermore in that respect so here at all. You need to have a well balanced internet connection to watch the actual loading online television feeds. The internet should be a top velocity dsl or even high speed link that have an improved capacity to manage large picture data data and ensure quicker buffering and therefore any seamless supply. You can start having rates of speed coming via 128kbps or even go up to 1mbps or more. Methods to view free american footbal 2011 reside streaming on the web television channels at no cost upabout pc: The pc specs You'll be able to watch stay buffering american footbal soccer on the net when you have some type of computer having rates greater than 500mhz and a Ram memory memory of atleast 600mb. The pc needs to have the computer processor regarding Pentium Four, Deb, Double primary or any other trustworthy one. They're however very basic technical features which usually any kind of personal laptop or computer system must already be having. -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Jun 27 19:34:48 2012 From: lists at ruby-forum.com (Kathie Esteptvxw) Date: Wed, 27 Jun 2012 21:34:48 +0200 Subject: [rspec-users] Watch Spain vs Portugal live online free stream Euro Semifinal 2012 Message-ID: <34354faae7c7462f62d77abdad122dc5@ruby-forum.com> Watch Spain Vs Portugal live stream, Spain Vs Portugal EURO 2012 football matches online, Spain Vs Portugal Live football online on pc, Spain Vs Portugal Live video streaming online, Spain Vs Portugal Live, Spain Vs Portugal Live football stream, Spain Vs Portugal Live football online http://watch-soccer-tv.com/ Spain Vs Portugal live conference championship games on pc TV.Watch Spain Vs Portugal Live Stream Online Preseason Internet TV partner(s) are CBS, Fox, NBC, ESPN, and EURO 2012 Network. Football Game EURO 2012 also treated as National Football League is consider as the highest level of professional American football in the United States. EURO 2012 was first formed by eleven teams in 1920 and the Commissioner was Roger Good ell Founded August 20, 1920, in Canton, Ohio. Most titles go to Spain Vs Portugal (13 titles). At first it was the American Professional Football Association, with the league changing its name to the National Football League in 1922. http://watch-soccer-tv.com/ Spain Vs Portugal Game Preview: Teams Name: Spain Vs Portugal Competition Events: National Football league (EURO 2012) Saut?s of Game: Spain Vs Portugal live TV Partners: CBS, Fox, NBC, ESPN, EURO 2012 Network. http://watch-soccer-tv.com/ Watch Live FREE Online >> http://watch-soccer-tv.com/ -- Posted via http://www.ruby-forum.com/. From dennis.kuczynski at gmail.com Thu Jun 28 19:11:19 2012 From: dennis.kuczynski at gmail.com (Dennis Kuczynski) Date: Thu, 28 Jun 2012 15:11:19 -0400 Subject: [rspec-users] Issue when testing ActiveRecord after_commit callbacks Message-ID: In an ActiveRecord model, I have an after_commit callback (:enqueue_job) which places a job on my background processing queue (Sidekiq) To test that the callback was firing when the database transaction was committed, I was using: object.should_receive(:enqueue_job) #should pass Which seems to work. However, to test that the test was valid, I attempted object.should_not_receive(:enqueue_job) #should fail But this did not fail. I tracked this down to ActiveRecord's DatabaseStatements' commit_transaction_records method, which ends up eating the RSpec Negative Method Expectation Exception (which fails fast) https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb If the negative method expectation did not fail fast, the test would probably work, but is there a better pattern for testing after_commit logic? (This was with rspec-mocks 2.10.1. use_transactional_fixtures was turned off to enable the callback.) Thanks, Dennis -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Fri Jun 29 01:48:47 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 28 Jun 2012 20:48:47 -0500 Subject: [rspec-users] Issue when testing ActiveRecord after_commit callbacks In-Reply-To: References: Message-ID: On Thu, Jun 28, 2012 at 2:11 PM, Dennis Kuczynski wrote: > In an ActiveRecord model, I have an after_commit callback (:enqueue_job) > which places a job on my background processing queue (Sidekiq) > > To test that the callback was firing when the database transaction > was?committed, I was using: > > object.should_receive(:enqueue_job) #should pass > > Which seems to work. ?However, to test that the test was valid, I attempted > > object.should_not_receive(:enqueue_job) #should fail > > But this did not fail. > > I tracked this down to ActiveRecord's > DatabaseStatements'?commit_transaction_records method, which ends up eating > the RSpec Negative Method Expectation Exception (which fails fast) > https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb > > If the negative method expectation did not fail fast, the test would > probably work, but is there a better pattern for testing after_commit logic? > > (This was with rspec-mocks 2.10.1. ?use_transactional_fixtures was turned > off to enable the callback.) > > Thanks, > Dennis Nice work finding the source of the problem. I guess you could do something like this: received = false obj.stub(:enqueue_job) do |*| received = true end # ... received.should be_true It ain't pretty, but it should work (should fail properly if you say `received.should be_false`). HTH, David From dennis.kuczynski at gmail.com Fri Jun 29 16:32:25 2012 From: dennis.kuczynski at gmail.com (Dennis Kuczynski) Date: Fri, 29 Jun 2012 09:32:25 -0700 (PDT) Subject: [rspec-users] Issue when testing ActiveRecord after_commit callbacks In-Reply-To: References: Message-ID: <241d09b3-27b0-4692-956f-ab8cb5b8ff94@googlegroups.com> Thanks, that works. After thinking about what I was testing, I decided that I should really have just been checking that the background job ends up in the queue in the first place. So for my new tests, I'm ignoring all the messages within the after_commit, and just checking that the job is in the queue after the commit completes. -Dennis On Thursday, June 28, 2012 9:48:47 PM UTC-4, dchel... at gmail.com wrote: > > On Thu, Jun 28, 2012 at 2:11 PM, Dennis Kuczynski > wrote: > > In an ActiveRecord model, I have an after_commit callback (:enqueue_job) > > which places a job on my background processing queue (Sidekiq) > > > > To test that the callback was firing when the database transaction > > was committed, I was using: > > > > object.should_receive(:enqueue_job) #should pass > > > > Which seems to work. However, to test that the test was valid, I > attempted > > > > object.should_not_receive(:enqueue_job) #should fail > > > > But this did not fail. > > > > I tracked this down to ActiveRecord's > > DatabaseStatements' commit_transaction_records method, which ends up > eating > > the RSpec Negative Method Expectation Exception (which fails fast) > > > https://github.com/rails/rails/blob/3-2-stable/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb > > > > If the negative method expectation did not fail fast, the test would > > probably work, but is there a better pattern for testing after_commit > logic? > > > > (This was with rspec-mocks 2.10.1. use_transactional_fixtures was > turned > > off to enable the callback.) > > > > Thanks, > > Dennis > > Nice work finding the source of the problem. I guess you could do > something like this: > > received = false > obj.stub(:enqueue_job) do |*| > received = true > end > # ... > received.should be_true > > It ain't pretty, but it should work (should fail properly if you say > `received.should be_false`). > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: