From lille.penguini at gmail.com Wed Feb 1 20:26:33 2012 From: lille.penguini at gmail.com (Lille) Date: Wed, 1 Feb 2012 17:26:33 -0800 (PST) Subject: [rspec-users] getting ActionController::RoutingError when I test namespaced controllers Message-ID: Hey folks, Using 2.6, I have functional tests arranged in my spec/controllers directory according to their namespace in my Rails 3 app/controllers directory, e.g., api/some_controller_spec.rb describe Api::SomeController, ... Well, when I run rspec at the directory level, e.g., rspec spec/ controllers/api the test behavior is normal. When I try to run all tests from the spec/controllers root, however, I get tons of failures due to ActionController::RoutingError. What is the fix? Thanks, Lille From jko170 at gmail.com Thu Feb 2 01:55:06 2012 From: jko170 at gmail.com (Justin Ko) Date: Wed, 1 Feb 2012 23:55:06 -0700 Subject: [rspec-users] getting ActionController::RoutingError when I test namespaced controllers In-Reply-To: References: Message-ID: <16719F20-DB87-41A5-BBC3-4F96159ACC4B@gmail.com> On Feb 1, 2012, at 6:26 PM, Lille wrote: > Hey folks, > > Using 2.6, I have functional tests arranged in my spec/controllers > directory according to their namespace in my Rails 3 app/controllers > directory, e.g., > > api/some_controller_spec.rb > > describe Api::SomeController, ... > > Well, when I run rspec at the directory level, e.g., rspec spec/ > controllers/api the test behavior is normal. When I try to run all > tests from the spec/controllers root, however, I get tons of failures > due to ActionController::RoutingError. > > What is the fix? > > Thanks, > > Lille > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users We're going to need more info than this. 1.) What is the exact error (paste the backtrace)? 2.) What are the exact commands you are running, and from what directory? Here are some things you can try before you reply again: 1.) Does this controller action work in development mode? 2.) Does the test log show that the correct action/controller is being hit? What is it responding with? That should be a good start. From tribes.romain at gmail.com Thu Feb 2 04:20:01 2012 From: tribes.romain at gmail.com (Romain Tribes) Date: Thu, 2 Feb 2012 10:20:01 +0100 Subject: [rspec-users] Game development: how to test interactions like an attack? Message-ID: Hello, I'm writing webgames with Rails and I want to test my code (and even TDD) but I'm really stuck figuring what to test. I read a lot of articles on the subject but I still don't know what to do in my case: how to start? For instance, a simple interaction in most game: a character attacks another one. What should be tested? With words, here is what I can say about an attack: It's an action from an attacker to a target. The attacker may have a weapon and the target may have an armor. In order to be successful, the attacker must hit the target, according to the combat skill of each actor and the precision of the weapon. When the target is hit, it receives damages according to the attacker power, the weapon damages and the resistance. A part of these damages may be absorbed by it's armor. So, what could my specs be with that? I really can't start? :( Thanks for your help! From tribes.romain at gmail.com Thu Feb 2 04:50:56 2012 From: tribes.romain at gmail.com (Romain Tribes) Date: Thu, 2 Feb 2012 10:50:56 +0100 Subject: [rspec-users] Game development: how to test interactions like an attack? Message-ID: <8CA63504-233E-4D5A-9A99-A3635668218C@gmail.com> Hello, I'm writing webgames with Rails and I want to test my code (and even TDD) but I'm really stuck figuring what to test. I read a lot of articles on the subject but I still don't know what to do in my case: how to start? For instance, a simple interaction in most game: a character attacks another one. What should be tested? With words, here is what I can say about an attack: It's an action from an attacker to a target. The attacker may have a weapon and the target may have an armor. In order to be successful, the attacker must hit the target, according to the combat skill of each actor and the precision of the weapon. When the target is hit, it receives damages according to the attacker power, the weapon damages and the resistance. A part of these damages may be absorbed by it's armor. So, what could my specs be with that? I really can't start? :( Thanks for your help! From matt at mattwynne.net Thu Feb 2 05:45:22 2012 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 2 Feb 2012 10:45:22 +0000 Subject: [rspec-users] Game development: how to test interactions like an attack? In-Reply-To: <8CA63504-233E-4D5A-9A99-A3635668218C@gmail.com> References: <8CA63504-233E-4D5A-9A99-A3635668218C@gmail.com> Message-ID: On 2 Feb 2012, at 09:50, Romain Tribes wrote: > Hello, > > I'm writing webgames with Rails and I want to test my code (and even TDD) but I'm really stuck figuring what to test. > I read a lot of articles on the subject but I still don't know what to do in my case: how to start? > > For instance, a simple interaction in most game: a character attacks another one. What should be tested? > With words, here is what I can say about an attack: > > It's an action from an attacker to a target. > The attacker may have a weapon and the target may have an armor. > In order to be successful, the attacker must hit the target, according to the combat skill of each actor and the precision of the weapon. > When the target is hit, it receives damages according to the attacker power, the weapon damages and the resistance. > A part of these damages may be absorbed by it's armor. > So, what could my specs be with that? I really can't start? :( Have you started to design a domain model for this? Could we see a picture? 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 julian at leviston.net Thu Feb 2 06:36:32 2012 From: julian at leviston.net (Julian Leviston) Date: Thu, 2 Feb 2012 22:36:32 +1100 Subject: [rspec-users] Game development: how to test interactions like an attack? In-Reply-To: References: Message-ID: <5BFE63AC-347A-487B-9E1D-049E094D8916@leviston.net> I always find it's very good to start simply. Make the simplest spec you can imagine, then the next, and so on... What is a spec? Some of this stuff might seem so obvious... for example... when you start playing your game, you expect that it'll present you with something... write a test for that. Basically any time you're doing something yourself to run your code, you should be able to spec it. That way you don't have to manually test things out. So I've got a basic question: have you started building your game? Do you have any idea of the requirements at all? Julian On 02/02/2012, at 8:20 PM, Romain Tribes wrote: > Hello, > > I'm writing webgames with Rails and I want to test my code (and even TDD) but I'm really stuck figuring what to test. > I read a lot of articles on the subject but I still don't know what to do in my case: how to start? > > For instance, a simple interaction in most game: a character attacks another one. What should be tested? > With words, here is what I can say about an attack: > > It's an action from an attacker to a target. > The attacker may have a weapon and the target may have an armor. > In order to be successful, the attacker must hit the target, according to the combat skill of each actor and the precision of the weapon. > When the target is hit, it receives damages according to the attacker power, the weapon damages and the resistance. > A part of these damages may be absorbed by it's armor. > So, what could my specs be with that? I really can't start? :( > > Thanks for your help! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jko170 at gmail.com Thu Feb 2 06:44:31 2012 From: jko170 at gmail.com (Justin Ko) Date: Thu, 2 Feb 2012 04:44:31 -0700 Subject: [rspec-users] Game development: how to test interactions like an attack? In-Reply-To: References: Message-ID: <20A38F7B-2210-4C48-9A3D-5C887E0E2035@gmail.com> On Feb 2, 2012, at 2:20 AM, Romain Tribes wrote: > Hello, > > I'm writing webgames with Rails and I want to test my code (and even TDD) but I'm really stuck figuring what to test. > I read a lot of articles on the subject but I still don't know what to do in my case: how to start? > > For instance, a simple interaction in most game: a character attacks another one. What should be tested? > With words, here is what I can say about an attack: > > It's an action from an attacker to a target. > The attacker may have a weapon and the target may have an armor. > In order to be successful, the attacker must hit the target, according to the combat skill of each actor and the precision of the weapon. > When the target is hit, it receives damages according to the attacker power, the weapon damages and the resistance. > A part of these damages may be absorbed by it's armor. What you just listed ^^ is the behavior of the system. The great thing about BDD is you can start _without_ needing to know the implementation details. The first step you can take is to setup some high level, outside-in testing. These tests interact with your program the same way as a user would. You'll hear these tests called many different names: acceptance, integration, functional, application, system, etc. I don't believe there is a correct term anymore, as everyone interprets the definitions differently. In the case of Ruby, you have excellent tools available for these tests: RSpec, MiniTest, Cucumber (used with RSpec or MiniTest). Personally, I prefer to use only RSpec, so let's use that as an example. Pick a simple behavior to start off with. A good one is something that the user _has_ to do first. For example, in a Rails app, this would be signing up: # project/spec/functional/signing_up_spec.rb describe 'Signing up' do context 'by visiting the sign up page' do before { go_to_the_sign_up_page } context 'and submitting the sign up form with valid data' do before { submit_the_sign_up_form_with_valid_data } it 'redirects to the dashboard page' do expect_to_be_on_the_dashboard_page end end end end Great, now I have my first spec. Obviously, if you tried to run this, it would completely fail since you haven't written any implementation code. At this point, writing more high level tests doesn't make sense because we haven't got the first one to pass. Let's focus on doing that. Alright, so as we can see from our spec, the first thing it does is "visits the sign up page". Okay, we need a sign up page. The sign up page is a single entity, and we're no longer concerned with how it interacts with other parts of the system. Therefore, we need to drop down to the "unit" level, and subsequently create a unit test for this entity: # project/spec/unit/sign_up_page_spec.rb describe SignUpPage do context 'given a coupon code' do it 'sets a hidden field called "coupon_code" with its value as the code' do expect_a_hidden_field_with_a_particular_value end end end Notice how we are still focusing on behavior. The difference is, we are only concerned with the behavior of just this entity/unit, not on its role or interactions in the system. Because of this, you'll sometimes see people call them "isolated unit tests". After you get the unit test to pass, you can check to see if the high level test can pass. The BDD process involves jumping back and forth between unit and high level tests. However, the high level tests are _always_ your guide. You drive the high level tests, and in turn they drive the unit tests. I think this is enough to get you started, but looking at your post, this could be your first high level test: describe 'Attacking' do let!(:attacker) { create_attacker } let!(:target) { create_target } context 'on the playing page' do before { go_to_the_playing_page } describe 'when an attacker hits a target' do before { hit_target(attacker, target) } it 'displays the damages on the target' do expect_page_to_display_the_correct_damage_amount end end end end > When the target is hit, it receives damages according to the attacker power, the weapon damages and the resistance. > So, what could my specs be with that? I really can't start? :( > > Thanks for your help! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From lille.penguini at gmail.com Thu Feb 2 07:22:36 2012 From: lille.penguini at gmail.com (Lille) Date: Thu, 2 Feb 2012 04:22:36 -0800 (PST) Subject: [rspec-users] getting ActionController::RoutingError when I test namespaced controllers In-Reply-To: <16719F20-DB87-41A5-BBC3-4F96159ACC4B@gmail.com> References: <16719F20-DB87-41A5-BBC3-4F96159ACC4B@gmail.com> Message-ID: OK, Given spec/controllers and given this is typical of the structure in my functional testing subdirectories... > > api/some_controller_spec.rb > > > ? describe Api::SomeController, ... ...when I attempt to test everything in the subdirectories from the root using this command -- rspec spec/controllers, I get the following error for every test in the subdirectories: ActionController::RoutingError: No route matches {:controller=>..., :action=>...} Meanwhile, running rspec at each subdirectory yields expected results and the controllers function in development. So, it feels like an rspec configuration thing that I need to adjust to account for the subdirectories, but what? Thanks, Lille From dchelimsky at gmail.com Thu Feb 2 08:50:46 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 2 Feb 2012 07:50:46 -0600 Subject: [rspec-users] getting ActionController::RoutingError when I test namespaced controllers In-Reply-To: References: <16719F20-DB87-41A5-BBC3-4F96159ACC4B@gmail.com> Message-ID: <2FFED119-4CC5-4581-A7D5-05E604C2B80F@gmail.com> On Feb 2, 2012, at 6:22 AM, Lille wrote: > OK, > > Given spec/controllers and given this is typical of the structure in > my functional testing subdirectories... > >>> api/some_controller_spec.rb >> >>> describe Api::SomeController, ... > > ...when I attempt to test everything in the subdirectories from the > root using this command -- rspec spec/controllers, I get the following > error for every test in the subdirectories: > > ActionController::RoutingError: > No route matches {:controller=>..., :action=>...} > > Meanwhile, running rspec at each subdirectory yields expected results > and the controllers function in development. > > So, it feels like an rspec configuration thing that I need to adjust > to account for the subdirectories, but what? Lille, This is no more clear than your original post. Justin asked you for the error and you didn't post it. He asked for the commands and the directories you were running them from and you described them again instead of just pasting them into the email. When you say "running rspec at each subdirectory", I don't know if you mean: rspec spec/controllers/sub1 or if you mean cd spec/constrollers/sub1 rspec So please copy the precise commands as they appear in your terminal window along with the backtrace you're getting when they fail. Otherwise we're just guessing here, and it's a waste of everybody's time. Cheers, David From lists at iDIAcomputing.com Thu Feb 2 12:24:17 2012 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Thu, 02 Feb 2012 12:24:17 -0500 Subject: [rspec-users] Game development: how to test interactions like an attack? In-Reply-To: <8CA63504-233E-4D5A-9A99-A3635668218C@gmail.com> References: <8CA63504-233E-4D5A-9A99-A3635668218C@gmail.com> Message-ID: <4F2AC6C1.9090206@iDIAcomputing.com> Romain, On 2/2/12 4:50 AM, Romain Tribes wrote: > Hello, > > I'm writing webgames with Rails and I want to test my code (and even TDD) but I'm really stuck figuring what to test. > I read a lot of articles on the subject but I still don't know what to do in my case: how to start? > > For instance, a simple interaction in most game: a character attacks another one. What should be tested? > With words, here is what I can say about an attack: > > It's an action from an attacker to a target. > The attacker may have a weapon and the target may have an armor. > In order to be successful, the attacker must hit the target, > according to the combat skill of each actor and the precision of the > weapon. > When the target is hit, it receives damages according to the attacker > power, the weapon damages and the resistance. > A part of these damages may be absorbed by it's armor. > So, what could my specs be with that? I really can't start? :( Start with the simplest scenario you can imagine. What would happen if the attacker had no weapon and the target had no armor? I can imagine scenarios with each having little skill, with each having great skill, and the two unbalanced scenarios where one has great skill and the other little. Is it possible for the attacker to miss? - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From lille.penguini at gmail.com Thu Feb 2 19:06:15 2012 From: lille.penguini at gmail.com (Lille) Date: Thu, 2 Feb 2012 16:06:15 -0800 (PST) Subject: [rspec-users] getting ActionController::RoutingError when I test namespaced controllers In-Reply-To: <2FFED119-4CC5-4581-A7D5-05E604C2B80F@gmail.com> References: <16719F20-DB87-41A5-BBC3-4F96159ACC4B@gmail.com> <2FFED119-4CC5-4581-A7D5-05E604C2B80F@gmail.com> Message-ID: <8235af22-fe4f-40a3-982b-5fae5b65fbdf@l1g2000vbc.googlegroups.com> When I use these commands from the application root rspec spec rspec spec/controllers I get errors (an example will be shown below) for every controller test in my subdirectory spec/controllers/api/beta, where the controller namespacing is carried over in any test as follows describe Api::Beta1::ThingController ... Somehow, I do NOT get any errors for the tests in the subdirectory when I run this command from the application root rspec spec/controllers/api/beta Here is an example of the error I get, with backtrace: 23) Api::Beta1::ThingController#loan server-side failure should have status code 500 and expected message body Failure/Error: response = post(action, params) ActionController::RoutingError: No route matches {:controller=>"api/beta1/ thing", :action=>"loan"} # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:464:in `raise_routing_error' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:460:in `rescue in generate' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:452:in `generate' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:493:in `generate' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:489:in `generate_extras' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:485:in `extra_keys' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_controller/test_case.rb:145:in `assign_parameters' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_controller/test_case.rb:438:in `process' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_controller/test_case.rb:49:in `process' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ actionpack-3.1.0/lib/action_controller/test_case.rb:370:in `post' # ./spec/controllers/api/beta1/thing_controller_spec.rb:72:in `raw_post' # ./spec/controllers/api/beta1/thing_controller_spec.rb:57:in `block (3 levels) in ' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/hooks.rb:35:in `instance_eval' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/hooks.rb:35:in `run_in' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/hooks.rb:70:in `block in run_all' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/hooks.rb:70:in `each' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/hooks.rb:70:in `run_all' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/hooks.rb:116:in `run_hook' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:221:in `block in eval_before_eachs' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:221:in `each' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:221:in `eval_before_eachs' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example.rb:145:in `run_before_each' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example.rb:47:in `block in run' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example.rb:107:in `with_around_hooks' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example.rb:45:in `run' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:294:in `block in run_examples' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:290:in `map' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:290:in `run_examples' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:262:in `run' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:263:in `block in run' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:263:in `map' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/example_group.rb:263:in `run' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/command_line.rb:24:in `block (2 levels) in run' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/command_line.rb:24:in `map' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/command_line.rb:24:in `block in run' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/reporter.rb:12:in `report' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/command_line.rb:21:in `run' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/runner.rb:69:in `run' # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun' I missed this issue when developing my tests, because I was running them using the command that succeeds. Now, I'm in trouble because I want to step back and test everything with a simple command from the app root: rpsec spec (Sorry to any bothered readers for any undue brevity in the previous post-response cycle, but I've assumed that the type of error (RoutingError) in combination with the way rspec works and fails for my functional tests was adequate to suggest a fix.) Thanks, Lille From tribes.romain at gmail.com Thu Feb 2 20:06:45 2012 From: tribes.romain at gmail.com (Romain Tribes) Date: Thu, 2 Feb 2012 17:06:45 -0800 (PST) Subject: [rspec-users] Game development: how to test interactions like an attack? In-Reply-To: References: Message-ID: <5877391.263.1328231205274.JavaMail.geo-discussion-forums@yqnd19> Thanks for your attention and your answers! I worked on that the whole afternoon: it's really timeconsuming when you are not used to test! My code is on GitHub : https://github.com/Sephi-Chan/LearnToTest As I said I read a lot of stuff about testing and TDD. Unfortunately, most of the time it's for systems with very little business logic and I don't believe I can learn good software design with simplistic systems (todo-lists/blogs/...). It's why I want to build something more interesting and focus on the business logic: not the controllers/views stuff. Anyway I hope you'll keep helping me to review and give me precious advices. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Feb 2 20:23:36 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 2 Feb 2012 19:23:36 -0600 Subject: [rspec-users] getting ActionController::RoutingError when I test namespaced controllers In-Reply-To: <8235af22-fe4f-40a3-982b-5fae5b65fbdf@l1g2000vbc.googlegroups.com> References: <16719F20-DB87-41A5-BBC3-4F96159ACC4B@gmail.com> <2FFED119-4CC5-4581-A7D5-05E604C2B80F@gmail.com> <8235af22-fe4f-40a3-982b-5fae5b65fbdf@l1g2000vbc.googlegroups.com> Message-ID: On Feb 2, 2012, at 6:06 PM, Lille wrote: > When I use these commands from the application root > > rspec spec > rspec spec/controllers > > I get errors (an example will be shown below) for every controller > test in my subdirectory spec/controllers/api/beta, where the > controller namespacing is carried over in any test as follows > > describe Api::Beta1::ThingController ... > > Somehow, I do NOT get any errors for the tests in the subdirectory > when I run this command from the application root > > rspec spec/controllers/api/beta > > Here is an example of the error I get, with backtrace: > > 23) Api::Beta1::ThingController#loan server-side failure should have > status code 500 and expected message body > Failure/Error: response = post(action, params) > ActionController::RoutingError: > No route matches {:controller=>"api/beta1/ > thing", :action=>"loan"} > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:464:in > `raise_routing_error' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:460:in > `rescue in generate' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:452:in > `generate' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:493:in > `generate' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:489:in > `generate_extras' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:485:in > `extra_keys' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_controller/test_case.rb:145:in > `assign_parameters' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_controller/test_case.rb:438:in `process' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_controller/test_case.rb:49:in `process' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_controller/test_case.rb:370:in `post' > # ./spec/controllers/api/beta1/thing_controller_spec.rb:72:in > `raw_post' > # ./spec/controllers/api/beta1/thing_controller_spec.rb:57:in > `block (3 levels) in ' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:35:in `instance_eval' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:35:in `run_in' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:70:in `block in run_all' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:70:in `each' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:70:in `run_all' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:116:in `run_hook' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:221:in `block in > eval_before_eachs' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:221:in `each' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:221:in `eval_before_eachs' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example.rb:145:in `run_before_each' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example.rb:47:in `block in run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example.rb:107:in `with_around_hooks' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example.rb:45:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:294:in `block in > run_examples' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:290:in `map' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:290:in `run_examples' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:262:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:263:in `block in run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:263:in `map' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:263:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/command_line.rb:24:in `block (2 levels) in > run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/command_line.rb:24:in `map' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/command_line.rb:24:in `block in run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/reporter.rb:12:in `report' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/command_line.rb:21:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/runner.rb:69:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun' > > I missed this issue when developing my tests, because I was running > them using the command that succeeds. Now, I'm in trouble because I > want to step back and test everything with a simple command from the > app root: > > rspec spec Thanks for the more detailed response. It definitely helps to understand what you're doing more clearly, though it sadly doesn't shed enough light on the problem (at least for me - this is not a problem I remember hearing of before). Can you post the relevant parts of config/routes.rb and the spec that's failing in the example above? From apremdas at gmail.com Thu Feb 2 22:57:13 2012 From: apremdas at gmail.com (Andrew Premdas) Date: Fri, 3 Feb 2012 03:57:13 +0000 Subject: [rspec-users] getting ActionController::RoutingError when I test namespaced controllers In-Reply-To: <8235af22-fe4f-40a3-982b-5fae5b65fbdf@l1g2000vbc.googlegroups.com> References: <16719F20-DB87-41A5-BBC3-4F96159ACC4B@gmail.com> <2FFED119-4CC5-4581-A7D5-05E604C2B80F@gmail.com> <8235af22-fe4f-40a3-982b-5fae5b65fbdf@l1g2000vbc.googlegroups.com> Message-ID: On 3 February 2012 00:06, Lille wrote: > When I use these commands from the application root > > rspec spec > rspec spec/controllers > > I get errors (an example will be shown below) for every controller > test in my subdirectory spec/controllers/api/beta, where the > controller namespacing is carried over in any test as follows > > describe Api::Beta1::ThingController ... > > Somehow, I do NOT get any errors for the tests in the subdirectory > when I run this command from the application root > > rspec spec/controllers/api/beta > > Here is an example of the error I get, with backtrace: > > 23) Api::Beta1::ThingController#loan server-side failure should have > status code 500 and expected message body > Failure/Error: response = post(action, params) > ActionController::RoutingError: > No route matches {:controller=>"api/beta1/ > thing", :action=>"loan"} > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:464:in > `raise_routing_error' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:460:in > `rescue in generate' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:452:in > `generate' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:493:in > `generate' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:489:in > `generate_extras' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_dispatch/routing/route_set.rb:485:in > `extra_keys' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_controller/test_case.rb:145:in > `assign_parameters' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_controller/test_case.rb:438:in `process' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_controller/test_case.rb:49:in `process' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/ > actionpack-3.1.0/lib/action_controller/test_case.rb:370:in `post' > # ./spec/controllers/api/beta1/thing_controller_spec.rb:72:in > `raw_post' > # ./spec/controllers/api/beta1/thing_controller_spec.rb:57:in > `block (3 levels) in ' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:35:in `instance_eval' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:35:in `run_in' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:70:in `block in run_all' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:70:in `each' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:70:in `run_all' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/hooks.rb:116:in `run_hook' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:221:in `block in > eval_before_eachs' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:221:in `each' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:221:in `eval_before_eachs' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example.rb:145:in `run_before_each' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example.rb:47:in `block in run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example.rb:107:in `with_around_hooks' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example.rb:45:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:294:in `block in > run_examples' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:290:in `map' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:290:in `run_examples' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:262:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:263:in `block in run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:263:in `map' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/example_group.rb:263:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/command_line.rb:24:in `block (2 levels) in > run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/command_line.rb:24:in `map' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/command_line.rb:24:in `block in run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/reporter.rb:12:in `report' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/command_line.rb:21:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/runner.rb:69:in `run' > # /Users/lille/.rvm/gems/ruby-1.9.2-p290 at rails310/gems/rspec- > core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun' > > I missed this issue when developing my tests, because I was running > them using the command that succeeds. Now, I'm in trouble because I > want to step back and test everything with a simple command from the > app root: > > rpsec spec > > (Sorry to any bothered readers for any undue brevity in the previous > post-response cycle, but I've assumed that the type of error > (RoutingError) in combination with the way rspec works and fails for > my functional tests was adequate to suggest a fix.) > > Thanks, > > Lille > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Just a wild guess here, but shouldn't the folder match the namespace, you have a beta folder and a Beta1 namespace -- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From apnea.diving.deep at gmail.com Fri Feb 3 17:29:12 2012 From: apnea.diving.deep at gmail.com (apneadiving) Date: Fri, 3 Feb 2012 14:29:12 -0800 (PST) Subject: [rspec-users] rails memoize and reload class => error raised Message-ID: <3a1ceffd-5f1b-4b87-9784-f3925c70eb5e@dn8g2000vbb.googlegroups.com> Hi, That's a bit off topic but since I use Spork + Rspec... Well, my classes are reloaded between each test wave so Rails' "memoize" method raises an error (which is expected, see code: http://rubydoc.info/docs/rails/3.0.0/ActiveSupport/Memoizable:memoize) Anyone resolved this issue with an elegant solution? From jko170 at gmail.com Fri Feb 3 18:56:22 2012 From: jko170 at gmail.com (Justin Ko) Date: Fri, 3 Feb 2012 16:56:22 -0700 Subject: [rspec-users] rails memoize and reload class => error raised In-Reply-To: <3a1ceffd-5f1b-4b87-9784-f3925c70eb5e@dn8g2000vbb.googlegroups.com> References: <3a1ceffd-5f1b-4b87-9784-f3925c70eb5e@dn8g2000vbb.googlegroups.com> Message-ID: On Feb 3, 2012, at 3:29 PM, apneadiving wrote: > Hi, > > That's a bit off topic but since I use Spork + Rspec... > > Well, my classes are reloaded between each test wave so Rails' > "memoize" method raises an error (which is expected, see code: > http://rubydoc.info/docs/rails/3.0.0/ActiveSupport/Memoizable:memoize) > > Anyone resolved this issue with an elegant solution? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Don't use #memoize, use `||=` From ze.tradr at gmail.com Sun Feb 5 03:29:42 2012 From: ze.tradr at gmail.com (Ze T) Date: Sun, 5 Feb 2012 00:29:42 -0800 (PST) Subject: [rspec-users] testing framework for test automation Message-ID: Hello, Anyone working in QA Test Automation with RSpec wouldn?t mind posting their testing framework or know where I can go to get more info on testing frameworks either with RSpec or Cucumber? I greatly appreciate. Thank you. From joe at josephwilk.net Sun Feb 5 09:11:35 2012 From: joe at josephwilk.net (Joseph Wilk) Date: Sun, 5 Feb 2012 14:11:35 +0000 Subject: [rspec-users] testing framework for test automation In-Reply-To: References: Message-ID: On Feb 5, 2012 2:04 PM, "Ze T" wrote: > > Hello, > Anyone working in QA Test Automation with RSpec wouldn?t mind posting > their testing framework or know where I can go to get more info on > testing frameworks either with RSpec or Cucumber? I greatly Perhaps you could give us a little more background to what you are testing. Is it a web app? Is it written in Ruby? What type of testing are you looking at? Integration tests, unit tests. Thanks -- Joseph Wilk http://blog.josephwilk.net > appreciate. Thank you. > _______________________________________________ > 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 julian at leviston.net Sun Feb 5 10:19:09 2012 From: julian at leviston.net (Julian Leviston) Date: Mon, 6 Feb 2012 02:19:09 +1100 Subject: [rspec-users] testing framework for test automation In-Reply-To: References: Message-ID: <6F493F09-6B53-4547-ADC7-CC938AC5FE0C@leviston.net> This will probably help you. http://fijiaaron.wordpress.com/2008/07/10/ruby-ci-options/ Julian On 05/02/2012, at 7:29 PM, Ze T wrote: > Hello, > Anyone working in QA Test Automation with RSpec wouldn?t mind posting > their testing framework or know where I can go to get more info on > testing frameworks either with RSpec or Cucumber? I greatly > appreciate. Thank you. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ze.tradr at gmail.com Mon Feb 6 03:20:13 2012 From: ze.tradr at gmail.com (Ze T) Date: Mon, 6 Feb 2012 00:20:13 -0800 (PST) Subject: [rspec-users] testing framework for test automation In-Reply-To: References: Message-ID: <4147c397-9646-42a5-8899-8528f2da79bb@ow3g2000pbc.googlegroups.com> > Perhaps you could give us a little more background to what you are testing. > Is it a web app? Is it written in Ruby? What type of testing are you > looking at? Integration tests, unit tests. Looking to run functional tests on site like www.kodakgallery.com or www.shutterfly.com it might or might not have web apps. I know for fact it will be with Ruby & Selenium WebDriver, so it would mostly be unit tests. Thank you for feedback. On Feb 5, 6:11?am, Joseph Wilk wrote: > On Feb 5, 2012 2:04 PM, "Ze T" wrote: > > > > > Hello, > > Anyone working in QA Test Automation with RSpec wouldn?t mind posting > > their testing framework or know where I can go to get more info on > > testing frameworks either with RSpec or Cucumber? I greatly > > Perhaps you could give us a little more background to what you are testing. > Is it a web app? Is it written in Ruby? What type of testing are you > looking at? Integration tests, unit tests. > > Thanks > -- > Joseph Wilkhttp://blog.josephwilk.net > > > appreciate. Thank you. > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Mon Feb 6 13:35:12 2012 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 6 Feb 2012 18:35:12 +0000 Subject: [rspec-users] testing framework for test automation In-Reply-To: <4147c397-9646-42a5-8899-8528f2da79bb@ow3g2000pbc.googlegroups.com> References: <4147c397-9646-42a5-8899-8528f2da79bb@ow3g2000pbc.googlegroups.com> Message-ID: <29FDA959-54AE-413A-BC8D-0E9FBC6FBF05@mattwynne.net> On 6 Feb 2012, at 08:20, Ze T wrote: >> Perhaps you could give us a little more background to what you are testing. >> Is it a web app? Is it written in Ruby? What type of testing are you >> looking at? Integration tests, unit tests. > > Looking to run functional tests on site like www.kodakgallery.com or > www.shutterfly.com > it might or might not have web apps. I know for fact it will be with > Ruby & Selenium WebDriver, > so it would mostly be unit tests. Thank you for feedback. Hi Ze, Sorry for the sales, but we wrote The Cucumber Book[1] to help guide teams who want to do this. I'd suggest the material in there would help you, particularly the chapters on using Capybara (which wraps Selenium Webdriver). [1] http://pragprog.com/book/hwcuc/the-cucumber-book 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 Mon Feb 6 20:45:30 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Mon, 6 Feb 2012 17:45:30 -0800 (PST) Subject: [rspec-users] nested route not receiving :id parameter within controller spec Message-ID: I've got a share method in my controller, and I have the following spec: describe PostsController do describe "#share" do it "doesn't blow up" do post :share, :id => @post.id end # ... etc And... It blows up! Failures: 1) PostsController#share shares Failure/Error: post :share ActionController::RoutingError: No route matches {:controller=>"posts", :action=>"share"} # ./spec/controllers/posts_controller_spec.rb:7 My routes has: resources :posts do post :share, :on => :member end rake routes shows: share_post POST /posts/:id/share(.:format) {:action=>"share", :controller=>"posts"} ... Why is it ignoring the :id parameter in my test and therefore blowing up? Thanks. Patrick J. Collins http://collinatorstudios.com From andrew at andrewtimberlake.com Mon Feb 6 22:39:15 2012 From: andrew at andrewtimberlake.com (Andrew Timberlake) Date: Tue, 7 Feb 2012 05:39:15 +0200 Subject: [rspec-users] nested route not receiving :id parameter within controller spec In-Reply-To: References: Message-ID: <4935EFB37563439BAB15154D1A16FD35@andrewtimberlake.com> The id belongs to post so your test line should be: post :share, :post_id => @post.id Andrew On Tuesday 07 February 2012 at 3:45 AM, Patrick J. Collins wrote: > I've got a share method in my controller, and I have the following spec: > > describe PostsController do > > describe "#share" do > > it "doesn't blow up" do > post :share, :id => @post.id > end > > # ... etc > > And... It blows up! > > Failures: > > 1) PostsController#share shares > Failure/Error: post :share > ActionController::RoutingError: > No route matches {:controller=>"posts", :action=>"share"} > # ./spec/controllers/posts_controller_spec.rb:7 > > My routes has: > > resources :posts do > post :share, :on => :member > end > > rake routes shows: > > share_post POST /posts/:id/share(.:format) {:action=>"share", :controller=>"posts"} > > ... > > Why is it ignoring the :id parameter in my test and therefore blowing up? > > Thanks. > > Patrick J. Collins > http://collinatorstudios.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 patrick at collinatorstudios.com Tue Feb 7 00:05:32 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Mon, 6 Feb 2012 21:05:32 -0800 (PST) Subject: [rspec-users] nested route not receiving :id parameter within controller spec In-Reply-To: <4935EFB37563439BAB15154D1A16FD35@andrewtimberlake.com> References: <4935EFB37563439BAB15154D1A16FD35@andrewtimberlake.com> Message-ID: I tried that and got the same result, plus rake routes says: share_post POST /posts/:id/share(.:format) {:action=>"share", :controller=>"posts"} NOT share_post POST /posts/:post_id/share(.:format) {:action=>"share", :controller=>"posts"} So I don't see how that can be the case... Patrick J. Collins http://collinatorstudios.com From jko170 at gmail.com Tue Feb 7 01:52:43 2012 From: jko170 at gmail.com (Justin Ko) Date: Mon, 6 Feb 2012 23:52:43 -0700 Subject: [rspec-users] nested route not receiving :id parameter within controller spec In-Reply-To: References: Message-ID: <812F63F8-AEE5-401C-98C1-D948AB6C522A@gmail.com> On Feb 6, 2012, at 6:45 PM, Patrick J. Collins wrote: > I've got a share method in my controller, and I have the following spec: > > describe PostsController do > > describe "#share" do > > it "doesn't blow up" do > post :share, :id => @post.id Does @post actually have an id? I believe the :id key will not be present if the value is nil. > end > > # ... etc > > And... It blows up! > > Failures: > > 1) PostsController#share shares > Failure/Error: post :share > ActionController::RoutingError: > No route matches {:controller=>"posts", :action=>"share"} > # ./spec/controllers/posts_controller_spec.rb:7 > > My routes has: > > resources :posts do > post :share, :on => :member > end > > rake routes shows: > > share_post POST /posts/:id/share(.:format) {:action=>"share", :controller=>"posts"} > > ... > > Why is it ignoring the :id parameter in my test and therefore blowing up? > > Thanks. > > Patrick J. Collins > http://collinatorstudios.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From andrew at andrewtimberlake.com Tue Feb 7 02:06:00 2012 From: andrew at andrewtimberlake.com (Andrew Timberlake) Date: Tue, 7 Feb 2012 09:06:00 +0200 Subject: [rspec-users] nested route not receiving :id parameter within controller spec In-Reply-To: References: <4935EFB37563439BAB15154D1A16FD35@andrewtimberlake.com> Message-ID: <682FBD57EC2A4722932CC7E2A181DB13@andrewtimberlake.com> Sorry, too quick to answer. Next clue is the fact that the RSpec error is ignoring your id attribute. try: post :share, :id => 42 and see if that gets you past the current error Andrew On Tuesday 07 February 2012 at 7:05 AM, Patrick J. Collins wrote: > I tried that and got the same result, plus rake routes says: > > share_post POST /posts/:id/share(.:format) {:action=>"share", :controller=>"posts"} > > NOT > > share_post POST /posts/:post_id/share(.:format) {:action=>"share", :controller=>"posts"} > > So I don't see how that can be the case... > > Patrick J. Collins > http://collinatorstudios.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 patrick at collinatorstudios.com Tue Feb 7 05:11:02 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Tue, 7 Feb 2012 02:11:02 -0800 (PST) Subject: [rspec-users] nested route not receiving :id parameter within controller spec In-Reply-To: <682FBD57EC2A4722932CC7E2A181DB13@andrewtimberlake.com> References: <4935EFB37563439BAB15154D1A16FD35@andrewtimberlake.com> <682FBD57EC2A4722932CC7E2A181DB13@andrewtimberlake.com> Message-ID: > Sorry, too quick to answer. > Next clue is the fact that the RSpec error is ignoring your id attribute. > try: > post :share, :id => 42 > and see if that gets you past the current error Yeah-- Unfortunatley I also had tried this and got the same result... Patrick J. Collins http://collinatorstudios.com From dchelimsky at gmail.com Tue Feb 7 07:31:18 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 7 Feb 2012 06:31:18 -0600 Subject: [rspec-users] nested route not receiving :id parameter within controller spec In-Reply-To: References: <4935EFB37563439BAB15154D1A16FD35@andrewtimberlake.com> <682FBD57EC2A4722932CC7E2A181DB13@andrewtimberlake.com> Message-ID: On Tue, Feb 7, 2012 at 4:11 AM, Patrick J. Collins wrote: >> Sorry, too quick to answer. >> Next clue is the fact that the RSpec error is ignoring your id attribute. >> try: >> post :share, :id => 42 >> and see if that gets you past the current error > > Yeah-- Unfortunatley I also had tried this and got the same result... Do you see any different behavior using a Rails functional test? From bjbq4d at gmail.com Thu Feb 9 15:42:44 2012 From: bjbq4d at gmail.com (Bryan Baugher) Date: Thu, 9 Feb 2012 14:42:44 -0600 Subject: [rspec-users] Autorun Picks Up Options Message-ID: Hi, I was trying to use the autorun feature of rspec but noticed that when I run the command to kick off the ruby scripts it picks up the options that I give to the command. 'myRubyBin -j optionValue' This then fails with this error, /usr/lib/ruby/1.8/optparse.rb:1448:in `complete' : invalid option: -j ( OptionParser::InvalidOption ) from /usr/lib/ruby/1.8/optparse.rb:1446:in `catch' from /usr/lib/ruby/1.8/optparse.rb:1446:in `complete' from /usr/lib/ruby/1.8/optparse.rb:1285:in `parse_in_order' from /usr/lib/ruby/1.8/optparse.rb:1252:in `catch' from /usr/lib/ruby/1.8/optparse.rb:1252:in `parse_in_order' from /usr/lib/ruby/1.8/optparse.rb:1246:in `order!' from /usr/lib/ruby/1.8/optparse.rb:1337:in `permute!' from /usr/lib/ruby/1.8/optparse.rb:1358:in `parse!' ... 6 levels... from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:26:in `parse_options' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:59:in `run' from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `autorun' Is there a way for rspec/autorun to ignore all options? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jko170 at gmail.com Fri Feb 10 03:59:14 2012 From: jko170 at gmail.com (Justin Ko) Date: Fri, 10 Feb 2012 01:59:14 -0700 Subject: [rspec-users] Autorun Picks Up Options In-Reply-To: References: Message-ID: <5A5D3A48-A5ED-4222-ADC1-20A29544D584@gmail.com> On Feb 9, 2012, at 1:42 PM, Bryan Baugher wrote: > Hi, > > I was trying to use the autorun feature of rspec but noticed that when I run the command to kick off the ruby scripts it picks up the options that I give to the command. > > 'myRubyBin -j optionValue' > > This then fails with this error, > > /usr/lib/ruby/1.8/optparse.rb:1448:in `complete' > : > invalid option: -j > ( > OptionParser::InvalidOption > ) > from /usr/lib/ruby/1.8/optparse.rb:1446:in `catch' > from /usr/lib/ruby/1.8/optparse.rb:1446:in `complete' > from /usr/lib/ruby/1.8/optparse.rb:1285:in `parse_in_order' > from /usr/lib/ruby/1.8/optparse.rb:1252:in `catch' > from /usr/lib/ruby/1.8/optparse.rb:1252:in `parse_in_order' > from /usr/lib/ruby/1.8/optparse.rb:1246:in `order!' > from /usr/lib/ruby/1.8/optparse.rb:1337:in `permute!' > from /usr/lib/ruby/1.8/optparse.rb:1358:in `parse!' > ... 6 levels... > from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:26:in `parse_options' > from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:59:in `run' > from /usr/lib/ruby/gems/1.8/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `autorun' > > Is there a way for rspec/autorun to ignore all options? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users "autorun" is designed to be a drop-in solution to run specs without the "rspec" binary. I think you have two options here: 1.) autorun accepts ARGV as its runner arguments. You could massage ARGV before requiring autorun. 2.) Use the RSpec runner explicitly: RSpec::Core::Runner.run(args) From lists at ruby-forum.com Fri Feb 10 09:30:49 2012 From: lists at ruby-forum.com (Paul Fashanu) Date: Fri, 10 Feb 2012 15:30:49 +0100 Subject: [rspec-users] Rspec testing (gunfight at coral) Message-ID: <58dbf1e9f7b4f0bf05cf0cc93faf75f2@ruby-forum.com> Can any one give me an explanation on whats going on in this exercise. And any advice on how i should go about it. I dont need any exact codes just yet. But at least a good idea on how to start will be good Thanks Exercise 2: Gunfight at the OK Corral Description Overview This exercise is to create a small ruby program to determine the winners of gunfights, as seen in old Western movies. The rules governing these gunfights are very simple: 1. We have a bunch of cowboys 2. Each cowboy can aim a gun at any number of other cowboys 3. If a cowboy has a gun aimed at them, we say they are attacked, with the cowboy aiming the gun doing the attacking. 4. Given a group of cowboys, we say that a subset of this group is conflict-free if none of the cowboys in the subset are attacking each other. 5. A cowboy (let's call him C is defended by some group of cowboys (let's call this group X) if any cowboy attacking C is attacked by a member of X. 6. We say that a group of cowboys is self-defending if every cowboy in the group is defended by the group, and the group is conflict-free. Task 1 Create a ruby class called Fighters that takes in a set of cowboys and attacks between cowboys, e.g. Fighters.new([:a,:b,:c],[[:a,:b],[:b,:c],[:c,:a]]) This represents the situation where we have 3 cowboys :a,:b,:c and :a aims at :b, :b aims at :c and :c aims at :a. Write rspec tests (in a file called fighters_test.rb) for the following methods on this class, and then implement these methods. 1. conflict_free?(cowboys) which takes in a set of cowboys and returns true if this set is conflict-free and false otherwise. 2. defended?(cowboy,group) which returns true if the cowboy is defended by the group and false otherwise. 3. self_defended?(group) which, when given a group, returns true if the group is a self defending group. Task 2 We can identify several different groups of safe cowboys. First, there are those cowboys that are unconditionally alive. For example, given the following configuration of fighters f=Fighters.new([:a,:b,:c],[[:a,:b],[:b,:c]]) Cowboys :a and :c will survive the fight as a would end up shooting b meaning that c would not be shot. Create methods called unconditionally_alive and unconditionally_dead which compute (and return as an array) those cowboys which are definitely alive and dead. Hint: To compute these, start with the cowboys which have no one aiming at them; these are unconditionally alive. Those cowboys being aimed at by these unconditionally alive cowboys are unconditionally dead, and those aimed at only by unconditionally dead cowboys are unconditionally alive and so on. Notes The problem described here actually stems from a very active research area in artificial intelligence called argumentation theory. If you're interested in finding out more about these concepts, see the book ``Argumentation in Artificial Intelligence'' edited by I. Rahwan and G. Simari. Chapter 6 is particularly relevant. This book is available as an e-book from the library. -- Posted via http://www.ruby-forum.com/. From patrick at collinatorstudios.com Mon Feb 13 15:16:21 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Mon, 13 Feb 2012 12:16:21 -0800 (PST) Subject: [rspec-users] stale records with integration testing? Message-ID: Hi, I was writing an integration test for my user signup form (with capybara), and found that my test was failing due to a validation error: "email is already taken". I'm a bit confused because I thought when I run "rspec spec/some_spec.rb", the test database would be wiped clear? Is that not the case? Patrick J. Collins http://collinatorstudios.com From lists at ruby-forum.com Mon Feb 13 17:46:16 2012 From: lists at ruby-forum.com (Cathal Curtis) Date: Mon, 13 Feb 2012 23:46:16 +0100 Subject: [rspec-users] Should I use cucumber or Controller RSpecs or both? Message-ID: Hi All, I'd like to get some other's opinions on testing controllers. Say I have a model and I want to prevent deletion of instances of it. The controllers's destroy action simply redirects to an error page - nothing else. Lets assume the relevant views have no links or buttons to delete the instance. I want to ensure that on receipt of a DELETE request for an instance of that model, that the application does in fact disallow the deletion and redirects to an error page. Should I create a cucumber test, with a step that would call something like: "delete url_for(...)"? Or should I leave it to a Controller RSpec? I have implemented both, the RSpec is working fine but I'm having trouble getting cucumber to follow the redirect and therefore my "Then I should be on error page" fails. I'd like to know if such a cucumber test is unnecessary. Should I even have such a cucumber test if the user cannot generate the condition/action/event through normal use of the application? If the controller RSpec proves that the controller responds with a redirect response to the correct page, is that all I need? Thanks in advance, Cathal. -- Posted via http://www.ruby-forum.com/. From sahmed1020 at gmail.com Mon Feb 13 21:31:15 2012 From: sahmed1020 at gmail.com (S Ahmed) Date: Mon, 13 Feb 2012 21:31:15 -0500 Subject: [rspec-users] requests versus cucumber Message-ID: For those of you who have used both rspec requests and cucumber, could you summarize the main differences between the two? Do they both serve the same purpose but with different implementation styles or they really aren't the same thing? I havent' used requests before, but I like the idea of being able to view both the 'request/behaviour' and the code on the same page. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jko170 at gmail.com Mon Feb 13 22:04:44 2012 From: jko170 at gmail.com (Justin Ko) Date: Mon, 13 Feb 2012 20:04:44 -0700 Subject: [rspec-users] stale records with integration testing? In-Reply-To: References: Message-ID: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> On Feb 13, 2012, at 1:16 PM, Patrick J. Collins wrote: > Hi, > > I was writing an integration test for my user signup form (with > capybara), and found that my test was failing due to a validation error: > "email is already taken". I'm a bit confused because I thought when I > run "rspec spec/some_spec.rb", the test database would be wiped clear? > > Is that not the case? > > Patrick J. Collins > http://collinatorstudios.com > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users You basically have two options to ensure a clean database: 1.) Transactional examples: RSpec.configuration.use_transactional_examples = true 2.) DatabaseCleaner: RSpec.configure do |config| config.before { DatabaseCleaner.start } config.after { DatabaseCleaner.clean } end Look into what those do. Let us know if you get stuck. From jko170 at gmail.com Mon Feb 13 22:57:49 2012 From: jko170 at gmail.com (Justin Ko) Date: Mon, 13 Feb 2012 20:57:49 -0700 Subject: [rspec-users] Should I use cucumber or Controller RSpecs or both? In-Reply-To: References: Message-ID: <32EFFF8D-955C-4E90-9BE0-57C9ACB14CBD@gmail.com> On Feb 13, 2012, at 3:46 PM, Cathal Curtis wrote: > Hi All, > > I'd like to get some other's opinions on testing controllers. > > Say I have a model and I want to prevent deletion of instances of it. > The controllers's destroy action simply redirects to an error page - > nothing else. > Lets assume the relevant views have no links or buttons to delete the > instance. > I want to ensure that on receipt of a DELETE request for an instance of > that model, that the application does in fact disallow the deletion and > redirects to an error page. > > Should I create a cucumber test, with a step that would call something > like: "delete url_for(...)"? > Or should I leave it to a Controller RSpec? > > I have implemented both, the RSpec is working fine but I'm having > trouble getting cucumber to follow the redirect and therefore my "Then I > should be on error page" fails. > > I'd like to know if such a cucumber test is unnecessary. > Should I even have such a cucumber test if the user cannot generate the > condition/action/event through normal use of the application? > If the controller RSpec proves that the controller responds with a > redirect response to the correct page, is that all I need? > > Thanks in advance, Cathal. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Some good discussion on this topic: http://solnic.eu/2012/02/02/yes-you-should-write-controller-tests.html From cnk at ugcs.caltech.edu Mon Feb 13 22:56:48 2012 From: cnk at ugcs.caltech.edu (Cynthia Kiser) Date: Mon, 13 Feb 2012 19:56:48 -0800 Subject: [rspec-users] Should I use cucumber or Controller RSpecs or both? In-Reply-To: References: Message-ID: <20120214035648.GA23760@ugcs.caltech.edu> Quoting Cathal Curtis : > I want to ensure that on receipt of a DELETE request for an instance of > that model, that the application does in fact disallow the deletion and > redirects to an error page. > > Should I create a cucumber test, with a step that would call something > like: "delete url_for(...)"? > Or should I leave it to a Controller RSpec? ... > I'd like to know if such a cucumber test is unnecessary. > Should I even have such a cucumber test if the user cannot generate the > condition/action/event through normal use of the application? In my opinion, if the user can't generate the event through normal interaction (clicking links, etc.) then it probably shouldn't be in a cucumber test. > If the controller RSpec proves that the controller responds with a > redirect response to the correct page, is that all I need? Yes. The two tests are trying to test the same thing and so are mostly redundant. But I think the RSpec test is the more appropriate test. It's a bonus that that one is already working. -- Cynthia N. Kiser cnk at ugcs.caltech.edu From dchelimsky at gmail.com Tue Feb 14 00:35:07 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 13 Feb 2012 23:35:07 -0600 Subject: [rspec-users] stale records with integration testing? In-Reply-To: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> Message-ID: On Mon, Feb 13, 2012 at 9:04 PM, Justin Ko wrote: > > On Feb 13, 2012, at 1:16 PM, Patrick J. Collins wrote: > >> Hi, >> >> I was writing an integration test for my user signup form (with >> capybara), and found that my test was failing due to a validation error: >> "email is already taken". ?I'm a bit confused because I thought when I >> run "rspec spec/some_spec.rb", the test database would be wiped clear? >> >> Is that not the case? >> >> Patrick J. Collins >> http://collinatorstudios.com >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > You basically have two options to ensure a clean database: > > 1.) Transactional examples: > > RSpec.configuration.use_transactional_examples = true > > 2.) DatabaseCleaner: > > RSpec.configure do |config| > ?config.before { DatabaseCleaner.start } > ?config.after { DatabaseCleaner.clean } > end > > Look into what those do. Let us know if you get stuck. What Justin says is true if you're running in the same process. If you're using Capybara to run examples in-browser, then option 2 will work for you, but option 1 will not. From patrick at collinatorstudios.com Tue Feb 14 02:36:32 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Mon, 13 Feb 2012 23:36:32 -0800 (PST) Subject: [rspec-users] stale records with integration testing? In-Reply-To: References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> Message-ID: > > 2.) DatabaseCleaner: > > > > RSpec.configure do |config| > > ?config.before { DatabaseCleaner.start } > > ?config.after { DatabaseCleaner.clean } > > end > > > > Look into what those do. Let us know if you get stuck. > > What Justin says is true if you're running in the same process. If > you're using Capybara to run examples in-browser, then option 2 will > work for you, but option 1 will not. Hmmm.. Well, I had actually tried the DatabaseCleaner gem prior to asking my question, and I saw no difference in the results... I just put that code back in spec_helper, and ran my specs and they fail again with "email already taken". It seems to break unless I explicitly put: User.all.map(&:destroy) in a before block........ Is there any reason why DatabaseCleaner might not be working? I'm on Rails 3.2 with rspec 2.8.0, and database_cleaner 0.7.1 Patrick J. Collins http://collinatorstudios.com From apremdas at gmail.com Tue Feb 14 04:52:25 2012 From: apremdas at gmail.com (Andrew Premdas) Date: Tue, 14 Feb 2012 09:52:25 +0000 Subject: [rspec-users] Should I use cucumber or Controller RSpecs or both? In-Reply-To: References: Message-ID: On 13 February 2012 22:46, Cathal Curtis wrote: > Hi All, > > I'd like to get some other's opinions on testing controllers. > > Say I have a model and I want to prevent deletion of instances of it. > The controllers's destroy action simply redirects to an error page - > nothing else. > Lets assume the relevant views have no links or buttons to delete the > instance. > I want to ensure that on receipt of a DELETE request for an instance of > that model, that the application does in fact disallow the deletion and > redirects to an error page. > > Should I create a cucumber test, with a step that would call something > like: "delete url_for(...)"? > Or should I leave it to a Controller RSpec? > > I have implemented both, the RSpec is working fine but I'm having > trouble getting cucumber to follow the redirect and therefore my "Then I > should be on error page" fails. > > I'd like to know if such a cucumber test is unnecessary. > Should I even have such a cucumber test if the user cannot generate the > condition/action/event through normal use of the application? > If the controller RSpec proves that the controller responds with a > redirect response to the correct page, is that all I need? > > Thanks in advance, Cathal. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Why do you want to ensure that the instance cannot be deleted. If its a business concern then you should write a cuke for it. If you just want to specify as a dev that it can't be deleted then perhaps you could write a routing spec that says there is no route for delete, though are you going to write specs that say you can't foo_it or bar_it? There are lots of security concerns that a business can have about users doing things that have no interaction in the UI. These are generally very easy to implement in cucumber e.g - after all you just need to visit a url to generate the request. The only issue is that in Rails you may not get the error page you expect because you are running in test mode. You can address that by using an @allow-rescue tag on the feature. HTH Andrew -- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Tue Feb 14 06:31:32 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 14 Feb 2012 05:31:32 -0600 Subject: [rspec-users] stale records with integration testing? In-Reply-To: References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> Message-ID: On Tue, Feb 14, 2012 at 1:36 AM, Patrick J. Collins wrote: >> > 2.) DatabaseCleaner: >> > >> > RSpec.configure do |config| >> > ?config.before { DatabaseCleaner.start } >> > ?config.after { DatabaseCleaner.clean } >> > end >> > >> > Look into what those do. Let us know if you get stuck. >> >> What Justin says is true if you're running in the same process. If >> you're using Capybara to run examples in-browser, then option 2 will >> work for you, but option 1 will not. > > Hmmm.. ?Well, I had actually tried the DatabaseCleaner gem prior to > asking my question, and I saw no difference in the results... ?I just > put that code back in spec_helper, and ran my specs and they fail again > with "email already taken". This could happen for one of two reasons: 1. The email is already in the database before you run your specs. To avoid this, use DatabaseCleaner to truncate the tables once before each run (not before each example). 2. Models are generated in before(:all) blocks, which are not implicitly wrapped in transactions. If you generate models in before(:all), then it is your responsibility to remove them in an after(:all). Also - DatabaseCleaner has two modes: transaction and truncation. Make sure you're using the appropriate one. HTH, David From dchelimsky at gmail.com Tue Feb 14 07:01:39 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 14 Feb 2012 06:01:39 -0600 Subject: [rspec-users] requests versus cucumber In-Reply-To: References: Message-ID: On Mon, Feb 13, 2012 at 8:31 PM, S Ahmed wrote: > For those of you who have used both rspec requests and cucumber, could you > summarize the main differences between the two? I realize that you're trying to solve a problem and we're here to be helpful, but the helpful people on this list volunteer their time. There is a wealth of material, much of it on this very list, that is already freely available on the internet that will help you to understand the difference: https://www.google.com/search?aq=f&sourceid=chrome&ie=UTF-8&q=request+specs+vs+cucumber. Please start by perusing the results of that search, and if you have any specific questions we're here to answer them. From jko170 at gmail.com Tue Feb 14 10:28:11 2012 From: jko170 at gmail.com (Justin Ko) Date: Tue, 14 Feb 2012 08:28:11 -0700 Subject: [rspec-users] stale records with integration testing? In-Reply-To: References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> Message-ID: <92DCB130-D9DA-469A-BDA6-C3F2EC8E9805@gmail.com> On Feb 13, 2012, at 10:35 PM, David Chelimsky wrote: > On Mon, Feb 13, 2012 at 9:04 PM, Justin Ko wrote: >> >> On Feb 13, 2012, at 1:16 PM, Patrick J. Collins wrote: >> >>> Hi, >>> >>> I was writing an integration test for my user signup form (with >>> capybara), and found that my test was failing due to a validation error: >>> "email is already taken". I'm a bit confused because I thought when I >>> run "rspec spec/some_spec.rb", the test database would be wiped clear? >>> >>> Is that not the case? >>> >>> Patrick J. Collins >>> http://collinatorstudios.com >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> You basically have two options to ensure a clean database: >> >> 1.) Transactional examples: >> >> RSpec.configuration.use_transactional_examples = true >> >> 2.) DatabaseCleaner: >> >> RSpec.configure do |config| >> config.before { DatabaseCleaner.start } >> config.after { DatabaseCleaner.clean } >> end >> >> Look into what those do. Let us know if you get stuck. > > What Justin says is true if you're running in the same process. If > you're using Capybara to run examples in-bro.wser, then option 2 will > work for you, but option 1 will not. You can still do this with an AR patch. Look at the "Transactions and database setup" in the Capybara README. Using DatabaseCleaner with truncation is SLOW. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Feb 14 11:23:10 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 14 Feb 2012 10:23:10 -0600 Subject: [rspec-users] stale records with integration testing? In-Reply-To: <92DCB130-D9DA-469A-BDA6-C3F2EC8E9805@gmail.com> References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> <92DCB130-D9DA-469A-BDA6-C3F2EC8E9805@gmail.com> Message-ID: On Tue, Feb 14, 2012 at 9:28 AM, Justin Ko wrote: > > On Feb 13, 2012, at 10:35 PM, David Chelimsky wrote: > >> On Mon, Feb 13, 2012 at 9:04 PM, Justin Ko wrote: >>> >>> On Feb 13, 2012, at 1:16 PM, Patrick J. Collins wrote: >>> >>>> Hi, >>>> >>>> I was writing an integration test for my user signup form (with >>>> capybara), and found that my test was failing due to a validation error: >>>> "email is already taken". ?I'm a bit confused because I thought when I >>>> run "rspec spec/some_spec.rb", the test database would be wiped clear? >>>> >>>> Is that not the case? >>>> >>>> Patrick J. Collins >>>> http://collinatorstudios.com >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> You basically have two options to ensure a clean database: >>> >>> 1.) Transactional examples: >>> >>> RSpec.configuration.use_transactional_examples = true >>> >>> 2.) DatabaseCleaner: >>> >>> RSpec.configure do |config| >>> ?config.before { DatabaseCleaner.start } >>> ?config.after { DatabaseCleaner.clean } >>> end >>> >>> Look into what those do. Let us know if you get stuck. >> >> What Justin says is true if you're running in the same process. If >> you're using Capybara to run examples in-bro.wser, then option 2 will >> work for you, but option 1 will not. > > You can still do this with an AR patch. Look at the "Transactions and database setup" in the Capybara README. "This may have thread safety implications and could cause strange failures, so use caution with this approach." > Using DatabaseCleaner with truncation is SLOW. True, but you can minimize that by using transaction by default, and specifying truncation for in-browser scenarios (which are already far slower than will be impacted by truncation). > >> _______________________________________________ >> 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 patrick at collinatorstudios.com Tue Feb 14 13:02:24 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Tue, 14 Feb 2012 10:02:24 -0800 (PST) Subject: [rspec-users] stale records with integration testing? In-Reply-To: References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> Message-ID: > This could happen for one of two reasons: > > 1. The email is already in the database before you run your specs. > > To avoid this, use DatabaseCleaner to truncate the tables once before > each run (not before each example). > > 2. Models are generated in before(:all) blocks, which are not > implicitly wrapped in transactions. > > If you generate models in before(:all), then it is your responsibility > to remove them in an after(:all). > > Also - DatabaseCleaner has two modes: transaction and truncation. Make > sure you're using the appropriate one. Ah... Ok cool, all of the above info solved my problem. Thanks! Patrick J. Collins http://collinatorstudios.com From lists at ruby-forum.com Tue Feb 14 14:14:22 2012 From: lists at ruby-forum.com (Jason Floyd) Date: Tue, 14 Feb 2012 20:14:22 +0100 Subject: [rspec-users] RSpec spec works on rails 3.2.0, fails on 3.2.0 Message-ID: <81f6191d3aca94ff279b62573b189b8c@ruby-forum.com> I have a spec that passes in rails 3.2.0, but fails in 3.2.1, and I have no idea why. Here's the spec: it "can be shown on the company menu" do doclib = Factory(:document_library, title: 'Test', menu: false, company: true) doclib.should be_valid end Here's the error message I get when running rspec: 1) DocumentLibrary can be shown on the company menu Failure/Error: doclib = Factory(:document_library, title: 'Test', menu: false, company: true) ArgumentError: wrong number of arguments (0 for 1) # ./spec/models/document_library_spec.rb:6:in `block (2 levels) in ' Other specs in this project using Factory Girl pass after the upgrade to 3.2.1, but not this one. What gives? I'm using ruby 1.9.3 with rvm. Here's my Gemfile: gem 'rails', '3.2.1' gem 'mysql2' gem 'dynamic_form' gem 'friendly_id' group :assets do gem 'sass-rails', " ~> 3.2.3" gem 'coffee-rails', "~> 3.2.1" gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' gem 'therubyracer' gem 'bcrypt-ruby' gem 'capistrano' gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git" group :test, :development do gem 'rspec-rails' gem 'launchy' gem 'ruby-debug19' gem 'database_cleaner' gem 'capybara-webkit' gem 'spork', '~> 0.9.0.rc' gem 'guard-spork' end group :development do gem 'fuubar' gem 'powder' end group :test do gem 'turn', :require => false gem 'capybara' gem 'factory_girl_rails' gem 'guard-rspec' end -- Posted via http://www.ruby-forum.com/. From jwizzchow at gmail.com Tue Feb 14 11:57:22 2012 From: jwizzchow at gmail.com (John Chow) Date: Tue, 14 Feb 2012 08:57:22 -0800 (PST) Subject: [rspec-users] Formatting Pending/Failures Output Message-ID: <15521481.408.1329238642597.JavaMail.geo-discussion-forums@pbcoz6> Hey Everyone, Quick question: is there a way to format the example text such that it's in nested format (much like the option *rspec -cfn*)? It's visually easier for me to read and comprehend the failures and pending examples. Thanks, John P.S. First time posting here, so I gotta say that I love RSpec! Yes, very noob-like, but had to say it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From croceldon at gmail.com Tue Feb 14 12:56:06 2012 From: croceldon at gmail.com (croceldon) Date: Tue, 14 Feb 2012 09:56:06 -0800 (PST) Subject: [rspec-users] Upgrading to rails 3.2.1 from 3.2.0 now causes my some specs to fail Message-ID: I'm using rvm with ruby 1.9.3, and RubyGems at 1.8.16. All my specs pass with Rails 3.2, but at Rails 3.2.1, I get the following error: 1) DocumentLibrary can be shown on the company menu Failure/Error: doclib = Factory(:document_library, title: 'Test', menu: false, company: true) ArgumentError: wrong number of arguments (0 for 1) # ./spec/models/document_library_spec.rb:6:in `block (2 levels) in ' What has changed from 3.2 to 3.2.1 to cause this error? Here's the spec: require 'spec_helper' describe DocumentLibrary do it "can be shown on the company menu" do doclib = Factory(:document_library, title: 'Test', menu: false, company: true) doclib.should be_valid end it 'can be hidden/shown on the menu' do doclib = Factory(:document_library, title: 'Test', menu: false) doclib.should be_valid end it "has a unique title" do Factory(:document_library, title: 'Test') doclib = DocumentLibrary.create(title: 'Test') doclib.should_not be_valid doclib.title = 'different' doclib.should be_valid end it "requires a title" do doclib = DocumentLibrary.create() doclib.should_not be_valid doclib.title = 'test' doclib.should be_valid end end From jko170 at gmail.com Tue Feb 14 15:44:02 2012 From: jko170 at gmail.com (Justin Ko) Date: Tue, 14 Feb 2012 13:44:02 -0700 Subject: [rspec-users] stale records with integration testing? In-Reply-To: References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> <92DCB130-D9DA-469A-BDA6-C3F2EC8E9805@gmail.com> Message-ID: On Feb 14, 2012, at 9:23 AM, David Chelimsky wrote: > On Tue, Feb 14, 2012 at 9:28 AM, Justin Ko wrote: >> >> On Feb 13, 2012, at 10:35 PM, David Chelimsky wrote: >> >>> On Mon, Feb 13, 2012 at 9:04 PM, Justin Ko wrote: >>>> >>>> On Feb 13, 2012, at 1:16 PM, Patrick J. Collins wrote: >>>> >>>>> Hi, >>>>> >>>>> I was writing an integration test for my user signup form (with >>>>> capybara), and found that my test was failing due to a validation error: >>>>> "email is already taken". I'm a bit confused because I thought when I >>>>> run "rspec spec/some_spec.rb", the test database would be wiped clear? >>>>> >>>>> Is that not the case? >>>>> >>>>> Patrick J. Collins >>>>> http://collinatorstudios.com >>>>> >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> You basically have two options to ensure a clean database: >>>> >>>> 1.) Transactional examples: >>>> >>>> RSpec.configuration.use_transactional_examples = true >>>> >>>> 2.) DatabaseCleaner: >>>> >>>> RSpec.configure do |config| >>>> config.before { DatabaseCleaner.start } >>>> config.after { DatabaseCleaner.clean } >>>> end >>>> >>>> Look into what those do. Let us know if you get stuck. >>> >>> What Justin says is true if you're running in the same process. If >>> you're using Capybara to run examples in-bro.wser, then option 2 will >>> work for you, but option 1 will not. >> >> You can still do this with an AR patch. Look at the "Transactions and database setup" in the Capybara README. > > "This may have thread safety implications and could cause strange > failures, so use caution with this approach." > >> Using DatabaseCleaner with truncation is SLOW. > > True, but you can minimize that by using transaction by default, and > specifying truncation for in-browser scenarios (which are already far > slower than will be impacted by truncation). cucumber-rails has good examples on how to set this up in RSpec: https://github.com/cucumber/cucumber-rails/blob/master/lib/cucumber/rails/database.rb It includes AR shared connection and truncation strategies. David, how come rspec-rails doesn't include support for these things as well? I don't really mind setting it up manually, but it does seem to be a necessary pattern for request specs. > >> >>> _______________________________________________ >>> 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Tue Feb 14 17:45:29 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Tue, 14 Feb 2012 16:45:29 -0600 Subject: [rspec-users] RSpec spec works on rails 3.2.0, fails on 3.2.0 In-Reply-To: <81f6191d3aca94ff279b62573b189b8c@ruby-forum.com> References: <81f6191d3aca94ff279b62573b189b8c@ruby-forum.com> Message-ID: On Tue, Feb 14, 2012 at 1:14 PM, Jason Floyd wrote: > I have a spec that passes in rails 3.2.0, but fails in 3.2.1, and I have > no idea why. > > Here's the spec: > > it "can be shown on the company menu" do > ?doclib = Factory(:document_library, title: 'Test', menu: false, > company: true) > ?doclib.should be_valid > end > > Here's the error message I get when running rspec: > > ?1) DocumentLibrary can be shown on the company menu > ? ? Failure/Error: doclib = Factory(:document_library, title: 'Test', > menu: false, company: true) > ? ? ArgumentError: > ? ? ? wrong number of arguments (0 for 1) > ? ? # ./spec/models/document_library_spec.rb:6:in `block (2 levels) in > ' > > > Other specs in this project using Factory Girl pass after the upgrade to > 3.2.1, but not > this one. ?What gives? Please run "rspec spec/models/document_library_spec.rb --backtrace" and post the output. From jko170 at gmail.com Tue Feb 14 18:16:08 2012 From: jko170 at gmail.com (Justin Ko) Date: Tue, 14 Feb 2012 16:16:08 -0700 Subject: [rspec-users] Formatting Pending/Failures Output In-Reply-To: <15521481.408.1329238642597.JavaMail.geo-discussion-forums@pbcoz6> References: <15521481.408.1329238642597.JavaMail.geo-discussion-forums@pbcoz6> Message-ID: <5A0ABA1A-867E-4815-B88E-6E6EF2F4B011@gmail.com> On Feb 14, 2012, at 9:57 AM, John Chow wrote: > Hey Everyone, > > Quick question: is there a way to format the example text such that it's in nested format (much like the option rspec -cfn)? It's visually easier for me to read and comprehend the failures and pending examples. I think "rspec --format documentation" or "rspec -f doc" is what you want. > > Thanks, > > John > > P.S. First time posting here, so I gotta say that I love RSpec! Yes, very noob-like, but had to say it. After 4 years, I still do too! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-use -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at ruby-forum.com Wed Feb 15 04:23:42 2012 From: lists at ruby-forum.com (Cathal Curtis) Date: Wed, 15 Feb 2012 10:23:42 +0100 Subject: [rspec-users] Should I use cucumber or Controller RSpecs or both? In-Reply-To: References: Message-ID: <9c7323a7b7080a41a47d7d60f1a0a4c4@ruby-forum.com> Cathal Curtis wrote in post #1046554: I found what I think is the answer to my question by chance while doing some further searching on the web: http://groups.google.com/group/ruby-capybara/browse_thread/thread/7b6c92e4c96c9135 Jonas Nicklas describes it as using the wrong tool for the job. Capybara is restricted to what a normal user can do. And he says it should be tested in a controller test/spec... -- Posted via http://www.ruby-forum.com/. From lists at ruby-forum.com Wed Feb 15 11:57:18 2012 From: lists at ruby-forum.com (Serguei Cambour) Date: Wed, 15 Feb 2012 17:57:18 +0100 Subject: [rspec-users] Such a simple test fails. But why ? Message-ID: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> I just tried to integrate a simple test to check some options passed as argument to a class to be executed: [code] require 'spec_helper' module PropertyInjector describe Options do describe "#source folder option" do it "sets up a source folder" do argv = %w{-e path/to/some/folder} puts "argv[0]: #{argv[0]}" puts "argv[1]: #{argv[1]}" options = Options.new(argv) puts "options.export_folder: #{options.export_folder}" options.export_folder.should == argv[1] end end end end [/code] class Options: [code] module PropertyInjector class Options def initialize(argv) @bundle_folder = DEFAULT_BUNDLE_FOLDER @export_folder = DEFAULT_EXPORT_FOLDER @import_file_path = File.join(DEFAULT_IMPORT_FOLDER, EXCEL_FILE_NAME) @export = true @locales = ['en'] parse(argv) end private def parse(argv) OptionParser.new do |opts| opts.banner = "Usage: translation properties injector [options]." opts.on("-e [EXPORT_FOLDER]", "--export [EXPORT_FOLDER]", String, "Path to the export folder to contain a generated Excel file, (default=#{DEFAULT_EXPORT_FOLDER}") do |folder| @export = true @export_folder = folder if folder end opts.on("-i [EXCEL_FILE_PATH]", "--import [EXCEL_FILE_PATH]", String, "Path to the Excel file to import translations from (default=#{DEFAULT_IMPORT_FOLDER}/#{EXCEL_FILE_NAME})") do |file_path| @export = false @import_file_path = file_path if file_path end opts.on("-b [BUNDLE_FOLDER]", "--bundle [BUNDLE_FOLDER]", String, "Path to the folder containing properties files, (default=#{DEFAULT_BUNDLE_FOLDER})") do |folder| @bundle_folder = folder if folder end opts.on("-l [l1,l2,l3]", "--langs [l1,l2,l3]", Array, "Locales values to use separated by comma, starting from the known one, default=en") do |langs| if langs @locales = langs.map(&:downcase) @locales.uniq! end end opts.on("-", "--help", "Show this message") do puts opts exit end begin argv = ["-h"] if argv.empty? opts.parse!(argv) rescue OptionParser::ParseError => e STDERR.puts e.message, "\n", opts exit(1) end end end end end [/code] After running the test, here is what I got: [code] PropertyInjector::Options #source folder option argv[0]: -e argv[1]: path/to/some/folder options.export_folder: path/to/some/folder sets up a source folder (FAILED - 1) Failures: 1) PropertyInjector::Options#source folder option sets up a source folder Failure/Error: options.export_folder.should == argv[1] expected: nil got: "path/to/some/folder" (using ==) # ./spec/property_injector/options_spec.rb:12:in `block (3 levels) in ' Finished in 0.01562 seconds 1 example, 1 failure Failed examples: rspec ./spec/property_injector/options_spec.rb:6 # PropertyInjector::Options#source folder option sets up a source folder [/code] WHY the second argument is NIL if it WAS NOT before (path/to/some/folder)? Thank you in advance. -- Posted via http://www.ruby-forum.com/. From katrina.owen at gmail.com Wed Feb 15 14:59:30 2012 From: katrina.owen at gmail.com (Katrina Owen) Date: Wed, 15 Feb 2012 20:59:30 +0100 Subject: [rspec-users] Such a simple test fails. But why ? In-Reply-To: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> References: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> Message-ID: On Wed, Feb 15, 2012 at 5:57 PM, Serguei Cambour wrote: > WHY the second argument is NIL if it WAS NOT before > (path/to/some/folder)? If you change this: > options.export_folder.should == argv[1] to this: options.export_folder.should eq(argv[1]) You will see that you get the value that you've set in DEFAULT_EXPORT_FOLDER. That's not quite the desired behavior either, though. I think the issue is with the OptionParser... you define all the options, but I can't see that you ever actually tell it to parse. > option_parser = OptionParser.new do |opts| > # lots of definitions > end If I'm reading this correctly, the missing piece of code is this: option_parser.parse(argv) Note that you don't want to use the bang version, because that will change your argv array, and when you compare it in the spec, argv[1] will be nil. Cheers, Katrina From katrina.owen at gmail.com Wed Feb 15 15:55:05 2012 From: katrina.owen at gmail.com (Katrina Owen) Date: Wed, 15 Feb 2012 21:55:05 +0100 Subject: [rspec-users] Such a simple test fails. But why ? In-Reply-To: References: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> Message-ID: On rereading, I see that you do parse the options using the parse! method, so the answer is to use parse(argv) instead of parse!(argv). The == vs eq() is probably irrelevant. Sorry to have brought it up. As an aside, i would recommend using a gist with an actual working (failing) examole, as that will make it easier to read, easy to run, and therefore easier to help. Hope this helps, Katrina -------------- next part -------------- An HTML attachment was scrubbed... URL: From mortenmoellerriis at gmail.com Wed Feb 15 16:31:36 2012 From: mortenmoellerriis at gmail.com (=?ISO-8859-1?Q?Morten_M=F8ller_Riis?=) Date: Wed, 15 Feb 2012 22:31:36 +0100 Subject: [rspec-users] Such a simple test fails. But why ? In-Reply-To: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> References: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> Message-ID: <-4627646220746261580@unknownmsgid> This looks a little funny in my phone. But what happens if you do this? ... options = Options.new(argv) puts "argv[0]: #{argv[0]}" puts "argv[1]: #{argv[1]}" ... Best regards Morten Sent from my iPhone On 15/02/2012, at 19.26, Serguei Cambour wrote: > I just tried to integrate a simple test to check some options passed as > argument to a class to be executed: > [code] > require 'spec_helper' > > module PropertyInjector > describe Options do > describe "#source folder option" do > it "sets up a source folder" do > argv = %w{-e path/to/some/folder} > puts "argv[0]: #{argv[0]}" > puts "argv[1]: #{argv[1]}" > options = Options.new(argv) > puts "options.export_folder: #{options.export_folder}" > options.export_folder.should == argv[1] > end > end > end > end > [/code] > class Options: > [code] > module PropertyInjector > class Options > def initialize(argv) > @bundle_folder = DEFAULT_BUNDLE_FOLDER > @export_folder = DEFAULT_EXPORT_FOLDER > @import_file_path = File.join(DEFAULT_IMPORT_FOLDER, > EXCEL_FILE_NAME) > @export = true > @locales = ['en'] > parse(argv) > end > > private > def parse(argv) > OptionParser.new do |opts| > opts.banner = "Usage: translation properties injector > [options]." > > opts.on("-e [EXPORT_FOLDER]", "--export [EXPORT_FOLDER]", > String, "Path to the export folder to contain a generated Excel file, > (default=#{DEFAULT_EXPORT_FOLDER}") do |folder| > @export = true > @export_folder = folder if folder > end > > opts.on("-i [EXCEL_FILE_PATH]", "--import [EXCEL_FILE_PATH]", > String, "Path to the Excel file to import translations from > (default=#{DEFAULT_IMPORT_FOLDER}/#{EXCEL_FILE_NAME})") do |file_path| > @export = false > @import_file_path = file_path if file_path > end > > opts.on("-b [BUNDLE_FOLDER]", "--bundle [BUNDLE_FOLDER]", > String, "Path to the folder containing properties files, > (default=#{DEFAULT_BUNDLE_FOLDER})") do |folder| > @bundle_folder = folder if folder > end > > opts.on("-l [l1,l2,l3]", "--langs [l1,l2,l3]", Array, "Locales > values to use separated by comma, starting from the known one, > default=en") do |langs| > if langs > @locales = langs.map(&:downcase) > @locales.uniq! > end > > end > > opts.on("-", "--help", "Show this message") do > puts opts > exit > end > > begin > argv = ["-h"] if argv.empty? > opts.parse!(argv) > rescue OptionParser::ParseError => e > STDERR.puts e.message, "\n", opts > exit(1) > end > end > end > end > end > [/code] > After running the test, here is what I got: > [code] > PropertyInjector::Options > #source folder option > argv[0]: -e > argv[1]: path/to/some/folder > options.export_folder: path/to/some/folder > sets up a source folder (FAILED - 1) > > Failures: > > 1) PropertyInjector::Options#source folder option sets up a source > folder > Failure/Error: options.export_folder.should == argv[1] > expected: nil > got: "path/to/some/folder" (using ==) > # ./spec/property_injector/options_spec.rb:12:in `block (3 levels) > in ' > > Finished in 0.01562 seconds > 1 example, 1 failure > > Failed examples: > > rspec ./spec/property_injector/options_spec.rb:6 # > PropertyInjector::Options#source folder option sets up a source folder > [/code] > WHY the second argument is NIL if it WAS NOT before > (path/to/some/folder)? > Thank you in advance. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From jko170 at gmail.com Wed Feb 15 16:39:23 2012 From: jko170 at gmail.com (Justin Ko) Date: Wed, 15 Feb 2012 14:39:23 -0700 Subject: [rspec-users] Such a simple test fails. But why ? In-Reply-To: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> References: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> Message-ID: <2ED82284-325E-476F-810E-D28A52F1DB94@gmail.com> On Feb 15, 2012, at 9:57 AM, Serguei Cambour wrote: > I just tried to integrate a simple test to check some options passed as > argument to a class to be executed: > [code] > require 'spec_helper' > > module PropertyInjector > describe Options do > describe "#source folder option" do > it "sets up a source folder" do > argv = %w{-e path/to/some/folder} > puts "argv[0]: #{argv[0]}" > puts "argv[1]: #{argv[1]}" > options = Options.new(argv) > puts "options.export_folder: #{options.export_folder}" > options.export_folder.should == argv[1] > end > end > end > end > [/code] > class Options: > [code] > module PropertyInjector > class Options > def initialize(argv) > @bundle_folder = DEFAULT_BUNDLE_FOLDER > @export_folder = DEFAULT_EXPORT_FOLDER > @import_file_path = File.join(DEFAULT_IMPORT_FOLDER, > EXCEL_FILE_NAME) > @export = true > @locales = ['en'] > parse(argv) > end > > private > def parse(argv) > OptionParser.new do |opts| > opts.banner = "Usage: translation properties injector > [options]." > > opts.on("-e [EXPORT_FOLDER]", "--export [EXPORT_FOLDER]", > String, "Path to the export folder to contain a generated Excel file, > (default=#{DEFAULT_EXPORT_FOLDER}") do |folder| > @export = true > @export_folder = folder if folder > end > > opts.on("-i [EXCEL_FILE_PATH]", "--import [EXCEL_FILE_PATH]", > String, "Path to the Excel file to import translations from > (default=#{DEFAULT_IMPORT_FOLDER}/#{EXCEL_FILE_NAME})") do |file_path| > @export = false > @import_file_path = file_path if file_path > end > > opts.on("-b [BUNDLE_FOLDER]", "--bundle [BUNDLE_FOLDER]", > String, "Path to the folder containing properties files, > (default=#{DEFAULT_BUNDLE_FOLDER})") do |folder| > @bundle_folder = folder if folder > end > > opts.on("-l [l1,l2,l3]", "--langs [l1,l2,l3]", Array, "Locales > values to use separated by comma, starting from the known one, > default=en") do |langs| > if langs > @locales = langs.map(&:downcase) > @locales.uniq! > end > > end > > opts.on("-", "--help", "Show this message") do > puts opts > exit > end > > begin > argv = ["-h"] if argv.empty? > opts.parse!(argv) > rescue OptionParser::ParseError => e > STDERR.puts e.message, "\n", opts > exit(1) > end > end > end > end > end > [/code] > After running the test, here is what I got: > [code] > PropertyInjector::Options > #source folder option > argv[0]: -e > argv[1]: path/to/some/folder > options.export_folder: path/to/some/folder > sets up a source folder (FAILED - 1) > > Failures: > > 1) PropertyInjector::Options#source folder option sets up a source > folder > Failure/Error: options.export_folder.should == argv[1] > expected: nil > got: "path/to/some/folder" (using ==) > # ./spec/property_injector/options_spec.rb:12:in `block (3 levels) > in ' > > Finished in 0.01562 seconds > 1 example, 1 failure > > Failed examples: > > rspec ./spec/property_injector/options_spec.rb:6 # > PropertyInjector::Options#source folder option sets up a source folder > [/code] > WHY the second argument is NIL if it WAS NOT before > (path/to/some/folder)? > Thank you in advance. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users OptionParser is obviously mutating "argv". Try passing "argv.dup" From lists at ruby-forum.com Thu Feb 16 05:14:12 2012 From: lists at ruby-forum.com (Serguei Cambour) Date: Thu, 16 Feb 2012 11:14:12 +0100 Subject: [rspec-users] Such a simple test fails. But why ? In-Reply-To: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> References: <9e14d25cd62411c454cb8cb26543e007@ruby-forum.com> Message-ID: <8fa887a310b998ae5de6122da020140f@ruby-forum.com> I found why and shame on me :(((. The array variable 'argv' was passed by reference into the Options class and was modified there by 'parse' method. That's why, when returned back to the testing code, the array was nil. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Thu Feb 16 05:17:33 2012 From: matt at mattwynne.net (Matt Wynne) Date: Thu, 16 Feb 2012 10:17:33 +0000 Subject: [rspec-users] stale records with integration testing? In-Reply-To: References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> <92DCB130-D9DA-469A-BDA6-C3F2EC8E9805@gmail.com> Message-ID: <5D0DEE59-6086-4F6B-8ECA-25F542699EA2@mattwynne.net> On 14 Feb 2012, at 20:44, Justin Ko wrote: > > On Feb 14, 2012, at 9:23 AM, David Chelimsky wrote: > >> On Tue, Feb 14, 2012 at 9:28 AM, Justin Ko wrote: >>> >>> On Feb 13, 2012, at 10:35 PM, David Chelimsky wrote: >>> >>>> On Mon, Feb 13, 2012 at 9:04 PM, Justin Ko wrote: >>>>> >>>>> On Feb 13, 2012, at 1:16 PM, Patrick J. Collins wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I was writing an integration test for my user signup form (with >>>>>> capybara), and found that my test was failing due to a validation error: >>>>>> "email is already taken". I'm a bit confused because I thought when I >>>>>> run "rspec spec/some_spec.rb", the test database would be wiped clear? >>>>>> >>>>>> Is that not the case? >>>>>> >>>>>> Patrick J. Collins >>>>>> http://collinatorstudios.com >>>>>> >>>>>> _______________________________________________ >>>>>> rspec-users mailing list >>>>>> rspec-users at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>>> You basically have two options to ensure a clean database: >>>>> >>>>> 1.) Transactional examples: >>>>> >>>>> RSpec.configuration.use_transactional_examples = true >>>>> >>>>> 2.) DatabaseCleaner: >>>>> >>>>> RSpec.configure do |config| >>>>> config.before { DatabaseCleaner.start } >>>>> config.after { DatabaseCleaner.clean } >>>>> end >>>>> >>>>> Look into what those do. Let us know if you get stuck. >>>> >>>> What Justin says is true if you're running in the same process. If >>>> you're using Capybara to run examples in-bro.wser, then option 2 will >>>> work for you, but option 1 will not. >>> >>> You can still do this with an AR patch. Look at the "Transactions and database setup" in the Capybara README. >> >> "This may have thread safety implications and could cause strange >> failures, so use caution with this approach." >> >>> Using DatabaseCleaner with truncation is SLOW. >> >> True, but you can minimize that by using transaction by default, and >> specifying truncation for in-browser scenarios (which are already far >> slower than will be impacted by truncation). > > cucumber-rails has good examples on how to set this up in RSpec: > https://github.com/cucumber/cucumber-rails/blob/master/lib/cucumber/rails/database.rb > > It includes AR shared connection and truncation strategies. > > David, how come rspec-rails doesn't include support for these things as well? I don't really mind setting it up manually, but it does seem to be a necessary pattern for request specs. Probably because it's crazy complicated. If you do want to support it too, let's work out a way to factor it out into a single shared library. FYI the feature for it is here: https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature 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 mdemetrios at gmail.com Wed Feb 15 21:36:03 2012 From: mdemetrios at gmail.com (Meltemi) Date: Wed, 15 Feb 2012 18:36:03 -0800 (PST) Subject: [rspec-users] How to set cookies before request spec? Message-ID: <31583817.186.1329359763444.JavaMail.geo-discussion-forums@pbvr2> I can't seem to figure out how to set a cookie for a Request spec? Tried: before(:each) do @user = Fabricate(:user) request.cookies[:id_token] = @user.id end but that gives a NoMethodError errors: undefined method `cookies' for nil:NilClass How does one run request specs when cookies need to be simulated? *Using Capybara if that matters* -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Thu Feb 16 07:21:58 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 16 Feb 2012 06:21:58 -0600 Subject: [rspec-users] stale records with integration testing? In-Reply-To: <5D0DEE59-6086-4F6B-8ECA-25F542699EA2@mattwynne.net> References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> <92DCB130-D9DA-469A-BDA6-C3F2EC8E9805@gmail.com> <5D0DEE59-6086-4F6B-8ECA-25F542699EA2@mattwynne.net> Message-ID: On Thu, Feb 16, 2012 at 4:17 AM, Matt Wynne wrote: > > On 14 Feb 2012, at 20:44, Justin Ko wrote: > > > On Feb 14, 2012, at 9:23 AM, David Chelimsky wrote: > > On Tue, Feb 14, 2012 at 9:28 AM, Justin Ko wrote: > > > On Feb 13, 2012, at 10:35 PM, David Chelimsky wrote: > > > On Mon, Feb 13, 2012 at 9:04 PM, Justin Ko wrote: > > > On Feb 13, 2012, at 1:16 PM, Patrick J. Collins wrote: > > > Hi, > > > I was writing an integration test for my user signup form (with > > capybara), and found that my test was failing due to a validation error: > > "email is already taken". ?I'm a bit confused because I thought when I > > run "rspec spec/some_spec.rb", the test database would be wiped clear? > > > Is that not the case? > > > Patrick J. Collins > > http://collinatorstudios.com > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > You basically have two options to ensure a clean database: > > > 1.) Transactional examples: > > > RSpec.configuration.use_transactional_examples = true > > > 2.) DatabaseCleaner: > > > RSpec.configure do |config| > > config.before { DatabaseCleaner.start } > > config.after { DatabaseCleaner.clean } > > end > > > Look into what those do. Let us know if you get stuck. > > > What Justin says is true if you're running in the same process. If > > you're using Capybara to run examples in-bro.wser, then option 2 will > > work for you, but option 1 will not. > > > You can still do this with an AR patch. Look at the "Transactions and > database setup" in the Capybara README. > > > "This may have thread safety implications and could cause strange > > failures, so use caution with this approach." > > > Using DatabaseCleaner with truncation is SLOW. > > > True, but you can minimize that by using transaction by default, and > > specifying truncation for in-browser scenarios (which are already far > > slower than will be impacted by truncation). > > > cucumber-rails has good examples on how to set this up in RSpec: > https://github.com/cucumber/cucumber-rails/blob/master/lib/cucumber/rails/database.rb > > It includes AR shared connection and truncation strategies. > > David, how come rspec-rails doesn't include support for these things as > well? I don't really mind setting it up manually, but it does seem to be a > necessary pattern for request specs. > > > Probably because it's crazy complicated. Seems so, but worthwhile. Also, I wasn't aware of the shared connection strategy before this thread. > If you do want to support it too, > let's work out a way to factor it out into a single shared library. I like this idea but am seriously overcommitted right now. Can you two coordinate on this? > FYI the > feature for it is here: > https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature > > cheers, > Matt From dchelimsky at gmail.com Thu Feb 16 07:59:19 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 16 Feb 2012 06:59:19 -0600 Subject: [rspec-users] How to set cookies before request spec? In-Reply-To: <31583817.186.1329359763444.JavaMail.geo-discussion-forums@pbvr2> References: <31583817.186.1329359763444.JavaMail.geo-discussion-forums@pbvr2> Message-ID: On Wed, Feb 15, 2012 at 8:36 PM, Meltemi wrote: > I can't seem to figure out how to set a cookie for a Request spec? ?Tried: > > before(:each) do > ??@user = Fabricate(:user) > ??request.cookies[:id_token] = @user.id > end > > but that gives a NoMethodError errors: undefined method `cookies' for > nil:NilClass > > How does one run request specs when cookies need to be simulated? > Using Capybara if that matters Request specs wrap Rails' integration tests, which simulate browser interaction, but that's all. The idea is to not stub, simulate, etc, anything internal at all. It's OK to create the `@user`, but cookies should get set by making other requests that do so. Make sense? From lists at iDIAcomputing.com Thu Feb 16 12:58:14 2012 From: lists at iDIAcomputing.com (George Dinwiddie) Date: Thu, 16 Feb 2012 12:58:14 -0500 Subject: [rspec-users] How to set cookies before request spec? In-Reply-To: <31583817.186.1329359763444.JavaMail.geo-discussion-forums@pbvr2> References: <31583817.186.1329359763444.JavaMail.geo-discussion-forums@pbvr2> Message-ID: <4F3D43B6.5000902@iDIAcomputing.com> Meltemi, On 2/15/12 9:36 PM, Meltemi wrote: > I can't seem to figure out how to set a cookie for a Request spec? Tried: > > before(:each) do > @user = Fabricate(:user) > request.cookies[:id_token] = @user.id > end > > but that gives a NoMethodError errors: undefined method `cookies' for > nil:NilClass In that snippit, "request" has not been constructed and therefore is nil. - George -- ---------------------------------------------------------------------- * George Dinwiddie * http://blog.gdinwiddie.com Software Development http://www.idiacomputing.com Consultant and Coach http://www.agilemaryland.org ---------------------------------------------------------------------- From matt at mattwynne.net Fri Feb 17 07:55:48 2012 From: matt at mattwynne.net (Matt Wynne) Date: Fri, 17 Feb 2012 12:55:48 +0000 Subject: [rspec-users] stale records with integration testing? In-Reply-To: References: <5A499142-C473-4E60-A598-682D6150DF69@gmail.com> <92DCB130-D9DA-469A-BDA6-C3F2EC8E9805@gmail.com> <5D0DEE59-6086-4F6B-8ECA-25F542699EA2@mattwynne.net> Message-ID: <774A91A7-4D40-4567-9D85-F638DE9615DA@mattwynne.net> On 16 Feb 2012, at 12:21, David Chelimsky wrote: > On Thu, Feb 16, 2012 at 4:17 AM, Matt Wynne wrote: >> >> On 14 Feb 2012, at 20:44, Justin Ko wrote: >> >> >> On Feb 14, 2012, at 9:23 AM, David Chelimsky wrote: >> >> On Tue, Feb 14, 2012 at 9:28 AM, Justin Ko wrote: >> >> >> On Feb 13, 2012, at 10:35 PM, David Chelimsky wrote: >> >> >> On Mon, Feb 13, 2012 at 9:04 PM, Justin Ko wrote: >> >> >> On Feb 13, 2012, at 1:16 PM, Patrick J. Collins wrote: >> >> >> Hi, >> >> >> I was writing an integration test for my user signup form (with >> >> capybara), and found that my test was failing due to a validation error: >> >> "email is already taken". I'm a bit confused because I thought when I >> >> run "rspec spec/some_spec.rb", the test database would be wiped clear? >> >> >> Is that not the case? >> >> >> Patrick J. Collins >> >> http://collinatorstudios.com >> >> >> _______________________________________________ >> >> rspec-users mailing list >> >> rspec-users at rubyforge.org >> >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> You basically have two options to ensure a clean database: >> >> >> 1.) Transactional examples: >> >> >> RSpec.configuration.use_transactional_examples = true >> >> >> 2.) DatabaseCleaner: >> >> >> RSpec.configure do |config| >> >> config.before { DatabaseCleaner.start } >> >> config.after { DatabaseCleaner.clean } >> >> end >> >> >> Look into what those do. Let us know if you get stuck. >> >> >> What Justin says is true if you're running in the same process. If >> >> you're using Capybara to run examples in-bro.wser, then option 2 will >> >> work for you, but option 1 will not. >> >> >> You can still do this with an AR patch. Look at the "Transactions and >> database setup" in the Capybara README. >> >> >> "This may have thread safety implications and could cause strange >> >> failures, so use caution with this approach." >> >> >> Using DatabaseCleaner with truncation is SLOW. >> >> >> True, but you can minimize that by using transaction by default, and >> >> specifying truncation for in-browser scenarios (which are already far >> >> slower than will be impacted by truncation). >> >> >> cucumber-rails has good examples on how to set this up in RSpec: >> https://github.com/cucumber/cucumber-rails/blob/master/lib/cucumber/rails/database.rb >> >> It includes AR shared connection and truncation strategies. >> >> David, how come rspec-rails doesn't include support for these things as >> well? I don't really mind setting it up manually, but it does seem to be a >> necessary pattern for request specs. >> >> >> Probably because it's crazy complicated. > > Seems so, but worthwhile. Also, I wasn't aware of the shared > connection strategy before this thread. > >> If you do want to support it too, >> let's work out a way to factor it out into a single shared library. > > I like this idea but am seriously overcommitted right now. Can you two > coordinate on this? I know how you feel, but I will try to help, yes. I think reading the feature is a good place to start: that's where I dumped my understanding of the problem when I last worked on it: >> https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature 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 thoen at edgevaleinteractive.com Fri Feb 17 11:06:48 2012 From: thoen at edgevaleinteractive.com (thoen) Date: Fri, 17 Feb 2012 08:06:48 -0800 (PST) Subject: [rspec-users] Rspec 2 expectations matching what is received, but failing Message-ID: <1d16d79b-661a-4b54-82f8-a052345b4ac3@v2g2000vbx.googlegroups.com> I noticed a couple of similar posts (such as http://groups.google.com/group/rspec/browse_thread/thread/81554bd8ad0b03a3/ed61a787c00dd601?lnk=gst&q=received+expected+is+the+same+as+got#ed61a787c00dd601), but they didn't seem to have the same situation I have. Also, I apologize in advance for posting a question that is likely a simple syntax error or similar that I just don't see. I am receiving the following error: Failures: 1) SignUpObserver#after_create callback for a volunteer with an email address delivers a 'new sign up' email to the event owner Failure/Error: subject { sign_up_observer.after_create(sign_up) } received :new_sign_up_owner with unexpected arguments expected: (#, ) got: (#, ) # ./app/models/sign_up_observer.rb:4:in `after_create' # ./spec/models/sign_up_observer_spec.rb:13:in `block (3 levels) in ' # ./spec/models/sign_up_observer_spec.rb:25:in `block (4 levels) in ' For this spec describe SignUpObserver do let(:event_owner) { mock_model(Person, :email => 'event_owner at test.host').as_null_object } let(:event) { mock_model(Event, :owner => event_owner).as_null_object } let(:volunteer) { mock_model(Person, :email => volunteer_email).as_null_object } let(:volunteer_opportunity) { mock_model(VolunteerOpportunity, :event => event, :title => 'volunteer opportunity title').as_null_object } let(:sign_up) { mock_model(SignUp, :assigner => event_owner, :person => volunteer, :volunteer_opportunity => volunteer_opportunity) } let(:sign_up_observer) { SignUpObserver.instance } describe '#after_create callback' do subject { sign_up_observer.after_create(sign_up) } context 'for a volunteer with an email address' do let(:volunteer_email) { 'email at test.host' } it "delivers a 'new sign up' email to the event owner" do mock = mock(:emailer) SignUpMailer.should_receive(:new_sign_up_owner).with(sign_up, event_owner).and_return(mock) mock.should_receive(:deliver) subject end it "delivers a 'new sign up' email to the person signing up" do should_send_kind_of_sign_up_email_to(:new_sign_up_signee, sign_up, volunteer) subject end end end end in SignUpObserver def after_create(sign_up) SignUpMailer.new_sign_up_signee(sign_up, sign_up.person).deliver if sign_up and sign_up.person and !sign_up.person.email.blank? SignUpMailer.new_sign_up_owner(sign_up, sign_up.volunteer_opportunity.event.owner) end So there are two things I can't get my head around. The first is the expectation matching what I got. The second is the second parameter (event_owner) seems to be nil. I have checked it using debugger and it is not nil. I am upgrading from Rails 2.3.14 to rails 3.0.10. It passes in 2.3.14 I am using Rspec 2.8 Your gentle advice is greatly appreciated. Tom From jko170 at gmail.com Tue Feb 21 09:03:22 2012 From: jko170 at gmail.com (Justin Ko) Date: Tue, 21 Feb 2012 01:03:22 -0800 (PST) Subject: [rspec-users] should_receive_chain Message-ID: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> Do you often find yourself doing this: active = double('active') active.should_receive(:first) users = double('users', active: active) account.should_receive(:users).and_return(users) for this: account.users.active.first ? Of course, we could use stub_chain, but that doesn't let us know *where* the chain broke. Would you like to do this? account.should_receive_chain(:users, :active, :first) Under the hood, it would create something like this: users = double('user') active = double('active') first = double('first') users.should_receive(:active).and_return(active) active.should_receive(:first).and_return(first) Note, this would *not* be part of RSpec, but rather a separate gem. Would this alleviate any pain for you? From ken.chien at gmail.com Tue Feb 21 13:43:12 2012 From: ken.chien at gmail.com (Ken Chien) Date: Tue, 21 Feb 2012 08:43:12 -0500 Subject: [rspec-users] should_receive_chain In-Reply-To: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> References: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> Message-ID: Hi Justin, On Tue, Feb 21, 2012 at 4:03 AM, Justin Ko wrote: > Would you like to do this? > > account.should_receive_chain(:users, :active, :first) > > I would love this syntax. I find that I usually resort to stub_chain and lose the ability to check that the object received a particular message. > Note, this would *not* be part of RSpec, but rather a separate gem. > > Would this alleviate any pain for you? > Why can't it be a part of RSpec? Regardless, it would be a nice addition to my specs. Regards, Ken -------------- next part -------------- An HTML attachment was scrubbed... URL: From timgremore at gmail.com Tue Feb 21 14:10:13 2012 From: timgremore at gmail.com (Tim Gremore) Date: Tue, 21 Feb 2012 08:10:13 -0600 Subject: [rspec-users] should_receive_chain In-Reply-To: References: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> Message-ID: +1 I've often wondered if there is a better way to stub this situation. On Tue, Feb 21, 2012 at 7:43 AM, Ken Chien wrote: > Hi Justin, > > On Tue, Feb 21, 2012 at 4:03 AM, Justin Ko wrote: > >> Would you like to do this? >> >> account.should_receive_chain(:users, :active, :first) >> >> > I would love this syntax. I find that I usually resort to stub_chain and > lose the ability to check that the object received a particular message. > > > >> Note, this would *not* be part of RSpec, but rather a separate gem. >> >> Would this alleviate any pain for you? >> > > Why can't it be a part of RSpec? Regardless, it would be a nice addition > to my specs. > > Regards, > Ken > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Tim Gremore 920 471-1716 -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick at collinatorstudios.com Tue Feb 21 17:21:52 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Tue, 21 Feb 2012 09:21:52 -0800 (PST) Subject: [rspec-users] should_receive_chain In-Reply-To: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> References: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> Message-ID: > Would you like to do this? > > account.should_receive_chain(:users, :active, :first) +1 from me! Patrick J. Collins http://collinatorstudios.com From mikepackdev at gmail.com Tue Feb 21 20:48:12 2012 From: mikepackdev at gmail.com (Mike Pack) Date: Tue, 21 Feb 2012 12:48:12 -0800 (PST) Subject: [rspec-users] should_receive_chain In-Reply-To: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> References: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> Message-ID: <8312878.51.1329857292526.JavaMail.geo-discussion-forums@ynnj12> Yup, I find myself doing this all the time. I think it should be considered that too deep of a stub chain could be a sign of poor abstraction/information hiding. Could lead to bad practices? On the flipside, this would be super helpful when dealing with Railsy stubs because of long scope chains (but IMO long scope chains should be enclosed in a method). Also, why not rspec core? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dchelimsky at gmail.com Wed Feb 22 15:41:18 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Feb 2012 09:41:18 -0600 Subject: [rspec-users] should_receive_chain In-Reply-To: <8312878.51.1329857292526.JavaMail.geo-discussion-forums@ynnj12> References: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> <8312878.51.1329857292526.JavaMail.geo-discussion-forums@ynnj12> Message-ID: On Tue, Feb 21, 2012 at 2:48 PM, Mike Pack wrote: > Yup, I find myself doing this all the time. I think it should be considered > that too deep of a stub chain could be a sign of poor > abstraction/information hiding. Could lead to bad practices? On the > flipside, this would be super helpful when dealing with Railsy stubs because > of long scope chains (but IMO long scope chains should be enclosed in a > method). > > Also, why not rspec core? First - it would be rspec-mocks, not rspec-core. Second - in all but the rarest cases (mostly fluent interfaces), it exacerbates highly coupled designs by making them seemingly easier to test (but in the long run they just add to the problems associated w/ coupling). This is already true of stub_chain, which I already regret including in rspec-mocks for these reasons. If @justinko introduces a separate gem for should_receive_chain, I'd probably want to move stub_chain to that gem as well. Note that I'm not saying that every use of stub_chain is incorrect, or un-pragmatic. I just think that if there's another way to get at that feature, rspec-mocks is better off without it. From matt at mattwynne.net Wed Feb 22 16:00:16 2012 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 22 Feb 2012 16:00:16 +0000 Subject: [rspec-users] should_receive_chain In-Reply-To: References: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> <8312878.51.1329857292526.JavaMail.geo-discussion-forums@ynnj12> Message-ID: On 22 Feb 2012, at 15:41, David Chelimsky wrote: > On Tue, Feb 21, 2012 at 2:48 PM, Mike Pack wrote: >> Yup, I find myself doing this all the time. I think it should be considered >> that too deep of a stub chain could be a sign of poor >> abstraction/information hiding. Could lead to bad practices? On the >> flipside, this would be super helpful when dealing with Railsy stubs because >> of long scope chains (but IMO long scope chains should be enclosed in a >> method). >> >> Also, why not rspec core? > > First - it would be rspec-mocks, not rspec-core. > > Second - in all but the rarest cases (mostly fluent interfaces), it > exacerbates highly coupled designs by making them seemingly easier to > test (but in the long run they just add to the problems associated w/ > coupling). This is already true of stub_chain, which I already regret > including in rspec-mocks for these reasons. If @justinko introduces a > separate gem for should_receive_chain, I'd probably want to move > stub_chain to that gem as well. > > Note that I'm not saying that every use of stub_chain is incorrect, or > un-pragmatic. I just think that if there's another way to get at that > feature, rspec-mocks is better off without it. ^ Yep, what he said ^ 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 jko170 at gmail.com Wed Feb 22 21:15:56 2012 From: jko170 at gmail.com (Justin Ko) Date: Wed, 22 Feb 2012 14:15:56 -0700 Subject: [rspec-users] should_receive_chain In-Reply-To: References: <31ad4dd7-9b87-4cb5-8bd3-de7237f229e0@qt10g2000pbb.googlegroups.com> <8312878.51.1329857292526.JavaMail.geo-discussion-forums@ynnj12> Message-ID: <60C7B512-E443-4CF7-AA57-6FAE045567AC@gmail.com> On Feb 22, 2012, at 9:00 AM, Matt Wynne wrote: > > On 22 Feb 2012, at 15:41, David Chelimsky wrote: > >> On Tue, Feb 21, 2012 at 2:48 PM, Mike Pack wrote: >>> Yup, I find myself doing this all the time. I think it should be considered >>> that too deep of a stub chain could be a sign of poor >>> abstraction/information hiding. Could lead to bad practices? On the >>> flipside, this would be super helpful when dealing with Railsy stubs because >>> of long scope chains (but IMO long scope chains should be enclosed in a >>> method). >>> >>> Also, why not rspec core? >> >> First - it would be rspec-mocks, not rspec-core. >> >> Second - in all but the rarest cases (mostly fluent interfaces), it >> exacerbates highly coupled designs by making them seemingly easier to >> test (but in the long run they just add to the problems associated w/ >> coupling). This is already true of stub_chain, which I already regret >> including in rspec-mocks for these reasons. If @justinko introduces a >> separate gem for should_receive_chain, I'd probably want to move >> stub_chain to that gem as well. >> >> Note that I'm not saying that every use of stub_chain is incorrect, or >> un-pragmatic. I just think that if there's another way to get at that >> feature, rspec-mocks is better off without it. > > ^ Yep, what he said ^ > > cheers, > Matt > > -- > Freelance programmer & coach > Author, http://pragprog.com/book/hwcuc/the-cucumber-book > Founder, http://www.relishapp.com/ > Twitter, https://twitter.com/mattwynne > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Now that I think about it, the only time I use stub_chain is in Rails controllers, for scopes (which is also pretty rare). I'm 100% for extracting stub_chain into a gem, along with any_instance. We could call it "rspec-mocks-extensions" :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From bill.christian at gmail.com Wed Feb 22 20:28:28 2012 From: bill.christian at gmail.com (Bill Christian) Date: Wed, 22 Feb 2012 12:28:28 -0800 (PST) Subject: [rspec-users] Advice on using Rspec as a data validation engine In-Reply-To: <639A8209-17EA-4585-AE94-C57E4916C740@me.com> References: <11845012.229.1323833571679.JavaMail.geo-discussion-forums@yqba2> <639A8209-17EA-4585-AE94-C57E4916C740@me.com> Message-ID: <19700518.172.1329942508704.JavaMail.geo-discussion-forums@yner4> I have a working prototype. However, I am having trouble instrumenting the automation. Are there existing examples or libraries that execute tests outside of a console? -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick at collinatorstudios.com Thu Feb 23 04:01:04 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Wed, 22 Feb 2012 20:01:04 -0800 (PST) Subject: [rspec-users] initializer require weirdness only within rspec? Message-ID: So, I've got the following structure: # config/application.rb config.autoload_paths += ["#{Rails.root}/lib"] # initializers/core_ext.rb require "core_ext/array.rb" require "core_ext/hash.rb" require "core_ext/numeric.rb" require "core_ext/float.rb" require "core_ext/object.rb" # lib/core_ext/* ( various opened classes with added methods ) ... So, I found that my specs were failing because these added methods did not exist in the context of the tests.. yet in the console, and in the app they do.. I added a "puts" call to the beginning of each require to see what was happening. In the console, I got all trues.. When running rspec spec, I got trues for array, float, and numeric, but false for object and hash! ....... Totally confused... Simply changing the initializer to specify Rails.root for those two files fixed the problem: # initializers/core_ext.rb require "core_ext/array.rb" require "#{Rails.root}/lib/core_ext/hash.rb" require "core_ext/numeric.rb" require "core_ext/float.rb" require "#{Rails.root}/lib/core_ext/object.rb" This gives all trues with rspec spec, but--- why? Patrick J. Collins http://collinatorstudios.com From dchelimsky at gmail.com Thu Feb 23 04:37:56 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 22 Feb 2012 22:37:56 -0600 Subject: [rspec-users] initializer require weirdness only within rspec? In-Reply-To: References: Message-ID: <299A5170-A739-4575-A090-B07E7B1D7AEB@gmail.com> On Feb 22, 2012, at 10:01 PM, "Patrick J. Collins" wrote: > So, I've got the following structure: > > # config/application.rb > config.autoload_paths += ["#{Rails.root}/lib"] > > # initializers/core_ext.rb > require "core_ext/array.rb" > require "core_ext/hash.rb" > require "core_ext/numeric.rb" > require "core_ext/float.rb" > require "core_ext/object.rb" > > # lib/core_ext/* > ( various opened classes with added methods ) > > ... > > So, I found that my specs were failing because these added methods did > not exist in the context of the tests.. yet in the console, and in the > app they do.. I added a "puts" call to the beginning of each require to > see what was happening. In the console, I got all trues.. When running > rspec spec, I got trues for array, float, and numeric, but false for > object and hash! > > ....... Totally confused... Simply changing the initializer to specify > Rails.root for those two files fixed the problem: > > # initializers/core_ext.rb > require "core_ext/array.rb" > require "#{Rails.root}/lib/core_ext/hash.rb" > require "core_ext/numeric.rb" > require "core_ext/float.rb" > require "#{Rails.root}/lib/core_ext/object.rb" > > This gives all trues with rspec spec, but--- why? Not certain and away from computer, but best guess is that another core_ext/object.rb lives in another lib (pretty sure active_support has this) that is, for whatever reason, showing up on the load path earlier when you're running rspec. Also, autoload paths is for loading files using autoload e.g. the first time any code refs Thing, rails looks for a file at thing.rb within the autoload directories. The way you're using it for lib is not only not as intended, but probably has no effect at all. Try commenting that line out and I suspect you'll see no difference. As for how to fix, I tend to do this sort of thing by requiring "#{Rails.root}/lib/core_ext" from environment.rb, and have that file require the files in lib/core_ext/. HTH, David From lists at ruby-forum.com Thu Feb 23 16:32:06 2012 From: lists at ruby-forum.com (Tom Tom) Date: Thu, 23 Feb 2012 17:32:06 +0100 Subject: [rspec-users] Testing Signin for Admin_Employee Message-ID: <9c86de1ec16afbd35ffc2fc94d472a89@ruby-forum.com> I am following railstutorial 2nd edition and in it we have a Signin test in our integration tests as follows: require 'spec_helper' describe "Authentication" do subject { page } describe "signin" do before { visit signin_path } it { should have_selector('h2', text: 'Sign in') } it { should have_selector('title', text: 'Sign in') } describe "with valid information" do let(:employee) { FactoryGirl.create(:employee) } before { valid_signin(employee) } it { should have_selector('title', text: employee.emp_full_name) } it { should_not have_link('Employees', href: employees_path) } it { should_not have_link('Profile', href: employee_path(employee)) } it { should_not have_link('Settings', href: edit_employee_path(employee)) } it { should_not have_link('New Employee', href: new_employee_path) } it { should have_link('Sign out', href: signout_path) } it { should_not have_link('Sign in', href: signin_path) } end end end This test passes as shown. I am trying to modify the test for the case when an Employee has admin privileges. To that end I have modified the app/views/layouts/_header.html.erb to ensure that only employees with admin privileges can see the four links that currently read as 'should_not have_link'. FactoryGirl has the ability to create an admin user. I have admin_employee defined in employee controller which is: def admin_employee redirect_to(root_path) unless current_user.admin? Can someone please help me design my test so that the above test will pass for an employee with admin privileges? Thanks. -- Posted via http://www.ruby-forum.com/. From jko170 at gmail.com Thu Feb 23 20:45:20 2012 From: jko170 at gmail.com (Justin Ko) Date: Thu, 23 Feb 2012 13:45:20 -0700 Subject: [rspec-users] Testing Signin for Admin_Employee In-Reply-To: <9c86de1ec16afbd35ffc2fc94d472a89@ruby-forum.com> References: <9c86de1ec16afbd35ffc2fc94d472a89@ruby-forum.com> Message-ID: <638991ED-73E7-4AA1-B028-D35BFA2728A4@gmail.com> On Feb 23, 2012, at 9:32 AM, Tom Tom wrote: > I am following railstutorial 2nd edition and in it we have a Signin test > in our integration tests as follows: > > require 'spec_helper' > > describe "Authentication" do > > subject { page } > > describe "signin" do > before { visit signin_path } > > it { should have_selector('h2', text: 'Sign in') } > it { should have_selector('title', text: 'Sign in') } > > describe "with valid information" do > let(:employee) { FactoryGirl.create(:employee) } > before { valid_signin(employee) } > > it { should have_selector('title', text: > employee.emp_full_name) } > > it { should_not have_link('Employees', href: > employees_path) } > it { should_not have_link('Profile', href: > employee_path(employee)) } > it { should_not have_link('Settings', href: > edit_employee_path(employee)) } > it { should_not have_link('New Employee', href: > new_employee_path) } > > it { should have_link('Sign out', href: signout_path) } > > it { should_not have_link('Sign in', href: signin_path) } > end > end > end > > This test passes as shown. > > I am trying to modify the test for the case when an Employee has admin > privileges. To that end I have modified the > app/views/layouts/_header.html.erb to ensure that only employees with > admin privileges can see the four links that currently read as > 'should_not have_link'. > > FactoryGirl has the ability to create an admin user. > I have admin_employee defined in employee controller which is: > > def admin_employee > redirect_to(root_path) unless current_user.admin? > > Can someone please help me design my test so that the above test will > pass for an employee with admin privileges? > > Thanks. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Hello, what you want is "shared examples/context": https://gist.github.com/1894922 From apnea.diving.deep at gmail.com Thu Feb 23 21:36:33 2012 From: apnea.diving.deep at gmail.com (apneadiving) Date: Thu, 23 Feb 2012 13:36:33 -0800 (PST) Subject: [rspec-users] testing around_save Message-ID: I've just upgraded to Rails 3.2.1 and I can't get my specs checking whether or not around_save work anymore. I simply did something like: object.should_receive :around_filter_name object.save.should be_true (Actually, it was slightly more complex, it's part of a state machine) From dchelimsky at gmail.com Fri Feb 24 01:36:46 2012 From: dchelimsky at gmail.com (David Chelimsky) Date: Thu, 23 Feb 2012 19:36:46 -0600 Subject: [rspec-users] testing around_save In-Reply-To: References: Message-ID: <3AE63E84-D90A-4B65-B232-8155E8C22310@gmail.com> On Feb 23, 2012, at 3:36 PM, apneadiving wrote: > I've just upgraded to Rails 3.2.1 and I can't get my specs checking > whether or not around_save work anymore. What version did you upgrade from? Anything else change in the process? > I simply did something like: > > object.should_receive :around_filter_name > object.save.should be_true > > (Actually, it was slightly more complex, it's part of a state machine) Mock objects (message expectations / should_receive) are for specifying interaction _between objects_, not internal implementation of a single object. There are plenty of guidelines that point in that direction, two of which are explicitly violated in this example: 1. mock your own code, not your dependencies (in this case you're mocking ActiveRecord internals) 2. don't mock the subject of a test The motivation for both of these guidelines is exactly what you're experiencing. Something changed out from under you and you have no idea what and why your test doesn't work anymore. I'd recommend using a black block approach for this instead of a message expectation: get the object into the state you want, call object.save, and then specify the resulting state. HTH, David From husseini.mel at gmail.com Thu Feb 23 23:38:39 2012 From: husseini.mel at gmail.com (Mohamad El-Husseini) Date: Thu, 23 Feb 2012 15:38:39 -0800 (PST) Subject: [rspec-users] Can someone clarify this RSpec block? Message-ID: <1778007.10172.1330040319744.JavaMail.geo-discussion-forums@ynbo36> I'm new to RSpec, Rails, and Ruby. I'm following the Rails Tutorial. I was going over some RSpec code and go wanted some clarification: describe "User pages" do subject { page } describe "sign up" do describe "with valid information" do before do fill_in "Name", with: "Mickey Mouse" fill_in "Email", with: "mickey at disney.com" fill_in "Password", with: "m1ck3y" fill_in "Confirmation", with: "m1ck3y" end it "should create a user" do # block 1 expect { click_button "Sign up" }.to change(User, :count).by(1) end describe "after saving the user" do #block 2 before { click_button 'Sign up' } let(:user) { User.find_by_email('mickey at disney.com') } it { should have_selector('title', text: user.name) } it { should have_link('Sign out') } end end Notice the "it 'should create a user'" block. Why doesn't the user we create in that block carry over to the next block? ("after saving the user")? Why is it necessary to write before { click_button 'Sign up' } in order to test for the user? Shouldn't the user already exist as it was created in block 2? I'm looking to understand the flow of events in RSpec. Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From jko170 at gmail.com Fri Feb 24 04:10:57 2012 From: jko170 at gmail.com (Justin Ko) Date: Thu, 23 Feb 2012 21:10:57 -0700 Subject: [rspec-users] Can someone clarify this RSpec block? In-Reply-To: <1778007.10172.1330040319744.JavaMail.geo-discussion-forums@ynbo36> References: <1778007.10172.1330040319744.JavaMail.geo-discussion-forums@ynbo36> Message-ID: On Feb 23, 2012, at 4:38 PM, Mohamad El-Husseini wrote: > I'm new to RSpec, Rails, and Ruby. I'm following the Rails Tutorial. I was going over some RSpec code and go wanted some clarification: > > describe "User pages" do > subject { page } > > describe "sign up" do > describe "with valid information" do > before do > fill_in "Name", with: "Mickey Mouse" > fill_in "Email", with: "mickey at disney.com" > fill_in "Password", with: "m1ck3y" > fill_in "Confirmation", with: "m1ck3y" > end > > it "should create a user" do # block 1 > expect { click_button "Sign up" }.to change(User, :count).by(1) > end > > describe "after saving the user" do #block 2 > before { click_button 'Sign up' } > let(:user) { User.find_by_email('mickey at disney.com') } > it { should have_selector('title', text: user.name) } > it { should have_link('Sign out') } > end > end > > Notice the "it 'should create a user'" block. Why doesn't the user we create in that block carry over to the next block? ("after saving the user")? Why is it necessary to write > > before { click_button 'Sign up' } in order to test for the user? Shouldn't the user already exist as it was created in block 2? > > I'm looking to understand the flow of events in RSpec. > > Thanks! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Each example (`it`) is run in isolation from the other examples -- there is no shared state. This keeps things clean and easy to understand. In your example, just add a method for "signing up": describe "User pages" do subject { page } describe "sign up" do describe "with valid information" do before do fill_in "Name", with: "Mickey Mouse" fill_in "Email", with: "mickey at disney.com" fill_in "Password", with: "m1ck3y" fill_in "Confirmation", with: "m1ck3y" end def click_sign_up_button click_button "Sign up" end it "should create a user" do # block 1 expect { click_sign_up_button }.to change(User, :count).by(1) end describe "after saving the user" do #block 2 before { click_sign_up_button } let(:user) { User.find_by_email('mickey at disney.com') } it { should have_selector('title', text: user.name) } it { should have_link('Sign out') } end end From apnea.diving.deep at gmail.com Fri Feb 24 13:58:58 2012 From: apnea.diving.deep at gmail.com (apneadiving) Date: Fri, 24 Feb 2012 05:58:58 -0800 (PST) Subject: [rspec-users] testing around_save In-Reply-To: <3AE63E84-D90A-4B65-B232-8155E8C22310@gmail.com> References: <3AE63E84-D90A-4B65-B232-8155E8C22310@gmail.com> Message-ID: <5bef1ed4-c41a-4425-a9fb-5bfc1c63c37c@z31g2000vbt.googlegroups.com> Hi David and thanks again, I run Rspec 2.8.0. and just upgraded from Rails 3.0.10 to Rails 3.2.1. I must admit, the spec wasn't clean. But it was quick and easy... Of course I keep your advice in mind, I just have to adapt to my particular case: * I work on a legacy and untested app, so factories require much time to be built * the callbacks run a lot of code which require I load plenty of data in the object, a bit overkill just to check whether or not the callback is triggered * I run a state machine and I want to be sure proper callbacks are called (or not) from one step to another, so there are many specs. I finally decided to redefine the callback content for the current object, since, in these particular specs, I don't care of what happens inside. I had to split my specs in two parts: context "initial status waiting_assignment" do before(:each) do document.instance_eval { def on_progress; yield; end } end it "check callback" do document.should_receive(:on_progress) document.status_progress end it "check transition" do document.status_progress document.status.should eq "in_progress" end end On Feb 24, 2:36?am, David Chelimsky wrote: > On Feb 23, 2012, at 3:36 PM, apneadiving wrote: > > > I've just upgraded to Rails 3.2.1 and I can't get my specs checking > > whether or not around_save work anymore. > > What version did you upgrade from? Anything else change in the process? > > > I simply did something like: > > > object.should_receive :around_filter_name > > object.save.should be_true > > > (Actually, it was slightly more complex, it's part of a state machine) > > Mock objects (message expectations / should_receive) are for specifying interaction _between objects_, not internal implementation of a single object. There are plenty of guidelines that point in that direction, two of which are explicitly violated in this example: > > 1. mock your own code, not your dependencies (in this case you're mocking ActiveRecord internals) > 2. don't mock the subject of a test > > The motivation for both of these guidelines is exactly what you're experiencing. Something changed out from under you and you have no idea what and why your test doesn't work anymore. I'd recommend using a black block approach for this instead of a message expectation: get the object into the state you want, call object.save, and then specify the resulting state. > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users From mattvanhorn at gmail.com Fri Feb 24 15:31:01 2012 From: mattvanhorn at gmail.com (Matthew Van Horn) Date: Fri, 24 Feb 2012 07:31:01 -0800 Subject: [rspec-users] Can someone clarify this RSpec block? In-Reply-To: <1778007.10172.1330040319744.JavaMail.geo-discussion-forums@ynbo36> References: <1778007.10172.1330040319744.JavaMail.geo-discussion-forums@ynbo36> Message-ID: Each "it" runs in isolation. The flow is, all the "before" blocks run in order from outer to inner, before each "it" block. You can think of each "it" expectation as sending you to the start, to test another isolated expectation about the process. This is good, because a failure in one part of the system won't necessarily break tests for another part. -- matt On Feb 23, 2012, at 3:38 PM, Mohamad El-Husseini wrote: > I'm new to RSpec, Rails, and Ruby. I'm following the Rails Tutorial. I was going over some RSpec code and go wanted some clarification: > > describe "User pages" do > subject { page } > > describe "sign up" do > describe "with valid information" do > before do > fill_in "Name", with: "Mickey Mouse" > fill_in "Email", with: "mickey at disney.com" > fill_in "Password", with: "m1ck3y" > fill_in "Confirmation", with: "m1ck3y" > end > > it "should create a user" do # block 1 > expect { click_button "Sign up" }.to change(User, :count).by(1) > end > > describe "after saving the user" do #block 2 > before { click_button 'Sign up' } > let(:user) { User.find_by_email('mickey at disney.com') } > it { should have_selector('title', text: user.name) } > it { should have_link('Sign out') } > end > end > > Notice the "it 'should create a user'" block. Why doesn't the user we create in that block carry over to the next block? ("after saving the user")? Why is it necessary to write > > before { click_button 'Sign up' } in order to test for the user? Shouldn't the user already exist as it was created in block 2? > > I'm looking to understand the flow of events in RSpec. > > Thanks! > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From me at jbrains.ca Sat Feb 25 14:25:30 2012 From: me at jbrains.ca (J. B. Rainsberger) Date: Sat, 25 Feb 2012 16:25:30 +0200 Subject: [rspec-users] Testing Signin for Admin_Employee In-Reply-To: <638991ED-73E7-4AA1-B028-D35BFA2728A4@gmail.com> References: <9c86de1ec16afbd35ffc2fc94d472a89@ruby-forum.com> <638991ED-73E7-4AA1-B028-D35BFA2728A4@gmail.com> Message-ID: On Thu, Feb 23, 2012 at 22:45, Justin Ko wrote: > Hello, what you want is "shared examples/context": > https://gist.github.com/1894922 I commented there, too. -- J. B. (Joe) Rainsberger :: http://www.jbrains.ca :: http://blog.thecodewhisperer.com Author, JUnit Recipes Free Your Mind to Do Great Work :: http://www.freeyourmind-dogreatwork.com Find out what others have to say about me at http://nta.gs/jbrains From member at linkedin.com Sat Feb 25 17:04:17 2012 From: member at linkedin.com (Pedro Brasileiro via LinkedIn) Date: Sat, 25 Feb 2012 17:04:17 +0000 (UTC) Subject: [rspec-users] Join my network on LinkedIn Message-ID: <858382124.1400579.1330189457392.JavaMail.app@ela4-app0132.prod> LinkedIn ------------ Pedro Brasileiro requested to add you as a connection on LinkedIn: ------------------------------------------ I'd like to add you to my professional network on LinkedIn. Accept invitation from Pedro Brasileiro http://www.linkedin.com/e/c0fwx7-gz2wgi5o-46/IvymfWqycahrnXkIwHGwgZqJcdGopgOdxFyMIpp/blk/I309587295_25/1BpC5vrmRLoRZcjkkZt5YCpnlOt3RApnhMpmdzgmhxrSNBszYRcBYRej8Te3kVc3d9bSZ4umcQilF3bP8MejcVe38Vej8LrCBxbOYWrSlI/EML_comm_afe/?hs=false&tok=0-2L9D07Twi581 View invitation from Pedro Brasileiro http://www.linkedin.com/e/c0fwx7-gz2wgi5o-46/IvymfWqycahrnXkIwHGwgZqJcdGopgOdxFyMIpp/blk/I309587295_25/3kOnPkVczsUdjAMcQALqnpPbOYWrSlI/svi/?hs=false&tok=0EYnP7iRHwi581 ------------------------------------------ Why might connecting with Pedro Brasileiro be a good idea? Pedro Brasileiro's connections could be useful to you: After accepting Pedro Brasileiro's invitation, check Pedro Brasileiro's connections to see who else you may know and who you might want an introduction to. Building these connections can create opportunities in the future. -- (c) 2012, LinkedIn Corporation -------------- next part -------------- An HTML attachment was scrubbed... URL: From sahmed1020 at gmail.com Sun Feb 26 16:36:45 2012 From: sahmed1020 at gmail.com (S Ahmed) Date: Sun, 26 Feb 2012 11:36:45 -0500 Subject: [rspec-users] requests: is it possible to put the fill_in's into a method? Message-ID: I'm testing my signup page, and I want to minimize the duplication of the fill_in code for filling in the form fields and testing how my page reacts when someone forgets to enter input. fill_in "....", with: "abc123" Any tricks of doing this? Say I have 10 fill_in calls, so say I want to test to make sure the form fails if any combination of the last 4 fields are missing. I was thinking of putting the first 6 fill_in calls into a method, and then calling that method: it "should ..." do enter_first_6 # now enter 3 of the 4 and verify end it "should ..." do enter_first_6 # now enter a different combination of the last 4 fields end I haven't tested this yet, just brainstorming, any other advise? I wish things worked liked attribute hashes where you could just call .merge and change the default set. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mguterl at gmail.com Sun Feb 26 17:02:36 2012 From: mguterl at gmail.com (Michael Guterl) Date: Sun, 26 Feb 2012 12:02:36 -0500 Subject: [rspec-users] requests: is it possible to put the fill_in's into a method? In-Reply-To: References: Message-ID: On Sun, Feb 26, 2012 at 11:36 AM, S Ahmed wrote: > I'm testing my signup page, and I want to minimize the duplication of the > fill_in code for filling in the form fields and testing how my page reacts > when someone forgets to enter input. > > fill_in "....", with: "abc123" > > Any tricks of doing this? > > Say I have 10 fill_in calls, so say I want to test to make sure the form > fails if any combination of the last 4 fields are missing. > > I was thinking of putting the first 6 fill_in calls into a method, and then > calling that method: > > it "should ..." do > ? enter_first_6 > ? # now enter 3 of the 4 and verify > end > > it "should ..." do > ? enter_first_6 > ? # now enter a different combination of the last 4 fields > end > > I haven't tested this yet, just brainstorming, any other advise? > > I wish things worked liked attribute hashes where you could just call .merge > and change the default set. > What about something like this? def sign_up(attributes = {}) attributes.reverse_merge!(:first_name => "First", :last_name => "Last", :email => "foo at example.org", :password => "password", :password_confirmation => "password") fill_in "First Name", :with => attributes[:first_name] fill_in "Last Name", :with => attributes[:last_name] fill_in "Email Address", :with => attributes[:email] fill_in "Password", :with => attributes[:password] fill_in "Confirm Password", :with => attributes[:password_confirmation] click_on "Submit" end Then call it with different attributes based on your scenarios: sign_up(:password_confirmation => "foo") sign_up(:email => '') Best, Michael Guterl From apremdas at gmail.com Sun Feb 26 17:25:51 2012 From: apremdas at gmail.com (Andrew Premdas) Date: Sun, 26 Feb 2012 17:25:51 +0000 Subject: [rspec-users] requests: is it possible to put the fill_in's into a method? In-Reply-To: References: Message-ID: On 26 February 2012 16:36, S Ahmed wrote: > I'm testing my signup page, and I want to minimize the duplication of the > fill_in code for filling in the form fields and testing how my page reacts > when someone forgets to enter input. > > fill_in "....", with: "abc123" > > Any tricks of doing this? > > Say I have 10 fill_in calls, so say I want to test to make sure the form > fails if any combination of the last 4 fields are missing. > > I was thinking of putting the first 6 fill_in calls into a method, and > then calling that method: > > it "should ..." do > enter_first_6 > # now enter 3 of the 4 and verify > end > > it "should ..." do > enter_first_6 > # now enter a different combination of the last 4 fields > end > > I haven't tested this yet, just brainstorming, any other advise? > > I wish things worked liked attribute hashes where you could just call > .merge and change the default set. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > Quite a good way to do this is to create a hash that has all your values and then modify the hash for your errors. So you could do something like def good_attrs() { :foo => 'foo' :bar => 'bar ... } end then have a fill in method that takes the hash def fill_in(attrs) attrs.each do |k,v| fill_in k, :with => v ... finally do your errors by fill_in(good_attrs(:with => {:foo => nil}) or use :except etc. You can also put your a spec inside a loop %w(foo bar bax).each do |bad_attr| it "should ... #{bad_attr}..." do fill_in(good_attrs(:except => {:bad_attr}) etc. All of top of my head so expect syntax errors, but hopefully enough to be useful All best Andrew HTH Andrew -- ------------------------ Andrew Premdas blog.andrew.premdas.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.dennis at gmail.com Sun Feb 26 18:23:34 2012 From: zach.dennis at gmail.com (Zach Dennis) Date: Sun, 26 Feb 2012 13:23:34 -0500 Subject: [rspec-users] Testing Signin for Admin_Employee In-Reply-To: References: <9c86de1ec16afbd35ffc2fc94d472a89@ruby-forum.com> <638991ED-73E7-4AA1-B028-D35BFA2728A4@gmail.com> Message-ID: On Sat, Feb 25, 2012 at 9:25 AM, J. B. Rainsberger wrote: > On Thu, Feb 23, 2012 at 22:45, Justin Ko wrote: > >> Hello, what you want is "shared examples/context": >> https://gist.github.com/1894922 > > I commented there, too. I commented there as well. -- @zachdennis http://www.continuousthinking.com http://www.mutuallyhuman.com From sahmed1020 at gmail.com Sun Feb 26 22:16:07 2012 From: sahmed1020 at gmail.com (S Ahmed) Date: Sun, 26 Feb 2012 17:16:07 -0500 Subject: [rspec-users] requests: is it possible to put the fill_in's into a method? In-Reply-To: References: Message-ID: ahh, nice makes sense thanks! On Sun, Feb 26, 2012 at 12:25 PM, Andrew Premdas wrote: > On 26 February 2012 16:36, S Ahmed wrote: > >> I'm testing my signup page, and I want to minimize the duplication of >> the fill_in code for filling in the form fields and testing how my page >> reacts when someone forgets to enter input. >> >> fill_in "....", with: "abc123" >> >> Any tricks of doing this? >> >> Say I have 10 fill_in calls, so say I want to test to make sure the form >> fails if any combination of the last 4 fields are missing. >> >> I was thinking of putting the first 6 fill_in calls into a method, and >> then calling that method: >> >> it "should ..." do >> enter_first_6 >> # now enter 3 of the 4 and verify >> end >> >> it "should ..." do >> enter_first_6 >> # now enter a different combination of the last 4 fields >> end >> >> I haven't tested this yet, just brainstorming, any other advise? >> >> I wish things worked liked attribute hashes where you could just call >> .merge and change the default set. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > Quite a good way to do this is to create a hash that has all your values > and then modify the hash for your errors. So you could do something like > > def good_attrs() > { > :foo => 'foo' > :bar => 'bar > ... > } > end > > then have a fill in method that takes the hash > > def fill_in(attrs) > attrs.each do |k,v| > fill_in k, :with => v > ... > > finally do your errors by > > fill_in(good_attrs(:with => {:foo => nil}) > > or use :except etc. > > You can also put your a spec inside a loop > > %w(foo bar bax).each do |bad_attr| > it "should ... #{bad_attr}..." do > fill_in(good_attrs(:except => {:bad_attr}) > > etc. > > All of top of my head so expect syntax errors, but hopefully enough to be > useful > > All best > > Andrew > > HTH > > Andrew > -- > ------------------------ > Andrew Premdas > blog.andrew.premdas.org > > > _______________________________________________ > 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 jed.schneider at gmail.com Mon Feb 27 17:58:13 2012 From: jed.schneider at gmail.com (jed schneider) Date: Mon, 27 Feb 2012 12:58:13 -0500 Subject: [rspec-users] color option Message-ID: <4CC55BC30D9D44F581A56BFCC6A00ECB@gmail.com> we are on rspec 2.6.4 and for awhile my color flag seems to be ignored when running specs in my .rspec file but my formatting option is picking up. Did the --color flag get changed? my .rspec file --color -f d thanks! -- jed schneider Sent with Sparrow (http://www.sparrowmailapp.com/?sig) -------------- next part -------------- An HTML attachment was scrubbed... URL: From husseini.mel at gmail.com Wed Feb 29 04:43:24 2012 From: husseini.mel at gmail.com (Mohamad El-Husseini) Date: Tue, 28 Feb 2012 20:43:24 -0800 (PST) Subject: [rspec-users] Can anyone tell me why this test is failing? Message-ID: <13167708.255.1330490604060.JavaMail.geo-discussion-forums@vbpw16> I ran this scenario in the console and it works as expected. But RSpec keeps failing the test and I can't understand why. describe User do before do @user = User.new(name: "Mickey Mouse", email: "mickey at disney.com", password: "m1ckey", password_confirmation: "m1ckey") end # Password describe "when password is not present" do before { @user.password = @user.password_confirmation = " " } it { should_not be_valid } end end --> expected valid? to return false, got true If I take out the @user.password_confirmation from the assignment, it works: before { @user.password = " " } it { should_not be_valid } But, as I said, using the console I can verify that everything works as expected. Why does adding @password_confirmation break the test? Here's my user model: class User < ActiveRecord::Base attr_accessible :name, :email, :password, :password_confirmation has_secure_password validates :password, length: { minimum: 6 } end -------------- next part -------------- An HTML attachment was scrubbed... URL: From jko170 at gmail.com Wed Feb 29 09:18:10 2012 From: jko170 at gmail.com (Justin Ko) Date: Wed, 29 Feb 2012 02:18:10 -0700 Subject: [rspec-users] Can anyone tell me why this test is failing? In-Reply-To: <13167708.255.1330490604060.JavaMail.geo-discussion-forums@vbpw16> References: <13167708.255.1330490604060.JavaMail.geo-discussion-forums@vbpw16> Message-ID: On Feb 28, 2012, at 9:43 PM, Mohamad El-Husseini wrote: > I ran this scenario in the console and it works as expected. But RSpec keeps failing the test and I can't understand why. > > describe User do > > before do > @user = User.new(name: "Mickey Mouse", email: "mickey at disney.com", password: "m1ckey", password_confirmation: "m1ckey") > end > > # Password > describe "when password is not present" do > before { @user.password = @user.password_confirmation = " " } > it { should_not be_valid } > end > end > > --> expected valid? to return false, got true > > If I take out the @user.password_confirmation from the assignment, it works: > > before { @user.password = " " } > it { should_not be_valid } > > But, as I said, using the console I can verify that everything works as expected. Why does adding @password_confirmation break the test? > > Here's my user model: > > class User < ActiveRecord::Base > attr_accessible :name, :email, :password, :password_confirmation > has_secure_password > validates :password, length: { minimum: 6 } > end > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users Can't reproduce. What versions are you using? Ruby, Rails, RSpec Also, do you have a `subject` set? From husseini.mel at gmail.com Wed Feb 29 12:58:30 2012 From: husseini.mel at gmail.com (Mohamad El-Husseini) Date: Wed, 29 Feb 2012 04:58:30 -0800 (PST) Subject: [rspec-users] Can anyone tell me why this test is failing? In-Reply-To: References: <13167708.255.1330490604060.JavaMail.geo-discussion-forums@vbpw16> Message-ID: <30308856.349.1330520310816.JavaMail.geo-discussion-forums@ynkz21> Sorry, after much frustration, I closed the terminal window and restarted everything. The test passed. I have a feeling it might have had something to do with Spork or Guard... sorry for the false alarm! I should restart my terminal more often! On Wednesday, February 29, 2012 6:18:10 AM UTC-3, Justin Ko wrote: > > > On Feb 28, 2012, at 9:43 PM, Mohamad El-Husseini wrote: > > > I ran this scenario in the console and it works as expected. But RSpec > keeps failing the test and I can't understand why. > > > > describe User do > > > > before do > > @user = User.new(name: "Mickey Mouse", email: "mickey at disney.com", > password: "m1ckey", password_confirmation: "m1ckey") > > end > > > > # Password > > describe "when password is not present" do > > before { @user.password = @user.password_confirmation = " " } > > it { should_not be_valid } > > end > > end > > > > --> expected valid? to return false, got true > > > > If I take out the @user.password_confirmation from the assignment, it > works: > > > > before { @user.password = " " } > > it { should_not be_valid } > > > > But, as I said, using the console I can verify that everything works as > expected. Why does adding @password_confirmation break the test? > > > > Here's my user model: > > > > class User < ActiveRecord::Base > > attr_accessible :name, :email, :password, :password_confirmation > > has_secure_password > > validates :password, length: { minimum: 6 } > > end > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > Can't reproduce. What versions are you using? Ruby, Rails, RSpec > > Also, do you have a `subject` set? > _______________________________________________ > 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 jko170 at gmail.com Wed Feb 29 13:10:24 2012 From: jko170 at gmail.com (Justin Ko) Date: Wed, 29 Feb 2012 06:10:24 -0700 Subject: [rspec-users] Can anyone tell me why this test is failing? In-Reply-To: <30308856.349.1330520310816.JavaMail.geo-discussion-forums@ynkz21> References: <13167708.255.1330490604060.JavaMail.geo-discussion-forums@vbpw16> <30308856.349.1330520310816.JavaMail.geo-discussion-forums@ynkz21> Message-ID: On Feb 29, 2012, at 5:58 AM, Mohamad El-Husseini wrote: > Sorry, after much frustration, I closed the terminal window and restarted everything. The test passed. I have a feeling it might have had something to do with Spork or Guard... sorry for the false alarm! I should restart my terminal more often! > > On Wednesday, February 29, 2012 6:18:10 AM UTC-3, Justin Ko wrote: > > On Feb 28, 2012, at 9:43 PM, Mohamad El-Husseini wrote: > > I ran this scenario in the console and it works as expected. But RSpec keeps failing the test and I can't understand why. > > > > describe User do > > > > before do > > @user = User.new(name: "Mickey Mouse", email: "mickey at disney.com", password: "m1ckey", password_confirmation: "m1ckey") > > end > > > > # Password > > describe "when password is not present" do > > before { @user.password = @user.password_confirmation = " " } > > it { should_not be_valid } > > end > > end > > > > --> expected valid? to return false, got true > > > > If I take out the @user.password_confirmation from the assignment, it works: > > > > before { @user.password = " " } > > it { should_not be_valid } > > > > But, as I said, using the console I can verify that everything works as expected. Why does adding @password_confirmation break the test? > > > > Here's my user model: > > > > class User < ActiveRecord::Base > > attr_accessible :name, :email, :password, :password_confirmation > > has_secure_password > > validates :password, length: { minimum: 6 } > > end > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > Can't reproduce. What versions are you using? Ruby, Rails, RSpec > > Also, do you have a `subject` set? > _______________________________________________ > 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 This is why I don't use spork. -------------- next part -------------- An HTML attachment was scrubbed... URL: