How to stop TDDium from running script/cucumber features automatically - ruby

I am using TDDium to run my tests continuously.
Every time I push something it runs using my tddium.yml configuration file:
:tddium:
:timeout: 90
:postgresql: false
:test_pattern:
- spec/**_spec.rb
:mysql:
:adapter: mysql2
:config:
:adapter: mysql2
:database: <%= ENV['TDDIUM_DB_NAME'] %>
:username: <%= ENV['TDDIUM_DB_USER'] %>
:password: <%= ENV['TDDIUM_DB_PASSWORD'] %>
:database: <%= ENV['TDDIUM_DB_NAME'] %>
As you can see, I'm specifying :test_pattern:.
Even though I have a set of .feature files in my features directory, I don't want it to run them automatically.
How do I stop TDDium from doing this?
I thought that by specifying :test_pattern: and not including the .feature pattern it'd skip them.
I've tried running tddium suite --edit and this is what happened:
bonsai-2 project$ tddium suite --edit
... Detected ruby ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin11.4.2]
... Detected bundle Bundler version 1.3.5
... Detected gem 1.8.24
... Configured test pattern from tddium.yml:
- spec/**_spec.rb
>>> To change the pattern:
1. Edit tddium.yml
2. Run `tddium suite --edit` again.
>>> To set up Hosted CI, enter a git URL to pull from.
You can also set a git URL to push to after tests pass.
>>> Set both pull and push URLs to 'disable' to disable hosted CI completely.
Enter git URL to pull from (default 'ssh://git#github.com/etagwerker/project.git') or enter 'disable':
Enter git URL to push to (default '') or enter 'disable': disable
Custom Campfire room for this suite (current: '') or enter 'disable': disable
Custom HipChat room for this suite (current: '') or enter 'disable': At Work
Updated suite successfully.
Any other ideas would be helpful.
Thanks!

I'd suggest disabling Tddium’s automatic test mapping (i.e. set :test_pattern to none)
:tddium:
:test_pattern: 'none'
Then you can manually invoke the tests through the :tests configuration.

If you have never run the test suite for your current branch, Tddium will simply pick up the test pattern and use it. If you have already configured the suite for the current branch, the simplest solution is to run tddium suite --edit.

Related

Foreman - replacing repo with local mirrors

We use foreman (v1.14.1) for provisioning and we have a working CentOS 7 installation media for the base OS.
When installing it does install the default repos in /etc/yum.repos.d with online mirrors but I want to replace this with our local mirrors.
I ran accross this workflow (from 2012)
It uses the following snippet to iterate over all the media of the current host os and set write out a repo definition.
<% #host.os.media.each do |media| -%>
[<%= media.name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') %>]
name=<%= media.name %>
baseurl=<%= #host.os.medium_uri #host, media.path %>
enabled=1
gpgcheck=0
<% end -%>
I have set several Installation media for this OS, each one of them having a specific repo URI (Base, Updates, Plus, Extras...).
The snippet is called in the %post install section of the kickstart but when I want to build the host I get the following error:
Failure parsing Kickstart default: The snippet 'FF_repos' threw an error:
undefined method 'media' for Operatingsystem::Jail (Redhat).
I understand that "#host.os.media.each" is not correct for iterating over the different medias, but how could I do it ?
Any help appreciated :)
Couldn't get this to work so I have simply changed my snippet "FF_repos" to directly bake the repos definition into corresponding repo files on disk.
I added the following in the %post section then to remove default repos and leave our.
rm -f /etc/yum.repos.d/*
<%= snippet("FF_repos") %>

Running Cucumber tests on different environments

I'm using Cucumber and Capybara for my automated front end tests.
I have two environments that I would like to run my tests on. One is a staging environment, and the other is the production environment.
Currently, I have my tests written to access staging directly.
visit('https://staging.somewhere.com')
I would like to re-use the tests in production (https://production.somewhere.com).
Would it be possible to store the URL in a variable in my step definitions
visit(domain)
and define domain using an environment variable called form the command line? Like
$> bundle exec cucumber features DOMAIN=staging
if I want to point the tests to my staging environment, or
$> bundle exec cucumber features DOMAIN=production
if I want it to run in production?
How do I go about setting this up? I'm fairly new to Ruby and I've been searching the forums for a straight forward information but could not find any. Let me know if I can provide more information. Thanks for your help!
In the project's config file, create a config.yml file
---
staging:
:url: https://staging.somewhere.com
production:
:url: https://production.somewhere.com
Then extra colon in the yml file allows the hash key to be called as a symbol.
In your support/env.rb file, add the following
require 'yaml'
ENV['TEST_ENV'] ||= 'staging'
project_root = File.expand_path('../..', __FILE__)
$BASE_URL = YAML.load_file(project_root + "/config/config.yml")[ENV['TEST_ENV']][:url]
This will default to the staging environment unless you override the TEST_ENV. Then, from your step or hook, you can call:
visit($BASE_URL)
or you might need :/
visit "#{$BASE_URL}"
This will allow you to use
bundle exec cucumber features TEST_ENV=production
I don't use cucumber much but you should be able to do
bundle exec cucumber features DOMAIN=staging
then in your tests use ENV['DOMAIN'] || YOUR_DEFAULT_DOMAIN to utilize this variable. YOUR_DEFAULT_DOMAIN should probably be your test environment.
See Here

Can't make Travis-CI work

I'm trying to set up Travis on this repo: https://github.com/lcguida/worksheet
I've put the travis.yml file there.
I've enabled the repository in my travis account (the "ON" button)
I've pushed some commits to see if it woukld trigger the tester.
I'm always getting this message in "My Repositories" tab: You don't have any repos set up on Travis CI
Here is my travis.yml file:
language: ruby
rvm:
- 2.0.0
- 2.1.1
script: 'bundle exec rake test'
Can't figure out what I'm doing wrrong
I made the same mistake as you when starting on Travis :-)
The file name you need is .travis.yml
Note the first dot.
You can see what's wrong by looking at https://travis-ci.org/lcguida/worksheet/requests . . . where it repeatedly says "missing config"

How do I run Capybara on similar pages from command line?

I have nearly identical versions of webapps on different sites.
What I'd like to do is specify the site at command line...
cucumber --server server1 --tags #tests
....
#servers = {'server1' => 'https://www.tests.com', 'server2' => 'https://www.foobar.com'}
....
Background:
Given I am on {#server1}
Scenario: Happy plan
When I go here
And I see this
Then I get that
What is the best way to running the same script on multiple similar websites? Can it be run from the command line?
Your best option is to use an environment variable for your server name:
cucumber SERVER=server1 --tags #tests
You can create a generic step:
Given I am on the configured test server
Then, in your step definition, you can look that up as you would in any normal Ruby code and set it as Capybara's base URL:
Given /^I am on the configured test server$/ do
server_name = ENV['SERVER']
url = #servers[server_name] or raise "Unknown test server: #{server_name}"
Capybara.app_host = url
end
Note that when using a remote server, you'll need to use a Capybara driver that supports it, such as Selenium: the default RackTest driver does not. You may also want to set run_server to false. See https://github.com/jnicklas/capybara#calling-remote-servers
Create some config and read it before executing scripts.
Put code for parsing config to features/support/env.rb, for example.

Can't access Heroku console with app name

I just started a new app and I was able to push it to Heroku, But I it seems, that I can't access the console.
The command, that I am running is:
heroku run console --app myappname
What I get, is:
Running `console` attached to terminal... up, run.3951 Usage: rails
new APP_PATH [options]
Options: -r, [--ruby=PATH] # Path to the Ruby binary of
your choice
# Default: /app/vendor/ruby-1.9.3/bin/ruby -b, [--builder=BUILDER] #
Path to a application builder (can be a filesystem path or URL) -m,
[--template=TEMPLATE] # Path to an application template (can be a
filesystem path or URL)
[--skip-gemfile] # Don't create a Gemfile
[--skip-bundle] # Don't run bundle install -G, [--skip-git] # Skip Git ignores and keeps -O,
[--skip-active-record] # Skip Active Record files -S,
[--skip-sprockets] # Skip Sprockets files -d,
[--database=DATABASE] # Preconfigure for selected database
(options:
mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
# Default: sqlite3 -j, [--javascript=JAVASCRIPT] # Preconfigure for selected JavaScript
library
# Default: jquery -J, [--skip-javascript] # Skip JavaScript files
[--dev] # Setup the application with Gemfile pointing to your Rails checkout
[--edge] # Setup the application with Gemfile pointing to Rails repository -T, [--skip-test-unit] # Skip
Test::Unit files
[--old-style-hash] # Force using old style hash (:foo = 'bar') on Ruby >= 1.9
Runtime options: -f, [--force] # Overwrite files that already
exist -p, [--pretend] # Run but do not make any changes -q,
[--quiet] # Suppress status output -s, [--skip] # Skip files
that already exist
Rails options: -h, [--help] # Show this help message and quit
-v, [--version] # Show Rails version number and quit
Description:
The 'rails new' command creates a new Rails application with a default
directory structure and configuration at the path you specify.
You can specify extra command-line arguments to be used every time
'rails new' runs in the .railsrc configuration file in your home directory.
Note that the arguments specified in the .railsrc file don't affect the
defaults values shown above in this help message.
Example:
rails new ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
I know, that the application name is correct, as I just pushed it and it is loaded.
When I look at the logs on Heroku for the moment, when I tried to hit the console, I see following:
2013-07-01T16:21:58.780979+00:00 heroku[api]: Starting process with command `bundle exec rails console` by mzaragoza#myemail.com
2013-07-01T16:22:09.000482+00:00 heroku[run.2993]: Awaiting client
2013-07-01T16:22:09.055474+00:00 heroku[run.2993]: Starting process with command `bundle exec rails console`
2013-07-01T16:22:10.342966+00:00 heroku[run.2993]: State changed from starting to up
2013-07-01T16:22:13.870963+00:00 heroku[run.2993]: Process exited with status 0
2013-07-01T16:22:13.889703+00:00 heroku[run.2993]: State changed from up to complete
What about heroku run rails c? Does it make any difference if you add rails?
PS: I'm unsure if you want to access Rails' console or just a normal shell, from the comments.
The correct form is => heroku run "any rails command here"
I had this problem when I upgraded to Rails > 4.0.0. The solution is to run locally the following command rake rails:update:bin. This will generate a bin directory in the root of your application. Make sure that it is not in your .gitignore file. Commit and then push the changes to Heroku.
For 3.2.x apps:
This also just happened to me when I removed script/rails from my repo and pushed to Heroku. Reverting the commit and pushing that change made things work again.

Resources