Started controller tests
This commit is contained in:
parent
9aa361eb33
commit
a9e89d00ef
23 changed files with 599 additions and 15 deletions
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
262
.idea/workspace.xml
generated
262
.idea/workspace.xml
generated
|
|
@ -1,7 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="42443dfa-4405-4cad-b0d1-6c57eb86e644" name="Default" comment="" />
|
||||
<list default="true" id="42443dfa-4405-4cad-b0d1-6c57eb86e644" name="Default" comment="">
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" />
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/.rspec" />
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/app/models/item.rb" />
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/app/models/todo.rb" />
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/db/migrate/20180216101219_create_todos.rb" />
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/db/migrate/20180216101247_create_items.rb" />
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/spec/models/item_spec.rb" />
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/spec/models/todo_spec.rb" />
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/spec/rails_helper.rb" />
|
||||
<change beforePath="" afterPath="$PROJECT_DIR$/spec/spec_helper.rb" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
<change beforePath="$PROJECT_DIR$/Gemfile" afterPath="$PROJECT_DIR$/Gemfile" />
|
||||
<change beforePath="$PROJECT_DIR$/Gemfile.lock" afterPath="$PROJECT_DIR$/Gemfile.lock" />
|
||||
<change beforePath="$PROJECT_DIR$/config/database.yml" afterPath="$PROJECT_DIR$/config/database.yml" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.bundle/" />
|
||||
<ignored path="$PROJECT_DIR$/components/" />
|
||||
<ignored path="$PROJECT_DIR$/public/system/" />
|
||||
|
|
@ -15,9 +30,68 @@
|
|||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="items_controller.rb" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/app/controllers/items_controller.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="todos.rb" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/spec/factories/todos.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="108">
|
||||
<caret line="6" column="3" lean-forward="false" selection-start-line="6" selection-start-column="3" selection-end-line="6" selection-end-column="3" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="items.rb" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/spec/factories/items.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="126">
|
||||
<caret line="7" column="3" lean-forward="false" selection-start-line="7" selection-start-column="3" selection-end-line="7" selection-end-column="3" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="todos_controller.rb" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/app/controllers/todos_controller.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/spec/rails_helper.rb" />
|
||||
<option value="$PROJECT_DIR$/Gemfile" />
|
||||
<option value="$PROJECT_DIR$/spec/models/todo_spec.rb" />
|
||||
<option value="$PROJECT_DIR$/spec/models/item_spec.rb" />
|
||||
<option value="$PROJECT_DIR$/config/database.yml" />
|
||||
<option value="$PROJECT_DIR$/app/models/item.rb" />
|
||||
<option value="$PROJECT_DIR$/app/models/todo.rb" />
|
||||
<option value="$PROJECT_DIR$/spec/factories/todos.rb" />
|
||||
<option value="$PROJECT_DIR$/spec/factories/items.rb" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsGulpfileManager">
|
||||
|
|
@ -25,10 +99,9 @@
|
|||
<sorting>DEFINITION_ORDER</sorting>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="x" value="260" />
|
||||
<option name="y" value="48" />
|
||||
<option name="width" value="1400" />
|
||||
<option name="height" value="986" />
|
||||
<option name="y" value="28" />
|
||||
<option name="width" value="1920" />
|
||||
<option name="height" value="1026" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||
|
|
@ -55,6 +128,40 @@
|
|||
<item name="vereto-api" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="vereto-api" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="vereto-api" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="vereto-api" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="app" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="vereto-api" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="vereto-api" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="app" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="controllers" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="vereto-api" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="vereto-api" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="app" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="models" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="vereto-api" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="vereto-api" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="spec" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="vereto-api" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="vereto-api" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="spec" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="factories" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="vereto-api" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="vereto-api" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="spec" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="models" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
|
|
@ -195,15 +302,16 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1518771982661</updated>
|
||||
<workItem from="1518771986536" duration="30000" />
|
||||
<workItem from="1518772064427" duration="242000" />
|
||||
<workItem from="1518772064427" duration="6225000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="272000" />
|
||||
<option name="totallyTimeSpent" value="6255000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="28" width="1920" height="1026" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.18643162" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
|
|
@ -212,7 +320,7 @@
|
|||
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.33799785" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.33799785" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
|
|
@ -235,4 +343,142 @@
|
|||
<breakpoint-manager />
|
||||
<watches-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/app/channels/application_cable/connection.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/controllers/application_controller.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/channels/application_cable/channel.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/spec/rails_helper.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="275">
|
||||
<caret line="57" column="52" lean-forward="true" selection-start-line="57" selection-start-column="52" selection-end-line="57" selection-end-column="52" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Gemfile">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="198">
|
||||
<caret line="11" column="25" lean-forward="false" selection-start-line="11" selection-start-column="25" selection-end-line="11" selection-end-column="25" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/spec/models/todo_spec.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="180">
|
||||
<caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/spec/models/item_spec.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="180">
|
||||
<caret line="10" column="0" lean-forward="false" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/models/item.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="54">
|
||||
<caret line="3" column="29" lean-forward="false" selection-start-line="3" selection-start-column="29" selection-end-line="3" selection-end-column="29" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/models/todo.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="90">
|
||||
<caret line="5" column="0" lean-forward="true" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/config/database.yml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="365">
|
||||
<caret line="25" column="26" lean-forward="false" selection-start-line="25" selection-start-column="26" selection-end-line="25" selection-end-column="26" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/db/migrate/20180216101247_create_items.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/db/migrate/20180216101219_create_todos.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.gitignore">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="360">
|
||||
<caret line="20" column="0" lean-forward="false" selection-start-line="20" selection-start-column="0" selection-end-line="20" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/controllers/todos_controller.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/app/controllers/items_controller.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/spec/factories/todos.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="108">
|
||||
<caret line="6" column="3" lean-forward="false" selection-start-line="6" selection-start-column="3" selection-end-line="6" selection-end-column="3" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/spec/factories/items.rb">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="126">
|
||||
<caret line="7" column="3" lean-forward="false" selection-start-line="7" selection-start-column="3" selection-end-line="7" selection-end-column="3" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
||||
1
.rspec
Normal file
1
.rspec
Normal file
|
|
@ -0,0 +1 @@
|
|||
--require spec_helper
|
||||
10
Gemfile
10
Gemfile
|
|
@ -9,7 +9,7 @@ end
|
|||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails', '~> 5.1.5'
|
||||
# Use sqlite3 as the database for Active Record
|
||||
gem 'sqlite3'
|
||||
gem 'mysql2', '>= 0.4.10'
|
||||
# Use Puma as the app server
|
||||
gem 'puma', '~> 3.7'
|
||||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
||||
|
|
@ -27,9 +27,17 @@ gem 'puma', '~> 3.7'
|
|||
|
||||
group :development, :test do
|
||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||
gem 'rspec-rails', '~> 3.5'
|
||||
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
||||
end
|
||||
|
||||
group :test do
|
||||
gem 'factory_girl_rails', '~> 4.0'
|
||||
gem 'shoulda-matchers', '~> 3.1'
|
||||
gem 'faker'
|
||||
gem 'database_cleaner'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'listen', '>= 3.0.5', '< 3.2'
|
||||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
||||
|
|
|
|||
37
Gemfile.lock
37
Gemfile.lock
|
|
@ -43,7 +43,16 @@ GEM
|
|||
byebug (10.0.0)
|
||||
concurrent-ruby (1.0.5)
|
||||
crass (1.0.3)
|
||||
database_cleaner (1.6.2)
|
||||
diff-lcs (1.3)
|
||||
erubi (1.7.0)
|
||||
factory_girl (4.9.0)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (4.9.0)
|
||||
factory_girl (~> 4.9.0)
|
||||
railties (>= 3.0.0)
|
||||
faker (1.8.7)
|
||||
i18n (>= 0.7)
|
||||
ffi (1.9.21)
|
||||
globalid (0.4.1)
|
||||
activesupport (>= 4.2.0)
|
||||
|
|
@ -62,6 +71,7 @@ GEM
|
|||
mini_mime (1.0.0)
|
||||
mini_portile2 (2.3.0)
|
||||
minitest (5.11.3)
|
||||
mysql2 (0.4.10)
|
||||
nio4r (2.2.0)
|
||||
nokogiri (1.8.2)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
|
|
@ -96,7 +106,26 @@ GEM
|
|||
rb-fsevent (0.10.2)
|
||||
rb-inotify (0.9.10)
|
||||
ffi (>= 0.5.0, < 2)
|
||||
rspec-core (3.7.1)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-expectations (3.7.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-mocks (3.7.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-rails (3.7.2)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec-core (~> 3.7.0)
|
||||
rspec-expectations (~> 3.7.0)
|
||||
rspec-mocks (~> 3.7.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-support (3.7.1)
|
||||
ruby_dep (1.5.0)
|
||||
shoulda-matchers (3.1.2)
|
||||
activesupport (>= 4.0.0)
|
||||
spring (2.0.2)
|
||||
activesupport (>= 4.2)
|
||||
spring-watcher-listen (2.0.1)
|
||||
|
|
@ -109,7 +138,6 @@ GEM
|
|||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
thor (0.20.0)
|
||||
thread_safe (0.3.6)
|
||||
tzinfo (1.2.5)
|
||||
|
|
@ -123,12 +151,17 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
byebug
|
||||
database_cleaner
|
||||
factory_girl_rails (~> 4.0)
|
||||
faker
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
mysql2 (>= 0.4.10)
|
||||
puma (~> 3.7)
|
||||
rails (~> 5.1.5)
|
||||
rspec-rails (~> 3.5)
|
||||
shoulda-matchers (~> 3.1)
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
sqlite3
|
||||
tzinfo-data
|
||||
|
||||
BUNDLED WITH
|
||||
|
|
|
|||
2
app/controllers/items_controller.rb
Normal file
2
app/controllers/items_controller.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
class ItemsController < ApplicationController
|
||||
end
|
||||
2
app/controllers/todos_controller.rb
Normal file
2
app/controllers/todos_controller.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
class TodosController < ApplicationController
|
||||
end
|
||||
5
app/models/item.rb
Normal file
5
app/models/item.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class Item < ApplicationRecord
|
||||
belongs_to :todo
|
||||
|
||||
validates_presence_of :name
|
||||
end
|
||||
5
app/models/todo.rb
Normal file
5
app/models/todo.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class Todo < ApplicationRecord
|
||||
has_many :items, dependent: :destroy
|
||||
|
||||
validates_presence_of :title, :created_by
|
||||
end
|
||||
|
|
@ -5,21 +5,26 @@
|
|||
# gem 'sqlite3'
|
||||
#
|
||||
default: &default
|
||||
adapter: sqlite3
|
||||
adapter: mysql2
|
||||
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
||||
timeout: 5000
|
||||
host: localhost
|
||||
username: root
|
||||
password: SuperSecret
|
||||
socket: /var/run/mysqld/mysqld.sock
|
||||
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
database: db/development.sqlite3
|
||||
database: vereto-api-dev
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
<<: *default
|
||||
database: db/test.sqlite3
|
||||
database: vereto-api-dev
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
database: db/production.sqlite3
|
||||
database: vereto-api-prod
|
||||
|
|
|
|||
10
db/migrate/20180216101219_create_todos.rb
Normal file
10
db/migrate/20180216101219_create_todos.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
class CreateTodos < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :todos do |t|
|
||||
t.string :title
|
||||
t.string :created_by
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
11
db/migrate/20180216101247_create_items.rb
Normal file
11
db/migrate/20180216101247_create_items.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
class CreateItems < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :items do |t|
|
||||
t.string :name
|
||||
t.boolean :done
|
||||
t.references :todo, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
32
db/schema.rb
Normal file
32
db/schema.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20180216101247) do
|
||||
|
||||
create_table "items", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.string "name"
|
||||
t.boolean "done"
|
||||
t.bigint "todo_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["todo_id"], name: "index_items_on_todo_id"
|
||||
end
|
||||
|
||||
create_table "todos", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||
t.string "title"
|
||||
t.string "created_by"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_foreign_key "items", "todos"
|
||||
end
|
||||
5
spec/controllers/items_controller_spec.rb
Normal file
5
spec/controllers/items_controller_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ItemsController, type: :controller do
|
||||
|
||||
end
|
||||
5
spec/controllers/todos_controller_spec.rb
Normal file
5
spec/controllers/todos_controller_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe TodosController, type: :controller do
|
||||
|
||||
end
|
||||
8
spec/factories/items.rb
Normal file
8
spec/factories/items.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# spec/factories/items.rb
|
||||
FactoryGirl.define do
|
||||
factory :item do
|
||||
name { Faker::StarWars.character }
|
||||
done false
|
||||
todo_id nil
|
||||
end
|
||||
end
|
||||
7
spec/factories/todos.rb
Normal file
7
spec/factories/todos.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# spec/factories/todos.rb
|
||||
FactoryGirl.define do
|
||||
factory :todo do
|
||||
title { Faker::Lorem.word }
|
||||
created_by { Faker::Number.number(10) }
|
||||
end
|
||||
end
|
||||
10
spec/models/item_spec.rb
Normal file
10
spec/models/item_spec.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Item, type: :model do
|
||||
# Association test
|
||||
# ensure an item record belongs to a single todo record
|
||||
it { should belong_to(:todo) }
|
||||
# Validation test
|
||||
# ensure column name is present before saving
|
||||
it { should validate_presence_of(:name) }
|
||||
end
|
||||
11
spec/models/todo_spec.rb
Normal file
11
spec/models/todo_spec.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Todo, type: :model do
|
||||
# Association test
|
||||
# ensure Todo model has a 1:m relationship with the Item model
|
||||
it { should have_many(:items).dependent(:destroy) }
|
||||
# Validation tests
|
||||
# ensure columns title and created_by are present before saving
|
||||
it { should validate_presence_of(:title) }
|
||||
it { should validate_presence_of(:created_by) }
|
||||
end
|
||||
76
spec/rails_helper.rb
Normal file
76
spec/rails_helper.rb
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
require 'spec_helper'
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
# Prevent database truncation if the environment is production
|
||||
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
||||
require 'rspec/rails'
|
||||
# Add additional requires below this line. Rails is not loaded until this point!
|
||||
require 'database_cleaner'
|
||||
# configure shoulda matchers to use rspec as the test framework and full matcher libraries for rails
|
||||
Shoulda::Matchers.configure do |config|
|
||||
config.integrate do |with|
|
||||
with.test_framework :rspec
|
||||
with.library :rails
|
||||
end
|
||||
end
|
||||
# Requires supporting ruby files with custom matchers and macros, etc, in
|
||||
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
||||
# run as spec files by default. This means that files in spec/support that end
|
||||
# in _spec.rb will both be required and run as specs, causing the specs to be
|
||||
# run twice. It is recommended that you do not name files matching this glob to
|
||||
# end with _spec.rb. You can configure this pattern with the --pattern
|
||||
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
||||
#
|
||||
# The following line is provided for convenience purposes. It has the downside
|
||||
# of increasing the boot-up time by auto-requiring all files in the support
|
||||
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
||||
# require only the support files necessary.
|
||||
#
|
||||
# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
||||
|
||||
# Checks for pending migrations and applies them before tests are run.
|
||||
# If you are not using ActiveRecord, you can remove this line.
|
||||
ActiveRecord::Migration.maintain_test_schema!
|
||||
|
||||
RSpec.configure do |config|
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = true
|
||||
# add `FactoryGirl` methods
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
|
||||
# start by truncating all the tables but then use the faster transaction strategy the rest of the time.
|
||||
config.before(:suite) do
|
||||
DatabaseCleaner.clean_with(:truncation)
|
||||
DatabaseCleaner.strategy = :transaction
|
||||
end
|
||||
|
||||
# RSpec Rails can automatically mix in different behaviours to your tests
|
||||
# based on their file location, for example enabling you to call `get` and
|
||||
# `post` in specs under `spec/controllers`.
|
||||
#
|
||||
# You can disable this behaviour by removing the line below, and instead
|
||||
# explicitly tag your specs with their type, e.g.:
|
||||
#
|
||||
# RSpec.describe UsersController, :type => :controller do
|
||||
# # ...
|
||||
# end
|
||||
#
|
||||
# The different available types are documented in the features, such as in
|
||||
# https://relishapp.com/rspec/rspec-rails/docs
|
||||
config.infer_spec_type_from_file_location!
|
||||
config.around(:each) do |example|
|
||||
DatabaseCleaner.cleaning do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
# Filter lines from Rails gems in backtraces.
|
||||
config.filter_rails_from_backtrace!
|
||||
# arbitrary gems may also be filtered via:
|
||||
# config.filter_gems_from_backtrace("gem name")
|
||||
end
|
||||
0
spec/requests/items_spec.rb
Normal file
0
spec/requests/items_spec.rb
Normal file
0
spec/requests/todos_spec.rb
Normal file
0
spec/requests/todos_spec.rb
Normal file
96
spec/spec_helper.rb
Normal file
96
spec/spec_helper.rb
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
||||
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
||||
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
||||
# this file to always be loaded, without a need to explicitly require it in any
|
||||
# files.
|
||||
#
|
||||
# Given that it is always loaded, you are encouraged to keep this file as
|
||||
# light-weight as possible. Requiring heavyweight dependencies from this file
|
||||
# will add to the boot time of your test suite on EVERY test run, even for an
|
||||
# individual file that may not need all of that loaded. Instead, consider making
|
||||
# a separate helper file that requires the additional dependencies and performs
|
||||
# the additional setup, and require it from the spec files that actually need
|
||||
# it.
|
||||
#
|
||||
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
||||
RSpec.configure do |config|
|
||||
# rspec-expectations config goes here. You can use an alternate
|
||||
# assertion/expectation library such as wrong or the stdlib/minitest
|
||||
# assertions if you prefer.
|
||||
config.expect_with :rspec do |expectations|
|
||||
# This option will default to `true` in RSpec 4. It makes the `description`
|
||||
# and `failure_message` of custom matchers include text for helper methods
|
||||
# defined using `chain`, e.g.:
|
||||
# be_bigger_than(2).and_smaller_than(4).description
|
||||
# # => "be bigger than 2 and smaller than 4"
|
||||
# ...rather than:
|
||||
# # => "be bigger than 2"
|
||||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||
end
|
||||
|
||||
# rspec-mocks config goes here. You can use an alternate test double
|
||||
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
||||
config.mock_with :rspec do |mocks|
|
||||
# Prevents you from mocking or stubbing a method that does not exist on
|
||||
# a real object. This is generally recommended, and will default to
|
||||
# `true` in RSpec 4.
|
||||
mocks.verify_partial_doubles = true
|
||||
end
|
||||
|
||||
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
||||
# have no way to turn it off -- the option exists only for backwards
|
||||
# compatibility in RSpec 3). It causes shared context metadata to be
|
||||
# inherited by the metadata hash of host groups and examples, rather than
|
||||
# triggering implicit auto-inclusion in groups with matching metadata.
|
||||
config.shared_context_metadata_behavior = :apply_to_host_groups
|
||||
|
||||
# The settings below are suggested to provide a good initial experience
|
||||
# with RSpec, but feel free to customize to your heart's content.
|
||||
=begin
|
||||
# This allows you to limit a spec run to individual examples or groups
|
||||
# you care about by tagging them with `:focus` metadata. When nothing
|
||||
# is tagged with `:focus`, all examples get run. RSpec also provides
|
||||
# aliases for `it`, `describe`, and `context` that include `:focus`
|
||||
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
||||
config.filter_run_when_matching :focus
|
||||
|
||||
# Allows RSpec to persist some state between runs in order to support
|
||||
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
||||
# you configure your source control system to ignore this file.
|
||||
config.example_status_persistence_file_path = "spec/examples.txt"
|
||||
|
||||
# Limits the available syntax to the non-monkey patched syntax that is
|
||||
# recommended. For more details, see:
|
||||
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
||||
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
||||
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
||||
config.disable_monkey_patching!
|
||||
|
||||
# Many RSpec users commonly either run the entire suite or an individual
|
||||
# file, and it's useful to allow more verbose output when running an
|
||||
# individual spec file.
|
||||
if config.files_to_run.one?
|
||||
# Use the documentation formatter for detailed output,
|
||||
# unless a formatter has already been configured
|
||||
# (e.g. via a command-line flag).
|
||||
config.default_formatter = "doc"
|
||||
end
|
||||
|
||||
# Print the 10 slowest examples and example groups at the
|
||||
# end of the spec run, to help surface which specs are running
|
||||
# particularly slow.
|
||||
config.profile_examples = 10
|
||||
|
||||
# Run specs in random order to surface order dependencies. If you find an
|
||||
# order dependency and want to debug it, you can fix the order by providing
|
||||
# the seed, which is printed after each run.
|
||||
# --seed 1234
|
||||
config.order = :random
|
||||
|
||||
# Seed global randomization in this process using the `--seed` CLI option.
|
||||
# Setting this allows you to use `--seed` to deterministically reproduce
|
||||
# test failures related to randomization by passing the same `--seed` value
|
||||
# as the one that triggered the failure.
|
||||
Kernel.srand config.seed
|
||||
=end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue