Rails Capybara run a specific file (test) - ruby-on-rails-3

Currently I have a huge integration test in a single file in my Rails 3 app in spec/main_spec.rb, and to run this test I simply do 'rake spec'. I want to begin to break this test up into differnt files. So lets say I create another test (file) called spec/another_spec.rb. How can I run this specific file? When I do...
bundle exec rake spec/another_spec.rb
Nother seems to happen...I don't get any errors, but I don't any feedback telling me whats passed or failed.

bundle exec rspec spec/another_spec.rb
or
rspec spec/another_spec.rb

Related

Adding a new Migration File using Rake (in the command line)

I know there's a way to automatically create the barebones of a migration file by entering some rake command in the command line but I can't seem to remember exactly what it is. I know it should look something like this...
rake db:create NAME=table_name
but that keeps failing. I also tried
rake db:create_migration NAME=table_name
but no luck with this either. The first attempt returns "Don't know how to build task 'table_name' and the second says "Don't know how to build task 'migration'
rake isn't the command for this, instead you can either:
manually create the file
run rails generate migration table_name in a rails app
or in my case where I'm not using rails, pliny-generate migration table_name

Run Cucumber Features in Parallel using parallel_tests gem

I am using Selenium locally to run two .feature files. Both pass locally. Neither of the tests interact with a db (nor will future tests). I would like to use the parallel_tests gem to spin up two selenium web browsers concurrently and run each .feature file. I have tried to follow the readme on gems homepage, but am still having no luck.
I can run rake parallel:features and I get the following output:
Using recorded test runtime
8 processes for 2 features, ~ 0 features per process
However, it then proceeds to fail immediately and informs me that I have not defined the scenarios.
I am using Rails 3.2 and Capybara
I have also tried adding begin; require 'parallel_tests/tasks'; rescue LoadError; end
to the top of my Rakefile which I found elsewhere, but doesn't help.
Try using:
parallel_cucumber -n 2 features

Capybara specs pass when run individually but fail when ran fail as part of a suite

Anyone know any particular reason why a request spec never passes when run with bundle exec rspec spec but passes when run directly bundle exec rspec spec/requests/models_spec.rb?
I have tried the spec in both selenium and poltergeist but get the same result. When I run the whole test suite the specs fail, when I run it individually it passes.
I have a related question concerning a model spec Why would RSpec report multiple validation errors of the same type? that could possibly be related.
Interesting but simple. Threads seems to have gotten intertwined and a button that should be saying Add was saying Manage. Temporary fix was to just delete everything from the database before running each spec.

how can I troubleshoot "rake test" missing from my list of rake tasks?

I have two apps. One is a very simple app that I built with rails new..., added a unit test to and ran the unit test. The other is an existing app that is running fine but I'd like to add some tests to it. In AppA (the simple one) when I run rake -vT I see:
...
rake test # Runs test:units, test:functionals, test:integrati...
rake test:recent # Run tests for {:recent=>"test:prepare"} / Test re...
rake test:single # Run tests for {:single=>"test:prepare"}
rake test:uncommitted # Run tests for {:uncommitted=>"test:prepare"} / Te...
...
Which seems normal. But when I run that same command in AppB (the existing app) I don't see any of the commands related to rake test. My first thought was to just 'bring over' the tests from AppA to AppB to see if that would help. So I wiped all content from the test directory in AppB and copied over the test directory from AppA. Still no rake test in the list of apps. But I can run a unit test in AppB via ruby -Itest test/unit/first_test.rb (oddly I have to comment out fixtures :all to get it to work, maybe that's a clue).
Found the answer to this last night. Where a new app's application.rb has:
require 'rails/all'
I had:
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
I did that because I was following a guide about MongoMapper I think. Go forward a few versions and the last line is commented out -- that's the real reason. I commented it out at the same time I switched my ODM over to Mongoid. I'm not sure why I commented it out, but that definitely did it.
Without knowing the contents of your Rakefile it's really hard to debug this, but you might be missing the .load_tasks call in the Rakefile.
If you're using Rails 3 you should have something like this:
MyApplication::Application.load_tasks
That line will take care of loading the default Rails tasks. You might be able to accomplish the same calling require "rails/tasks" in your Rakefile.

System rake test task doesn't run my tests

I'm sure I'm doing something naive or stupid, I'm just not sure what it is.
I'm writing a simple library for parsing data URIs. Being so simple, I figured I'd go ahead and just give ruby-1.9's minitest a whirl. The tests run great when I run them by hand, but when I try to run them with 'rake test', hoping to invoke the system rake test task, I get no joy. Specifically, with trace and verbose:
Donalds-Decisiv-MacBook-Pro:data_uri dball$ rake test -t -v
(in /Users/dball/src/data_uri)
** Invoke test (first_time, not_needed)
I've got tests in the test folder, they all start with test_ and end in .rb. Any ideas?
The repository of the project is http://github.com/dball/data_uri
Tests are not invoked because you didn't give rake any information about them.
Put this task in Rakefile:
require 'rake/testtask'
Rake::TestTask.new do |i|
i.test_files = FileList['test/test_*.rb']
i.verbose = true
end
Or grab a patch for your project.