我有一个__CODE__包含一些幻灯片和菜单.
#wrap {
position: relative;
top: 0;
transition: top 1.4s cubic-bezier(.49,.22,.52,1.35);
}Run Code Online (Sandbox Code Playgroud)
下面是我的CSS的__CODE__.
<div id="wrap"></div>Run Code Online (Sandbox Code Playgroud)
任何人都可以解释一下过渡房产在这里做了什么?.
我无法理解它在div上产生的影响.
我正在测试我的model方法,它返回给我一个Account object.我正在检查我的表是否插入了一个新的row,我的模型反映了它的计数.
以下是我的规格.
it "can create an account" do
create_account = Account.create(account: acc)
create_account.should change(Account, :count).by(1);
end
Run Code Online (Sandbox Code Playgroud)
我得到的错误
8) Account can create an account
Failure/Error: create_account.should change(Account, :count).by(1);
expected #count to have changed by 1, but was not given a block
Run Code Online (Sandbox Code Playgroud) 我尝试json使用工厂构建一个,但是当我尝试build它时它是空的。
下面是Factory课。
require 'faker'
FactoryGirl.define do
factory :account do |f|
f.name {Faker::Name.name}
f.description {Faker::Name.description}
end
factory :accjson, class:Hash do
"@type" "accountResource"
"createdAt" "2014-08-07T14:31:58"
"createdBy" "2"
"disabled" "false"
end
end
Run Code Online (Sandbox Code Playgroud)
以下是我正在尝试构建的方式。
hashed_response = FactoryGirl.build(:accjson)
expect(account.to_json).to eq(hashed_response.to_json);
Run Code Online (Sandbox Code Playgroud)
但我的hashed_response似乎总是空的object。
我有一个下面的规范,我是mocking我的用户模型stubbing及其方法.
require 'spec_helper'
describe User do
let(:username) {"test@test.com"}
let(:password) {"123"}
let(:code) {"0"}
context "when signing in" do
let(:expected_results) { {token:"123"}.to_json }
it "should sign in" do
expect(User).to receive(:login).with({email: username, password: password, code: code})
.and_return(expected_results)
end
end
end
Run Code Online (Sandbox Code Playgroud)
当我尝试运行我的测试用例时,我得到以下错误.
Failure/Error: expect(User).to receive(:login).with({email: username, password: password, code: code})
(<User (class)>).login({:email=>"test@test.com", :password=>"123", :code=>"0"})
expected: 1 time with arguments: ({:email=>"test@test.com", :password=>"123", :code=>"0"})
received: 0 times
Run Code Online (Sandbox Code Playgroud) 为什么这个代码会抛出undefined?
function Obj() {
this.a = 12;
this.b = "a";
this.privilegedMethod = function () {
this.a++;
privateMethod();
};
function privateMethod() {
this.b = "foo";
console.log(this.b);
}
}
Run Code Online (Sandbox Code Playgroud)
调用如下所示的函数,在"严格模式"中抛出... undefined.
var a = new Obj();
console.log(a.privilegedMethod());
Run Code Online (Sandbox Code Playgroud) 我得到以下错误ActionController :: UrlGenerationError.
ActionController::UrlGenerationError:
No route matches {:action=>"/accounts/100", :controller=>"accounts"}
Run Code Online (Sandbox Code Playgroud)
下面是我的代码抛出此错误.
it "can find an account" do
Account.should_receive(:find, with: {id: 2055, authorization: @auth}
get "/accounts/100", nil, {"AUTH_TOKEN" => @auth}
hashed_response = {
"@type" => "test",
"createdAt" => "2014-07-24T15:26:49",
"description" => "Something about test",
"disabled" => false
}
expect(response.status).to eq 200
expect(response.body).to eq(hashed_response.to_json);
end
Run Code Online (Sandbox Code Playgroud)
我对此做了一个google,并且知道没有为此定义路由.以下是我的config/routes.rb档案
Rails.application.routes.draw do
resources :accounts do
resources :holders
end
end
Run Code Online (Sandbox Code Playgroud)