Skip to content
This repository was archived by the owner on Sep 30, 2018. It is now read-only.

Commit 941e643

Browse files
committed
Use rspec for running specs
1 parent 1fc9329 commit 941e643

14 files changed

+103
-114
lines changed

Gemfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
source 'https://rubygems.org'
22
gemspec
3-
4-
gem 'opal', :github => 'opal/opal'
5-
gem 'opal-jquery', :github => 'opal/opal-jquery'
6-
gem 'opal-spec', :github => 'opal/opal-spec'

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ require 'bundler'
22
Bundler.require
33
require 'opal/activesupport'
44

5-
require 'opal/spec/rake_task'
6-
Opal::Spec::RakeTask.new(:default)
5+
require 'opal/rspec/rake_task'
6+
Opal::RSpec::RakeTask.new(:default)

opal/vienna/record_array.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ def initialize
1111
@records = []
1212
end
1313

14+
def ==(arr)
15+
@records == arr
16+
end
17+
1418
def method_missing(sym, *args, &block)
1519
@records.__send__(sym, *args, &block)
1620
end

spec/eventable_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def events
3838

3939
obj.off(:foo, handler)
4040
obj.trigger(:foo)
41-
called.should be_false
41+
called.should eq(false)
4242
end
4343
end
4444

spec/model/accessing_attributes_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ def last_name=(name)
1818
model.first_name = "Adam"
1919
model[:first_name].should eq("Adam")
2020
end
21-
22-
it "raises an exception when accessing an undefined attribute" do
23-
lambda { model[:foo] }.should raise_error(Exception)
24-
end
2521
end
2622

2723
describe "#[]=" do

spec/model/attribute_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ class ModelAttributeSpec < Vienna::Model
88
describe ".attribute" do
99

1010
let(:model) { ModelAttributeSpec.new }
11-
let(:attributes) { model.instance_variable_get(:@attributes) }
1211

1312
it "should create a reader method for attribute" do
14-
model.respond_to?(:first_name).should be_true
13+
model.should respond_to(:first_name)
1514
end
1615

1716
it "should create a writer method for attribute" do
18-
model.respond_to?(:first_name=).should be_true
17+
model.should respond_to(:first_name=)
1918
end
2019

2120
describe "writer" do

spec/model/initialize_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ class ModelInitializeSpec < Vienna::Model
3636
end
3737

3838
it "marks the model as being a new record" do
39-
ModelInitializeSpec.new.new_record?.should be_true
39+
ModelInitializeSpec.new.should be_new_record
4040
end
4141

4242
it "marks the model as not being loaded" do
43-
ModelInitializeSpec.new.loaded?.should be_false
43+
ModelInitializeSpec.new.should_not be_loaded
4444
end
4545
end
4646
end

spec/model/load_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
it "marks the model instance as loaded" do
99
model.load({})
10-
model.loaded?.should be_true
10+
model.should be_loaded
1111
end
1212

1313
it "marks the model as not being a new record" do
1414
model.load({})
15-
model.new_record?.should be_false
15+
model.should_not be_new_record
1616
end
1717
end
1818
end

spec/model/persistence_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@
1111
called = false
1212
model.on(:destroy) { called = true }
1313
model.did_destroy
14-
called.should be_true
14+
called.should eq(true)
1515
end
1616

1717
it "triggers a :destroy event on the class" do
1818
called = false
1919
SimpleModel.on(:destroy) { called = true }
2020
model.did_destroy
21-
called.should be_true
21+
called.should eq(true)
2222
end
2323

2424
it "removes the record from the class identity_map" do
2525
model = SimpleModel.load(:first_name => "Adam", id: 872)
2626

2727
model.did_destroy
28-
SimpleModel.identity_map[model.id].should be_nil
28+
SimpleModel.identity_map[model.id].should eq(nil)
2929
end
3030
end
3131

3232
describe "#did_create" do
3333
it "sets @new_record to false" do
3434
model.did_create
35-
model.new_record?.should be_false
35+
model.new_record?.should eq(false)
3636
end
3737

3838
it "adds record to class identity_map" do
@@ -51,14 +51,14 @@
5151
called = false
5252
model.on(:create) { called = true }
5353
model.did_create
54-
called.should be_true
54+
called.should eq(true)
5555
end
5656

5757
it "triggers a :create event on the class" do
5858
called = false
5959
model.class.on(:create) { called = true }
6060
model.did_create
61-
called.should be_true
61+
called.should eq(true)
6262
end
6363
end
6464

spec/model_spec.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
require 'spec_helper'
22

33
describe Vienna::Model do
4-
before do
5-
SimpleModel.reset!
6-
AdvancedModel.reset!
7-
end
8-
94
describe ".new" do
105
it "should set @new_record to true" do
11-
SimpleModel.new.new_record?.should be_true
6+
SimpleModel.new.new_record?.should eq(true)
127
end
138
end
149

@@ -35,7 +30,7 @@
3530

3631
it "should set @new_record to false on the model" do
3732
model = SimpleModel.load(id: 42)
38-
model.new_record?.should be_false
33+
model.new_record?.should eq(false)
3934
end
4035

4136
it "should cache model" do

0 commit comments

Comments
 (0)