Skip to content

Instantly share code, notes, and snippets.

View andreaseriksson's full-sized avatar

Andreas Eriksson andreaseriksson

View GitHub Profile
@andreaseriksson
andreaseriksson / gist:5604428
Created May 18, 2013 13:41
RSPEC Controller spec #UPDATE
describe 'PUT#update' do
before :each do
@message = create(:message, name: "Aaron Sumner",
email: "[email protected]")
end
it "locates the requested @message" do
put :update, id: @message, message: attributes_for(:message)
expect(assigns(:message)).to eq(@message)
end
@andreaseriksson
andreaseriksson / gist:5604424
Created May 18, 2013 13:40
RSPEC Controller spec #CREATE
describe "POST#create" do
context "with valid attributes" do
it "saves the new message in the database" do
expect{
post :create, message: attributes_for(:message)
}.to change(Message, :count).by(1)
end
it "redirects to the home page" do
@andreaseriksson
andreaseriksson / gist:5604420
Created May 18, 2013 13:39
RSPEC Controller spec #EDIT
describe 'GET#edit' do
it "assigns the requested message to @message" do
message = create(:message)
get :edit, id: message
expect(assigns(:message)).to eq message
end
it "renders the :edit template" do
message = create(:message)
get :edit, id: message
@andreaseriksson
andreaseriksson / gist:5604417
Created May 18, 2013 13:38
RSPEC Controller spec #NEW
describe 'GET#new' do
it "assigns a new Message to @message" do
get :new
expect(assigns(:message)).to be_a_new(Message)
end
it "renders the :new template" do
get :new
expect(response).to render_template :new
end
@andreaseriksson
andreaseriksson / gist:5604414
Last active December 17, 2015 11:39
RSPEC Controller spec #SHOW
describe 'GET#show' do
it "assigns the requested message to @message" do
message = create(:message)
get :show, id: message
expect(assigns(:message)).to eq message
end
it "renders the :show template" do
message = create(:message)
get :show, id: message
@andreaseriksson
andreaseriksson / gist:5604408
Last active December 17, 2015 11:39
RSPEC Controller spec #INDEX
describe 'GET#index' do
it "populates an array of messages" do
message = create(:message)
get :index
expect(assigns(:messages)).to match_array [message]
end
it "renders the :index view" do
get :index
response.should render_template :index
@andreaseriksson
andreaseriksson / gist:5604219
Created May 18, 2013 12:14
BOOTSTRAP Popover & Tooltip
<script>
$(function(){
//Tooltip
$("a[data-toggle=tooltip], span[data-toggle=tooltip], .tip").tooltip();
//Popover
$("a[data-toggle=popover], .info").popover().click(function(e) {
e.preventDefault()
});
});
@andreaseriksson
andreaseriksson / gist:5604195
Created May 18, 2013 12:03
BOOTSTRAP Horizontal form
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputEmail">Email</label>
<div class="controls">
<input type="text" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password</label>
<div class="controls">
@andreaseriksson
andreaseriksson / gist:5604189
Created May 18, 2013 12:01
BOOTSTRAP Button-group
<div class="btn-group">
<button class="btn">Left</button>
<button class="btn">Middle</button>
<button class="btn">Right</button>
</div>
@andreaseriksson
andreaseriksson / gist:5604179
Created May 18, 2013 11:57
BOOTSTRAP Modal
<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">