Created
May 21, 2018 11:13
-
-
Save CodePint/f09f601a68c672e2d48e40552fdf43ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe GymsController, type: :controller do | |
let(:gym) { Gym.create!(gym_name: "Stronghold gym", about: "Brand new bouldering gym in Tottenham Hale", address: "Tottenham Hale, London", email: "stronghold@gmail.com" )} | |
let(:climber) { User.create!(email: 'climber@sendroute.com', password: '123456', first_name: 'test', last_name: 'test', user_name: 'climber') } | |
let!(:gym_create) {{ gym_name: "The Castle Gym", about: "Classic multi story climbing gym in central london", address: "Finsbury Park - London", email: "castleclimbing@gmail.com" } } | |
before do | |
sign_in(climber) | |
end | |
context 'GET #index' do | |
it 'returns a success response' do | |
get :index | |
expect(response).to be_success | |
end | |
end | |
context 'GET #show' do | |
it 'returns a success response' do | |
get :show, params: {id: gym.to_param} | |
expect(response).to be_success | |
end | |
end | |
context 'GET #new' do | |
it 'returns a success response' do | |
get :new | |
expect(response).to be_success | |
end | |
end | |
context 'POST #create' do | |
it 'returns a success response' do | |
expect { | |
post :create, params:{gym: gym_create} | |
}.to change(Gym, :count).by(1) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment