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

learn more… | top users | synonyms

2
votes
1answer
49 views

DRY-ing up some rspec

I have an rspec spec test that has two sets of the same tests (from 24 Pull Requests). I thought I'd refactor the spec whilst I fixed something else. Normally I just do a basic ...
0
votes
2answers
57 views

Factory Girl in Rails

I have a FactoryGirl page that generates same data but in two different languages. The variable names are the same. How do I write it in the smartest way possible without having to write a huge bunch ...
1
vote
3answers
74 views

Refactoring RSpec/Capybara tests

Is there a better way of representing this RSpec code on Rails using Capybara? There are three scenarios only for when the sign up validations fail so is there a better way of representing them ...
3
votes
1answer
62 views
2
votes
1answer
36 views

Mixing Watir::Browser into RSpec

In my previous Watir question I was making a module with session_FF accepting a block. Now I want to make the same but via RSpec. Here is my try: ...
1
vote
2answers
37 views

Removing duplication in RSpec

I’m still relatively new to the TDD scene. I’m writing a Rails app, and some duplication immediately sticks out at me in my first model spec. How else can I approach this? ...
0
votes
0answers
23 views

Refactor expect block

...
2
votes
1answer
56 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
148 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
62 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. ...
7
votes
1answer
184 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 ...
5
votes
1answer
1k 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
183 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 ...
4
votes
2answers
212 views

My first model RSpec

This is my first model RSpec test: ...
10
votes
2answers
233 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
72 views

DRYing Up RSpec

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

Pig Latin Translator in Ruby and Rspec

PigLatin Kata ...
2
votes
3answers
328 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
255 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
104 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
147 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
135 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
70 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
115 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
777 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
62 views

Refactor specs for service class methods

Service Class ...
1
vote
1answer
64 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
6k 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
154 views

How might I make this code more DRY?

I have the following Ruby code in an RSpec file: ...
5
votes
2answers
441 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
932 views
1
vote
1answer
310 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
199 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
125 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
288 views

My first RSpec test - Rock Paper Scissors

I'm relatively familiar to Ruby, but I'm brand-new to testing code. I've decided to use RSpec because as it seems like a popular option. The game works perfectly, but the spec has a lot of repetition ...
5
votes
1answer
5k 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 ...