tdd

RSpec - Undefined method `key?'

戏子无情 提交于 2020-02-23 07:18:18
问题 I'm trying to run a test for rendering templates and ran into the error: undefined method `key?' for 1014:Fixnum The stub of my model's instance works as it should in my route tests but not so much here. What am I doing wrong? describe RestaurantsController do let(:restaurant) { FactoryGirl.build_stubbed(:restaurant) } describe 'GET #show' do before { get :show, restaurant.id } it { should render_template('show') } end end Full Error 1) RestaurantsController GET #show Failure/Error: before {

Testing only the public method on a mid sized class?

点点圈 提交于 2020-02-21 06:03:46
问题 I have a class called FooJob() which runs on a WCF windows service. This class has only 2 public methods, the constructor, and a Run() method. When clients call my service, a Dim a new instance of the Job class, pass in some parameters to the ctor, then call Run()... Run() will take the parameters, do some logic, send a (real time) request to an outside data vendor, take the response, do some business logic, then put it in the database... Is it wise to only write a single unit test then (if

Testing only the public method on a mid sized class?

前提是你 提交于 2020-02-21 06:00:27
问题 I have a class called FooJob() which runs on a WCF windows service. This class has only 2 public methods, the constructor, and a Run() method. When clients call my service, a Dim a new instance of the Job class, pass in some parameters to the ctor, then call Run()... Run() will take the parameters, do some logic, send a (real time) request to an outside data vendor, take the response, do some business logic, then put it in the database... Is it wise to only write a single unit test then (if

What exactly is the 'Saff Squeeze' method of finding a bug?

自作多情 提交于 2020-01-30 19:46:47
问题 I have read Kent Beck's original blog post on the Saff Squeeze method. I have also read this InfoQ post that elaborates a bit more on the topic but does not provide any examples. I know that it is essentially a way of homing in on a bug without relying on the debugger. However I find Kent's example to be not that clear. Can someone more enlightened educate me on how to use this approach with a clear, concrete example? It'll hopefully serve as a learning resource for anyone else researching

What exactly is the 'Saff Squeeze' method of finding a bug?

我与影子孤独终老i 提交于 2020-01-30 19:46:06
问题 I have read Kent Beck's original blog post on the Saff Squeeze method. I have also read this InfoQ post that elaborates a bit more on the topic but does not provide any examples. I know that it is essentially a way of homing in on a bug without relying on the debugger. However I find Kent's example to be not that clear. Can someone more enlightened educate me on how to use this approach with a clear, concrete example? It'll hopefully serve as a learning resource for anyone else researching

Test driven development to check database queries involved methods

倖福魔咒の 提交于 2020-01-29 04:39:50
问题 I want to create a database driven application using Golang. I am trying to do it TDD way. When I try to test methods that make Sql queries, What all are the packages available ? I don't want to connect to the default database that I use for development. I can write code to take up another test database while running a test, but is there any go library that already does it. Is there any library that does db tests without connecting to database at all ? What is the standard way to do database

Show runtime for each rspec example

余生长醉 提交于 2020-01-29 03:18:52
问题 currently I'm running more than 1k examples and it's taking a long time to complete (more than 20 minutes!!! ). I'd like to identify which examples are the ones taking more time to complete, is there any way to run rspec and return the time each example takes to complete(individually)? I'm using rspec 1.3.0 and rspec-rails 1.2.3 回答1: You can use profiling to list your 10 slowest examples: spec -p spec/*/*_spec.rb --colour --format profile If you run this on a specific test suite you can get

Confused on how to write tests for classes that are refactored to compose other classes

可紊 提交于 2020-01-25 14:33:25
问题 I haven't read widely or thoroughly on TDD, but I feel like I do know the basics. One point of TDD is that you write the tests first. In the case of a Calculator program, perhaps one test case looks like this: public class CalculatorTest { public void shouldSumOneAndOneCorrectly() { Calculator calc = new Calculator(); calc.push(new Number(1)); calc.push(new SumOperator()); calc.push(new Number(1)); Number sum = calc.equals(); assert(sum.equals(new Number(2))); } } If I write the above test

Confused on how to write tests for classes that are refactored to compose other classes

时光毁灭记忆、已成空白 提交于 2020-01-25 14:33:09
问题 I haven't read widely or thoroughly on TDD, but I feel like I do know the basics. One point of TDD is that you write the tests first. In the case of a Calculator program, perhaps one test case looks like this: public class CalculatorTest { public void shouldSumOneAndOneCorrectly() { Calculator calc = new Calculator(); calc.push(new Number(1)); calc.push(new SumOperator()); calc.push(new Number(1)); Number sum = calc.equals(); assert(sum.equals(new Number(2))); } } If I write the above test

Confused on how to write tests for classes that are refactored to compose other classes

岁酱吖の 提交于 2020-01-25 14:33:07
问题 I haven't read widely or thoroughly on TDD, but I feel like I do know the basics. One point of TDD is that you write the tests first. In the case of a Calculator program, perhaps one test case looks like this: public class CalculatorTest { public void shouldSumOneAndOneCorrectly() { Calculator calc = new Calculator(); calc.push(new Number(1)); calc.push(new SumOperator()); calc.push(new Number(1)); Number sum = calc.equals(); assert(sum.equals(new Number(2))); } } If I write the above test