Skip to content

Commit

Permalink
Replace factory_girl to factory_bot
Browse files Browse the repository at this point in the history
  • Loading branch information
hirocaster committed Feb 25, 2018
1 parent ebb88f0 commit ff82c9b
Show file tree
Hide file tree
Showing 31 changed files with 111 additions and 111 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ end
group :test do
gem 'capybara'
gem 'coveralls', require: false
gem 'factory_girl_rails'
gem 'factory_bot_rails'
gem 'konacha'
gem 'launchy'
gem 'poltergeist'
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ GEM
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
execjs (2.7.0)
factory_girl (4.9.0)
factory_bot (4.8.2)
activesupport (>= 3.0.0)
factory_girl_rails (4.9.0)
factory_girl (~> 4.9.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
faraday (0.13.1)
multipart-post (>= 1.2, < 3)
Expand Down Expand Up @@ -309,7 +309,7 @@ DEPENDENCIES
capybara
coffee-rails (~> 4.1.0)
coveralls
factory_girl_rails
factory_bot_rails
feed_searcher (>= 0.0.6)
feedjira
haml
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/about_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe AboutController do
before do
@feed = FactoryGirl.create(:feed)
@feed = FactoryBot.create(:feed)
end

describe 'GET /' do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/api/config_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe Api::ConfigController do
let(:member) do
FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala', config_dump: { 'use_wait' => '0' })
FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala', config_dump: { 'use_wait' => '0' })
end

context 'logged in' do
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/api/feed_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

describe Api::FeedController do
before do
@member = FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala')
@feed = FactoryGirl.create(:feed, feedlink: "http://feeds.feedburner.com/mala/blog")
@subscription = FactoryGirl.create(:subscription, feed: @feed, member: @member)
@folder = FactoryGirl.create(:folder, member: @member)
@member = FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala')
@feed = FactoryBot.create(:feed, feedlink: "http://feeds.feedburner.com/mala/blog")
@subscription = FactoryBot.create(:subscription, feed: @feed, member: @member)
@folder = FactoryBot.create(:folder, member: @member)
end

describe 'POST /discover' do
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/api/folder_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

describe Api::FolderController do
before do
@member = FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala')
@folder = FactoryGirl.create(:folder)
@member = FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala')
@folder = FactoryBot.create(:folder)
end

describe 'POST /create' do
Expand Down
10 changes: 5 additions & 5 deletions spec/controllers/api/pin_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe Api::PinController do
before do
@member = FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala')
@member = FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala')
end

let(:error) do
Expand All @@ -12,13 +12,13 @@

describe 'POST /all' do
it 'renders json' do
3.times.each { FactoryGirl.create(:pin, member: @member) }
3.times.each { FactoryBot.create(:pin, member: @member) }
post :all, {}, { member_id: @member.id }
expect(response.body).to be_json
end

it 'renders purified link' do
FactoryGirl.create(:pin, member: @member, link: 'http://www.example.com/get?x=1&y=2')
FactoryBot.create(:pin, member: @member, link: 'http://www.example.com/get?x=1&y=2')
post :all, {}, { member_id: @member.id }
expect(JSON.parse(response.body).last['link']).to include('&amp;')
end
Expand Down Expand Up @@ -54,7 +54,7 @@
end
context "pin exists" do
let(:link) { 'http://la.ma.la/blog/diary_200810292006.htm' }
before { FactoryGirl.create(:pin, member: @member, link: link) }
before { FactoryBot.create(:pin, member: @member, link: link) }
it 'return success' do
post :remove, { link: link }, { member_id: @member.id }
expect(JSON.parse(response.body)).to include("isSuccess" => true)
Expand All @@ -63,7 +63,7 @@
end

describe 'POST /clear' do
before { FactoryGirl.create(:pin, member: @member) }
before { FactoryBot.create(:pin, member: @member) }
it 'renders json' do
post :clear, {}, { member_id: @member.id }
expect(response.body).to be_json
Expand Down
20 changes: 10 additions & 10 deletions spec/controllers/api_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

describe ApiController do
before do
@member = FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala')
@feed = FactoryGirl.create(:feed)
@item = FactoryGirl.create(:item, feed: @feed)
@subscription = FactoryGirl.create(:subscription, feed: @feed, member: @member)
@crawl_status = FactoryGirl.create(:crawl_status, feed: @feed)
@member = FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala')
@feed = FactoryBot.create(:feed)
@item = FactoryBot.create(:item, feed: @feed)
@subscription = FactoryBot.create(:subscription, feed: @feed, member: @member)
@crawl_status = FactoryBot.create(:crawl_status, feed: @feed)
end

describe 'GET /all' do
before {
@items = Array.new(3) { FactoryGirl.create(:item, feed: @feed) }
@items = Array.new(3) { FactoryBot.create(:item, feed: @feed) }
}
it 'renders json' do
get :all, { subscribe_id: @subscription.id }, { member_id: @member.id }
Expand All @@ -28,9 +28,9 @@
end

it 'renders purified link' do
feed = FactoryGirl.create :feed
item = FactoryGirl.create :item, feed: feed, link: 'http://www.example.com/get?x=1&y=2'
subscription = FactoryGirl.create :subscription, feed: feed, member: @member
feed = FactoryBot.create :feed
item = FactoryBot.create :item, feed: feed, link: 'http://www.example.com/get?x=1&y=2'
subscription = FactoryBot.create :subscription, feed: feed, member: @member
get :all, { subscribe_id: subscription.id }, { member_id: @member.id }
expect(JSON.parse(response.body)['items'].first['link']).to include('&amp;')
end
Expand Down Expand Up @@ -81,7 +81,7 @@

describe 'GET /subs' do
before {
@unread_subscription = FactoryGirl.create(:unread_subscription, member: @member)
@unread_subscription = FactoryBot.create(:unread_subscription, member: @member)
}
context 'default' do
it "has read and unread subscriptions" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe ApplicationController do
let(:member) { FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala') }
let(:member) { FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala') }

describe '#login_required' do
controller do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/favicon_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe FaviconController do
before do
@feed = FactoryGirl.create(:feed)
@feed = FactoryBot.create(:feed)
end

let(:image_header) {
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/import_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe ImportController do
before do
@member = FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala')
@member = FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala')
end

describe 'POST /import' do
Expand Down
14 changes: 7 additions & 7 deletions spec/controllers/rpc_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
require 'spec_helper'

describe RpcController do
let(:member) { FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala') }
let(:member) { FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala') }

before do
member.set_auth_key
allow_any_instance_of(Member).to receive(:subscribe_feed).and_return(FactoryGirl.create(:subscription))
allow_any_instance_of(Member).to receive(:subscribe_feed).and_return(FactoryBot.create(:subscription))
end

describe 'POST /update_feed' do
let(:params) { FactoryGirl.attributes_for(:item) }
let(:params) { FactoryBot.attributes_for(:item) }

it 'renders json' do
post :update_feed, { api_key: member.auth_key, json: params.to_json }
Expand All @@ -26,7 +26,7 @@
end

context 'Not Feed' do
let(:params){FactoryGirl.attributes_for(:item).slice(:link, :title, :body, :author, :category, :published_date).merge( feedtitle: 'malamalamala', api_key: member.auth_key, feedlink: 'http://ma.la')}
let(:params){FactoryBot.attributes_for(:item).slice(:link, :title, :body, :author, :category, :published_date).merge( feedtitle: 'malamalamala', api_key: member.auth_key, feedlink: 'http://ma.la')}
it 'creates new item' do
expect {
post :update_feed, { api_key: member.auth_key, json: params.to_json }
Expand All @@ -37,7 +37,7 @@
end

context 'JSON-RPC' do
let(:params) { FactoryGirl.attributes_for(:item).slice(:link, :title, :body, :author, :category, :published_date) }
let(:params) { FactoryBot.attributes_for(:item).slice(:link, :title, :body, :author, :category, :published_date) }
it 'creates new item' do
expect {
post :update_feed, { api_key: member.auth_key, json: params.to_json }
Expand All @@ -48,7 +48,7 @@
end

context 'Not-Feed ON JSON RPC' do
let(:params) { FactoryGirl.attributes_for(:item).slice(:link, :title, :body, :author, :category, :published_date).merge( feedtitle: 'malamalamala', feedlink: 'http://ma.la') }
let(:params) { FactoryBot.attributes_for(:item).slice(:link, :title, :body, :author, :category, :published_date).merge( feedtitle: 'malamalamala', feedlink: 'http://ma.la') }
it 'creates new item' do
expect {
post :update_feed, { api_key: member.auth_key, json: params.to_json }
Expand All @@ -59,7 +59,7 @@
end

context 'without guid' do
let(:params) { FactoryGirl.attributes_for(:item_without_guid) }
let(:params) { FactoryBot.attributes_for(:item_without_guid) }

it 'creates a new item with guid == link' do
expect {
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/sessions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe SessionsController do
let(:member) {
FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala')
FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala')
}

let(:valid_sessions) {
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/subscribe_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe SubscribeController do
before do
@member = FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala')
@member = FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala')
end

describe 'GET /confirm' do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/user_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe UserController do

let :member do
FactoryGirl.create(:member, username: 'bulkneets', password: 'mala', password_confirmation: 'mala')
FactoryBot.create(:member, username: 'bulkneets', password: 'mala', password_confirmation: 'mala')
end

let :rss_mime_type do
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/crawl_statuses.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :crawl_status do
end
end
8 changes: 4 additions & 4 deletions spec/factories/feeds.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# -*- coding: utf-8 -*-
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
sequence(:feed_feedlink_seq) {|n| "http://feeds.feedburner.com/mala/blog/?#{n}" }

factory :feed do
feedlink { FactoryGirl.generate(:feed_feedlink_seq) }
feedlink { FactoryBot.generate(:feed_feedlink_seq) }
link 'http://la.ma.la/blog/'
title '最速インターフェース研究会'
description 'はてな使ったら負けかなと思っている'
end

factory :crawl_ok_feed, parent: :feed do
crawl_status { FactoryGirl.create(:crawl_status, status: Fastladder::Crawler::CRAWL_OK) }
crawl_status { FactoryBot.create(:crawl_status, status: Fastladder::Crawler::CRAWL_OK) }
subscribers_count 1
end

Expand Down
4 changes: 2 additions & 2 deletions spec/factories/folders.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :folder do
name 'ライフハック'
end
Expand Down
8 changes: 4 additions & 4 deletions spec/factories/items.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
sequence(:item_link_seq) {|n| "http://la.ma.la/blog/diary_200810292006.htm?n=#{n}" }
sequence(:item_guid_seq) {|n| "guid#{n}" }

factory :item do
link { FactoryGirl.generate(:item_link_seq) }
link { FactoryBot.generate(:item_link_seq) }
title '最速インターフェース研究会 :: 近況'
body '観光目的で7ヶ月ほど京都旅行に行っていた。<br>祇園祭楽しかったですね。'
author 'mala'
Expand All @@ -15,7 +15,7 @@
enclosure_type nil
digest nil
version 1
guid { FactoryGirl.generate(:item_guid_seq) }
guid { FactoryBot.generate(:item_guid_seq) }
stored_on { Time.now }
modified_on { Time.now }
created_on { Time.now }
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/members.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :member do
username 'bulkneets'
email 'bulkneets@ma.la'
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/pins.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
sequence(:pin_link_seq) {|n| "http://la.ma.la/blog/diary_200810292006.htm?n=#{n}" }

factory :pin do
Expand Down
8 changes: 4 additions & 4 deletions spec/factories/subscriptions.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
# Read about factories at https://github.com/thoughtbot/factory_bot

FactoryGirl.define do
FactoryBot.define do
factory :subscription do
feed { FactoryGirl.create(:feed) }
feed { FactoryBot.create(:feed) }
end

factory :unread_subscription, parent: :subscription do
feed { FactoryGirl.create(:feed, items: [FactoryGirl.create(:item, stored_on: 1.hour.ago)]) }
feed { FactoryBot.create(:feed, items: [FactoryBot.create(:item, stored_on: 1.hour.ago)]) }
has_unread true
viewed_on { 2.hour.ago }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/account_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

feature 'Set auth key' do
let(:member) { FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala') }
let(:member) { FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala') }

before do
login_as(member)
Expand Down
2 changes: 1 addition & 1 deletion spec/features/signin_stories_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
subject { page }

let(:member) {
FactoryGirl.create(:member, password: 'mala', password_confirmation: 'mala')
FactoryBot.create(:member, password: 'mala', password_confirmation: 'mala')
}

context "when sign in as a member" do
Expand Down
Loading

0 comments on commit ff82c9b

Please sign in to comment.