小编dro*_*lot的帖子

从javascript重定向turbolinks

是否可以制作window.location.replacewindow.location.href使用turbolinks,就像它是一个简单的链接?

javascript ruby-on-rails turbolinks

8
推荐指数
1
解决办法
6120
查看次数

获取所有嵌套的花括号

可以从字符串中获取嵌套花括号中的所有内容吗?例如:

敏捷的棕色狐狸跳过了懒狗

所以我需要:

  • 过了
  • 跳过{懒惰}

从大多数嵌套的顺序来看,这个顺序更好.

php regex preg-match-all preg-match

2
推荐指数
1
解决办法
2730
查看次数

RSpec,Factory Girl和Capybara:没有保存任何物品

我有RSpec可安装的Rails引擎:

RSpec.configure do |config|
  config.use_transactional_fixtures = false

  config.before(:suite) do
    DatabaseCleaner.clean_with(:truncation)
  end

  config.before(:each) do |example|
    DatabaseCleaner.strategy= example.metadata[:js] ? :truncation : :transaction
    DatabaseCleaner.start
  end

  config.after(:each) do
    DatabaseCleaner.clean
  end
end
Run Code Online (Sandbox Code Playgroud)

简单工厂:

FactoryGirl.define do
  factory :post, :class => MyEngine::Post do
    title 'title'
  end
end
Run Code Online (Sandbox Code Playgroud)

水豚特色:

require 'spec_helper'

describe 'Post', :type => :feature do
  let(:post) { FactoryGirl.create :post }

  it 'index action should have post' do
    visit posts_path
    expect(page).to have_text(post.title)
  end
end
Run Code Online (Sandbox Code Playgroud)

Post模型没有任何验证.

但是当我运行测试时,它表明没有创建帖子.

还有ActiveRecord日志:

INSERT INTO "my_engine_posts" ...
RELEASE SAVEPOINT active_record_1
rollback transaction
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails capybara database-cleaner factory-bot

1
推荐指数
1
解决办法
355
查看次数