Rails project using BDD(RSpec and Cucumber) - ruby-on-rails

Basically I want to use BDD(RSpec and cucumber) to make a complete rails project.Is it possible and if yes is it good to make a project using outside-in Rails development?
I will be doing it the way as it is given in - The RSpec Book .
Thanks in advance .
I want to make a rails project. I am thinking of making it using Rspec and Cucumber.
What I mean is using TDD. Writing tests and then passing it by writing the desired application code .

I think so.
You can use rspec for any ruby code: rails, sinatra, writing a gem and even plain ruby code. But you can use this if you want to work on rails https://github.com/rspec/rspec-rails
I'm not very familiar with cucumber, but if you visit its wiki https://github.com/cucumber/cucumber/wiki , you'll find that it can be used in rails, sinatra, Merb, even with other language

Related

Is there any complete real life Rails project with RSpec?

I'm learning RSpec for a while and reading some articles, books and other resources. But I wonder if is there any complete real life Rails project, that using RSpec, with source codes available to examine. I study some gems and Ruby projects but still I think it would be better to see a Rails project's source code in action.
Discourse is a large, real world project you could take a look at.
They use RSpec and you can view all their testing code here.
Another huge open source rails app using rspec is spree commerce https://github.com/spree/spree

Load Rails 3 test fixtures into development database

I have a nice set of fixtures that I use for testing. When a request test fails it is handy to run the app interactively with the test fixtures loaded. But if I run the full server with -e test I get all kinds of crazy errors, probably having to do with the pipeline.
-- edit --
When I visit the home page I get this in the browser:
I say it's crazy, because I don't understand it :) In particular, I am using twitter-bootstrap and I am unclear about sass/scss/css work with Twitter Bootstrap + Rails so it's highly likely that I have some detail wrong in how I am using them together (or that the gem twitter-bootstrap-rails has some bug.)
Ah, much better question :-).
The twitter-bootstrap-rails gem uses LESS, which is similar to SASS in what it does, but not the same. SASS is the default for Rails, and a good choice. If you want to use SASS, (and based on the error, it appears you are), then use the Bootstrap SASS gem instead, linked here. It may be possible to use both LESS and SASS together, but that seems like a Bad Idea to me.
Check out Ryan Bates' excellent RailsCast which covers using Twitter Bootstrap in Rails. It covers both alternatives. And then fork over the $9 to get Pro access to his continued RailsCast with more details.

Alternative to current Ruby on Rails testing methods?

I find that in order to thoroughly test a Rails application with Rspec I am required to write more test code than actual functional Ruby code. Call me crazy but this does not seems right. Is there a different/alternate approach (even one that is not as comprehensive as Rspec).
For unit testing I guess you won't find any replacement.
But for integration testing, you could create scenarios within your browser thanks to Selenium. See: http://seleniumhq.org/
There are many option available here are the few list
Rspec
Watir
Cucumber
factorygirl
capybara
and many more

Rails acceptance testing without using rspec but using capybara

I am looking for an example of acceptance testing in Rails without using rspec. My current client uses ruby 1.9.2 and all the tests are written using minitest and they are concerned about the slowness of rspec. Anyways that discussion is over.
I need to write a few functional tests and am looking for examples of how to do functional tests without using rspec. And I would like to use capybara.
I am using Rails 3.0.10 .
sounds like you want to be looking at Cucumber - http://cukes.info/ perhaps?

RSpec/Gem development: Stubbing rails templates

I'm currently working on a couple of different gems both of which mainly consist of rails view helpers.
My problem is that some of these helpers require rendered rails templates to test the output - but I am unsure of the best way to stub a template, without a rails application. I presume that I should be able to leverage rspec-rails in some capacity, but i've been having trouble getting that to work without a rails app present.
Am I approaching this the wrong way? What's the current best-practice to test rails-specific features (in particular - things that happen only in the view) during gem development?
I use the excellent enginex gem, which helps you in setting up a gem skeleton with an embedded rails application for testing. This way you can easily test any rails dependency inside that application. To generate rspec tests run it as follows (default is test-unit):
enginex -t rspec your-gem-name
What I did to incorporate this into my gem, was run this inside some test folder, and copied the necessary files over to my gem. As an example, you could check it out inside my cocoon gem.
Hope this helps.

Resources