RSpec is a behaviour-driven development (BDD) framework for the Ruby language.

learn more… | top users | synonyms

0
votes
0answers
18 views

Refactor expect block

...
2
votes
1answer
47 views

Unit-testing account transaction code

I'm playing with unit-testing in Ruby. There is a situation that I don't know if is good enough or if I am doing the wrong abstraction. I have two classes: ...
1
vote
1answer
70 views

Various RSpec tests

I've just written my first full batch of RSpec tests and wondered if anyone can comment at a glance on how they might be written easier, more readable, faster etc. There are some pending specs so ...
0
votes
0answers
41 views

Creating a spec for confirming user accounts

I've created a spec that how a user confirms his account. It tests the following scenarios: While this code is completely untested (wrote it all in the browser) I don't see why it wouldn't work. ...
6
votes
1answer
120 views

Binary converter and sufficient tests

I just finished writing a basic binary conversion class in Ruby. I'm curious to see if anyone has suggestions for improvements. In particular, I'm looking for the cleanest, shortest, most succinct ...
3
votes
1answer
362 views

My first controller rspec test

I'm just started learning TDD with Rails and RSpec. This is my first test for controller. Just plain RESTful UserController that responds with JSON, so it has no new and edit methods. Please review it ...
5
votes
1answer
96 views

BinarySearch Kata in Ruby

I've just completed this binary search kata - which has some weird requirements - and I spent a little while "cleaning" up my code and making it more compact. I would appreciate some feedback on the ...
3
votes
2answers
152 views

My first model RSpec

This is my first model RSpec test: ...
10
votes
2answers
184 views

Cash Register Kata

The Setup This kata is a spin on the old backpack problem. Please give feedback on both the kata itself as well as my solution. I'm not sure if the kata needs to lead the student more or if this is a ...
2
votes
1answer
60 views

DRYing Up RSpec

How would you DRY up this RSpec code? ...
3
votes
1answer
125 views

Pig Latin Translator in Ruby and Rspec

PigLatin Kata ...
2
votes
3answers
236 views

Pig Latin Code Kata

I've just complete a Pig Latin translator as a code kata and I was hoping someone would review it for me. Here is the kata: ...
2
votes
1answer
197 views

How can this rails controller test be cleaner refactored?

I tend to write quite explicit tests for my rails controllers exposing APIs with two seperate concerns: meeting the defined API-Response with headers headers and the response itself ensuring the ...
0
votes
1answer
86 views

Ruby Kata Gem: WordWrap

I've just completed the WordWrap Kata in the Ruby Kata gem and I'd love some feedback. Thanks! Here's the Kata: ...
2
votes
1answer
133 views

Advanced Calculator Kata

This is the CalculatorAdvanced Kata from the Kata gem. I've just finished it and would love some feedback on my solution. ...
3
votes
1answer
132 views

Weekly flex calculator

This is one of the first RSpec tests I've written, and I'm not really sure what the best practices are etc. My question basically is: what would you do differently? What is good? What is bad? The ...
2
votes
1answer
62 views

Using RSpec subject to setup a test

I find myself using subject blocks in my tests to setup example because it is succinct. However is this considered bad form and can it have undesired consequences? ...
2
votes
1answer
64 views

How to separate 2 tangled methods?

I have this (working) code: ...
2
votes
1answer
100 views

General thoughts on the style of this rspec-rails test

Here's a test from a Rails app I'm working on. I want to know if I'm using describe, let, ...
3
votes
1answer
604 views

Can I improve the way this model RSpec is written?

I'm new to RSpec and testing in general. I've come up with a spec for testing my Content model and I need some feedback 'cause I ...
1
vote
1answer
61 views

Refactor specs for service class methods

Service Class ...
1
vote
1answer
63 views

Converting tests to specs

I use RSpec but in a way I would use any xUnit framework. Can this snippet be refactored to look more BDD like (using subject and stuff)? ...
4
votes
2answers
5k views

RSpec integration tests for a simple Rails API

The Model is simple. A Player class with three attributes: first_name, last_name, and team_id. I'm just trying to get a handle on TDD for what will expand into a much more robust API. Below is my ...
3
votes
1answer
146 views

How might I make this code more DRY?

I have the following Ruby code in an RSpec file: ...
5
votes
2answers
393 views

Spoj's 1st problem in tdd using Ruby

I am pretty new to TDD and is following problems on spoj.pl for practice. I need help with following code; it was my first attempt. Problem: Your program is to use the brute-force approach in order ...
1
vote
1answer
789 views
1
vote
1answer
246 views

How to refactor my controller specs?

In my project (https://github.com/GCorbel/comment-my-projects) I have this kind of code to test my controllers. ...
4
votes
3answers
195 views

First BDD/RSpec tests, would like some review regarding idioms, conventions and style

This is my first attempt at BDD and RSpec. I'm more of a C# xUnit kind of guy. I wrote this class while developing a 2D random tile map generator (just for fun). The project is still ongoing. I ...
1
vote
1answer
123 views

Rspec Request break when teammate pushes some changes

This is my rspec integration test for user, it always breaks when my teammate change something, how do i improve this? ...
2
votes
1answer
1k views

Tidying scaffolded Rails controller spec with subject/let

I was just looking at a standard scaffolded Rails controller spec, and tried to get it to use subject or let blocks, and failed miserably ... can subject or let tidy controller specs the same as it ...
2
votes
1answer
266 views

What can I do to improve my first RSpec test

I'm relatively familiar with Ruby, but I'm brand new to testing my code. I decided to use RSpec because as it seems like a popular option and wrote a basic Rock Paper Scissors game to be tested. The ...
5
votes
1answer
4k views

spec_helper.rb for RSpec, Capybara, FactoryGirl, Spork and Devise

Having been through hundreds of often-conflicting posts on testing with RSpec, Capybara, FactoryGirl, Spork, Guard and Devise without Cucumber, this is the spec_helper which "seems to" work. I'm ...