Skip to content

Commit aa10cbd

Browse files
committed
Added first feature specs
1 parent 824c3a0 commit aa10cbd

9 files changed

Lines changed: 80 additions & 4 deletions

File tree

evaluationserver/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ group :development, :test do
6464
gem 'faker'
6565
gem 'database_cleaner'
6666
gem "i18n-tasks"
67+
gem 'capybara'
6768
gem 'simplecov', require: false
6869
gem 'brakeman', require: false
6970
end

evaluationserver/Gemfile.lock

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ GEM
4040
tzinfo (~> 1.1)
4141
acts_as_list (0.9.10)
4242
activerecord (>= 3.0)
43+
addressable (2.5.2)
44+
public_suffix (>= 2.0.2, < 4.0)
4345
arel (8.0.0)
4446
ast (2.4.0)
4547
bootstrap-multiselect-rails4 (0.0.1)
@@ -48,6 +50,13 @@ GEM
4850
sass (~> 3.2)
4951
brakeman (4.1.1)
5052
builder (3.2.3)
53+
capybara (2.18.0)
54+
addressable
55+
mini_mime (>= 0.1.3)
56+
nokogiri (>= 1.3.3)
57+
rack (>= 1.0.0)
58+
rack-test (>= 0.5.4)
59+
xpath (>= 2.0, < 4.0)
5160
climate_control (0.2.0)
5261
cocaine (0.5.8)
5362
climate_control (>= 0.0.3, < 1.0)
@@ -138,6 +147,7 @@ GEM
138147
mimemagic (= 0.3.0)
139148
parser (2.5.0.5)
140149
ast (~> 2.4.0)
150+
public_suffix (3.0.2)
141151
puma (3.11.0)
142152
rack (2.0.3)
143153
rack-test (0.8.2)
@@ -242,6 +252,8 @@ GEM
242252
websocket-driver (0.6.5)
243253
websocket-extensions (>= 0.1.0)
244254
websocket-extensions (0.1.3)
255+
xpath (3.0.0)
256+
nokogiri (~> 1.8)
245257

246258
PLATFORMS
247259
ruby
@@ -252,6 +264,7 @@ DEPENDENCIES
252264
bootstrap-multiselect-rails4
253265
bootstrap-sass (~> 3.2.0)
254266
brakeman
267+
capybara
255268
cocoon
256269
database_cleaner
257270
factory_bot
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rails_helper'
2+
3+
RSpec.feature "analyze experiment", type: :feature do
4+
pending "add some scenarios (or delete) #{__FILE__}"
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rails_helper'
2+
3+
RSpec.feature "conduct experiment", type: :feature do
4+
pending "add some scenarios (or delete) #{__FILE__}"
5+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require 'rails_helper'
2+
3+
RSpec.feature "create experiment", type: :feature do
4+
scenario "without authorization" do
5+
visit new_experiment_path
6+
expect(page).not_to have_content(t('experiments.new'))
7+
end
8+
9+
scenario "with authorization" do
10+
authenticate_as_admin
11+
visit new_experiment_path
12+
expect(page).to have_content(t('experiments.new'))
13+
title = Faker::Name.last_name
14+
description = Faker::TheFreshPrinceOfBelAir.quote
15+
fill_in 'experiment_title', with: title
16+
fill_in 'experiment_description', with: description
17+
find('input[name="commit"]').click
18+
expect(Experiment.last.title).to eq(title)
19+
expect(Experiment.last.description).to eq(description)
20+
end
21+
22+
23+
24+
end

evaluationserver/spec/rails_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
# require only the support files necessary.
2222
#
2323
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
24-
24+
require 'capybara/rails'
25+
require 'capybara/rspec'
2526
# Checks for pending migrations and applies them before tests are run.
2627
# If you are not using ActiveRecord, you can remove this line.
2728
ActiveRecord::Migration.maintain_test_schema!

evaluationserver/spec/requests/create_experiments_spec.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
require 'rails_helper'
22

3-
RSpec.describe "CreateExperiments", type: :request do
4-
describe "GET /create_experiments" do
3+
RSpec.describe "Experiments", type: :request do
4+
describe "GET /experiments" do
55
it "works! (now write some real specs)" do
6-
get create_experiments_path
6+
get experiments_path
7+
expect(response).to have_http_status(200)
8+
end
9+
end
10+
11+
describe "GET /experiment/:id" do
12+
it "works! (now write some real specs)" do
13+
get experiments_path
714
expect(response).to have_http_status(200)
815
end
916
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Dir[Rails.root.join('spec/support/features/**/*.rb')].each { |f| require f }
2+
RSpec.configure do |config|
3+
config.include Features::SessionHelpers, type: :feature
4+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module Features
2+
module SessionHelpers
3+
def authenticate_as_admin
4+
admin_user = "admin"
5+
page.driver.browser.authorize(admin_user,ENV['ADMIN_PASSWORD'])
6+
end
7+
8+
9+
def t(*args)
10+
I18n.translate!(*args)
11+
end
12+
13+
14+
15+
end
16+
end

0 commit comments

Comments
 (0)