Skip to content
This repository has been archived by the owner on Jul 31, 2019. It is now read-only.

Commit

Permalink
Add some specs for example
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Jan 12, 2014
1 parent 86b41d0 commit 57733de
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Gemfile
@@ -1,6 +1,8 @@
source 'https://rubygems.org'

gem 'rake'
gem 'opal', :github => 'opal/opal'
gem 'opal-jquery', :github => 'opal/opal-jquery'
gem 'vienna', :github => 'opal/vienna'
gem 'opal-haml'
gem 'opal-haml', :github => 'opal/opal-haml'
gem 'opal-rspec', '0.3.0.beta2'
8 changes: 8 additions & 0 deletions Rakefile
@@ -0,0 +1,8 @@
require 'bundler'
Bundler.require

require 'opal/rspec/rake_task'
Opal::RSpec::RakeTask.new(:default) do |s|
s.append_path 'app'
s.append_path 'vendor'
end
28 changes: 28 additions & 0 deletions spec/todo_spec.rb
@@ -0,0 +1,28 @@
require 'opal'
require 'vienna'
require 'models/todo'

RSpec.configure do |config|
config.before { Todo.reset! }
end

describe Todo do
before do
@task_a = Todo.create(title: 'Foo', completed: true)
@task_b = Todo.create(title: 'Bar', completed: false)
@task_c = Todo.create(title: 'Baz', completed: true)
@task_d = Todo.create(title: 'Buz', completed: false)
end

describe '.active' do
it "returns all non-completed todos" do
expect(Todo.active).to eq([@task_b, @task_d])
end
end

describe '.completed' do
it "returns all completed todos" do
expect(Todo.completed).to eq([@task_a, @task_c])
end
end
end

0 comments on commit 57733de

Please sign in to comment.