Test already tested rails app with rspec and cucumber - ruby-on-rails

I've started a project on rails, and so far I'm testing it using rails' built in test suite. Is there a way to start testing it using rspec and cucumber at this point? How to do this?
Thanks!

This is a really weird question. What do you mean you've been using Rails' built-in test suite? What version of Rails are you using?
To start with testing, say models, in RSpec, you invoke the following command in Rails 3:
rails generate rspec:model <ModelName>
In Rails 2.x:
script/generate rspec:model <ModelName>
Cucumber is a bit different, but it starts with (Rails 3):
rails generate cucumber:install
Rails 2.x:
script/generate cucumber
All of this information is easily accessible on their respective Github pages. Is there anything more specific you need?

Related

Ruby on Rails: 4.2.0 differences between rails and bin/rails

So starting from Rails 4.1.x there seems to be a recommended way to use rails under the application folder. Instead of the traditional:
rails server
it is recommended by Rails official guide to use
bin/rails server
It looks like the bin/rails is referencing rails with additional stuff. What would be the additional benefits of using bin/rails compared to rails?
A second question is - I was used to use rails server, rails console, etc. rather than bin/rails server, bin/rails console. Without using bin/rails, would I lose anything (like misloading some libs, etc.)?
Thanks.
Put the following line in your bin/rails file: puts "In the bin/rails file"
Now run rails server. You'll likely see that the rails command is executing the bin/rails file.
I'm guessing the official guide suggests using bin/rails for two reasons:
Avoid using another instance of rails if your paths are not set up properly.
Speed - bin/rails seems to be a bit faster than just rails

How to start and setup Ruby On Rails development with eclipse

I am having excellent experience in Java and eclipse, But new to Ruby on Rails, can anyone point to the best resources, or step which i can follow to start with Ruby On Rails development and enviornment setup for windows.
I think Rails Tutorial is a best place for you to start learning, setup environment and development for Ruby on Rails:
Rails Tutorial
Rails Guide and about API
Some videos Rails Cast
Book Rails 3 way
One more thing, I think many Rails developers will not build Rails application on Window.
I have been using it fine. You just have to setup the correct run config to run rails -s

about rails plugins/engines

I am looking at rails plugins to help me modularize my application. I have some basic questions that I am confused about.
Can a rails plugin have its own DB? My application is very little traffic, for internal use, so I am fine with the idea of separate sqlite DB's for each plugin. When I do a "rails plugin new" even if I use --full, there is no database.yml generated. If I create one and do a rake db:create, no sqlite db is created.
Is there a good tutorial available for creating a rails plugin with rails 3.2? Most I find are older and use the enginex gem which I think is now built into rails.
Can you run your plugin as a standalone app for testing, i.e. using WEBrick? When I run "rails server" in my plugin directory, it just says "Error: Command not recognized".
I guess that's it, I am just confused on how to begin.
Creating Migrations
The Rails Guide "Getting Started with Engines" instructs you to use 'rails g model post' from the root directory for your engine.
Getting Started with Engines
If you do this, it will create the db/migrate folder for you with the migration inside of it.
$ rails g model post
invoke active_record
create db/migrate/20120517184738_create_my_engine_posts.rb
create app/models/my_engine/post.rb
invoke test_unit
create test/unit/my_engine/post_test.rb
create test/fixtures/my_engine/posts.yml
You can also generate migrations directly just the same, just as you do with a Rails app.
$ rails g migration AddMyEngineTable
invoke active_record
create db/migrate/20120517185241_add_my_engine_table.rb
Running Rails Server
The Rails Guide also states to run 'rails s' from test/dummy, not from the root of your engine directory.
I see that from an ASCIICast on the subject which covered Rails 3.1 RC5 that you used to be able to run 'rails s' from the root directory of your engine/gem. This is no longer the case.
From the Rails issue posted on Github three months ago it appears that they needed to keep the scope of the engine separate from the scope of the dummy app.
Issue #4894: Mountable Engines Rails File
In short run from the engine root:
test/dummy/script/rails s

rails - how do I create an application with rails new, specifing rspec for testing and haml for views at that moment

Rails 3.1
I can do:
rails new myApp -d mysql to set the database ok.
Is it possible to set rspec at the same time (or is it the default in 3.1?) and haml.
I googled and looked in the guides but it was not clear.
I know I can add rspec and haml gems and go from there but I was wondering if there are options to set those when doing rails new
No. I think it's because Rails has dependencies on mysql and other databases, whereas it has no support for rspec or any testing tool other than test/unit / minitest.

Missing script/generate in Rails 3

I just installed Rails 3 and created my first app. The install of Rails3 + ruby 1.9 went very smoothly but I am missing the generate script in script/generate.
I have created a new app from scratch with no options to verify.
Any idea why this is happening and how to fix it?
all script/* commands has been removed from rails 3. You should use rails generate or rails g instead of script/generate, rails server or rails s instead of script/server and so on.
try
rails generate ...
the only script existing now is rails all others will be called as parameter of rails.
Take a look a the Ruby on Rails Guides: Getting Started with Rails

Resources