FAQ Database Discussion Community


TDD a Hiera hash in Puppet

hash,rspec,tdd,puppet,hiera
spec/classes/test_spec.rb require 'spec_helper' describe 'test' do let(:hiera_data) { { :a => 'hello' } } it { should contain_file('/tmp/hello') } end manifests/init.pp class test { $a = hiera('a') file {"/tmp/$a":} } results in: [[email protected] test]$ rspec . Finished in 1.11 seconds (files took 3 seconds to load) 1 example, 0 failures...

Rails4 Minitest | using a shared reusable object

ruby-on-rails,ruby,ruby-on-rails-4,tdd,minitest
I am getting the following error when I run rake test with minitest: $ rake test DL is deprecated, please use Fiddle Run options: --seed 55196 # Running: .EE Finished in 0.950979s, 3.1546 runs/s, 1.0515 assertions/s. 1) Error: CategoryTest#test_invalid_without_name: NoMethodError: undefined method `name=' for nil:NilClass test/models/category_test.rb:14:in `test_invalid_without_name' 2) Error: CategoryTest#test_invalid_without_long_name:...

How to test the template of an Ionic modal?

javascript,modal-dialog,tdd,ionic-framework,ionic
I'd like to test the template of an Ionic modal. The problem is that I cannot access the template through the modal. I figured out a workaround and it works, but there must be other solution. I solved this in the following way: Created a mock Angular directive using the...

iOS: Writing tests for blocks

