Skip to content

Commit

Permalink
use factory girl
Browse files Browse the repository at this point in the history
  • Loading branch information
fionnbharra committed Mar 8, 2016
1 parent 32be450 commit c3bf7ac
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ group :development, :test do
gem 'database_cleaner'
gem 'rest-client'
gem 'rspec-rails'
gem "factory_girl_rails", "~> 4.0"
end

group :development do
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ GEM
rack (>= 1.3.0)
erubis (2.7.0)
execjs (2.6.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.6.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
font-awesome-rails (4.5.0.0)
railties (>= 3.2, < 5.0)
gherkin (2.12.2)
Expand Down Expand Up @@ -270,6 +275,7 @@ DEPENDENCIES
database_cleaner
dotenv-rails
dragonfly (~> 1.0.12)
factory_girl_rails (~> 4.0)
image_size
jbuilder (~> 2.0)
jquery-rails
Expand Down
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160304180012) do
ActiveRecord::Schema.define(version: 20160307143900) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -69,6 +69,7 @@
t.string "key"
t.boolean "dimensions_changed"
t.boolean "pass"
t.string "url"
end

add_index "tests", ["run_id"], name: "index_tests_on_run_id", using: :btree
Expand Down
22 changes: 22 additions & 0 deletions spec/factories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FactoryGirl.define do
factory :project do
name 'spec_project'
end

factory :suite do
name 'spec_suite'
project
end

factory :run do
suite
end

factory :test do
name 'rspec_test'
browser 'na'
platform 'na'
size '0'
run
end
end
15 changes: 4 additions & 11 deletions spec/models/test_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
require 'rails_helper'

RSpec.describe Test do
it 'flags if the tests has failed more than five consecutive times' do
project = Project.create!(name: 'spec_project')
suite = project.suites.create!(name: 'spec_suite')
run = suite.runs.create!
test_params = {
name: 'rspec_test',
browser: 'na',
platform: 'na',
size: '0'
}
5.times do
run.tests.create!(test_params)
FactoryGirl.create(:test)
end
test = run.tests.create!(test_params)
test = FactoryGirl.create(:test)
expect(test.five_consecutive_failures).to eq true
end
end
3 changes: 3 additions & 0 deletions spec/support/factory_girl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
end

0 comments on commit c3bf7ac

Please sign in to comment.