How do you debug factory_girl? i've tried to put debugger in there but i just cant. I just want to test why my associations aren't working right
How did you use the debugger? If you tried to use it in test environment, I'm not surprised it didn't work. But factory_girl is not limited to test environment.
Simply require factory_girl gem and relevant factories in development environment, start the server with debugger (or just console) and you're set for debugging.
UPDATE
I have this setup in https://github.com/lstejskal/icanhazblog. When you install it and run 'rails console', you can then do stuff like:
$ a = Factory.create :article
=> #<Article _id: 4dc27b867319e80fb2000001, created_at: 2011-05-05 10:27:18 UTC,
updated_at: 2011-05-05 10:27:18 UTC, title: "Article 1", content: "This is a content
for Article 1.", visible: true, published_at: 2011-02-11 23:00:00 UTC, tags: ["ruby",
"rails", "sinatra"]>
$ a.title
=> "Article 1"
Just add something like this when starting in development mode:
require 'factory_girl'
# require factories
Dir["#{PATH_TO_FACTORIES}/*.rb"].each { |f| require f }
Related
I have a working Gatsby install that I've been adding to, however, in trying to build in some graphQL build-time data fetching, I've run into an issue that causes error when running npm start (gatsby develop) or gatsby build.
I installed gatsby-source-graphql as described here:
https://www.npmjs.com/package/gatsby-source-graphql
And I included it in my gatsby-config.js like this:
module.exports = {
// Optional
siteMetadata: {
title: `Title from siteMetadata`,
},
plugins: [
{
resolve: `gatsby-plugin-manifest`,
options: {
name: "Project Template",
short_name: "PT",
start_url: "/",
background_color: "#6b37bf",
theme_color: "#6b37bf",
// Enables "Add to Homescreen" prompt and disables browser UI (including back button)
// see https://developers.google.com/web/fundamentals/web-app-manifest/#display
display: "standalone",
icon: "src/images/icon.png", // This path is relative to the root of the site.
// An optional attribute which provides support for CORS check.
// If you do not provide a crossOrigin option, it will skip CORS for manifest.
// Any invalid keyword or empty string defaults to `anonymous`
crossOrigin: `use-credentials`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
// GraphQL APIs for use during build-time.
// https://www.npmjs.com/package/gatsby-source-graphql
//////////////////////////////////////////////////////
{
resolve: "gatsby-source-graphql",
options: {
// Arbitrary name for the remote schema Query type
typeName: "SpaceX",
// Field under which the remote schema will be accessible. You'll use this in your Gatsby query
fieldName: "spaceX",
// Url to query from
url: "https://api.spacex.land/graphql/",
},
},
// {
// resolve: "gatsby-source-graphql",
// options: {
// // Arbitrary name for the remote schema Query type
// typeName: "SWAPI",
// // Field under which the remote schema will be accessible. You'll use this in your Gatsby query
// fieldName: "swapi",
// // Url to query from
// url: "https://swapi-graphql.netlify.app/.netlify/functions/index",
// },
// },
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
`gatsby-plugin-react-helmet`,
`gatsby-theme-material-ui`,
{
resolve: `gatsby-plugin-nprogress`,
options: {
// Setting a color is optional.
color: `tomato`,
// Disable the loading spinner.
showSpinner: false,
},
},
`gatsby-plugin-transition-link`,
`gatsby-plugin-layout`, // Trial and error showed this needs to be last (But that doesn't mean it will always work in the dev environment, try npm run clean or if that fails - test in build)
],
}
But it produces this error:
Error in "/Users//Documents/projects/project/node_modules/gatsby-source-graphql/gatsby-node.js":
Cannot find module 'gatsby/graphql'
Error: Cannot find module 'gatsby/graphql'
- loader.js:636 Function.Module._resolveFilename
internal/modules/cjs/loader.js:636:15
- loader.js:562 Function.Module._load
internal/modules/cjs/loader.js:562:25
- loader.js:692 Module.require
internal/modules/cjs/loader.js:692:17
- v8-compile-cache.js:159 require
[client]/[v8-compile-cache]/v8-compile-cache.js:159:20
- gatsby-node.js:8 Object.<anonymous>
[tbwa-project-template]/[gatsby-source-graphql]/gatsby-node.js:8:5
- v8-compile-cache.js:178 Module._compile
[client]/[v8-compile-cache]/v8-compile-cache.js:178:30
- loader.js:789 Object.Module._extensions..js
internal/modules/cjs/loader.js:789:10
- loader.js:653 Module.load
internal/modules/cjs/loader.js:653:32
- loader.js:593 tryModuleLoad
internal/modules/cjs/loader.js:593:12
- loader.js:585 Function.Module._load
internal/modules/cjs/loader.js:585:3
- loader.js:692 Module.require
internal/modules/cjs/loader.js:692:17
- v8-compile-cache.js:159 require
[client]/[v8-compile-cache]/v8-compile-cache.js:159:20
- resolve-module-exports.ts:197 resolveModuleExports
[client]/[gatsby]/src/bootstrap/resolve-module-exports.ts:197:26
- validate.ts:348 forEach
[client]/[gatsby]/src/bootstrap/load-plugins/validate.ts:348:31
- Array.forEach
- validate.ts:340 collatePluginAPIs
[client]/[gatsby]/src/bootstrap/load-plugins/validate.ts:340:20
not finished load plugins - 0.727s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project-template#1.0.0 start: `gatsby develop`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project-template#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/_logs/2021-02-04T00_31_34_070Z-debug.log
What I've tried:
I've tried two different gatsby-source-graphql definitions in the config (only ever one at a time), but both produce the error. THe second one (commented out above) is taken directly from The github page example and the Gatsby example.
I've tried changing the order of the plugins (i've tried every position) but still get the error.
If I comment any and all gatsby-source-graphql sections in the config, it doesn't produce the error.
If I comment out all plugins except one of the gatsby-source-graphql sections, I still get the exact same error.
I've also tried removing the node_modules folder, running npm run clean, and then npm install again with no change.
I've tried DanceParty's solution described in the link below as well with no change:
https://github.com/gatsbyjs/gatsby/issues/8249
I've tried running npm update and npm install npm#latest -g and saw no change.
My environment report using gatsby info --clipboard is:
System:
OS: macOS 10.15.7
CPU: (4) x64 Intel(R) Core(TM) i5-6287U CPU # 3.10GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 10.23.1 - /usr/local/bin/node
npm: 6.14.10 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 88.0.4324.96
Firefox: 85.0
Safari: 14.0.2
npmPackages:
gatsby: ^2.26.1 => 2.32.0
gatsby-image: ^2.10.0 => 2.11.0
gatsby-plugin-layout: ^1.9.0 => 1.10.0
gatsby-plugin-manifest: ^2.11.0 => 2.12.0
gatsby-plugin-material-ui: ^2.1.10 => 2.1.10
gatsby-plugin-nprogress: ^2.9.0 => 2.10.0
gatsby-plugin-react-helmet: ^3.8.0 => 3.10.0
gatsby-plugin-sharp: ^2.13.0 => 2.14.0
gatsby-plugin-transition-link: ^1.20.5 => 1.20.5
gatsby-source-filesystem: ^2.10.0 => 2.11.0
gatsby-theme-material-ui: ^1.0.13 => 1.0.13
gatsby-transformer-sharp: ^2.11.0 => 2.12.0
npmGlobalPackages:
gatsby-cli: 2.19.0
Any ideas?
I started creating a minimal reproduction and adding everything back one by one, but decided to play more with my first setup for a little...and I'm glad I did.
Here's what caused the issue:
This Gatsby install is part of a Project Template we use which includes backend code, front-end, pipeline deployment scripts, etc.
The structure is similar to:
ProjectTemplate folder
client folder
server folder
other folders
The Gatsby install lives in the client folder but occasionally I need to go into the root folder to do certain things.
So what happened!?
I accidentally installed gatsby-source-graphql into the root folder instead of the client folder. That's all.
I should have picked this up when I ran gatsby info --clipboard as it's clearly not listed as a dependency.
As far as I understand, the protractor-cucumber-framework passes through the cucumberOpts object to cucumber, which allows the user to specify cucumber options like strict and tags. I'm trying to use a TeamCity reporter with this framework. According to the instructions for the reporters, (e.g. TeamCity Reporter, to use this reporter you use the --format option to specify the reporter when running cucumber. So my interpretation is that I should specify the format property in the cucumberOpts object in the same way. i.e. cucumber -f TeamCityFormatter::Formatter becomes:
cucumberOpts: {
'format': 'TeamCityFormatter::Formatter'
}
But when I do this, I get the error:
Unhandled rejection Error: ENOENT: no such file or directory, open 'C:\Dev\fork\Billing.Test.Automation.V2\:Formatter':
I thought maybe I just need to specify the name of the module, so I tried:
cucumberOpts: {
'format': 'TeamCityFormatter'
}
Which gave me this error:
Unhandled rejection Error: Cannot find module 'C:\Dev\fork\Billing.Test.Automation.V2\TeamCityFormatter'
So that looks like it is looking for a module, so I tried pointing it to the module in the node_modules folder:
cucumberOpts: {
'format': 'node_modules/teamcity-formatter'
}
And I get this error:
Unhandled rejection TypeError: this.registerHandler is not a function
Is there some special way to use a cucumber reporter via the protractor-cucumber-framework?
Not an answer but an example of how a package can be imported as a plugin
onPrepare:fucntion(){
...
},
// Here the magic happens
plugins: [{
package: 'protractor-multiple-cucumber-html-reporter-plugin',
options: {
automaticallyGenerateReport: true,
removeExistingJsonReportFile: true,
displayDuration: true
}
}],
My project: https://github.com/sebastian3495/sebastian3495.github.io
My website (current displayed without css rendered): https://sebastian3495.github.io/
How can I have all links point to my github project instead of localhost?
What am I missing? I am new to jekyll and web development isn't my strongest point, so please bear with me.
EDIT: My config file hasbeen updated
_config.yml
title: Blog Title
description: Describe your website here.
# put your disqus here
remote_theme: aron-bordin/neo-hpstr-jekyll-theme
disqus_shortname:
reading_time: true # if true, shows the estimated reading time for a post
words_per_minute: 200
logo: images/logo.png # logo visible in the topbar
excerpt_separator: <!--more-->
url: https://sebastian3495.github.io
# draw your top menu here
# each item must have a title and a url.
# To list post categories. use type: 'categories'
# To create sub categories. add a submenu item
# See the example
menu:
- title: 'Home'
url: '/'
- title: 'Fork'
url: 'http://github.com/aron-bordin/neo-hpstr-jekyll-theme'
- title: 'Install'
url: 'http://github.com/aron-bordin/neo-hpstr-jekyll-theme#installation'
- title: 'Tags'
url: '/tags'
- title: 'Categories'
url: '/categories'
type: 'categories'
- title: 'Favorites'
url: '#'
submenu:
- title: 'Code Highlighter'
url: '/intro/code-highlighting-post/'
- title: 'Sample Post'
url: '/intro/sample-post/'
# Owner/author information
owner:
name: Sebastian Nielsen
site: http://aronbordin.com
avatar: images/avatar.jpg
bio: "TEsting stuff off! . :D . It shouldn't be super long but a good two sentences or two should suffice."
email: you#email.com
# Twitter nick for use in Twitter cards and follow button.
twitter: aron_bordin # if no twitter in this config, the twitter follow button will be removed
# GitHub nick for use in follow button in author block.
github: aron-bordin
# Twitter account associated with the site if different from owner/author twitter account.
# Used in Twitter cards.
twitter:
# Social networking links used in author block underneath posts. Update and remove as you like.
social:
- title: "github"
url: "https://github.com/aron-bordin"
- title: "linkedin"
url: "https://br.linkedin.com/in/aronbordin"
- title: "youtube"
url: "https://www.youtube.com/channel/UCfnSek-9HPWOx5e2pH7VFgg"
# Background image to be tiled on all pages
background:
# Analytics and webmaster tools stuff goes here
google_analytics:
google_verify:
# https://ssl.bing.com/webmaster/configure/verify/ownership Option 2 content= goes here
bing_verify:
# http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
timezone: America/New_York
locale: en_US
future: true
highlighter: rouge
markdown: kramdown
sass:
sass_dir: _sass
style: compressed
# https://github.com/mojombo/jekyll/wiki/Permalinks
permalink: /:categories/:title/
# Amount of post to show on home page
paginate: 5
# if true, shows the floatting share buttons
float_share: true
# Octopress
# Default extensions
post_ext: md
page_ext: md
# Found in _templates/
post_layout: post
page_layout: page
# Format titles with titlecase?
titlecase: true
include: [".htaccess", "C:/Users/sebas/Documents/GitHub/Sebastian_Nielsen_Blog/_includes"]
exclude: ["demo/*", "lib", "config.rb", "Capfile", "config", "Gemfile", "Gemfile.lock", "README.md", "LICENSE", "log", "Rakefile", "Rakefile.rb", "tmp", "less", "*.sublime-project", "*.sublime-workspace", "test", "spec", "Gruntfile.js", "package.json", "node_modules"]
plugins: ["jekyll-paginate", "jekyll-remote-theme"]
theme: neo-hpstr-jekyll-theme
Since you're using a third-party theme, I understand you followed the instructions to run jekyll build locally first and then uploaded the contents of your ./_site directory.
The issue here is that recent versions of Jekyll automatically sets the url key to http://localhost:4000 when you build locally.
You have two basic choices:
To use both third-party themes and third-party plugins on GitHub Pages, you need to build the site locally by changing the JEKYLL_ENV env to production (or anything else other than development)
JEKLL_ENV=production bundle exec jekyll build
(on Windows, you need to run set JEKLL_ENV=production first followed by the jekyll incantation.
To use a third-party theme that requires only official plugins, and the theme-repo itself is also hosted on GitHub, you can use the remote_theme feature (included by default in recent versions of gem "github-pages"):
# _config.yml
remote_theme: aron-bordin/neo-hpstr-jekyll-theme
Refer: https://github.com/benbalter/jekyll-remote-theme for details on the jekyll-remote-theme plugin usage.
As you're pushing locally generated code, you need to :
In _config.yml, set url: https://sebastian3495.github.io
Run a bundle exec jekyll build
Push the resulting code to github.
Obviously it is not that simple. Let's start from the beginning: I'm working on a shared project and yesterday I've been asked to add the plugin mgI18n. I followed the readme file step by step, but when it came down to run the command line to create the table used by the plugin, I got this:
database "" does not exists
I searched it, and I found out that sfConfig::get('app_mgI18nPlugin_connection'); returned an empty value. It was weird, because I've done every step right, setting the value in my app.yml and clearing symfony cache, so I logged sfConfig::getAll(); and found out that the only values for 'app_' stored here were the ones from the file app.yml in the plugin folder of kdDoctrineGuardFacebookConnectPlugin. I've already tried removing that file and clearing the cache, obtaining only to lose these values.
Here is the file contents:
project/apps/frontend/config/app.yml
all:
#other values
facebook:
appId: yyy
secret: yyy
cookie: true
script_lang: fr_FR
perms: email
mgI18nPlugin:
connection: doctrine
cultures_available:
fr: Français
en: English
it: Italiano
de: Deutsch
project/plugins/kdDoctrineGuardFacebookConnectPlugin/config/app.yml
all:
facebook:
appId: xxx
secret: xxx
cookie: true
script_lang: fr_FR
perms: email
and this is what I get when I log sfConfig::getAll(); :
array('app_facebook_appId' => 'xxx',
'app_facebook_secret' => 'xxx',
'app_facebook_cookie' => true,
'app_facebook_script_lang' => 'fr_FR',
'app_facebook_perms' => 'email',
)
Why the values for the main app.yml are not loaded? How do I correct this behaviour?
Thank you all in advance for your help, if you need more specifics I'll glady add them
If I understood you well you are in a command line task context (some sfTask). Symfony tasks by default do not run in application context. In most cases just call your task as
./symfony namespace:name --application=frontend
and you will have your configs.
If it is your own task just add it an option with default value in your configure method:
$this->addOptions(array(
new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'),
...
)
Plugin settings are loaded correctly, because plugins are configured per project not application (you enable them in ProjectConfiguration, not generated frontendConfiguration class)
I've made a site using Haml and Sinatra. After the update (I guess it was after that) the site didn't work any more; here is a minimal example:
/app.rb:
require 'rubygems' if RUBY_VERSION < '1.9'
require 'sinatra'
require 'haml'
get "/" do
haml :index
end
/views/layout.haml
!!!
%html{ :xmlns => "http://ww.w3.org/1999/xhtml", :lang => "en", "xml:lang" => "en" }
%head
%title test
%body
= yield
/view/index.haml
%p test
and it throws me the following exception:
/usr/lib/ruby/gems/1.9.1/gems/tilt-1.3.2/lib/tilt/template.rb in initialize
raise ArgumentError, "file or block required" if (#file || block).nil?
/usr/lib/ruby/gems/1.9.1/gems/sinatra-1.3.0.a/lib/sinatra/base.rb in new
template.new(path, 1, options)
/usr/lib/ruby/gems/1.9.1/gems/sinatra-1.3.0.a/lib/sinatra/base.rb in block in compile_template
template.new(path, 1, options)
/usr/lib/ruby/gems/1.9.1/gems/tilt-1.3.2/lib/tilt.rb in fetch
#cache[key] ||= yield
/usr/lib/ruby/gems/1.9.1/gems/sinatra-1.3.0.a/lib/sinatra/base.rb in compile_template
template_cache.fetch engine, data, options do
/usr/lib/ruby/gems/1.9.1/gems/sinatra-1.3.0.a/lib/sinatra/base.rb in render
template = compile_template(engine, data, options, views)
/usr/lib/ruby/gems/1.9.1/gems/sinatra-1.3.0.a/lib/sinatra/base.rb in haml
render :haml, template, options, locals
I haven't really found a way to fix it, does anyone know how to interpret it?
I get the same error with Sinatra 1.3.0.a (the version you're using, which I assume is a release candidate and not a full release), but updating to the current latest (1.3.0.e) fixes it, as does downgrading to the latest stable release (1.2.6). So your answer is upgrade or downgrade.
You can load a specific version of a gem using:
gem "sinatra", "=1.2.6"
before you call require "sinatra", or you could look into using Bundler (which uses the same syntax).