Skip to content

Instantly share code, notes, and snippets.

@ml242
Last active December 28, 2015 17:38
Show Gist options
  • Save ml242/7536924 to your computer and use it in GitHub Desktop.
Save ml242/7536924 to your computer and use it in GitHub Desktop.
Adding Rspec and Guard to a ruby project that isn't backed by Rails
go to your directory
run --> rspec --init
cd into rspec (this is where you create your helper, i.e. bus_spec.rb), or just use touch to place them
cd ..
run --> rspec spec/
run --> bundle init
add gem 'rspec'
add gem 'guard-rspec'
run --> bundle install
run --> guard init rspec
run --> guard
#context is for setting up initial conditions
#one use case of descibe is for describing various methods that the class has
after context or describe, see below. This is very powerful so keep reading.
before(:each) do
@user = User.new(params)
end
OR BETTER (more specific)
let(:user) do
User.new(params)
end
it "provides gender blah blah blah" do
expect(user.gender).to eq(m)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment