> mkdir foo > cd foo > gem install bundler
Gemfile
source 'https://rubygems.org' gem 'minitest', '~> 5.3.4' gem 'rspec', '2.14.1' gem 'capybara', '2.3.0' gem 'selenium-webdriver'
> bundle install > rspec --init
lib/zombie.rb
class Zombie attr_accessor :name def initialize @name = 'Ash' end end
spec/lib/zombie_spec.rb
require 'zombie' describe Zombie do it 'is named Ash' do zombie = Zombie.new expect(zombie.name).to eq('Ash') end end
> rspec spec/lib/zombie_spec.rb
Trouble shooting
Use this is having trouble with named routes and rspec.
# Added below ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' RSpec.configure do |config| config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus config.order = 'random' config.use_transactional_fixtures = true config.include Capybara::DSL # JR - added to get paths working end
Leave a Reply