Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: lingohub/lingohub_ruby
base: bdf1138b65
...
head fork: lingohub/lingohub_ruby
compare: 0c051d831d
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
View
24 spec/integration/lingohub/models/project_spec.rb
@@ -27,15 +27,15 @@
projects[title].destroy
end
- its(:owner) { should == owner }
- its(:title) { should == title }
- its(:link) { should == link }
- its(:weburl) { should == weburl }
- its(:resources_url) { should == resources_url }
- its(:collaborators_url) { should == collaborators_url }
- its(:invitations_url) { should == invitations_url }
- its(:translations_url) { should == translations_url }
- its(:search_url) { should == search_url }
+ its(:owner) { should == owner }
+ its(:title) { should == title }
+ its(:link) { should == link }
+ its(:weburl) { should == weburl }
+ its(:resources_url) { should == resources_url }
+ its(:collaborators_url) { should == collaborators_url }
+ its(:invitations_url) { should == invitations_url }
+ its(:translations_url) { should == translations_url }
+ its(:search_url) { should == search_url }
its(:translations_count) do
pending 'this should imo return 0 but returns nil instead'
@@ -48,9 +48,9 @@
subject { project.destroy }
- let(:project) { projects[title] }
- let(:projects) { Lingohub::Spec.projects }
- let(:title) { 'Test' }
+ let(:projects) { Lingohub::Spec.projects }
+ let(:project) { projects[title] }
+ let(:title) { 'Test' }
before do
projects.create(title)
View
75 spec/integration/lingohub/models/projects_spec.rb
@@ -3,29 +3,70 @@
describe Lingohub::Models::Projects do
let(:projects) { Lingohub::Spec.projects }
- let(:title) { 'Test' }
+ let(:title) { 'Test' }
describe '#create' do
- subject { projects.create(title) }
- after do
- projects[title].destroy
+ subject { OkJson.decode(response) }
+
+ let(:response) { projects.create(title) }
+
+ context 'when an invalid title is given' do
+
+ context 'when nil is given as title' do
+ let(:title) { nil }
+
+ specify { expect { subject }.to raise_error(RestClient::BadRequest) }
+ end
+
+ context 'when an already existing title is given' do
+ before do
+ projects.create(title)
+ end
+
+ after do
+ projects[title].destroy
+ end
+
+ specify { expect { subject }.to raise_error(RestClient::BadRequest) }
+ end
end
- it 'creates the project on the server' do
- subject
- projects[title].should be_instance_of(Lingohub::Models::Project)
+ context 'when a valid title is given' do
+
+ after do
+ projects[title].destroy
+ end
+
+ it { should be_instance_of(Hash) }
+
+ specify do
+ expect { subject }.to change { Lingohub::Spec.projects.all.size }.by(1)
+ end
+
+ it 'should create the project on the server' do
+ subject
+ Lingohub::Spec.projects[title].title.should == title
+ end
end
end
describe '#[]' do
subject { projects[title] }
- context 'with no projects defined' do
+ context 'when the given title is nil' do
+ let(:title) { nil }
+
+ it { should be_nil }
+ end
+
+ context 'when no project with the given title is available' do
+ let(:title) { 'N/A' }
+
it { should be_nil }
end
- context 'with projects defined' do
+ context 'when a project with the given title is available' do
before do
projects.create(title)
@@ -37,7 +78,7 @@
it { should be_instance_of(Lingohub::Models::Project) }
- it 'returns the available project' do
+ it 'should be the requested project' do
subject.title.should == title
end
end
@@ -47,11 +88,12 @@
subject { projects.all }
- context 'with no projects defined' do
- it { should be_empty }
+ context 'when no projects are available' do
+ it { should be_instance_of(Hash) }
+ it { should be_empty }
end
- context 'with projects defined' do
+ context 'when projects are available' do
let(:project) { subject[title] }
@@ -63,10 +105,11 @@
projects[title].destroy
end
- it { should_not be_empty }
+ it { should be_instance_of(Hash) }
+ it { should have_key(title) }
- it 'returns the available project' do
- project.title.should == title
+ it 'should return a project keyed by its title' do
+ subject[title].title.should == title
end
end
end
View
5 spec/spec_helper.rb
@@ -15,6 +15,11 @@
# so we can use `:vcr` rather than `:vcr => true`;
# in RSpec 3 this will no longer be necessary.
c.treat_symbols_as_metadata_keys_with_true_values = true
+
+ # support inclusion filter :focus
+ c.filter_run_including :focus => true
+ # will run all the examples when none match the inclusion filter
+ c.run_all_when_everything_filtered = true
end
module Lingohub

No commit comments for this range

Something went wrong with that request. Please try again.