class CommentsController < ApplicationController
before_action :set_post
def create
@comment = @post.comments.build(comment_params)
use my_crate::add;
#[test]
fn test_public_api() {
assert_eq!(add(3, 4), 7);
}
package com.example.myapp.data.repository
import com.example.myapp.data.local.PostDao
import com.example.myapp.data.local.PostEntity
import com.example.myapp.data.remote.ApiService
import com.example.myapp.models.Post
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { fileURLToPath, URL } from 'node:url';
const resolvePath = (relative: string): string =>
fileURLToPath(new URL(relative, import.meta.url));
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
#[cfg(test)]
mod tests {
class ExplainAnalyzer
def initialize(relation, watched_tables:)
@relation = relation
@watched_tables = Array(watched_tables).map(&:to_s)
end
package api_test
import (
"encoding/json"
"net/http"
"net/http/httptest"
import express, { Express, NextFunction, Request, Response } from 'express';
import { userRoutes } from './userRoutes';
function authenticate(req: Request, res: Response, next: NextFunction) {
const header = req.header('authorization');
if (!header || !header.startsWith('Bearer ')) {
use std::io::Write;
use tempfile::NamedTempFile;
fn main() -> std::io::Result<()> {
let mut tmpfile = NamedTempFile::new()?;
writeln!(tmpfile, "Hello, temp file!")?;
FactoryBot.define do
factory :post do
association :author, factory: :user
sequence(:title) { |n| "Post Title #{n}" }
body { Faker::Lorem.paragraphs(number: 3).join("\n\n") }
status { :draft }
-- Create test database
CREATE DATABASE myapp_test;
-- Test isolation with transactions
/*
beforeEach(async () => {
import { http, HttpResponse } from 'msw';
export interface Product {
id: number;
name: string;
}