Skip to content

Commit

Permalink
add rspec output
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbeales committed Mar 25, 2018
1 parent 98c6955 commit acc2abd
Show file tree
Hide file tree
Showing 30 changed files with 1,296 additions and 134 deletions.
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
--require spec_helper
--format Fuubar --format documentation --out ./spec/rspec.txt
--color
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ group :test do
gem 'coveralls', '~> 0.7.1', require: false # code coverage
gem 'database_cleaner', '=1.6.1', require: false # for test database cleaning
gem 'factory_bot', '~> 4.0', require: false # for test data setup
gem 'fuubar', '~> 2.3.1', require: false # rspec formatter
gem 'rack-test', '~> 0.8.3', require: false # for testing rake servers
gem 'rspec', '~> 3.7.0', require: false # for behavioral driven testing
gem 'rubocop', '~> 0.54.0', require: false # syntax checking
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ GEM
ffi (1.9.23-x64-mingw32)
formatador (0.2.5)
fspath (3.1.0)
fuubar (2.3.1)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
gh (0.15.1)
addressable (~> 2.4.0)
backports
Expand Down Expand Up @@ -231,6 +234,7 @@ DEPENDENCIES
dotenv (~> 2.2.1)
facets (~> 3.1.0)
factory_bot (~> 4.0)
fuubar (~> 2.3.1)
guard (~> 2.14.2)
guard-rspec (~> 4.7.3)
jsonb_accessor (~> 1.0.0)
Expand Down
15 changes: 15 additions & 0 deletions db/fixtures/LaunchRequest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "1.0",
"session": {
"new": true,
"sessionId": "amzn1.echo-api.session.abeee1a7-aee0-41e6-8192-e6faaed9f5ef",
"attributes": {},
"user": {
"userId": "amzn1.account.AM3B227HF3FAM1B261HK7FFM3A2"
}
},
"request": {
"type": "LaunchRequest",
"requestId": "amzn1.echo-api.request.9cdaa4db-f20e-4c58-8d01-c75322d6c423"
}
}
9 changes: 9 additions & 0 deletions spec/intents/launch_request_intent_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# frozen_string_literal: true

RSpec.describe 'Launch Intent', type: :request do
it 'accepts alexa launch request object' do
sample_request = JSON.parse(File.read('./db/fixtures/LaunchRequest.json'))
expect(sample_request['request']['type']).to eq('LaunchRequest')
end
end
62 changes: 44 additions & 18 deletions spec/models/arm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,34 @@
end

describe '#respond_to?' do
it { expect(subject.respond_to?(:name)).to be_truthy }
it { expect(subject.respond_to?(:number)).to be_truthy }
it { expect(subject.respond_to?(:schedule)).to be_truthy }
it { expect(subject.respond_to?(:study)).to be_truthy }
it { expect(subject.respond_to?(:study_events)).to be_truthy }
it { expect(subject.respond_to?(:created_at)).to be_truthy }
it { expect(subject.respond_to?(:updated_at)).to be_truthy }

it { expect(subject.respond_to?(:random_name)).not_to be_truthy }
context '#name' do
it { expect(subject.respond_to?(:name)).to be_truthy }
end
context '#number' do
it { expect(subject.respond_to?(:number)).to be_truthy }
end
context '#schedule' do
it { expect(subject.respond_to?(:schedule)).to be_truthy }
end
context '#study' do
it { expect(subject.respond_to?(:study)).to be_truthy }
end
context '#study_events' do
it { expect(subject.respond_to?(:study_events)).to be_truthy }
end
context '#created_at' do
it { expect(subject.respond_to?(:created_at)).to be_truthy }
end
context '#updated_at' do
it { expect(subject.respond_to?(:updated_at)).to be_truthy }
end
context '#not_an_attibute' do
it { expect(subject.respond_to?(:not_an_attibute)).not_to be_truthy }
end
end

describe '#name' do
it 'is set to arm1 if missing' do
it 'is set to "arm1" if missing' do
subject.name = nil
subject.valid?
expect(subject.name).to eq('arm ' + subject.number.to_s)
Expand All @@ -46,23 +61,30 @@
expect(subject.errors[:schedule].size).to eq(1)
end

context '#schedule missing' do
it 'is missing study' do
context 'missing schedule' do
it 'study is nil' do
subject.schedule = nil
expect(subject.study).to be_nil
end
end

context '#schedule#arms' do
context '#arms' do
it do
subject.schedule.arms.concat(subject)
expect(subject.schedule.arms.index(subject)).not_to be_nil
end

it do
subject.schedule.arms.concat(subject)
expect(subject.schedule.arms.size).to be > 0
end
end
end

