Permalink
Browse files

new rspec syntax

  • Loading branch information...
1 parent 49eccfb commit 81959e2622fcb9448bbd24d0765c11c59caf4dd5 @flyerhzm committed Jan 23, 2014
@@ -5,8 +5,8 @@
context "cell rendering" do
context "rendering tabs" do
- let(:repository) { FactoryGirl.create(:repository) }
- let(:build) { FactoryGirl.create(:build, :repository => repository) }
+ let(:repository) { create(:repository) }
+ let(:build) { create(:build, :repository => repository) }
context "current" do
subject { render_cell(:build, :tabs, "current", repository) }
@@ -31,7 +31,7 @@
end
context "rendering history_links" do
- let(:repository) { FactoryGirl.create(:repository) }
+ let(:repository) { create(:repository) }
context "last 10" do
subject { render_cell(:build, :history_links, repository, 10) }
@@ -53,8 +53,8 @@
end
context "rendering content" do
- let(:repository) { FactoryGirl.create(:repository) }
- let(:build) { FactoryGirl.create(:build, :repository => repository, :warning_count => 10).tap { |build| build.run!; build.complete! } }
+ let(:repository) { create(:repository) }
+ let(:build) { create(:build, :repository => repository, :warning_count => 10).tap { |build| build.run!; build.complete! } }
before do
File.stubs(:read).returns("")
end
@@ -15,8 +15,8 @@
end
context "rendering display with current_user" do
- let(:user) { FactoryGirl.create(:user) }
- let(:repository) { FactoryGirl.create(:repository) }
+ let(:user) { create(:user) }
+ let(:repository) { create(:repository) }
subject { render_cell(:header, :display, user, repository) }
it { should have_link("Home") }
@@ -5,15 +5,15 @@
before { skip_repository_callbacks }
context "rendering tabs" do
- subject { render_cell(:repository, :tabs, "configs", FactoryGirl.create(:repository)) }
+ subject { render_cell(:repository, :tabs, "configs", create(:repository)) }
it { should have_link("Overview") }
it { should have_css("li.active a", :text => "Configurations") }
it { should have_link("Collaborators") }
end
context "rendering configurations_form" do
- let(:repository) { FactoryGirl.create(:repository) }
+ let(:repository) { create(:repository) }
before do
repository.expects(:config_file_path).returns("/tmp")
YAML.expects(:load_file).with("/tmp")
@@ -25,9 +25,9 @@
context "renderding public" do
before do
- public_repository = FactoryGirl.create(:repository, name: "public", visible: true)
- private_repository = FactoryGirl.create(:repository, name: "private", visible: false)
- last_build = FactoryGirl.create(:build, repository: public_repository, duration: 20)
+ public_repository = create(:repository, name: "public", visible: true)
+ private_repository = create(:repository, name: "private", visible: false)
+ last_build = create(:build, repository: public_repository, duration: 20)
last_build.update_attribute(:position, 5)
end
subject { render_cell(:repository, :public) }
@@ -3,12 +3,12 @@
describe BuildsController do
before do
skip_repository_callbacks
- @user = FactoryGirl.create(:user)
- @repository = FactoryGirl.create(:repository)
+ @user = create(:user)
+ @repository = create(:repository)
@repository.users << @user
end
- let(:build) { FactoryGirl.create(:build, repository: @repository) }
+ let(:build) { create(:build, repository: @repository) }
context "GET :index" do
context "without position" do
@@ -3,16 +3,16 @@
describe CollaboratorsController do
before do
skip_repository_callbacks
- @repository = FactoryGirl.create(:repository)
+ @repository = create(:repository)
- user = FactoryGirl.create(:user)
+ user = create(:user)
sign_in user
end
context "GET :index" do
it "should list all collaborators" do
- collaborator1 = FactoryGirl.create(:user)
- collaborator2 = FactoryGirl.create(:user)
+ collaborator1 = create(:user)
+ collaborator2 = create(:user)
@repository.users << collaborator1
@repository.users << collaborator2
@@ -10,7 +10,7 @@
end
it "should assign contact with current_user" do
- user = FactoryGirl.create(:user)
+ user = create(:user)
sign_in user
get :new
@@ -4,7 +4,7 @@
describe "GET 'index'" do
it "returns http success" do
- user = FactoryGirl.create(:user)
+ user = create(:user)
sign_in user
get 'index'
response.should be_success
@@ -5,10 +5,10 @@
context "GET :show" do
it "should assign repository" do
- user = FactoryGirl.create(:user)
- repository = FactoryGirl.create(:repository)
+ user = create(:user)
+ repository = create(:repository)
user.repositories << repository
- build = FactoryGirl.create(:build, :repository => repository)
+ build = create(:build, :repository => repository)
sign_in user
get :show, id: repository.id
response.should be_ok
@@ -18,15 +18,15 @@
context "GET :new" do
it "should assign repository" do
- user = FactoryGirl.create(:user, nickname: "flyerhzm")
+ user = create(:user, nickname: "flyerhzm")
sign_in user
get :new
response.should be_ok
assigns(:repository).should_not be_nil
end
it "should redirect to user/edit page if current_user didn't input email" do
- user = FactoryGirl.create(:user, nickname: "flyerhzm", email: "flyerhzm@fakemail.com")
+ user = create(:user, nickname: "flyerhzm", email: "flyerhzm@fakemail.com")
sign_in user
get :new
response.should redirect_to(edit_user_registration_path)
@@ -35,7 +35,7 @@
context "POST :create" do
before do
- user = FactoryGirl.create(:user, nickname: "flyerhzm")
+ user = create(:user, nickname: "flyerhzm")
sign_in user
end
@@ -52,7 +52,7 @@
end
it "should redirect to user/edit page if current_user didn't input email" do
- user = FactoryGirl.create(:user, nickname: "flyerhzm", email: "flyerhzm@fakemail.com")
+ user = create(:user, nickname: "flyerhzm", email: "flyerhzm@fakemail.com")
sign_in user
post :create, repository: {github_name: "flyerhzm/railsbp.com"}
response.should redirect_to(edit_user_registration_path)
@@ -75,7 +75,7 @@
}
it "should generate build" do
- repository = FactoryGirl.build(:repository, html_url: "https://github.com/railsbp/rails-bestpractices.com", authentication_token: "123456789")
+ repository = build(:repository, html_url: "https://github.com/railsbp/rails-bestpractices.com", authentication_token: "123456789")
Repository.expects(:where).with(html_url: "https://github.com/railsbp/rails-bestpractices.com").returns([repository])
repository.expects(:generate_build).with("develop", last_message)
post :sync, token: "123456789", payload: hook_json, format: 'json'
@@ -84,7 +84,7 @@
end
it "should not generate build if authentication_token does not match" do
- repository = FactoryGirl.build(:repository, html_url: "https://github.com/railsbp/rails-bestpractices.com", authentication_token: "987654321")
+ repository = build(:repository, html_url: "https://github.com/railsbp/rails-bestpractices.com", authentication_token: "987654321")
Repository.expects(:where).with(html_url: "https://github.com/railsbp/rails-bestpractices.com").returns([repository])
post :sync, token: "123456789", payload: hook_json, format: 'json'
response.should be_ok
@@ -98,7 +98,7 @@
end
it "should not generate build and notify privacy if repository is private" do
- repository = FactoryGirl.build(:repository, private: true, html_url: "https://github.com/railsbp/rails-bestpractices.com", authentication_token: "123456789")
+ repository = build(:repository, private: true, html_url: "https://github.com/railsbp/rails-bestpractices.com", authentication_token: "123456789")
Repository.expects(:where).with(html_url: "https://github.com/railsbp/rails-bestpractices.com").returns([repository])
repository.expects(:notify_privacy)
post :sync, token: "123456789", payload: hook_json, format: 'json'
@@ -107,7 +107,7 @@
end
it "should not generate build if repository is not rails" do
- repository = FactoryGirl.build(:repository, rails: false, html_url: "https://github.com/railsbp/rails-bestpractices.com", authentication_token: "123456789")
+ repository = build(:repository, rails: false, html_url: "https://github.com/railsbp/rails-bestpractices.com", authentication_token: "123456789")
Repository.expects(:where).with(html_url: "https://github.com/railsbp/rails-bestpractices.com").returns([repository])
post :sync, token: "123456789", payload: hook_json, format: 'json'
response.should be_ok
@@ -5,12 +5,12 @@
context "#notify_build_success" do
before do
- @user1 = FactoryGirl.create(:user, email: "user1@gmail.com")
- @user2 = FactoryGirl.create(:user, email: "user2@gmail.com")
- @repository = FactoryGirl.create(:repository, github_name: "flyerhzm/test")
+ @user1 = create(:user, email: "user1@gmail.com")
+ @user2 = create(:user, email: "user2@gmail.com")
+ @repository = create(:repository, github_name: "flyerhzm/test")
@repository.users << @user1
@repository.users << @user2
- @build = FactoryGirl.create(:build, repository: @repository, warning_count: 10, last_commit_id: "123456789", branch: "develop", last_commit_message: "hello", duration: 20)
+ @build = create(:build, repository: @repository, warning_count: 10, last_commit_id: "123456789", branch: "develop", last_commit_message: "hello", duration: 20)
end
subject { UserMailer.notify_build_success(@build) }
@@ -27,12 +27,12 @@
context "#notify_configuration_created" do
before do
- @user1 = FactoryGirl.create(:user, email: "user1@gmail.com")
- @user2 = FactoryGirl.create(:user, email: "user2@gmail.com")
- @repository = FactoryGirl.create(:repository, github_name: "flyerhzm/test")
+ @user1 = create(:user, email: "user1@gmail.com")
+ @user2 = create(:user, email: "user2@gmail.com")
+ @repository = create(:repository, github_name: "flyerhzm/test")
@repository.users << @user1
@repository.users << @user2
- @configuration = FactoryGirl.create(:configuration, name: "Fat Model", url: "http://rails-bestpracitces.com")
+ @configuration = create(:configuration, name: "Fat Model", url: "http://rails-bestpracitces.com")
end
subject { UserMailer.notify_configuration_created(@configuration, @repository) }
@@ -45,9 +45,9 @@
context "#notify_repository_privacy" do
before do
- @user1 = FactoryGirl.create(:user, email: "user1@gmail.com")
- @user2 = FactoryGirl.create(:user, email: "user2@gmail.com")
- @repository = FactoryGirl.create(:repository, github_name: "flyerhzm/test")
+ @user1 = create(:user, email: "user1@gmail.com")
+ @user2 = create(:user, email: "user2@gmail.com")
+ @repository = create(:repository, github_name: "flyerhzm/test")
@repository.users << @user1
@repository.users << @user2
end
@@ -5,9 +5,9 @@
context "new user" do
before do
- User.current = FactoryGirl.create(:user)
- @visible_repository = FactoryGirl.create(:repository, visible: true)
- @private_repository = FactoryGirl.create(:repository, visible: false)
+ User.current = create(:user)
+ @visible_repository = create(:repository, visible: true)
+ @private_repository = create(:repository, visible: false)
@ability = Ability.new(nil)
end
@@ -22,11 +22,11 @@
context "user" do
before do
- @user = FactoryGirl.create(:user)
- @user_repository = FactoryGirl.create(:repository, visible: false)
- @other_repository = FactoryGirl.create(:repository, visible: false)
+ @user = create(:user)
+ @user_repository = create(:repository, visible: false)
+ @other_repository = create(:repository, visible: false)
@user.repositories << @user_repository
- @own_repository = FactoryGirl.create(:repository, visible: false)
+ @own_repository = create(:repository, visible: false)
@user.own_repositories << @own_repository
@ability = Ability.new(@user)
end
View
@@ -6,42 +6,42 @@
before { skip_repository_callbacks }
context "#short_commit_id" do
- subject { FactoryGirl.create(:build, :last_commit_id => "1234567890") }
+ subject { create(:build, :last_commit_id => "1234567890") }
its(:short_commit_id) { should == "1234567" }
end
context "#analyze_path" do
before do
- @repository = FactoryGirl.create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
+ @repository = create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
end
subject { @build = @repository.builds.create(last_commit_id: "987654321") }
its(:analyze_path) { should == Rails.root.join("builds/flyerhzm/railsbp.com/commit/987654321").to_s }
end
context "#html_output_file" do
before do
- @repository = FactoryGirl.create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
+ @repository = create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
end
subject { @build = @repository.builds.create(last_commit_id: "987654321") }
its(:html_output_file) { should == Rails.root.join("builds/flyerhzm/railsbp.com/commit/987654321/rbp.html").to_s }
end
context "#yaml_output_file" do
before do
- @repository = FactoryGirl.create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
+ @repository = create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
end
subject { @build = @repository.builds.create(last_commit_id: "987654321") }
its(:yaml_output_file) { should == Rails.root.join("builds/flyerhzm/railsbp.com/commit/987654321/rbp.yml").to_s }
end
context "#template_file" do
- subject { @build = FactoryGirl.create(:build) }
+ subject { @build = create(:build) }
its(:template_file) { should == Rails.root.join("app/views/builds/rbp.html.erb").to_s }
end
context "#run!" do
before do
- repository = FactoryGirl.create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
+ repository = create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
@build = repository.builds.create(last_commit_id: "987654321")
@build.run!
end
@@ -63,7 +63,7 @@
context "#rerun!" do
before do
- repository = FactoryGirl.create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
+ repository = create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
@build = repository.builds.create(last_commit_id: "987654321")
@build.aasm_state = "failed"
@build.save
@@ -80,7 +80,7 @@
context "config_directory_path" do
before do
- @repository = FactoryGirl.create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
+ @repository = create(:repository, github_name: "flyerhzm/railsbp.com", name: "railsbp.com", git_url: "git://github.com/flyerhzm/railsbp.com.git")
end
subject { @build = @repository.builds.create(last_commit_id: "987654321") }
its(:config_directory_path) { should == Rails.root.join("builds/flyerhzm/railsbp.com/commit/987654321/railsbp.com/config/").to_s }
@@ -7,12 +7,12 @@
context "#notify_collaborators" do
before do
skip_repository_callbacks
- @repository1 = FactoryGirl.create(:repository)
- @repository2 = FactoryGirl.create(:repository)
+ @repository1 = create(:repository)
+ @repository2 = create(:repository)
end
it "should notify all collaborators" do
- @configuration = FactoryGirl.create(:configuration)
+ @configuration = create(:configuration)
UserMailer.expects(:notify_configuration_created).with(@configuration, @repository1)
UserMailer.expects(:notify_configuration_created).with(@configuration, @repository2)
Delayed::Worker.new.work_off
Oops, something went wrong.

0 comments on commit 81959e2

Please sign in to comment.