我正在尝试为我的模型做一个简单的测试Course,我写了这个工厂:
FactoryGirl.define do
factory :course do
name 'How to be happy ?'
end
end
Run Code Online (Sandbox Code Playgroud)
course_spec.rb:
require "rspec"
require 'factory_girl_rails'
describe "When a course is created" do
it "can't be deleted if any student is enrolled to it" do
FactoryGirl.find_definitions
course = FactoryGirl.build(:course)
student= Student.create!
course.students << student
course.destroy
course.name.should !=nil
end
end
Run Code Online (Sandbox Code Playgroud)
但是,我达到了这条线
course = FactoryGirl.build(:course)
Run Code Online (Sandbox Code Playgroud)
我收到错误:
FactoryGirl::DuplicateDefinitionError: Factory already registered: course
Run Code Online (Sandbox Code Playgroud)
如果我在工厂评论:课程定义,我得到:
NameError: uninitialized constant Course
Run Code Online (Sandbox Code Playgroud)
有什么好主意吗?
这是我的Gem Envioronment:
RubyGems Environment:
RUBYGEMS VERSION: 1.8.10
RUBY VERSION: 1.9.3 …Run Code Online (Sandbox Code Playgroud) 我们有一个桌面应用程序,我们有一个ListView,它ListView.ItemTemplate是一个扩展的KPageScrollViewerScrollViewer
虽然我们设定VirtualizingStackPanel.IsVirtualizing="True"和 VirtualizingStackPanel.VirtualizationMode="Recycling"
我们注意到KPageScrollViewer的构造函数(在其中ItemTemplate)总是在查看ListView中的项目时执行.
我们期望它将被创建4到5次,然后,相同的实例将用于查看数据,因为我们使用的是回收模式,但这不会发生,因此我们最终会得到越来越多的KPageScrollViewer实例创造..
是因为我们定制了ListView.ItemsPanel吗?
<ListView.ItemsPanel>
<ItemsPanelTemplate >
<p:KVirtualizingStackPanel IsItemsHost="True"
Run Code Online (Sandbox Code Playgroud)
有什么好主意吗?我想知道哪些原因会导致回收功能丢失?
<ListView x:Class="KETAB.KStudio.Stage.PagesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:p="clr-namespace:KETAB.KStudio.Stage"
Name="PagesList" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden"
Loaded="instScroll_Loaded"
AllowDrop="True"
MouseMove="PagesList_MouseMove"
ScrollViewer.PanningMode="None"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.CleanUpVirtualizedItem="PagesList_CleanUpVirtualizedItem"
VirtualizingStackPanel.VirtualizationMode="Recycling"
>
<ListView.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/StageResources.xaml"/>
<ResourceDictionary Source="/KETAB.KStudio.UserControls;component/ScrollViewerStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Opacity="0.4" Color="Transparent" />
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Opacity="0.4" Color="Transparent" />
<!--<p:PageWidthConverter x:Key="PageWidthConverter" />-->
<p:PageWidthConverter x:Key="pageWidthConverter" />
<p:PageHeightConverter x:Key="pageHeightConverter" />
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding …Run Code Online (Sandbox Code Playgroud) 我想知道是否有可能ShouldBroadcast在Laravel中进行测试?我的测试将触发实现的偶数ShouldBroadcast,但是,我注意到广播并未发生。
当然,广播事件本身就是在应用程序中进行的。
有没有人尝试过这种测试?
我已经安装了最后一个版本的will_paginate,我试图在我的视图中使用它,如下所示:
@courses = Course.paginate(:page => params[:page])
will_paginate @courses
Run Code Online (Sandbox Code Playgroud)
但是,我在视图中什么都没得到!任何的想法 ??
满足以下条件:
>> defined? WillPaginate
>> ActiveRecord::Base.respond_to? :paginate
Run Code Online (Sandbox Code Playgroud)
有什么我想念的吗?
我正在尝试写两个拒绝和批准行动的链接,但是,我不知道如何写出正确的路线,
我的路线.rb
put 'approve_class_room/:id(.:format)', :to => 'class_room_member_ships#approve'
put 'reject_class_room/:id(.:format)', :to => 'class_room_member_ships#reject'
Run Code Online (Sandbox Code Playgroud)
但是,在rake路线中,我得到:
PUT /approve_class_room/:id(.:format) class_room_member_ships#approve
PUT /reject_class_room/:id(.:format) class_room_member_ships#reject
Run Code Online (Sandbox Code Playgroud)
那么,什么是正确的link_to路径?
我的链接是
= link_to 'approve', approve_class_room_path
Run Code Online (Sandbox Code Playgroud)
它不会工作,我得到:
undefined local variable or method `approve_class_room_path'
Run Code Online (Sandbox Code Playgroud)
ps:我正在尝试让link_to使用AJAX工作,在同一页面上进行批准,AM我是否正确?什么是link_to路径?
有什么好主意吗?
当我在heroku使用SendGrid服务时,我注意到当我发送基于HTML的电子邮件时,CSS没有效果,任何人都可以告诉我什么可能是错的?
我试图将它作为html.haml,html.erb发送,但两者都不起作用,尽管在发送的电子邮件中正确查看了图像.
任何的想法 ?
如何使用pry调试rails应用程序而不是RubyMine IRB控制台?我应该在我的gemfile中添加pry-rails和pry吗?
这是我的测试:
require "rspec"
describe HomeController do
render_views
it "should renders the home" do
get :home
response.should render_template("home")
response.should include_text("Simulate Circuits Online")
end
end
Run Code Online (Sandbox Code Playgroud)
但是,我得到了:
1) HomeController should renders the home
Failure/Error: response.should include_text("Some text to be test ..")
NoMethodError:
undefined method `include_text' for #<RSpec::Core::ExampleGroup::Nested_1:0xd429a0c>
# ./spec/controllers/home_controller_spec.rb:9:in `block (2 levels) in <top (required)>'
# (eval):6:in `block in fork'
# (eval):6:in `fork'
# (eval):6:in `fork'
Run Code Online (Sandbox Code Playgroud)
那么,测试所呈现文本的正确方法是什么?
编辑
如果我尝试 response.should have_content("My text ..")
我明白了
1) HomeController should renders the home
Failure/Error: response.should have_content("My …Run Code Online (Sandbox Code Playgroud) 虽然phenix服务器正常启动,但我在观察者的应用程序列表中看不到它。
我所做的是:
elixir -S mix phoenix.server
Run Code Online (Sandbox Code Playgroud)
并且,它是另一个终端:
iMac:~ Apple$ iex
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Interactive Elixir (1.2.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :observer.start
:ok
Run Code Online (Sandbox Code Playgroud)
这是我的应用程序的启动方式:
defmodule Rumbl do
use Application
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
# Start the endpoint when the application starts
supervisor(Rumbl.Endpoint, []),
# Start the Ecto repository
supervisor(Rumbl.Repo, []), …Run Code Online (Sandbox Code Playgroud) .net ×1
compression ×1
css ×1
elixir ×1
factory-bot ×1
gzip ×1
heroku ×1
html-email ×1
javascript ×1
laravel ×1
laravel-5.1 ×1
laravel-5.2 ×1
pry ×1
recycle ×1
routes ×1
rspec ×1
rspec2 ×1
rubymine ×1
scroll ×1
sendgrid ×1
tdd ×1
wpf ×1