describe '#study' do
it { expect(subject.schedule.study).to eq(subject.study) }
it 'equals test study' do
expect(subject.schedule.study).to eq(subject.study)
end
end

describe '#number' do
Expand All @@ -89,7 +111,7 @@
expect(subject.errors[:number].size).to eq(1)
end

it do
it 'must equal 10000' do
subject.number = 10_000
subject.valid?
expect(subject.errors[:number].size).to eq(0)
Expand Down Expand Up @@ -139,7 +161,7 @@
end

describe '#destroy!' do
it do
it 'also removes study_events' do
another_object = TestFactory.test_arm2
events = another_object.study_events
another_object.destroy!
Expand All @@ -148,12 +170,16 @@
end

describe '#to_s' do
it { expect(subject.to_s).to eq "#{subject.study} #{subject.schedule} #{subject.name} #{subject.number}" }
it 'prints study schedule name number' do
expect(subject.to_s).to eq "#{subject.study} #{subject.schedule} #{subject.name} #{subject.number}"
end
end

describe '#created_at today' do
# expect record to be created within the last 5 minutes to check timestamp works
it { expect(Time.now - subject.created_at).to be < 300 }
it 'is created less than 5 minutes ago' do
expect(Time.now - subject.created_at).to be < 300
end
end
end
end
21 changes: 15 additions & 6 deletions spec/models/assessment_instrument_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@
end

describe '#respond_to?' do
it { expect(subject.respond_to?(:assessment)).to be_truthy }
it { expect(subject.respond_to?(:instrument)).to be_truthy }
it { expect(subject.respond_to?(:created_at)).to be_truthy }
it { expect(subject.respond_to?(:updated_at)).to be_truthy }

it { expect(subject.respond_to?(:random_name)).not_to be_truthy }
context '#assessment' do
it { expect(subject.respond_to?(:assessment)).to be_truthy }
end
context '#instrument' do
it { expect(subject.respond_to?(:instrument)).to be_truthy }
end
context '#created_at' do
it { expect(subject.respond_to?(:created_at)).to be_truthy }
end
context '#updated_at' do
it { expect(subject.respond_to?(:updated_at)).to be_truthy }
end
context '#not_an_attibute' do
it { expect(subject.respond_to?(:not_an_attibute)).not_to be_truthy }
end
end

describe '#instrument' do
Expand Down
45 changes: 33 additions & 12 deletions spec/models/assessment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,39 @@
end

describe '#respond_to?' do
it { expect(subject.respond_to?(:visit)).to be_truthy }
it { expect(subject.respond_to?(:survey)).to be_truthy }
it { expect(subject.respond_to?(:user)).to be_truthy }
it { expect(subject.respond_to?(:order_number)).to be_truthy }
it { expect(subject.respond_to?(:assessment_instruments)).to be_truthy }
it { expect(subject.respond_to?(:instruments)).to be_truthy }
it { expect(subject.respond_to?(:responses)).to be_truthy }
it { expect(subject.respond_to?(:scores)).to be_truthy }
it { expect(subject.respond_to?(:created_at)).to be_truthy }
it { expect(subject.respond_to?(:updated_at)).to be_truthy }

it { expect(subject.respond_to?(:random_name)).not_to be_truthy }
context '#visit' do
it { expect(subject.respond_to?(:visit)).to be_truthy }
end
context '#survey' do
it { expect(subject.respond_to?(:survey)).to be_truthy }
end
context '#user' do
it { expect(subject.respond_to?(:user)).to be_truthy }
end
context '#order_number' do
it { expect(subject.respond_to?(:order_number)).to be_truthy }
end
context '#assessment_instruments' do
it { expect(subject.respond_to?(:assessment_instruments)).to be_truthy }
end
context '#instruments' do
it { expect(subject.respond_to?(:instruments)).to be_truthy }
end
context '#responses' do
it { expect(subject.respond_to?(:responses)).to be_truthy }
end
context '#scores' do
it { expect(subject.respond_to?(:scores)).to be_truthy }
end
context '#created_at' do
it { expect(subject.respond_to?(:created_at)).to be_truthy }
end
context '#updated_at' do
it { expect(subject.respond_to?(:updated_at)).to be_truthy }
end
context '#not_an_attibute' do
it { expect(subject.respond_to?(:not_an_attibute)).not_to be_truthy }
end
end

describe '#visit' do
Expand Down
13 changes: 9 additions & 4 deletions spec/models/choice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
it { expect(subject.respond_to?(:score)).to be_truthy }
it { expect(subject.respond_to?(:response_scale)).to be_truthy }
it { expect(subject.respond_to?(:responses)).to be_truthy }
it { expect(subject.respond_to?(:created_at)).to be_truthy }
it { expect(subject.respond_to?(:updated_at)).to be_truthy }

