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

Commit 57733de

Browse files
committedJan 12, 2014
Add some specs for example
1 parent 86b41d0 commit 57733de

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed
 

‎Gemfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
source 'https://rubygems.org'
22

3+
gem 'rake'
34
gem 'opal', :github => 'opal/opal'
45
gem 'opal-jquery', :github => 'opal/opal-jquery'
56
gem 'vienna', :github => 'opal/vienna'
6-
gem 'opal-haml'
7+
gem 'opal-haml', :github => 'opal/opal-haml'
8+
gem 'opal-rspec', '0.3.0.beta2'

‎Rakefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'bundler'
2+
Bundler.require
3+
4+
require 'opal/rspec/rake_task'
5+
Opal::RSpec::RakeTask.new(:default) do |s|
6+
s.append_path 'app'
7+
s.append_path 'vendor'
8+
end

‎spec/todo_spec.rb

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'opal'
2+
require 'vienna'
3+
require 'models/todo'
4+
5+
RSpec.configure do |config|
6+
config.before { Todo.reset! }
7+
end
8+
9+
describe Todo do
10+
before do
11+
@task_a = Todo.create(title: 'Foo', completed: true)
12+
@task_b = Todo.create(title: 'Bar', completed: false)
13+
@task_c = Todo.create(title: 'Baz', completed: true)
14+
@task_d = Todo.create(title: 'Buz', completed: false)
15+
end
16+
17+
describe '.active' do
18+
it "returns all non-completed todos" do
19+
expect(Todo.active).to eq([@task_b, @task_d])
20+
end
21+
end
22+
23+
describe '.completed' do
24+
it "returns all completed todos" do
25+
expect(Todo.completed).to eq([@task_a, @task_c])
26+
end
27+
end
28+
end

0 commit comments

Comments
 (0)
This repository has been archived.