unit-testing,tdd,ios,objective-c,cocoa
I am trying to write a test for a function that takes in a success and failure block. Here was my first attempt at a test: - (void)testThatValidSearchProducesSearchResults { __block NSArray *searchResults; __block NSError *searchError; [self.searchQuery searchForPlaces:@"The White House" success:^(NSArray *places) { searchResults = places; } failure:^(NSError *error) { searchError...

how to simulate sequence during DAO layer test

junit,tdd,dao,spring-test
I have spring+hibernate project, I want to write Unit test case for DAO layers, Currently I am using HSqldb's in memory DB to test it. (I referred this ) In project, IDs are provided by sequences, As I am using in-memory DB, during test sequence are not presents so it...

Unit testing a Response RedirectToRoute that returns an anonymous type

c#,unit-testing,tdd,rhino-mocks,anonymous-types
I am testing an HttpModule in an AspNet MVC application using HttpResponseBase objects as suggested by Kazi Rashid's blog In my code under test I have: context.Response.RedirectToRoute(new { Controller = "C1", Action = "A1" }); In my Unit Test (using RhinoMocks in a separate Test Project), I can get the...

How to make mocha fail when no expect within it()

unit-testing,tdd,mocha,karma-mocha,mocha-phantomjs
Is there an option to set mocha to report test as failing in case no expect provided within it() function? Idea is workflow to be like this: add one it() with desc and callback function the it() is reported as fail since no expectation is set in the callback expectation...

How do I test a component were the output goes to a database using Cucumber?

java,testing,tdd,cucumber,domain-driven-design
Recently there was a discussion in my team about how to properly test a component of our system where the output is stored in a database. We use DDD to create our system so the component ultimately talks to a repository that has different stores implemented to talk to a...

How would I test window prompts and confirms with Karma / Jasmine?

javascript,tdd,karma-jasmine,e2e-testing
I'm pretty new to TDD and I've been doing some programming prompts from reddit to learn it. This one is an acronym generator that asks for a string to be converted, displays it, and then asks if the user wants to generate another. My trouble is that I don't know...

Mocha breakpoints using Visual Studio Code

node.js,tdd,mocha,bdd,vscode
Is it possible to add breakpoints to ones Mocha tests using Visual Studio Code? Normally when debugging code one need to configure the launch.json, setting the program attribute to the javascript file to execute. I am not sure how to do this for for Mocha though....

Failing RSpec tests of Controller with nested resource and associated FactoryGirl objects

ruby-on-rails,testing,rspec,tdd,factory-girl
I'm building a project to learn Rails and testing, and struggling to troubleshoot errors in an RSpec test of a controller that directs a nested resource. My code works as expected in a browser. I believe the problem relates to my test set-up and the associations of FactoryGirl objects. I...

Create automated tests for interactive shell based on Python's cmd module

python,python-3.x,tdd,py.test,python-cmd
I am building an interactive shell using Python 3 and the cmd module. I have already written simple unit tests using py.test to test the individual functions, such as the do_* functions. I'd like to create more comprehensive tests that actually interact with the shell itself by simulating a user's...

When running jasmine tests, how can I know if I am in a describe block, beforeEach block or it block?

javascript,testing,tdd,jasmine,spy
I need to throw an exception if a utility is used outside of an 'it' or 'beforeEach' block in my tests. Example - describe('some test', function(){ useUtil(); // should throw exception beforeEach(function(){ useUtil() // should work }) it('should test something', function(){ useUtil() // should work }) }) The util creates...

assert_select and assert_template test. What is it doing?

ruby-on-rails,tdd
This is from the Hartl Tutorial: Here is my test: test "index including pagination" do log_in_as(@user) get users_path assert_template 'users/index' assert_select 'div.pagination' User.paginate(page: 1).each do |user| assert_select 'a[href=?]', user_path(user), text: user.name end end Here is my code which is the index.html.erb. I am not showing the application.html.erb. <% provide(:title, 'All...

Dollar Object intricacies

c#,tdd,assertions
I am reading Kent Beck's book "Test Driven Development: By Example." In his book, there is a coding example: public class Dollar { public int _amount; public Dollar(int amount) { _amount = amount; } public Dollar Times(int multiplier) { return new Dollar(_amount *= multiplier); } } [TestMethod] public void TestMethod2()...

How to make JUnit test fall down if constuctor is present?

java,junit,tdd
I am learning JUnit and Test Driven Development practice. I have empty Money interface: public interface Money { } CommonMoney class which implements Money interface: public class CommonMoney implements Money { private CommonMoney() { } public static Money create(String decimalPart, Currency currency) { return new Money() { }; } }...

Gulp mocha crashes nodemon

node.js,tdd,gulp,mocha,nodemon
I have a problem with my mocha gulp task. To run the tests, I have to launch the server, and then run the tests. The problem appears when a test fails : nodemon crashes and the node process still running. Here's my gulpfile: 'use strict'; var gulp = require('gulp'), mocha...

ASP MVC 5 testing RedirectToAction

asp.net,asp.net-mvc,unit-testing,tdd
I'm testing whether a controller doesn't have a parameter, it should redirect to action "Index". // Controller code return RedirectToAction("Index"); // Unit test code ActionResult result = Controller.Action(null); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); Assert. // HERE i need to test it is going to Index, how do I do that? ...

Sinon - when to use spies/mocks/stubs or just plain assertions?

node.js,unit-testing,tdd,mocha,sinon
I'm trying to understand how Sinon is used properly in a node project. I have gone through examples, and the docs, but I'm still not getting it. I have setup a directory with the following structure to try and work through the various Sinon features and understand where they fit...

Using Model Attributes inside another Model's Factory - Rails

ruby-on-rails,tdd,factory-girl,faker
I have a factory called Message, which HABTM Users. I want to mock sender_id inside the Message Factory. If I do: sender_id { FactoryGirl.build(:user}.id } I get: FactoryGirl:DuplicateDefinitionError How can I refer to another factory's data attribute (id in my case)? ...

Java interview test

java,testing,tdd
This morning in a work interview they asked me if I get a some legacy code with no tests at all, and I need to modify something, how would I do it to be completely sure that I break nothing. My answer was, first of all I would create a...

How long may Unit tests take in TDD?

unit-testing,tdd
I have a general question about TDD. As we all know, Test Driven Development requires a lot of testing. In best practice, you should test your code after everytime, you have coded something new, that you can test. Therefor it is very reasonable, to keep your tests as fast as...

python assertRaises don't pass test if function with parameters

python,tdd
assertRaises give an assertion error with the following code. Is there something I'm doing wrong? class File_too_small(Exception): "Check file size" def foo(a,b): if a<b: raise File_too_small class some_Test(unittest.TestCase): def test_foo(self): self.assertRaises(File_too_small,foo(1,2)) The test seems to pass with the following modification though def foo: raise File_too_small def test_foo(self): self.assertRaises(File_too_small,foo) ...

tdd - creating tests for 3rd party code

unit-testing,testing,tdd,functional-testing,functional-dependencies
How do I create unit tests if the method or procedure I'm testing against relies on a piece of code from a 3rd party? Say, I have a method that uses classes from a third party source that requires setup that can only be done in a functional test. How...

Go: Property exists but Go compiler says it doesn't?

go,tdd
filelogger.go package logger import ( "io" ) type FileLogger struct{ File io.Writer } func NewFileLogger(file io.Writer) *FileLogger{ return &FileLogger{file} } func (this *FileLogger) Log(message string) error { _, err := this.File.Write([]byte(appendNewLine(message))) return err } filelogger_test.go: package logger import ( "testing" "github.com/stretchr/testify/assert" ) type WriterMock struct{ data []byte } func (this...

In C, should Unit Test be written for Header file or C file

c,unit-testing,struct,tdd
I have a header file which contains declaration of struct and some methods, and a 'C' file which defines(implements) the struct and the methods. Now while writing Unit Test Cases, I need to check if some struct variable(which do not have getter methods) are modified.Since the struct's definition is contained...

TypeError: wrong argument type class (expected module) in rspec

ruby,rspec,tdd
i'm developing a simple net application (packed as a gem) to learn Ruby and TDD. I have this class (receiver.rb): require 'eventmachine' class Receiver < EM::Connection def initialize(port) EM.run do EM.open_datagram_socket('0.0.0.0', port, self) end end end And this test (receiver_spec.rb): require "spec_helper" require "net/receiver" describe "Receiver" do it "can istantiate"...

Copying odd-value elements from array in C++

c++,arrays,tdd
I have the following code: int copyOddOnly(int *dest, int *src, int n) { int copyList = 0; for(int i = 0; i < n; i++) { if(src[i]%2!=0) { dest[i]=src[i]; copyList = copyList + 1; } } return copyList; } It's meant to take all the elements with odd values from...

Javascript Unit Testing in Symfony

javascript,unit-testing,symfony2,tdd
So some context: We use Symfony to load our assets (as we have quite a few dependencies (Underscore, Marionette, Backbone, .. etc) and we run Javascript unit tests, using Jasmine. So to run them within our CI server, we use PhantomJS to hit the spec Symfony route. The problem then...

RhinoMocks AssertWasCalled throws Exception

c#-4.0,tdd,rhino-mocks-3.5
I am new to TDD and RhinoMocks. I am trying to test AssertWasCalled but having problems. The constructor to my test is as follows: public AccountControllerTests() { _webAuthenticator = MockRepository.GenerateMock<IWebAuthenticator>(); } And my test is like this: [TestMethod] public void AccountControllerCallsWebAuthenticator_CreateSignInTicketForGoodLoginCredentials() { const string username = "good-username"; const string password...

View Controller TDD

ios,unit-testing,swift,uiviewcontroller,tdd
I am trying to add some unit tests to my project to test view controllers. However I seem to be having problems with seemingly simple things. I have created a sample project which I will refer to. https://github.com/pangers/ViewControllerTesting The sample contains a UINavigationController as the initial view controller. The root...

Factory Girl Nested Associations

ruby-on-rails,unit-testing,rspec,tdd,factory-girl
I have several Rails models with nested relationship using has_one through, and no matter how I seem to structure my FactoryGirl factories I can't get the relationship to be correctly setup. Models class User < ActiveRecord::Base has_one :subscription has_one :plan, through: :subscription has_one :usage_limit, through: :plan end class Subscription <...

Mocha Test: Uncaught TypeError: Cannot read property 'status' of null

node.js,tdd,mocha,superagent,expect.js
Learning TDD and my first simple test for my "Hello World" server response is failing in Mocha. I'm using Mocha.js, Superagent, & Expect.js. When I curl -i localhost:8080, I get the correct response and status code. HTTP/1.1 200 OK Content-Type: text/plain Date: Mon, 27 Apr 2015 17:55:36 GMT Connection: keep-alive...

Rspec: Factory Girl & Complex Associations

ruby-on-rails,ruby,rspec,tdd,factory-girl
I am trying to test a helper method that would return the amount of Subscribers a Campaign is targeting. Being fairly new to TDD, I am having a hard time wrapping my head around how to write this one since the associations are quite complex. A Campaign "targets" by whether...

Using OCMockito to mock methods that are void

ios,tdd,ocmockito,ochamcrest
In using OCMockito, the below works great: DSAPIManager *mockAPIManager = mock([DSAPIManager class]); [given([mockAPIManager initWithBaseURL:[mockAPIManager baseURL]]) willReturn:[DSAPIManager sharedAPIManager]]; However when I try the same thing on a method with multiple arguments (see code below), I get an "Argument type 'void' is incomplete' compiler error. DSAPIManager *mockAPIManager = mock([DSAPIManager class]); [given([mockAPIManager setLoginCredentialsWithEmail:@""...

Dependency injection + full virtual vs interfaces

c++,tdd,inversion-of-control,solid-principles
I quite often find myself creating interfaces that I am using just at the signature to inject a dependency, ending up with class AIface and class AImpl : public AIface. And quite often I never implement any other subclass of class AIface Is there any advantage of this approach vs...

Injecting dependency with Guice in non-constructor method

java,mocking,tdd,guice,roboguice
I'm working on a component that creates HTTP requests dynamically, and I'd like to be able to mock those requests for unit testing. Currently the implementation looks something like this: class ModelClass { public void populate() { HTTPRequest request = new HTTPRequest(); //configure request... request.send(); } } Is there a...

How to synchronous test animation in AngularJS 1.3.15?

javascript,angularjs,tdd,jasmine
I guess I have a migration issue with angular-animate.js from version 1.2 to 1.3. Here is my animation 'use strict'; angular.module('cookbook', ['ngAnimate']) .animation('.slide-down', function() { var NG_HIDE_CLASS = 'ng-hide'; return { beforeAddClass: function(element, className, done) { alert('before add'); if(className === NG_HIDE_CLASS) { element.slideUp(done); } }, removeClass: function(element, className, done) {...

Dynamic expectations in Rspec

ruby-on-rails,ruby,testing,rspec,tdd
I am trying to test a dynamic url path through an Rspec expectation, as below: describe 'registering a user' do context 'with valid data' do it 'confirms user registration' do visit '/users/new' fill_in 'Name here...', with: 'johnny bloggs' fill_in 'Your email here...', with: '[email protected]' click_button 'Notify me' expect(current_path).to eq '/users/@user.id'...

Rails RSpec testing a simple link redirect_to path

ruby-on-rails,rspec,tdd,capybara,response.redirect
I am having difficulty writing an RSpec test in a rails app to make sure that a simple link from my app's homepage redirects to the about page. I have the following in my feature test file: scenario "Have links redirect to the correct paths" do visit '/' click_link('about') expect(response).to...

What is the Flask version of Django's render_to_string function?

python,django,flask,tdd,render-to-string
So, I'm trying to learn TDD for Flask, by translating this code to Flask. I've been trying to find how to render a template to a string for a while now. Here is what I have tried: render_template(...) render_template_string(...) make_response(render_template(...)).data and none of them seem to work. The error in...

Testing c++ console output via TDD

c++,unit-testing,boost,console,tdd
I am writing c++ program using Test Driven Development Approach. I have a function which uses console output. I would like to write a test which is able to test whether the console output is the same like the expected output. I saw this can be solved and should be...

How to test that a route does not work?

ruby-on-rails,ruby-on-rails-4,tdd,testng
How can I negate the following test? test "should route to post" do post = posts(:one) assert_routing "/posts/#{post.id}", { controller: "posts", action: "show", id: "#{post.id}" } end I want to test that the route /posts/1 does not exist....

How redundant should my unit tests be regarding varied input?

c#,unit-testing,tdd
So I'm new to unit testing (late to the party, but I'm here at least). I'm extracting some common code used by several of my ASP.NET MVC web applications into one or more class libraries. I'm now writing unit tests for some of that code...most of which are actually extension...

redirect_to after failed validation possible in rails?

ruby-on-rails,validation,tdd
Here is my test: def test_words_with_non_letters_are_rejected visit '/plays' click_link_or_button 'Play New Word' fill_in 'play[word]', :with => 'boom!' click_link_or_button 'Play!' assert page.has_css?("#errors") fill_in 'play[word]', :with => '37nums' click_link_or_button 'Play!' assert page.has_css?("#errors") fill_in 'play[word]', :with => 'ok' click_link_or_button 'Play!' assert_equal '/plays', current_path end Here is my controller: class PlaysController < ApplicationController def...

Difference between Factory_Girl linting and Rspec's expect to be_valid

ruby-on-rails,rspec,tdd,automated-tests,factory-girl
What is the difference between testing factories with [Factory_Girl Lint]1, and RSpec's: ... it 'has a valid factory' do expect(build(:foo)).to be_valid end ... Am I correct to assume that Factory_Girl Lint checking for schema / db level validations like null: false, and the Rspec's expect to be_valid checks for model-level...

Mocking free function

c++,unit-testing,tdd,googlemock
I am stuck in a problem and can't seem to find the solution. I am using VS2005 SP1 for compiling the code. I have a global function: A* foo(); I have a mock class class MockA : public A { public: MOCK_METHOD0 (bar, bool()); ... }; In the sources, it...

Best practice for handling appsettings values

c#,.net,tdd
I'm trying to write code as better I can, for that reason looking at some code I wrote in past I've seen that I access to .config appsetting with something as Public void Do() { Var x = ConfigurationManager.AppSettings.Get("foo"); doSomethingElse(x); } Writing test on this method I asked myself wasn't...

MsTests MVC5 Controller not triggering OnAuthorization

c#,asp.net-mvc-5,tdd,bdd
I'm testing controller actions on my current project. Got a method to mock the logged user so I can control access to the data itself, on one of the methods I forgot to mock the user and I got surprised, instead of getting a redirect (defined behaviour for non-anonymous actions...

Factory Girl & Rspec controller test failure

ruby-on-rails,rspec,tdd,factory-girl,rspec3
I am still fairly new to testing and still wrapping my head around Factory Girl, which I believe to be the culprit of this failure. As simple as the solution will probably be, I have searched other posts with the same failure message but the answers are not working for...

Need help in passing this simple mocha test in javascript

node.js,tdd,mocha
Here, I wrote a simple utilities class in Javascript that parses and stringify Json data. //public/js/utilities.js function UtilitiesClass(){ var parserJson = function(obj){ if (typeof(obj) !== "undefined") { return JSON.parse(obj); }; } var stringifyJson = function(obj){ if (typeof(obj) !== "undefined") { return JSON.stringify(obj); }; } } module.exports = UtilitiesClass Then in...

Unit testing with Rspec and C extensions

ruby,unit-testing,rspec,tdd,ruby-c-extension
Every body seems to be talking about TDD and BDD these days so i thought i give it a try on a smallish home project. A short backgrund I am developing a class Device in a C extension that interacts with a native C API for controlling remote devices like...

How to refactor tests in tdd?

unit-testing,tdd
I'm performing this TDD kata excercise: http://osherove.com/tdd-kata-1 I produced following code (points from 1 to 5 in this excercise - I have unit tests for it): public class StringCalculator { private readonly string[] _defaultSeparators = { ",", "\n" }; public int Add(string numbers) { // Parser section (string to list...

How am I getting 'InternalError: table “dev~guestbook!!Entities” already exists' when I just created datastore?

python,google-app-engine,tdd,nosetests
I'm trying to figure out how to setup Test Driven Development for GAE. I start the tests with: nosetests -v --with-gae I keep getting the error: InternalError: table "dev~guestbook!!Entities" already exists The datastore doesn't exist until I create it in the setUp(), but I'm still getting an error that the...

Trace only class under test with rcov

ruby,tdd,rcov
I want to start rcov for a single test but the execution took several seconds/minutes since rcov seems to load the complete applications and starts to trace all source files. I'm only interested in the rcov report for the class under test. To improve the feedback time I want to...

Testing behaviour of classes with deep nested dependencies

php,testing,tdd,bdd,behat
I am starting using Behat and I was thinking what is the correct way to do something like this: I am testing system behaviour with Behat (the domain, not web) and i want to test behaviour that uses UserService class. UserService takes UserRepository (Interface) as an argument. Should i create...

moq and fetching an exception

unit-testing,tdd,moq
I'm trying to learn moq test with some simple examples I have public class CustomerService { private readonly ICustomerRepository _repository; public CustomerService(ICustomerRepository repository) { _repository = repository; } public void CreateWithMoney(CustomerDTO dto) { var cust = new Customer { FirstName = dto.FirstName, LastName = dto.LastName, FinacialStatus = dto.FinacialStatus }; if...

Writing tests before writing code

unit-testing,testing,tdd,bdd
As far as I understand TDD and BDD cycle is something like: Start by writing tests See them fail Write code Pass the tests Repeat The question is how do you write tests before you have any code? Should I create some kind of class skeletons or interfaces? Or have...

Why does Jasmine toEqual return true when comparing empty array with empty object?

javascript,tdd,jasmine
I get why the following returns false... expect({}).toBe({}); And I get why the following returns true... expect({}).toEqual({}); But why is the following true? expect([]).toEqual({}); ...

Test actors creation in akka hookers (preStart)

scala,tdd,akka,scalatest
I want to test that preStart() creates right actors tree (Correct me, if I choose wrong place to create actors tree). class Central extends Actor { var summer : ActorRef = _ override def preStart() = { val printerProps = Props[Printer] val printer = context.actorOf(printerProps, "printer") val summerProps = Props(new...

How to add a new source directory to an Android Studio project?

android,android-studio,gradle,tdd,integration-testing
So ultimately I'm trying to separate my integration tests from the unit tests in an Android Studio project. I've found a few resources on the subject: http://selimober.com/blog/2014/01/24/separate-unit-and-integration-tests-using-gradle/ https://blog.safaribooksonline.com/2013/08/22/gradle-test-organization/ Separating integration tests from unit tests in Android Studio All these seem to indicate that the way to go is to create...

I keep getting this error “ NoMethodError:undefined method `visit' for #

ruby-on-rails,rspec,tdd
I'm working on this http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/ and I keep getting this error. I'm using rails 4.1 terminal Failures: 1) Tasks GET /tasks display some task Failure/Error: visit tasks_path NoMethodError: undefined method `visit' for #<RSpec::ExampleGroups::Tasks::GETTasks:0x007fcfbd633758> # /Users/estebangallego/.rvm/gems/ruby-2.2.0/gems/actionpack-4.1.8/lib/action_dispatch/testing/assertions/routing.rb:171:in `method_missing' #...

How to notate that the parameter value doesn't matter in a JUnit test?

java,junit,tdd,semantics,hamcrest
I'm doing some TDD using JUnit4, Mockito, and Hamcrest. My current test looks like this: FeatureFilter featureFilter = FeatureFilter .describeFeature() .addFeatureRef("myNewFeature", thatIsAvailable() .atEndpoint("/resourceWithFeature")) .andDisable(); assertThat(featureFilter.isDisabledFor("/resourceWithFeature", null, "myNewFeature"), is(true)); assertThat(featureFilter.isDisabledFor("/irrelevant", null, "myNewFeature"), is(false)); assertThat(featureFilter.isDisabledFor("/resourceWithFeature", null, "self"), is(false)); The...

first time trying tdd. which tests should I write?

testing,tdd,bdd
I'm working on an application for access control on gyms. I want to make all this app testable, but it's my first time with TDD/BDD. I don't exactly know which tests should I create. Maybe tests from user's perspective? Something like: As a visitor, I want to enter gym. As...

Swift - Getting around build errors in test-driven development?

ios,xcode,unit-testing,swift,tdd
I'm starting to learn how to do test-driven development, and I'm working with Swift. I'm suppose to have a test which should fail then write the code needed to get it to pass. From my understanding the test should successfully run, just fail. However, in Swift, when I try to...

Kiwi: concrete difference between mock and nullMock?

ios,unit-testing,testing,tdd,kiwi
I'm using Kiwi on a project and am not quite clear on when to use a mock versus a nullMock. Here is what Kiwi's documentation currently provides: A plain mock object will raise an exception when it receives a selector or message pattern that it does not expect. Expected messages...

How to initialize constant string for multiple tests in google test?

tdd,googletest
I'm using google test and I have a cpp-file containing several tests. I would like to initialize a string with the current date and time when starting the first test. I would like to use this string in all other tests, too. How can I do this. I've tried the...

How do I test parent methods?

c#,.net,unit-testing,tdd
Suppose I have an interface that looks like this: interface IMyAPIService { List<Order> GetOrders(); } And a class that implements it: class MyAPIService : IMyAPIService { public List<Order> GetOrders() {} public bool Login() {} } Login calls an external service. I can mock the external service and thus test Login...

Mocking Sealed Class with RhinoMocks

c#,unit-testing,tdd,rhino-mocks
I am fairly new to TDD and I am trying to mock HttpContextBase in an MVC app. I also need to mock the Response property and the HttpCookieCollection of that. The HttpCookieCollection class is sealed though and RhinoMocks says it cannot mock sealed classes. Any advice on how I should...

Run only one mocha test file on change with gulp

node.js,tdd,mocha,gulp
I have a standard gulp test watcher and runner for my Node.js/mocha setup; gulp.task('mocha', function() { process.env.NODE_ENV = 'test'; return gulp.src(['./test/**/*.js'], {read: false}) .pipe(mocha({recursive: true, reporter: 'list', ui: 'bdd'})) .on('error', gutil.log); }); gulp.task('tests', function() { gulp.watch(sources.concat(tests), ['mocha']); }); I'm wondering how to adapt my watch task (and the other) to...

Applying the same test to all members of a collection

objective-c,cocoa,tdd,xctest
In a test I have a NSArray with several objects. They must all pass the same test. Is there a better or more elegant way to express this than just doing a for-in and applying the same macro to each element?...

Rails 4: Factory Girl & Rspec with associated Model

ruby-on-rails,ruby,rspec,tdd,factory-girl
I previously fixed an issue with some code that works though it is a little ugly. Problem now is that it breaks my tests! The idea here is that I can create a Campaign and associate 1 zip-file and one-to-many pdfs. Previous question and solution: Rails 4.2: Unknown Attribute or...

Intern test of async service (ftp) does not fail test on error

node.js,asynchronous,tdd,intern
I've written an intern test whose job is to make an FTP connection and carry out an operation over the connection. If any of the steps fail, the test should fail. I have two versions of this, one that tries to reject or resolve the async dfd manually, and another...

Writing test code for Text to json data parsing in ruby on rails

ruby-on-rails,json,tdd
I am new in rails. I have some texts files. I parse the text files to json in a predefined format. Now i need to write test code for checking text data is converting into json data or not. what tests should I check? how should I start it? which...

Go: Test cannot pass?

go,tdd
I'm having a problem making this test pass. The problem is, the Write() method in my struct needs to write to a property, but io.Writer interface does not accept pointer as its receiver. filelogger.go: package logger import ( "io" ) type FileLogger struct{ File io.Writer } func NewFileLogger(file io.Writer) *FileLogger{...

TDD and Protected Methods [duplicate]

c#,asp.net-mvc,tdd
This question already has an answer here: Should Private/Protected methods be under unit test? 9 answers I am trying to learn TDD by creating a copy of an existing MVC app I have but I am creating a copy of it from scratch using TDD. In my existing app...

Using Chai - how to check object property contains DOM element

javascript,jquery,tdd,bdd,chai
How can I test that an object property contains the value of a DOM element in Chai, eg: someObject = function(){ element: $('#foo'); } How do I check that element equals the jquery object $('#foo')? So far, I have tried: someObject.should.have.property('element', $('#foo') someObject.should.have.property('element').with.value($('#foo')) But these fail. Anyone have any ideas?...