it { expect(subject.respond_to?(:random_name)).not_to be_truthy }
context '#created_at' do
it { expect(subject.respond_to?(:created_at)).to be_truthy }
end
context '#updated_at' do
it { expect(subject.respond_to?(:updated_at)).to be_truthy }
end
context '#not_an_attibute' do
it { expect(subject.respond_to?(:not_an_attibute)).not_to be_truthy }
end
end

describe '#response_scale' do
Expand Down
17 changes: 12 additions & 5 deletions spec/models/folder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
end

describe '#respond_to?' do
it { expect(subject.respond_to?(:name)).to be_truthy }
context '#name' do
it { expect(subject.respond_to?(:name)).to be_truthy }
end
it { expect(subject.respond_to?(:projects)).to be_truthy }
it { expect(subject.respond_to?(:created_at)).to be_truthy }
it { expect(subject.respond_to?(:updated_at)).to be_truthy }

it { expect(subject.respond_to?(:random_name)).not_to be_truthy }
context '#created_at' do
it { expect(subject.respond_to?(:created_at)).to be_truthy }
end
context '#updated_at' do
it { expect(subject.respond_to?(:updated_at)).to be_truthy }
end
context '#not_an_attibute' do
it { expect(subject.respond_to?(:not_an_attibute)).not_to be_truthy }
end
end

describe '#name' do
Expand Down
18 changes: 12 additions & 6 deletions spec/models/instrument_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
end

describe '#respond_to?' do
it { expect(subject.respond_to?(:name)).to be_truthy }
context '#name' do
it { expect(subject.respond_to?(:name)).to be_truthy }
end
it { expect(subject.respond_to?(:content)).to be_truthy }
it { expect(subject.respond_to?(:title)).to be_truthy }
it { expect(subject.respond_to?(:instructions)).to be_truthy }
Expand All @@ -22,11 +24,15 @@
it { expect(subject.respond_to?(:study_event_instruments)).to be_truthy }
it { expect(subject.respond_to?(:study_events)).to be_truthy }
it { expect(subject.respond_to?(:items)).to be_truthy }

it { expect(subject.respond_to?(:created_at)).to be_truthy }
it { expect(subject.respond_to?(:updated_at)).to be_truthy }

it { expect(subject.respond_to?(:random_name)).not_to be_truthy }
context '#created_at' do
it { expect(subject.respond_to?(:created_at)).to be_truthy }
end
context '#updated_at' do
it { expect(subject.respond_to?(:updated_at)).to be_truthy }
end
context '#not_an_attibute' do
it { expect(subject.respond_to?(:not_an_attibute)).not_to be_truthy }
end
end

describe '#name' do
Expand Down
17 changes: 12 additions & 5 deletions spec/models/item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@
end

describe '#respond_to?' do
it { expect(subject.respond_to?(:name)).to be_truthy }
context '#name' do
it { expect(subject.respond_to?(:name)).to be_truthy }
end
it { expect(subject.respond_to?(:choices)).to be_truthy }
it { expect(subject.respond_to?(:instrument)).to be_truthy }
it { expect(subject.respond_to?(:response_scale)).to be_truthy }
it { expect(subject.respond_to?(:created_at)).to be_truthy }
it { expect(subject.respond_to?(:updated_at)).to be_truthy }

it { expect(subject.respond_to?(:random_name)).not_to be_truthy }
context '#created_at' do
it { expect(subject.respond_to?(:created_at)).to be_truthy }
end
context '#updated_at' do
it { expect(subject.respond_to?(:updated_at)).to be_truthy }
end
context '#not_an_attibute' do
it { expect(subject.respond_to?(:not_an_attibute)).not_to be_truthy }
end
end

describe '#name' do
Expand Down
13 changes: 9 additions & 4 deletions spec/models/journal_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
it { expect(subject.respond_to?(:entry_date)).to be_truthy }
it { expect(subject.respond_to?(:entry)).to be_truthy }
it { expect(subject.respond_to?(:journal)).to be_truthy }
it { expect(subject.respond_to?(:created_at)).to be_truthy }
it { expect(subject.respond_to?(:updated_at)).to be_truthy }

it { expect(subject.respond_to?(:random_name)).not_to be_truthy }
context '#created_at' do
it { expect(subject.respond_to?(:created_at)).to be_truthy }
end
context '#updated_at' do
it { expect(subject.respond_to?(:updated_at)).to be_truthy }
end
context '#not_an_attibute' do
it { expect(subject.respond_to?(:not_an_attibute)).not_to be_truthy }
end
end

describe '#entry_date' do
Expand Down

0 comments on commit acc2abd

Please sign in to comment.