RSpec is a behaviour-driven development (BDD) framework for the Ruby language.
2
votes
1answer
28 views
Rspec controller tests
I wanted to keep my controller tests DRY, readable, and make writing new tests very simple so that it encourages good practices like one assertion per test (if you have to redo a lot of work over and ...
1
vote
0answers
26 views
Geocoding users' IPs
My Rails app geocodes users' IP when they are created and also when they update their data only if they change their city. The geocoding is slowing down my tests ridiculously.
This seems to me to be ...
1
vote
3answers
409 views
Checking whether two strings are isomorphic
I was trying to solve a problem to determine if 2 strings are isomorphic. They are isomorphic when each character in string one can be replaced with another character in string 2. Two different ...
4
votes
1answer
114 views
Rspec - testing basic functionality - redundant testing?
Being pretty new to testing, I was wondering how many of these tests make sense.
restaurants_controller_spec.rb
...
3
votes
2answers
183 views
Building a chain of responsibility in Ruby to apply transformators on an object
I try to make a middleware stack system in the rack way (but not for HTTP request).
Here is the main class:
...
2
votes
3answers
112 views
Controller actions permisson specs
I'm just starting with rails and testing, and not sure what's good way to dry code like this.
...
1
vote
0answers
73 views
4
votes
1answer
302 views
RSpec test for pagination
This is a Rspec test for pagination in Rails project. I'm not sure if I should write the test in spec/requests or ...
2
votes
1answer
107 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
102 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 ...
2
votes
3answers
383 views
RSpec/Capybara tests
There are three scenarios only for when the sign up validations fail, so is there a better way of representing them rather than having 4 scenarios? I don't want to create a model folder so please ...
5
votes
2answers
575 views
3
votes
1answer
81 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
78 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?
...
2
votes
1answer
60 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
2answers
417 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 ...
7
votes
1answer
398 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 ...
6
votes
1answer
5k 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
305 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
435 views
10
votes
2answers
390 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 ...
3
votes
1answer
89 views
3
votes
1answer
473 views
2
votes
3answers
537 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
343 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 ...
1
vote
1answer
158 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
215 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.
...
4
votes
1answer
146 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
95 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
68 views
2
votes
1answer
158 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
1k 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
65 views
1
vote
1answer
69 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)?
...
3
votes
2answers
7k 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
157 views
5
votes
2answers
564 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 ...
2
votes
1answer
1k views
Is the comparing active record result with array of object in rspec test flexible?
Is the test flexible?
...
1
vote
1answer
436 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
208 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
135 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
2k 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
324 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 ...
3
votes
1answer
91 views
City class and spec for testing it
I have written a class and spec for testing my class. Can anyone determine whether or not this is a correct and good spec?
Class:
...
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 ...